QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#604514#3086. Edge Subsetsgrass8cowAC ✓60ms14188kbC++172.4kb2024-10-02 11:40:482024-10-02 11:40:48

Judging History

你现在查看的是最新测评结果

  • [2024-10-02 11:40:48]
  • 评测
  • 测评结果:AC
  • 用时:60ms
  • 内存:14188kb
  • [2024-10-02 11:40:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,m,U[410],V[410],a,b,p2[30];
namespace Sub1{
	int dp[1<<20],dp2[1<<20];
	bool vi[210][2];
	void sol(){
		for(int i=1;i<=m;i++){
		if(V[i]-U[i]==a)vi[V[i]][0]=1;
		else vi[V[i]][1]=1;
		}
		dp[0]=1;
		for(int i=1;i<=n;i++){
			memset(dp2,0,sizeof(dp2));
			for(int s=0;s<(1<<a);s++)if(dp[s]){
				if(!(s&1)&&vi[i][0])(dp2[(s>>1)|p2[a-1]]+=dp[s])%=mod;
				if(!(s&p2[a-b])&&vi[i][1])(dp2[(s>>1)|p2[a-b-1]|p2[a-1]]+=dp[s])%=mod;
				(dp2[s>>1]+=dp[s])%=mod;
			}
			for(int s=0;s<(1<<a);s++)dp[s]=dp2[s];
		}
		int ans=0;
		for(int s=0;s<(1<<a);s++)(ans+=dp[s])%=mod;printf("%d",ans);
	}
}
namespace Sub2{
	int dp[1<<10][1<<10],h,dp2[1<<10][1<<10];
	bool xp[410],va[410],vb[410];
	void sol(){
		for(int i=1;i<=m;i++){
			if(U[i]+a==V[i])va[V[i]]=1;
			else vb[U[i]]=1;
		}
		h=n/a;
		int ans=1;
		for(int is=0;is<a;is++)if(!xp[is]){
			memset(dp,0,sizeof(dp));
			int u=is;
			dp[0][0]=1;
			while(!xp[u]){
				xp[u]=1;
				for(int i=0;i<h;i++){
					int x=u+1+i*a;
					memset(dp2,0,sizeof(dp2));
					for(int s1=0;s1<(1<<h);s1++)for(int s2=0;s2<p2[h];s2++)if(dp[s1][s2]){
						if(i&&!(s2&p2[i-1])&&va[x])(dp2[(is==u)?(s1|p2[i-1]|p2[i]):s1][s2|p2[i]|p2[i-1]]+=dp[s1][s2])%=mod;
						if(u!=is&&vb[x]){
							if(u+b<a){
								if(!(s2&p2[i]))
									(dp2[(is==u+b)?(s1|p2[i]):s1][s2|p2[i]]+=dp[s1][s2])%=mod;
							}
							else if(i+1<h){
								if(!(s2&p2[i+1]))
									(dp2[(is==u+b-a)?(s1|p2[i+1]):s1][s2|p2[i]|p2[i+1]]+=dp[s1][s2])%=mod;
							}
						}
						(dp2[s1][(s2&((1<<i)))?(s2^(1<<i)):s2]+=dp[s1][s2])%=mod;
					}
					for(int s1=0;s1<p2[h];s1++)for(int s2=0;s2<p2[h];s2++)dp[s1][s2]=dp2[s1][s2];
				}
				u=(u+a-b)%a;
			}
			int sum=0;
			for(int s1=0;s1<p2[h];s1++)for(int s2=0;s2<p2[h];s2++)if(dp[s1][s2]){
				int zb=dp[s1][s2];
				for(int i=0;i<h;i++)if(vb[u+1+i*a]&&!((s1>>i)&1)){
					if(u+b<a){
						if(!(s2&p2[i]))zb=zb*2%mod;
					}
					else if(i+1<h){
						if(!(s2&p2[i+1]))zb=zb*2%mod;
					}
				}
				(sum+=zb)%=mod;
			}
			ans=1ll*ans*sum%mod;
		}
		printf("%d\n",(ans+mod)%mod);
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	if(a<b)swap(a,b);
	p2[0]=1;
	for(int i=1;i<=20;i++)p2[i]=2*p2[i-1];
	for(int i=1;i<=m;i++)
		scanf("%d%d",&U[i],&V[i]);
	if(a<=20){Sub1::sol();return 0;}
	n=((n-1)/a+1)*a;
	Sub2::sol();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 13ms
memory: 14188kb

input:

50 97 31 32
5 37
15 46
2 33
15 46
6 37
14 46
1 32
2 34
5 36
1 32
5 37
3 35
11 42
12 44
2 33
1 33
10 42
3 35
12 43
14 46
18 49
2 34
1 33
12 43
15 47
13 45
12 44
11 42
9 41
1 32
7 39
3 35
4 35
11 43
11 42
13 45
2 34
12 43
6 38
18 50
3 35
4 36
13 45
17 49
12 43
3 34
15 46
3 34
1 32
11 42
4 35
2 34
10 4...

output:

28284459

result:

ok single line: '28284459'

Test #2:

score: 0
Accepted
time: 17ms
memory: 13176kb

input:

62 19 4 30
54 58
9 13
24 54
3 7
23 53
55 59
29 33
15 45
5 35
13 17
51 55
56 60
1 31
19 49
52 56
1 31
28 58
39 43
46 50

output:

69120

result:

ok single line: '69120'

Test #3:

score: 0
Accepted
time: 49ms
memory: 13440kb

input:

171 233 128 159
35 163
14 142
31 159
38 166
25 153
19 147
16 144
23 151
9 168
9 168
3 131
12 171
12 140
12 171
3 162
2 130
9 168
31 159
11 170
5 164
10 169
38 166
11 170
6 165
7 166
6 165
6 165
33 161
22 150
2 161
2 161
43 171
35 163
31 159
11 170
4 163
5 133
31 159
12 171
42 170
8 167
19 147
36 164...

output:

312199656

result:

ok single line: '312199656'

Test #4:

score: 0
Accepted
time: 20ms
memory: 13968kb

input:

67 61 41 56
4 60
7 48
10 66
2 58
13 54
11 67
1 57
26 67
26 67
1 57
18 59
5 61
24 65
25 66
4 60
3 59
7 48
7 48
11 67
8 64
21 62
11 52
16 57
8 64
11 52
9 65
19 60
12 53
3 59
4 45
5 61
24 65
17 58
5 46
8 64
1 57
4 60
8 64
1 57
10 66
6 47
10 66
6 62
7 48
2 43
6 47
2 58
9 65
24 65
5 61
16 57
10 66
4 60
2...

output:

6075000

result:

ok single line: '6075000'

Test #5:

score: 0
Accepted
time: 10ms
memory: 13632kb

input:

28 38 16 24
3 27
2 18
4 28
9 25
4 28
3 27
4 20
2 26
6 22
3 19
12 28
2 26
4 28
1 25
9 25
1 25
3 19
4 28
5 21
1 25
2 26
2 26
2 26
8 24
6 22
1 25
10 26
12 28
2 18
8 24
10 26
3 27
4 28
12 28
2 26
3 27
1 25
3 27

output:

1800

result:

ok single line: '1800'

Test #6:

score: 0
Accepted
time: 15ms
memory: 12288kb

input:

53 53 39 42
2 44
2 41
10 52
11 50
13 52
12 51
1 43
7 49
2 44
2 44
5 44
13 52
9 48
2 41
4 46
10 52
9 48
8 50
7 49
3 45
2 44
5 44
9 51
2 44
10 52
12 51
1 43
11 50
1 40
11 53
5 44
6 45
8 50
4 46
8 50
3 45
2 41
1 40
4 43
3 45
4 46
2 44
3 42
1 43
7 49
8 47
4 46
4 46
10 49
1 43
13 52
6 48
3 42

output:

87040

result:

ok single line: '87040'

Test #7:

score: 0
Accepted
time: 18ms
memory: 13756kb

input:

97 141 41 62
24 86
36 77
16 78
56 97
40 81
21 83
25 87
17 58
25 87
48 89
10 72
26 88
12 74
54 95
51 92
45 86
37 78
35 97
2 64
19 81
52 93
24 86
26 67
14 76
29 91
29 91
27 89
38 79
17 79
2 64
22 84
34 96
2 64
5 67
38 79
5 67
13 75
23 85
1 63
21 62
32 94
2 64
55 96
31 93
10 72
33 95
17 79
27 89
12 53
...

output:

232133432

result:

ok single line: '232133432'

Test #8:

score: 0
Accepted
time: 41ms
memory: 14036kb

input:

200 15 29 82
45 74
10 92
106 188
5 87
9 38
106 188
102 184
88 117
81 110
36 118
99 181
18 100
55 84
10 39
84 166

output:

9216

result:

ok single line: '9216'

Test #9:

score: 0
Accepted
time: 4ms
memory: 9968kb

input:

19 6 1 12
2 14
9 10
6 18
1 2
2 14
10 11

output:

18

result:

ok single line: '18'

Test #10:

score: 0
Accepted
time: 34ms
memory: 12252kb

input:

184 110 42 105
86 128
52 94
138 180
32 137
76 181
53 158
10 115
42 84
26 131
84 126
68 173
33 138
9 114
70 175
33 138
42 84
86 128
13 118
53 95
50 92
53 158
118 160
57 162
79 184
94 136
20 62
48 153
55 97
5 47
63 168
5 110
138 180
10 52
70 175
61 166
94 136
18 60
69 174
30 135
109 151
37 79
26 131
1...

output:

413200571

result:

ok single line: '413200571'

Test #11:

score: 0
Accepted
time: 8ms
memory: 12132kb

input:

29 36 5 23
11 16
1 24
2 25
14 19
5 10
2 7
6 11
6 29
2 25
3 26
23 28
1 24
20 25
14 19
5 28
2 25
11 16
6 29
9 14
23 28
1 24
5 28
5 28
4 27
18 23
7 12
5 10
20 25
4 27
1 24
1 24
19 24
17 22
3 26
17 22
23 28

output:

20480

result:

ok single line: '20480'

Test #12:

score: 0
Accepted
time: 20ms
memory: 12264kb

input:

99 60 37 56
47 84
43 99
7 63
29 85
22 59
23 79
43 80
31 68
14 51
12 49
4 41
52 89
25 81
2 39
59 96
58 95
37 74
4 60
8 45
20 76
37 93
14 51
37 74
34 71
18 55
29 85
17 73
46 83
1 57
43 99
57 94
36 92
27 83
26 63
37 93
39 95
37 74
29 66
16 72
17 73
55 92
15 71
9 46
30 86
28 84
27 64
38 94
38 75
1 57
42...

output:

633338756

result:

ok single line: '633338756'

Test #13:

score: 0
Accepted
time: 17ms
memory: 11904kb

input:

21 40 17 19
4 21
2 19
2 19
1 20
1 20
2 21
4 21
2 21
1 20
2 21
2 19
2 21
2 21
1 20
1 20
2 21
1 20
1 20
1 20
2 19
1 20
2 21
3 20
4 21
3 20
1 18
1 20
1 20
1 20
3 20
2 21
2 21
1 20
2 19
4 21
3 20
1 20
4 21
1 18
4 21

output:

25

result:

ok single line: '25'

Test #14:

score: 0
Accepted
time: 0ms
memory: 10040kb

input:

10 12 3 6
4 7
2 5
7 10
4 10
6 9
4 10
5 8
2 8
3 9
3 9
3 6
1 4

output:

96

result:

ok single line: '96'

Test #15:

score: 0
Accepted
time: 26ms
memory: 12284kb

input:

108 74 28 79
70 98
3 31
11 90
48 76
6 85
11 90
72 100
14 93
5 84
3 82
57 85
50 78
9 88
6 85
10 38
19 98
5 84
7 86
9 88
8 36
9 37
5 84
30 58
58 86
54 82
19 98
77 105
19 47
20 99
13 92
5 84
60 88
11 90
9 88
33 61
2 30
3 82
21 49
24 103
7 86
20 48
26 54
23 102
62 90
14 93
18 97
26 54
21 49
49 77
27 55
...

output:

357363562

result:

ok single line: '357363562'

Test #16:

score: 0
Accepted
time: 26ms
memory: 14152kb

input:

74 71 16 72
8 24
34 50
2 74
1 17
55 71
23 39
1 73
34 50
16 32
33 49
2 74
2 74
2 74
29 45
2 74
53 69
2 74
2 74
2 74
1 73
2 74
1 73
2 74
37 53
54 70
10 26
22 38
28 44
1 73
2 74
31 47
1 73
30 46
4 20
9 25
2 74
1 73
2 74
1 73
1 73
15 31
18 34
1 73
2 74
1 73
56 72
1 73
1 73
1 73
2 74
1 73
18 34
26 42
1 7...

output:

23887872

result:

ok single line: '23887872'

Test #17:

score: 0
Accepted
time: 18ms
memory: 12684kb

input:

68 87 9 51
5 56
2 53
9 18
7 58
3 54
3 54
13 64
12 63
15 66
15 66
18 27
25 34
22 31
4 13
13 64
3 12
11 20
6 15
49 58
50 59
14 65
23 32
41 50
17 68
38 47
8 59
29 38
22 31
13 64
21 30
14 65
17 68
55 64
11 62
56 65
5 14
17 68
14 65
3 12
24 33
4 13
18 27
9 18
10 61
15 24
6 57
17 68
58 67
8 59
2 53
24 33
...

output:

109584111

result:

ok single line: '109584111'

Test #18:

score: 0
Accepted
time: 3ms
memory: 10108kb

input:

13 13 3 10
1 11
1 11
2 12
2 12
8 11
3 13
2 12
3 13
5 8
2 12
6 9
1 4
8 11

output:

64

result:

ok single line: '64'

Test #19:

score: 0
Accepted
time: 0ms
memory: 10108kb

input:

10 12 4 6
2 8
3 9
1 7
4 8
4 10
4 8
3 9
1 7
2 6
1 7
5 9
4 10

output:

48

result:

ok single line: '48'

Test #20:

score: 0
Accepted
time: 41ms
memory: 12988kb

input:

146 55 52 117
2 119
7 124
60 112
45 97
75 127
73 125
62 114
64 116
68 120
8 125
44 96
89 141
1 118
15 132
25 142
11 128
8 125
42 94
21 138
37 89
47 99
13 130
66 118
12 129
66 118
29 146
78 130
21 138
24 141
6 123
1 118
26 78
9 61
9 126
19 136
17 69
5 122
51 103
37 89
9 61
9 126
9 61
57 109
69 121
82...

output:

624951169

result:

ok single line: '624951169'

Test #21:

score: 0
Accepted
time: 24ms
memory: 12828kb

input:

90 165 32 70
15 85
41 73
16 48
10 80
11 81
10 80
9 79
2 34
1 71
51 83
9 41
44 76
5 75
14 84
18 88
10 80
26 58
53 85
11 81
50 82
14 84
5 75
23 55
53 85
20 90
4 74
43 75
37 69
50 82
55 87
43 75
34 66
14 84
42 74
7 77
18 50
7 77
11 81
41 73
5 75
17 87
5 75
58 90
20 90
2 72
10 80
12 44
16 86
50 82
27 59...

output:

153529998

result:

ok single line: '153529998'

Test #22:

score: 0
Accepted
time: 31ms
memory: 13228kb

input:

154 305 6 60
76 136
48 108
47 53
73 79
67 73
73 133
92 152
79 139
37 97
92 98
26 32
79 139
71 131
35 95
54 60
90 150
26 86
87 93
91 97
75 135
31 91
1 61
75 135
65 125
9 69
58 64
51 111
81 87
33 93
1 7
62 122
51 111
89 149
134 140
39 45
19 79
71 77
10 70
31 91
69 129
108 114
46 52
25 31
72 78
47 107
...

output:

577194680

result:

ok single line: '577194680'

Test #23:

score: 0
Accepted
time: 60ms
memory: 12780kb

input:

200 91 70 197
63 133
3 200
42 112
115 185
54 124
129 199
2 199
53 123
2 199
53 123
56 126
37 107
115 185
99 169
2 199
15 85
2 199
2 199
120 190
18 88
55 125
39 109
2 199
19 89
3 200
55 125
2 199
3 200
51 121
3 200
2 199
29 99
1 198
6 76
63 133
53 123
42 112
2 199
7 77
2 199
2 199
40 110
2 199
36 106...

output:

75497031

result:

ok single line: '75497031'

Test #24:

score: 0
Accepted
time: 36ms
memory: 13528kb

input:

169 227 20 42
121 163
110 152
87 129
1 43
2 22
118 138
116 158
28 48
17 59
60 80
24 66
78 98
85 127
30 50
58 78
60 80
89 109
93 135
42 84
106 126
117 137
69 89
86 106
21 41
105 125
123 143
112 154
107 127
137 157
121 141
18 60
47 89
66 108
64 84
93 135
51 93
21 41
109 151
82 124
125 167
42 84
15 57
...

output:

589483734

result:

ok single line: '589483734'

Test #25:

score: 0
Accepted
time: 37ms
memory: 14084kb

input:

114 12 94 110
20 114
4 98
11 105
3 97
1 95
1 111
4 114
12 106
4 98
1 111
1 111
20 114

output:

120

result:

ok single line: '120'

Test #26:

score: 0
Accepted
time: 12ms
memory: 14068kb

input:

64 75 3 22
39 61
55 58
19 22
23 26
56 59
33 55
25 28
23 45
29 32
22 44
13 35
39 61
29 51
11 33
34 56
28 50
16 38
20 23
12 34
60 63
41 44
31 34
39 61
2 24
33 55
33 55
18 40
47 50
7 29
25 47
57 60
42 45
23 26
23 45
28 31
5 8
39 61
13 35
21 43
39 61
31 34
49 52
35 57
23 45
4 26
9 31
38 41
31 53
4 26
30...

output:

647238066

result:

ok single line: '647238066'

Test #27:

score: 0
Accepted
time: 16ms
memory: 12328kb

input:

69 60 35 42
1 36
8 43
5 47
34 69
9 44
25 60
21 56
30 65
13 48
29 64
24 59
1 43
31 66
16 51
33 68
29 64
31 66
3 38
11 53
30 65
12 47
3 38
24 59
8 50
20 62
5 47
18 60
31 66
24 66
9 44
21 56
8 43
28 63
2 44
28 63
2 37
30 65
18 53
15 57
12 47
13 48
18 53
13 48
1 43
12 54
8 43
27 69
24 66
11 53
27 69
16 ...

output:

193536000

result:

ok single line: '193536000'

Test #28:

score: 0
Accepted
time: 43ms
memory: 13376kb

input:

154 19 57 145
9 154
6 151
15 72
4 149
8 153
8 153
92 149
3 148
5 150
39 96
9 66
87 144
4 149
32 89
37 94
4 149
9 66
79 136
9 154

output:

9216

result:

ok single line: '9216'

Test #29:

score: 0
Accepted
time: 22ms
memory: 13400kb

input:

86 167 46 64
14 78
8 72
32 78
34 80
36 82
16 80
38 84
2 66
4 68
13 59
17 81
1 65
16 80
26 72
38 84
33 79
18 64
6 70
13 77
8 72
40 86
20 66
2 66
21 85
11 57
12 76
19 65
16 80
11 75
15 79
2 66
11 75
13 59
35 81
7 53
40 86
10 56
18 64
26 72
21 85
13 59
1 47
19 65
32 78
1 65
9 55
24 70
39 85
13 77
20 84...

output:

326280861

result:

ok single line: '326280861'

Test #30:

score: 0
Accepted
time: 47ms
memory: 13348kb

input:

161 212 9 154
110 119
52 61
3 157
6 160
47 56
2 156
96 105
53 62
39 48
63 72
5 159
3 12
5 159
6 160
1 155
24 33
125 134
1 155
27 36
72 81
3 157
148 157
1 155
6 160
151 160
4 158
39 48
3 157
48 57
2 156
23 32
101 110
47 56
5 159
126 135
16 25
43 52
92 101
108 117
68 77
101 110
4 158
3 157
106 115
2 1...

output:

436577286

result:

ok single line: '436577286'

Test #31:

score: 0
Accepted
time: 31ms
memory: 13304kb

input:

137 34 54 60
24 78
59 113
1 61
16 76
48 102
43 97
77 131
54 114
45 99
40 94
75 129
51 105
67 127
21 81
2 62
10 70
19 79
58 112
49 109
66 126
41 95
17 71
50 110
60 114
62 122
77 137
13 73
34 94
61 121
54 108
22 76
43 97
81 135
42 102

output:

716636160

result:

ok single line: '716636160'

Test #32:

score: 0
Accepted
time: 34ms
memory: 13976kb

input:

194 166 94 115
38 153
82 176
71 186
48 142
61 155
100 194
69 184
71 165
10 125
10 104
25 140
98 192
71 165
46 161
66 160
63 178
13 128
59 153
27 121
67 161
4 98
50 144
29 123
76 191
26 120
44 159
5 120
35 150
49 164
62 177
46 161
28 122
59 174
28 143
64 158
75 190
82 176
42 157
51 145
58 173
44 159
...

output:

701324308

result:

ok single line: '701324308'

Test #33:

score: 0
Accepted
time: 7ms
memory: 13456kb

input:

50 14 3 25
34 37
3 28
19 22
17 42
21 24
19 22
21 46
7 10
22 47
15 40
14 17
1 4
15 40
7 32

output:

1296

result:

ok single line: '1296'

Test #34:

score: 0
Accepted
time: 23ms
memory: 13464kb

input:

124 32 11 45
87 98
38 83
31 76
27 72
80 91
110 121
15 26
46 57
48 93
108 119
41 52
27 38
47 58
42 53
42 87
96 107
42 87
5 50
34 79
88 99
70 115
31 76
36 81
38 49
73 84
69 80
23 68
35 46
28 39
6 17
63 108
96 107

output:

61931520

result:

ok single line: '61931520'

Test #35:

score: 0
Accepted
time: 39ms
memory: 13888kb

input:

143 113 43 119
74 117
14 133
5 124
17 136
11 54
8 127
13 56
8 127
7 126
32 75
100 143
10 129
24 143
14 133
30 73
4 123
15 134
8 51
86 129
14 133
4 47
20 63
82 125
17 136
13 132
88 131
24 67
5 124
43 86
89 132
15 134
6 125
88 131
22 141
18 137
22 141
19 138
54 97
14 133
44 87
10 129
55 98
18 137
17 1...

output:

367673481

result:

ok single line: '367673481'

Test #36:

score: 0
Accepted
time: 32ms
memory: 12692kb

input:

136 202 7 65
26 91
53 118
35 100
21 86
45 52
101 108
110 117
64 129
126 133
54 119
78 85
19 26
9 74
15 22
102 109
128 135
70 77
104 111
90 97
113 120
43 50
33 40
24 31
128 135
2 67
60 125
100 107
90 97
43 108
28 93
103 110
99 106
34 41
49 56
6 71
84 91
71 78
25 90
91 98
5 70
39 46
100 107
1 66
120 1...

output:

687030906

result:

ok single line: '687030906'

Test #37:

score: 0
Accepted
time: 18ms
memory: 13748kb

input:

83 16 9 65
11 76
5 14
44 53
13 78
1 66
17 82
44 53
8 17
71 80
9 18
1 66
45 54
6 15
11 76
74 83
31 40

output:

6144

result:

ok single line: '6144'

Test #38:

score: 0
Accepted
time: 30ms
memory: 12728kb

input:

145 234 97 104
35 139
33 137
16 113
10 107
19 123
17 121
7 111
40 144
26 123
11 115
21 125
8 112
36 140
22 126
24 121
25 129
19 116
2 99
15 119
13 110
5 102
1 105
48 145
5 109
39 143
23 127
39 136
8 112
13 117
18 115
2 106
36 140
9 106
11 115
46 143
40 137
40 144
3 100
12 116
8 105
27 131
23 120
27 ...

output:

312986744

result:

ok single line: '312986744'

Test #39:

score: 0
Accepted
time: 47ms
memory: 13252kb

input:

176 206 15 153
6 159
17 170
1 154
21 174
113 128
13 166
84 99
49 64
27 42
99 114
23 176
77 92
21 174
1 154
8 161
17 170
54 69
13 166
65 80
5 158
71 86
9 162
23 38
23 176
87 102
9 162
112 127
78 93
75 90
7 160
61 76
10 25
15 168
157 172
70 85
61 76
3 18
34 49
83 98
85 100
46 61
12 165
22 175
16 169
8...

output:

892529060

result:

ok single line: '892529060'

Test #40:

score: 0
Accepted
time: 2ms
memory: 10056kb

input:

7 2 4 6
1 7
1 7

output:

2

result:

ok single line: '2'

Test #41:

score: 0
Accepted
time: 40ms
memory: 12996kb

input:

132 237 34 121
8 129
89 123
5 126
2 123
3 124
4 38
63 97
49 83
65 99
1 122
22 56
9 130
1 122
68 102
8 129
50 84
97 131
83 117
23 57
9 130
1 122
11 132
2 123
65 99
11 132
57 91
1 122
2 123
6 127
89 123
9 130
38 72
6 127
89 123
4 125
24 58
8 129
11 132
57 91
1 35
18 52
8 129
2 123
9 130
45 79
73 107
7...

output:

755087388

result:

ok single line: '755087388'

Test #42:

score: 0
Accepted
time: 31ms
memory: 12900kb

input:

161 194 81 105
53 158
9 114
17 122
1 106
11 116
9 114
69 150
10 115
2 83
47 128
64 145
45 150
26 131
35 140
13 118
42 123
76 157
54 135
1 82
27 132
23 104
9 90
10 115
62 143
70 151
48 129
47 152
19 124
28 133
47 128
67 148
70 151
11 116
77 158
55 160
17 122
26 131
39 120
79 160
13 94
20 125
74 155
3...

output:

657401043

result:

ok single line: '657401043'

Test #43:

score: 0
Accepted
time: 57ms
memory: 13332kb

input:

195 255 74 174
44 118
70 144
9 183
13 187
78 152
9 183
6 180
43 117
1 175
17 191
5 179
15 189
20 194
38 112
34 108
7 181
14 188
18 192
12 186
21 195
11 185
59 133
9 183
6 80
119 193
1 175
64 138
83 157
4 78
4 178
24 98
13 187
38 112
118 192
21 195
21 195
76 150
15 189
19 193
9 183
19 193
84 158
15 1...

output:

789035478

result:

ok single line: '789035478'

Test #44:

score: 0
Accepted
time: 15ms
memory: 12728kb

input:

42 11 4 40
1 5
1 41
3 7
3 7
36 40
1 41
26 30
37 41
27 31
33 37
2 42

output:

256

result:

ok single line: '256'

Test #45:

score: 0
Accepted
time: 46ms
memory: 12380kb

input:

152 34 19 141
6 147
2 143
71 90
10 29
11 152
105 124
10 151
102 121
4 145
1 142
102 121
93 112
51 70
71 90
7 148
95 114
8 149
10 151
128 147
105 124
3 144
3 144
2 143
7 148
30 49
11 152
8 149
56 75
2 143
4 145
9 150
37 56
12 31
101 120

output:

3538944

result:

ok single line: '3538944'

Test #46:

score: 0
Accepted
time: 39ms
memory: 12496kb

input:

31 39 6 20
7 27
8 14
20 26
11 17
16 22
11 31
14 20
9 29
24 30
11 31
2 22
7 27
22 28
18 24
4 24
2 22
7 27
25 31
10 16
22 28
4 10
10 30
10 30
8 28
24 30
7 27
9 29
20 26
23 29
7 13
5 25
7 13
11 31
12 18
13 19
8 28
2 22
1 21
6 12

output:

243360

result:

ok single line: '243360'

Test #47:

score: 0
Accepted
time: 44ms
memory: 13476kb

input:

158 98 57 146
4 150
36 93
82 139
96 153
12 158
27 84
9 155
22 79
9 155
2 59
6 152
54 111
96 153
8 154
6 152
9 155
10 67
1 147
11 157
8 154
1 147
1 147
83 140
77 134
4 150
4 150
7 153
3 149
47 104
10 156
10 156
59 116
86 143
50 107
10 156
99 156
6 152
79 136
12 158
11 157
7 153
17 74
73 130
7 64
8 15...

output:

167751740

result:

ok single line: '167751740'

Test #48:

score: 0
Accepted
time: 59ms
memory: 12904kb

input:

197 327 63 181
5 68
66 129
26 89
12 193
45 108
92 155
10 191
4 185
13 194
38 101
101 164
39 102
95 158
14 195
50 113
25 88
8 189
5 186
14 195
9 190
15 196
15 78
68 131
127 190
33 96
19 82
3 184
16 197
14 195
4 185
70 133
6 187
7 188
57 120
2 183
33 96
1 182
94 157
112 175
55 118
104 167
12 193
11 19...

output:

719708467

result:

ok single line: '719708467'

Test #49:

score: 0
Accepted
time: 19ms
memory: 13144kb

input:

96 112 45 55
38 93
40 85
39 94
26 71
28 73
22 67
7 52
24 69
1 56
51 96
14 59
40 95
20 75
3 58
10 65
15 70
22 77
24 79
9 64
15 70
36 81
12 67
1 56
10 55
21 66
39 94
23 78
14 69
20 65
37 92
6 61
30 75
17 62
4 59
26 71
48 93
4 59
22 77
22 77
24 69
45 90
40 85
36 91
22 67
37 92
14 69
18 73
6 61
37 82
40...

output:

761577193

result:

ok single line: '761577193'

Test #50:

score: 0
Accepted
time: 40ms
memory: 13528kb

input:

136 64 102 121
2 123
7 109
14 116
1 122
12 133
13 134
5 126
10 112
12 114
11 113
11 132
5 126
8 110
10 131
4 125
3 124
14 116
3 105
23 125
16 118
21 123
6 108
2 123
29 131
9 111
21 123
13 134
4 106
11 132
17 119
12 133
11 132
12 114
2 123
16 118
23 125
4 106
3 105
11 132
27 129
6 127
7 109
10 131
4 ...

output:

104976000

result:

ok single line: '104976000'

Test #51:

score: 0
Accepted
time: 30ms
memory: 12204kb

input:

144 165 36 89
16 52
41 130
39 128
92 128
43 132
41 77
34 123
62 98
96 132
6 95
33 69
44 133
38 127
6 42
59 95
25 114
60 96
42 131
36 125
78 114
51 140
70 106
34 123
66 102
40 129
12 101
16 105
53 142
39 75
30 119
30 66
7 96
6 42
46 135
84 120
106 142
75 111
5 94
29 118
23 112
7 96
48 137
50 139
27 6...

output:

715831971

result:

ok single line: '715831971'

Test #52:

score: 0
Accepted
time: 28ms
memory: 12824kb

input:

109 181 16 85
62 78
15 100
15 100
17 33
2 87
31 47
54 70
3 88
15 100
15 31
12 97
31 47
19 104
7 92
52 68
39 55
11 27
22 107
22 107
24 109
20 105
55 71
9 94
4 20
9 94
6 91
66 82
74 90
59 75
20 105
1 86
22 107
23 39
1 86
15 100
9 94
21 106
22 107
30 46
28 44
19 104
64 80
18 103
17 102
3 88
8 24
21 106...

output:

329553739

result:

ok single line: '329553739'

Test #53:

score: 0
Accepted
time: 28ms
memory: 13656kb

input:

111 151 15 82
11 26
64 79
19 34
96 111
45 60
18 100
59 74
26 41
51 66
3 85
52 67
62 77
26 41
30 45
79 94
71 86
27 109
90 105
31 46
7 89
21 103
9 91
6 88
6 88
81 96
73 88
25 107
86 101
29 111
66 81
87 102
23 105
27 109
61 76
66 81
18 100
1 83
80 95
17 99
13 95
4 86
19 101
21 103
96 111
72 87
28 110
3...

output:

965108037

result:

ok single line: '965108037'

Test #54:

score: 0
Accepted
time: 40ms
memory: 12852kb

input:

198 311 53 90
52 142
38 91
117 170
51 141
2 55
5 95
70 160
4 57
129 182
57 147
92 182
7 97
12 65
137 190
41 94
8 61
102 192
14 104
101 154
100 190
37 127
20 73
106 196
8 61
67 157
65 118
97 150
26 116
2 92
68 121
53 143
42 132
97 150
67 157
16 106
82 135
140 193
21 74
77 167
30 120
126 179
90 180
32...

output:

410971626

result:

ok single line: '410971626'

Test #55:

score: 0
Accepted
time: 6ms
memory: 12224kb

input:

24 35 8 23
4 12
8 16
15 23
1 24
13 21
1 24
10 18
1 24
1 24
1 9
1 24
9 17
1 24
4 12
14 22
1 24
9 17
2 10
12 20
1 24
12 20
12 20
1 9
1 24
1 24
7 15
14 22
1 24
1 24
1 24
7 15
1 24
3 11
1 24
1 24

output:

2160

result:

ok single line: '2160'

Test #56:

score: 0
Accepted
time: 42ms
memory: 13144kb

input:

178 288 10 125
70 80
66 76
4 14
43 53
95 105
91 101
122 132
21 146
15 140
22 147
83 93
13 138
7 17
104 114
22 32
23 148
103 113
20 145
52 177
39 164
153 163
39 164
118 128
159 169
114 124
35 45
1 126
40 165
6 131
41 166
137 147
39 164
48 173
25 150
42 52
10 135
8 133
23 148
66 76
21 31
7 132
151 161...

output:

357773223

result:

ok single line: '357773223'

Test #57:

score: 0
Accepted
time: 21ms
memory: 12780kb

input:

87 172 4 63
49 53
16 79
17 80
61 65
76 80
24 87
37 41
14 77
36 40
12 75
35 39
81 85
16 79
50 54
44 48
30 34
52 56
32 36
5 68
3 66
2 65
11 74
7 70
72 76
67 71
43 47
39 43
1 5
65 69
9 72
22 26
59 63
20 83
20 83
10 73
9 13
2 6
4 8
4 67
3 66
18 81
9 13
60 64
56 60
48 52
21 84
50 54
80 84
12 75
61 65
6 6...

output:

704319198

result:

ok single line: '704319198'

Test #58:

score: 0
Accepted
time: 21ms
memory: 12172kb

input:

68 71 11 60
45 56
8 68
2 62
6 66
6 66
5 65
53 64
2 62
6 17
6 66
3 63
2 13
4 64
27 38
1 61
6 66
1 12
5 65
8 68
2 62
49 60
52 63
1 61
22 33
51 62
6 66
50 61
2 62
23 34
2 62
5 65
11 22
42 53
7 67
38 49
10 21
8 68
47 58
6 66
2 62
4 64
24 35
39 50
1 61
1 61
40 51
7 67
8 68
4 64
5 65
5 65
3 63
3 63
10 21
...

output:

19511294

result:

ok single line: '19511294'

Test #59:

score: 0
Accepted
time: 54ms
memory: 12184kb

input:

188 235 10 166
19 185
7 173
16 182
5 15
6 172
129 139
126 136
11 177
13 179
36 46
5 15
90 100
97 107
21 187
4 170
155 165
21 187
108 118
15 25
13 179
9 175
19 185
94 104
92 102
4 170
61 71
23 33
63 73
45 55
130 140
18 184
15 181
54 64
19 185
11 177
55 65
85 95
71 81
5 171
18 184
16 182
108 118
2 168...

output:

273757138

result:

ok single line: '273757138'

Test #60:

score: 0
Accepted
time: 19ms
memory: 13456kb

input:

82 91 34 37
21 55
35 69
13 50
25 62
36 73
21 55
14 48
26 60
12 49
16 50
18 52
22 56
30 67
25 62
27 64
25 59
35 69
11 48
27 61
12 49
47 81
25 59
40 77
33 70
33 67
48 82
28 65
25 62
35 72
38 72
30 67
22 56
26 60
25 59
31 68
9 46
45 79
31 68
23 57
43 80
7 41
23 60
23 60
42 76
4 38
44 78
13 47
33 67
26 ...

output:

525591025

result:

ok single line: '525591025'

Test #61:

score: 0
Accepted
time: 15ms
memory: 14100kb

input:

102 172 11 27
22 49
28 39
3 30
44 71
32 43
26 53
64 75
17 28
79 90
15 42
65 92
40 67
84 95
84 95
71 82
4 15
50 77
10 21
32 43
60 71
32 43
71 82
60 87
88 99
64 75
62 89
64 75
16 43
84 95
42 53
75 102
72 99
45 56
77 88
11 22
3 14
48 75
23 50
24 35
83 94
18 45
66 77
47 74
7 18
84 95
43 54
56 83
7 34
57...

output:

190688917

result:

ok single line: '190688917'

Test #62:

score: 0
Accepted
time: 11ms
memory: 10056kb

input:

63 113 2 7
40 42
32 39
28 30
8 10
7 9
54 56
9 11
48 55
28 35
15 17
21 28
47 54
34 41
37 44
42 49
24 31
11 18
56 58
19 26
18 20
14 21
56 58
37 39
55 57
19 21
42 44
8 10
5 12
14 21
30 32
51 58
52 59
4 11
57 59
51 53
10 12
46 48
40 47
47 54
9 11
28 30
21 28
52 59
52 54
36 43
58 60
12 14
54 56
54 61
33 ...

output:

767525465

result:

ok single line: '767525465'

Test #63:

score: 0
Accepted
time: 7ms
memory: 9976kb

input:

37 66 1 12
27 28
3 4
15 27
5 17
21 22
7 8
24 36
2 3
5 17
7 19
7 19
10 22
1 2
3 15
35 36
10 11
24 36
7 8
4 16
25 26
13 14
6 18
10 11
35 36
5 17
26 27
21 22
7 19
9 10
22 23
4 16
19 20
21 33
10 11
2 3
23 24
13 14
8 9
1 2
25 37
23 35
29 30
15 16
17 29
4 16
6 18
16 28
19 31
2 14
5 6
8 9
31 32
28 29
25 37...

output:

27935760

result:

ok single line: '27935760'

Test #64:

score: 0
Accepted
time: 12ms
memory: 12752kb

input:

51 93 27 43
7 50
2 45
20 47
8 35
15 42
3 46
4 47
7 50
5 32
7 34
24 51
13 40
2 45
4 31
6 33
5 48
1 44
3 46
5 48
3 46
6 49
8 35
5 48
2 45
6 49
8 51
21 48
1 28
5 32
5 48
4 47
7 50
22 49
11 38
2 45
1 28
5 32
2 45
5 48
11 38
4 47
3 46
21 48
9 36
7 50
24 51
2 45
7 50
7 50
4 47
6 49
5 48
8 51
2 45
5 48
8 3...

output:

6000000

result:

ok single line: '6000000'

Test #65:

score: 0
Accepted
time: 29ms
memory: 12480kb

input:

168 171 10 87
23 33
39 126
61 71
71 158
147 157
4 91
40 127
34 121
49 136
54 64
60 147
26 113
76 163
66 76
2 12
150 160
116 126
40 50
25 112
128 138
26 36
31 118
94 104
2 89
34 44
158 168
85 95
25 112
47 134
115 125
18 28
136 146
64 74
70 157
35 122
119 129
59 146
31 41
70 157
26 36
13 100
41 128
66...

output:

598812938

result:

ok single line: '598812938'

Test #66:

score: 0
Accepted
time: 31ms
memory: 12104kb

input:

163 309 18 24
71 89
129 147
15 39
18 42
134 152
84 108
115 133
128 152
138 162
93 111
62 80
143 161
58 82
106 124
25 49
25 49
14 38
27 51
54 78
142 160
98 122
101 119
130 154
133 157
110 134
54 78
105 123
78 102
34 52
131 155
19 37
110 134
92 116
67 91
129 147
83 107
82 100
74 98
95 119
52 76
109 12...

output:

157233449

result:

ok single line: '157233449'

Test #67:

score: 0
Accepted
time: 38ms
memory: 13924kb

input:

173 324 90 125
37 162
46 171
81 171
82 172
78 168
14 104
4 129
38 163
5 95
19 144
33 158
64 154
25 115
36 126
15 140
22 147
43 168
19 144
8 133
31 121
4 129
29 119
22 112
21 146
32 157
27 117
22 147
17 142
48 138
18 143
26 151
59 149
62 152
42 167
54 144
21 146
21 146
3 128
48 138
8 133
50 140
36 16...

output:

579575222

result:

ok single line: '579575222'

Test #68:

score: 0
Accepted
time: 55ms
memory: 12584kb

input:

193 346 43 170
49 92
19 189
23 193
132 175
75 118
15 185
1 171
3 173
17 60
19 189
2 45
11 181
81 124
7 177
21 191
60 103
3 173
7 177
78 121
103 146
18 61
42 85
27 70
14 57
1 171
125 168
120 163
1 171
1 171
57 100
43 86
139 182
22 192
139 182
44 87
77 120
41 84
54 97
23 193
8 178
6 176
4 174
54 97
16...

output:

996951630

result:

ok single line: '996951630'

Test #69:

score: 0
Accepted
time: 23ms
memory: 13420kb

input:

97 151 63 77
2 65
18 81
7 84
13 90
1 64
18 95
30 93
26 89
10 73
21 84
2 79
7 84
11 74
5 68
14 77
15 92
2 65
25 88
17 94
32 95
29 92
11 74
14 91
18 95
12 75
7 84
15 92
8 85
17 80
2 79
20 83
17 80
1 78
13 90
14 77
19 96
8 85
4 67
19 96
5 82
5 68
18 95
14 91
2 79
22 85
3 80
19 96
22 85
8 85
32 95
20 83...

output:

594285772

result:

ok single line: '594285772'

Test #70:

score: 0
Accepted
time: 3ms
memory: 9960kb

input:

10 11 2 9
3 5
6 8
8 10
1 3
3 5
8 10
8 10
1 10
1 10
7 9
1 10

output:

26

result:

ok single line: '26'

Test #71:

score: 0
Accepted
time: 15ms
memory: 13700kb

input:

61 69 13 42
4 46
15 57
15 57
17 59
14 56
9 51
9 51
8 50
8 50
3 45
43 56
13 55
7 49
4 46
10 52
39 52
47 60
16 58
10 23
20 33
1 14
14 56
12 54
7 49
19 61
16 58
35 48
17 59
17 30
31 44
23 36
15 28
33 46
15 57
46 59
2 44
2 15
40 53
14 56
13 26
4 46
4 46
34 47
42 55
24 37
2 44
4 46
35 48
9 51
1 43
15 28
...

output:

817152000

result:

ok single line: '817152000'

Test #72:

score: 0
Accepted
time: 30ms
memory: 13332kb

input:

119 196 9 89
95 104
2 11
12 101
19 108
1 90
16 25
26 115
5 14
25 34
91 100
9 98
2 91
75 84
101 110
6 95
8 17
23 32
17 106
30 119
96 105
91 100
30 39
4 93
48 57
92 101
5 94
9 98
30 119
16 105
37 46
5 94
13 102
19 28
2 91
28 117
70 79
15 104
40 49
104 113
10 99
74 83
77 86
28 117
26 115
44 53
24 113
3...

output:

824075663

result:

ok single line: '824075663'

Test #73:

score: 0
Accepted
time: 8ms
memory: 12992kb

input:

59 66 26 32
12 44
28 54
3 35
20 46
4 30
14 40
2 34
26 58
8 40
27 53
7 33
21 47
7 33
31 57
1 27
3 35
14 46
26 58
5 31
26 58
21 47
20 46
14 46
11 43
30 56
8 40
18 44
10 42
10 36
18 50
16 48
24 56
4 36
23 49
28 54
6 38
21 53
10 36
26 58
21 53
10 36
16 48
7 39
7 33
33 59
18 44
10 36
20 52
22 54
9 35
16 ...

output:

405285882

result:

ok single line: '405285882'

Test #74:

score: 0
Accepted
time: 20ms
memory: 12884kb

input:

101 187 36 38
22 58
63 101
6 42
33 71
44 82
54 92
52 88
46 82
61 99
12 48
21 57
44 82
21 57
37 75
52 88
50 88
52 90
14 52
23 59
41 79
24 60
7 43
48 84
47 85
12 50
20 58
29 67
15 53
8 44
63 101
55 93
24 60
18 54
28 66
9 47
38 76
60 96
29 65
2 40
61 99
1 37
11 49
58 96
40 76
2 40
2 40
5 41
18 56
54 92...

output:

900777340

result:

ok single line: '900777340'

Test #75:

score: 0
Accepted
time: 35ms
memory: 13000kb

input:

156 231 72 106
5 111
4 110
18 90
68 140
84 156
3 75
26 98
69 141
20 126
10 116
8 114
15 121
45 151
43 115
37 143
39 111
37 143
22 128
26 132
65 137
50 122
5 77
36 108
37 143
19 125
82 154
82 154
80 152
6 112
32 138
25 131
5 111
45 151
14 86
26 132
17 89
50 156
5 111
78 150
4 76
19 125
28 134
82 154
...

output:

655735988

result:

ok single line: '655735988'

Test #76:

score: 0
Accepted
time: 47ms
memory: 13508kb

input:

186 335 146 155
17 172
22 168
20 166
17 163
7 153
11 157
14 169
23 169
13 159
16 171
29 175
13 159
14 169
37 183
25 180
31 177
33 179
8 163
30 185
26 181
39 185
24 170
11 157
19 174
25 180
21 176
25 171
2 148
19 165
5 160
7 162
21 176
30 185
11 157
17 163
1 156
37 183
2 148
9 155
39 185
15 170
17 16...

output:

694374741

result:

ok single line: '694374741'

Test #77:

score: 0
Accepted
time: 18ms
memory: 12976kb

input:

78 146 15 24
6 21
12 36
58 73
62 77
1 16
22 46
35 50
50 74
60 75
38 53
20 35
32 56
23 38
55 70
44 68
17 32
43 67
19 34
4 19
63 78
44 59
29 53
37 52
39 54
40 64
48 72
5 29
30 45
20 35
50 74
5 29
33 57
31 46
26 41
16 31
33 48
29 44
47 62
49 64
46 70
55 70
25 49
16 31
8 32
40 55
45 69
20 35
28 52
32 56...

output:

242799874

result:

ok single line: '242799874'

Test #78:

score: 0
Accepted
time: 36ms
memory: 13508kb

input:

142 212 21 110
19 40
11 121
74 95
26 47
7 117
8 118
88 109
35 56
53 74
100 121
21 131
15 36
21 131
7 117
75 96
3 113
11 121
23 44
32 142
9 119
93 114
8 118
21 131
91 112
13 123
55 76
25 135
12 122
111 132
3 113
63 84
111 132
11 121
11 121
12 122
95 116
42 63
93 114
104 125
89 110
14 124
81 102
96 11...

output:

466697322

result:

ok single line: '466697322'

Test #79:

score: 0
Accepted
time: 51ms
memory: 13940kb

input:

158 182 22 156
2 158
2 158
1 157
2 158
1 157
34 56
134 156
2 158
113 135
30 52
94 116
42 64
1 157
118 140
121 143
69 91
124 146
62 84
2 158
2 158
105 127
2 158
128 150
1 157
1 157
12 34
2 158
46 68
65 87
34 56
41 63
2 158
1 157
87 109
2 158
58 80
1 157
30 52
111 133
28 50
116 138
34 56
2 158
2 158
1...

output:

577704244

result:

ok single line: '577704244'

Test #80:

score: 0
Accepted
time: 16ms
memory: 12344kb

input:

99 146 52 59
18 77
5 64
40 92
5 64
34 93
8 67
30 82
15 74
27 79
25 77
13 72
23 75
11 63
37 89
26 85
20 79
33 85
12 71
32 84
13 72
29 88
27 79
2 54
4 63
43 95
24 83
11 63
13 65
1 60
36 95
6 65
18 77
21 73
42 94
45 97
44 96
35 87
12 64
20 72
41 93
37 89
31 83
30 82
26 85
13 72
1 60
3 62
26 85
33 85
4 ...

output:

226054729

result:

ok single line: '226054729'

Test #81:

score: 0
Accepted
time: 27ms
memory: 13588kb

input:

106 132 20 90
25 45
64 84
2 92
14 104
9 29
11 101
17 37
11 101
80 100
8 98
25 45
6 96
8 28
35 55
9 99
12 102
11 101
1 91
4 94
59 79
39 59
49 69
13 103
10 100
16 106
7 97
49 69
69 89
11 101
72 92
8 98
2 92
7 27
81 101
12 32
56 76
34 54
12 102
13 33
83 103
15 105
4 24
52 72
4 24
16 106
53 73
15 105
4 ...

output:

869249388

result:

ok single line: '869249388'

Test #82:

score: 0
Accepted
time: 13ms
memory: 9924kb

input:

76 106 4 8
1 5
45 53
34 38
31 39
28 36
29 37
55 59
42 50
25 33
72 76
20 28
38 46
56 64
33 41
42 50
66 74
2 6
23 31
68 72
47 55
27 35
36 40
7 11
38 42
68 76
70 74
9 13
46 50
67 75
28 36
34 42
44 52
23 27
21 25
1 9
23 27
23 31
5 9
67 75
56 64
24 28
52 60
43 51
48 52
32 36
32 40
27 35
5 9
28 32
41 49
4...

output:

456454764

result:

ok single line: '456454764'

Test #83:

score: 0
Accepted
time: 10ms
memory: 12192kb

input:

48 64 6 27
40 46
14 41
1 28
22 28
8 35
23 29
10 16
4 31
13 40
11 38
5 32
17 44
7 13
3 30
11 17
16 22
12 18
20 47
13 19
18 45
16 43
10 16
32 38
16 22
11 38
7 34
11 17
16 43
7 34
10 37
33 39
19 46
37 43
15 42
20 47
37 43
41 47
19 46
13 40
19 46
21 48
21 48
1 7
15 21
26 32
7 34
11 17
31 37
11 38
8 35
4...

output:

145728000

result:

ok single line: '145728000'

Test #84:

score: 0
Accepted
time: 27ms
memory: 13848kb

input:

98 177 4 91
46 50
2 93
58 62
2 6
7 98
5 96
84 88
41 45
1 92
7 11
3 94
47 51
73 77
7 98
85 89
6 97
6 97
5 96
56 60
76 80
4 95
45 49
1 5
4 95
65 69
5 96
6 97
59 63
88 92
10 14
86 90
5 96
50 54
5 96
2 93
6 97
7 98
92 96
2 93
3 94
34 38
2 93
33 37
77 81
7 98
7 98
7 98
7 98
1 92
5 96
57 61
7 98
14 18
7 1...

output:

689893215

result:

ok single line: '689893215'

Test #85:

score: 0
Accepted
time: 29ms
memory: 12312kb

input:

87 173 59 86
21 80
22 81
1 87
1 87
1 87
22 81
14 73
1 87
20 79
19 78
3 62
13 72
1 87
1 87
15 74
1 87
2 61
16 75
17 76
20 79
1 87
1 87
1 87
21 80
28 87
6 65
1 87
2 61
8 67
1 87
19 78
1 87
8 67
15 74
1 87
1 87
10 69
1 87
12 71
1 87
1 87
10 69
28 87
1 87
1 87
1 87
5 64
1 87
27 86
11 70
1 87
1 87
1 87
1...

output:

83886080

result:

ok single line: '83886080'

Test #86:

score: 0
Accepted
time: 16ms
memory: 13788kb

input:

54 104 6 47
30 36
25 31
20 26
5 11
6 53
32 38
2 49
29 35
32 38
6 53
35 41
1 48
1 7
2 49
16 22
2 49
3 50
23 29
4 10
2 49
2 49
48 54
36 42
6 53
6 53
4 51
1 48
35 41
2 49
6 53
21 27
26 32
25 31
9 15
1 48
4 51
3 9
1 48
5 52
34 40
6 53
2 49
28 34
29 35
6 53
4 51
4 51
5 52
2 49
38 44
1 48
47 53
22 28
28 3...

output:

982698494

result:

ok single line: '982698494'

Test #87:

score: 0
Accepted
time: 37ms
memory: 13716kb

input:

137 235 23 111
40 63
25 136
20 131
18 129
15 126
102 125
39 62
2 113
3 114
21 132
1 112
101 124
1 24
70 93
10 121
68 91
19 42
27 50
81 104
93 116
59 82
23 134
65 88
12 123
16 127
42 65
37 60
72 95
100 123
32 55
12 123
22 133
3 114
11 122
10 121
103 126
17 128
2 113
20 131
25 136
23 134
52 75
15 126
...

output:

341998780

result:

ok single line: '341998780'

Test #88:

score: 0
Accepted
time: 11ms
memory: 13900kb

input:

73 133 9 38
29 38
54 63
10 19
18 27
16 54
1 10
28 37
38 47
11 49
2 11
41 50
19 28
1 39
49 58
61 70
20 29
32 70
33 71
10 48
26 35
6 15
2 11
2 11
27 65
28 66
30 68
22 60
21 59
32 41
34 72
4 13
4 42
16 54
61 70
14 52
47 56
13 51
6 15
25 63
25 34
26 35
3 12
26 64
14 52
26 64
16 25
29 67
1 10
7 16
35 44
...

output:

69719187

result:

ok single line: '69719187'

Test #89:

score: 0
Accepted
time: 22ms
memory: 13020kb

input:

81 88 16 65
3 68
61 77
11 76
42 58
8 73
14 79
45 61
6 22
6 71
57 73
8 73
22 38
19 35
65 81
56 72
44 60
15 80
42 58
30 46
14 79
13 78
10 75
10 75
11 27
8 73
12 77
1 17
47 63
16 32
15 80
1 66
10 75
4 69
55 71
9 74
11 76
30 46
3 19
31 47
1 17
14 79
14 79
8 73
50 66
1 66
15 31
16 81
46 62
7 72
3 68
53 6...

output:

518033287

result:

ok single line: '518033287'

Test #90:

score: 0
Accepted
time: 25ms
memory: 13600kb

input:

80 98 4 75
34 38
2 77
18 22
46 50
3 78
29 33
55 59
2 77
2 77
3 78
5 80
43 47
29 33
31 35
3 78
45 49
4 79
5 80
5 80
54 58
7 11
4 8
39 43
2 77
3 78
60 64
70 74
1 5
2 77
3 78
2 6
4 79
1 76
58 62
3 78
56 60
2 77
46 50
3 78
71 75
5 80
3 78
3 78
4 79
76 80
69 73
56 60
3 78
71 75
2 77
27 31
2 77
5 80
52 56...

output:

477249529

result:

ok single line: '477249529'

Test #91:

score: 0
Accepted
time: 41ms
memory: 12688kb

input:

156 247 133 136
18 151
7 143
1 137
19 152
5 138
11 147
12 148
15 151
3 139
22 155
11 147
23 156
14 147
15 148
23 156
19 152
18 151
2 138
6 139
4 137
17 153
3 136
12 148
10 146
12 145
14 150
3 139
18 154
18 151
3 139
6 142
21 154
1 137
1 134
5 141
8 141
10 143
6 142
2 138
2 135
1 137
16 149
5 138
15 ...

output:

557505137

result:

ok single line: '557505137'

Test #92:

score: 0
Accepted
time: 35ms
memory: 13716kb

input:

120 184 45 118
2 120
2 120
43 88
64 109
1 119
2 120
1 119
2 120
39 84
54 99
1 119
21 66
1 119
50 95
2 120
2 120
74 119
60 105
2 120
33 78
2 120
1 119
1 119
2 120
55 100
40 85
2 120
13 58
2 120
1 119
2 120
2 120
31 76
2 120
29 74
1 119
2 120
53 98
2 120
1 119
69 114
61 106
50 95
1 119
1 119
2 120
61 ...

output:

754937505

result:

ok single line: '754937505'

Test #93:

score: 0
Accepted
time: 24ms
memory: 12836kb

input:

88 152 31 83
5 88
2 85
1 84
26 57
19 50
13 44
28 59
25 56
14 45
55 86
5 88
5 88
3 86
25 56
1 84
1 84
27 58
25 56
3 34
5 88
1 84
9 40
1 84
5 88
55 86
1 84
10 41
45 76
31 62
11 42
1 84
5 88
4 87
1 84
3 86
1 84
2 85
3 86
5 88
5 88
1 84
32 63
41 72
5 88
56 87
29 60
1 84
4 87
7 38
4 87
1 84
3 86
3 86
5 8...

output:

681125630

result:

ok single line: '681125630'

Test #94:

score: 0
Accepted
time: 20ms
memory: 13304kb

input:

102 142 28 72
54 82
17 89
30 102
13 85
3 75
25 53
3 31
20 92
27 99
10 82
4 76
2 74
2 74
20 92
18 46
25 53
2 74
3 75
25 53
58 86
17 89
8 80
48 76
1 29
57 85
22 94
60 88
26 98
23 95
3 75
2 74
51 79
23 95
4 76
3 75
29 57
30 102
28 100
15 43
15 43
23 95
7 35
5 77
40 68
8 36
13 85
38 66
16 88
30 58
13 41...

output:

369526981

result:

ok single line: '369526981'

Test #95:

score: 0
Accepted
time: 19ms
memory: 14132kb

input:

114 184 31 33
55 88
48 81
9 42
53 84
72 103
5 38
82 113
41 72
9 42
56 89
32 65
83 114
54 85
29 62
76 109
43 76
71 102
77 108
11 44
30 63
2 35
18 49
23 54
39 72
11 44
75 108
36 67
13 44
78 111
51 82
69 102
28 61
33 64
57 88
45 78
80 113
66 97
44 75
45 76
62 95
82 113
79 110
18 51
73 106
22 55
25 56
3...

output:

626334651

result:

ok single line: '626334651'

Test #96:

score: 0
Accepted
time: 5ms
memory: 9976kb

input:

20 26 2 15
3 18
3 5
1 16
17 19
1 3
2 17
18 20
5 20
17 19
5 7
4 19
5 7
8 10
4 6
3 5
4 19
16 18
1 16
1 16
3 18
2 17
3 18
2 17
5 20
2 17
2 17

output:

512

result:

ok single line: '512'

Test #97:

score: 0
Accepted
time: 42ms
memory: 13060kb

input:

146 195 115 126
25 140
22 137
17 143
14 129
14 140
21 136
14 129
18 144
22 137
14 140
5 131
11 137
13 139
5 131
14 140
7 122
29 144
10 136
16 142
8 123
21 136
2 117
11 126
20 135
28 143
3 118
7 133
11 137
1 116
4 119
19 145
4 130
8 134
12 127
8 134
8 134
19 134
7 122
4 130
14 140
9 135
1 116
8 134
1...

output:

860695626

result:

ok single line: '860695626'

Test #98:

score: 0
Accepted
time: 25ms
memory: 13588kb

input:

122 182 7 57
21 28
33 90
56 63
66 73
14 21
34 41
4 61
34 41
75 82
80 87
80 87
10 67
6 13
18 75
67 74
5 62
58 65
63 70
49 56
48 105
59 116
36 93
66 73
71 78
78 85
5 62
36 93
7 14
53 110
23 80
65 122
111 118
55 62
63 120
58 65
111 118
73 80
30 37
65 122
63 120
51 108
94 101
9 66
33 90
111 118
53 60
9 ...

output:

387940705

result:

ok single line: '387940705'

Test #99:

score: 0
Accepted
time: 3ms
memory: 9968kb

input:

12 20 3 8
9 12
1 9
2 10
2 10
9 12
3 6
4 12
7 10
3 6
1 9
2 10
3 6
1 4
1 4
3 11
2 10
4 7
1 9
2 5
1 4

output:

132

result:

ok single line: '132'

Test #100:

score: 0
Accepted
time: 26ms
memory: 12372kb

input:

125 192 14 76
38 114
10 86
62 76
2 78
43 57
55 69
22 98
18 94
70 84
105 119
43 119
14 28
36 50
98 112
46 122
5 81
17 31
14 90
19 33
19 33
18 32
27 103
29 105
73 87
1 77
49 125
17 93
95 109
18 32
35 49
20 96
1 15
18 94
84 98
108 122
4 80
66 80
2 78
3 79
44 120
109 123
83 97
34 48
7 21
2 78
57 71
85 9...

output:

513309247

result:

ok single line: '513309247'