QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#49702#4703. Sibling Rivalryzyz07#AC ✓35ms4924kbC++111.1kb2022-09-22 15:29:272022-09-22 15:29:29

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-22 15:29:29]
  • 评测
  • 测评结果:AC
  • 用时:35ms
  • 内存:4924kb
  • [2022-09-22 15:29:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define For(Ti,Ta,Tb) for(int Ti=(Ta);Ti<=(Tb);++Ti)
#define Dec(Ti,Ta,Tb) for(int Ti=(Ta);Ti>=(Tb);--Ti)
#define Debug(...) fprintf(stderr,__VA_ARGS__)
using ll=long long;
const int N=55,Inf=0x3f3f3f3f;
int n,m,len[3],f[N][3],exc[N][N][N*2];
vector<int> g[N];
int main(){
	ios::sync_with_stdio(false),cin.tie(nullptr);
	cin>>n>>m>>len[0]>>len[1]>>len[2];
	int mx=max({len[0],len[1],len[2]});
	For(i,1,m){
		int u,v;cin>>u>>v;
		g[v].push_back(u);
	}
	For(i,1,n){
		queue<pair<int,int>> q;
		q.push({i,0});
		while(!q.empty()){
			auto [u,d]=q.front();q.pop();
			if(d>mx||exc[i][u][d]) continue;
			exc[i][u][d]=1;
			for(int v:g[u]) if(!exc[i][v][d+1]) q.push({v,d+1});
		}
	}
	For(i,1,n-1) f[i][0]=f[i][1]=f[i][2]=Inf;
	For(i,1,n*n) For(u,1,n) For(v,1,n) For(j,0,2){
		int dis=max({f[u][0],f[u][1],f[u][2]})+1;
		if(exc[u][v][len[j]]&&dis<f[v][j]) f[v][j]=dis;
	}
	int ans=max({f[1][0],f[1][1],f[1][2]});
	if(ans==Inf) cout<<"IMPOSSIBLE\n";
	else cout<<ans<<'\n';
	#ifdef zyz
		Debug("Elapsed time: %dms\n",int(clock()));
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3556kb

input:

3 3 1 2 4
1 2
2 3
3 1

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3752kb

input:

9 13 1 2 3
1 2
2 3
1 4
2 4
3 4
4 5
5 6
4 9
5 9
6 9
9 7
7 8
8 7

output:

2

result:

ok single line: '2'

Test #3:

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

input:

6 11 1 2 2
1 2
1 3
2 3
3 2
2 4
3 4
4 5
5 4
4 6
5 6
1 5

output:

2

result:

ok single line: '2'

Test #4:

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

input:

49 112 1 2 3
1 2
1 3
2 3
2 4
3 1
3 2
3 4
4 5
4 6
5 6
5 7
6 4
6 5
6 7
7 8
7 9
8 9
8 10
9 7
9 8
9 10
10 11
10 12
11 12
11 13
12 10
12 11
12 13
13 14
13 15
14 15
14 16
15 13
15 14
15 16
16 17
16 18
17 18
17 19
18 16
18 17
18 19
19 20
19 21
20 21
20 22
21 19
21 20
21 22
22 23
22 24
23 24
23 25
24 22
24 ...

output:

32

result:

ok single line: '32'

Test #5:

score: 0
Accepted
time: 9ms
memory: 4212kb

input:

46 105 3 1 2
1 45
1 43
45 43
45 17
43 1
43 45
43 17
17 8
17 14
8 14
8 13
14 17
14 8
14 13
13 31
13 36
31 36
31 21
36 13
36 31
36 21
21 19
21 27
19 27
19 9
27 21
27 19
27 9
9 34
9 30
34 30
34 24
30 9
30 34
30 24
24 29
24 40
29 40
29 38
40 24
40 29
40 38
38 25
38 23
25 23
25 6
23 38
23 25
23 6
6 5
6 2...

output:

30

result:

ok single line: '30'

Test #6:

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

input:

43 98 3 2 1
1 42
1 41
42 41
42 40
41 1
41 42
41 40
40 39
40 38
39 38
39 37
38 40
38 39
38 37
37 36
37 35
36 35
36 34
35 37
35 36
35 34
34 33
34 32
33 32
33 31
32 34
32 33
32 31
31 30
31 29
30 29
30 28
29 31
29 30
29 28
28 27
28 26
27 26
27 25
26 28
26 27
26 25
25 24
25 23
24 23
24 22
23 25
23 24
23 ...

output:

28

result:

ok single line: '28'

Test #7:

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

input:

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

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #8:

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

input:

47 69 3 1 2
1 36
1 29
36 1
29 7
29 3
7 29
3 15
3 35
15 3
35 9
35 19
9 35
19 32
19 38
32 19
38 23
38 33
23 38
33 12
33 5
12 33
5 30
5 40
30 5
40 46
40 4
46 40
4 21
4 22
21 4
22 41
22 2
41 22
2 34
2 45
34 2
45 42
45 28
42 45
28 25
28 6
25 28
6 43
6 24
43 6
24 13
24 20
13 24
20 11
20 17
11 20
17 18
17 ...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #9:

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

input:

45 66 3 2 1
1 44
1 43
44 1
43 42
43 41
42 43
41 40
41 39
40 41
39 38
39 37
38 39
37 36
37 35
36 37
35 34
35 33
34 35
33 32
33 31
32 33
31 30
31 29
30 31
29 28
29 27
28 29
27 26
27 25
26 27
25 24
25 23
24 25
23 22
23 21
22 23
21 20
21 19
20 21
19 18
19 17
18 19
17 16
17 15
16 17
15 14
15 13
14 15
13 ...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #10:

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

input:

50 111 1 2 3
46 2
46 3
2 3
2 4
3 46
3 2
3 4
4 5
4 6
5 6
5 7
6 4
6 5
6 7
7 8
7 9
8 9
8 10
9 7
9 8
9 10
10 11
10 12
11 12
11 13
12 10
12 11
12 13
13 14
13 15
14 15
14 16
15 13
15 14
15 16
16 17
16 18
17 18
17 19
18 16
18 17
18 19
19 20
19 21
20 21
20 22
21 19
21 20
21 22
22 23
22 24
23 24
23 25
24 22
...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #11:

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

input:

48 108 3 1 2
5 32
5 17
32 17
32 36
17 5
17 32
17 36
36 27
36 6
27 6
27 37
6 36
6 27
6 37
37 35
37 4
35 4
35 47
4 37
4 35
4 47
47 3
47 25
3 25
3 28
25 47
25 3
25 28
28 39
28 41
39 41
39 19
41 28
41 39
41 19
19 16
19 15
16 15
16 9
15 19
15 16
15 9
9 24
9 38
24 38
24 26
38 9
38 24
38 26
26 33
26 45
33 ...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #12:

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

input:

46 105 3 2 1
46 45
46 44
45 44
45 43
44 46
44 45
44 43
43 42
43 41
42 41
42 40
41 43
41 42
41 40
40 39
40 38
39 38
39 37
38 40
38 39
38 37
37 36
37 35
36 35
36 34
35 37
35 36
35 34
34 33
34 32
33 32
33 31
32 34
32 33
32 31
31 30
31 29
30 29
30 28
29 31
29 30
29 28
28 27
28 26
27 26
27 25
26 28
26 27...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #13:

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

input:

49 97 1 2 3
1 2
1 3
2 3
2 4
3 1
3 2
3 4
4 5
4 6
5 6
5 7
6 4
6 5
6 7
7 8
7 9
8 9
8 10
9 7
9 8
9 10
10 11
10 12
11 12
11 13
12 10
12 11
12 13
13 14
13 15
14 15
14 16
15 13
15 14
15 16
16 17
16 18
17 18
17 19
18 16
18 17
18 19
19 20
19 21
20 21
20 22
21 19
21 20
21 22
22 23
22 24
23 24
23 25
24 22
24 2...

output:

20

result:

ok single line: '20'

Test #14:

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

input:

46 90 3 1 2
1 39
1 10
39 10
39 2
10 1
10 39
10 2
2 6
2 18
6 18
6 16
18 2
18 6
18 16
16 26
16 5
26 5
26 21
5 16
5 26
5 21
21 34
21 15
34 15
34 29
15 21
15 34
15 29
29 23
29 19
23 19
23 42
19 29
19 23
19 42
42 3
42 33
3 33
3 12
33 42
33 3
33 12
12 38
12 7
38 7
38 45
7 12
7 38
7 45
45 31
45 44
31 44
31...

output:

18

result:

ok single line: '18'

Test #15:

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

input:

43 83 3 2 1
1 42
1 41
42 41
42 40
41 1
41 42
41 40
40 39
40 38
39 38
39 37
38 40
38 39
38 37
37 36
37 35
36 35
36 34
35 37
35 36
35 34
34 33
34 32
33 32
33 31
32 34
32 33
32 31
31 30
31 29
30 29
30 28
29 31
29 30
29 28
28 27
28 26
27 26
27 25
26 28
26 27
26 25
25 24
25 23
24 23
24 22
23 25
23 24
23 ...

output:

16

result:

ok single line: '16'

Test #16:

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

input:

49 97 1 2 3
31 2
31 3
2 3
2 4
3 31
3 2
3 4
4 5
4 6
5 6
5 7
6 4
6 5
6 7
7 8
7 9
8 9
8 10
9 7
9 8
9 10
10 11
10 12
11 12
11 13
12 10
12 11
12 13
13 14
13 15
14 15
14 16
15 13
15 14
15 16
16 17
16 18
17 18
17 19
18 16
18 17
18 19
19 20
19 21
20 21
20 22
21 19
21 20
21 22
22 23
22 24
23 24
23 25
24 22
2...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #17:

score: 0
Accepted
time: 14ms
memory: 4340kb

input:

47 94 3 1 2
22 20
22 30
20 30
20 46
30 22
30 20
30 46
46 15
46 25
15 25
15 28
25 46
25 15
25 28
28 2
28 9
2 9
2 27
9 28
9 2
9 27
27 3
27 36
3 36
3 18
36 27
36 3
36 18
18 12
18 40
12 40
12 32
40 18
40 12
40 32
32 6
32 14
6 14
6 34
14 32
14 6
14 34
34 45
34 5
45 5
45 33
5 34
5 45
5 33
33 39
33 4
39 4
...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #18:

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

input:

45 91 3 2 1
15 44
15 43
44 43
44 42
43 15
43 44
43 42
42 41
42 40
41 40
41 39
40 42
40 41
40 39
39 38
39 37
38 37
38 36
37 39
37 38
37 36
36 35
36 34
35 34
35 33
34 36
34 35
34 33
33 32
33 31
32 31
32 30
31 33
31 32
31 30
30 29
30 28
29 28
29 27
28 30
28 29
28 27
27 26
27 25
26 25
26 24
25 27
25 26
...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #19:

score: 0
Accepted
time: 9ms
memory: 4588kb

input:

49 91 3 1 2
1 26
1 37
1 10
26 37
37 10
37 3
10 3
10 44
3 13
3 44
13 44
44 7
44 6
44 20
7 6
6 20
6 25
20 25
20 32
25 42
25 32
42 32
32 31
32 8
32 15
31 8
8 15
8 14
15 14
15 28
14 12
14 28
12 28
28 29
28 35
28 40
29 35
35 40
35 19
40 19
40 5
19 24
19 5
24 5
5 11
5 41
5 36
11 41
41 36
41 46
36 46
36 18...

output:

16

result:

ok single line: '16'

Test #20:

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

input:

50 92 3 1 2
1 3
1 25
1 29
3 25
25 29
25 32
29 32
29 21
32 12
32 21
12 21
21 14
21 17
21 28
14 17
17 28
17 8
28 8
28 34
8 4
8 34
4 34
34 15
34 42
34 30
15 42
42 30
42 16
30 16
30 18
16 41
16 18
41 18
18 5
18 22
18 7
5 22
22 7
22 27
7 27
7 11
27 39
27 11
39 11
11 47
11 36
11 31
47 36
36 31
36 6
31 6
3...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #21:

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

input:

49 91 5 2 3
1 29
1 5
1 43
29 5
5 43
5 47
43 47
43 6
47 45
47 6
45 6
6 16
6 24
6 14
16 24
24 14
24 42
14 42
14 13
42 20
42 13
20 13
13 37
13 38
13 9
37 38
38 9
38 22
9 22
9 34
22 15
22 34
15 34
34 26
34 41
34 28
26 41
41 28
41 35
28 35
28 27
35 7
35 27
7 27
27 2
27 25
27 36
2 25
25 36
25 32
36 32
36 ...

output:

8

result:

ok single line: '8'

Test #22:

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

input:

50 92 5 2 3
1 2
1 20
1 17
2 20
20 17
20 12
17 12
17 23
12 3
12 23
3 23
23 33
23 5
23 7
33 5
5 7
5 16
7 16
7 9
16 42
16 9
42 9
9 19
9 49
9 48
19 49
49 48
49 30
48 30
48 27
30 25
30 27
25 27
27 35
27 24
27 34
35 24
24 34
24 10
34 10
34 38
10 32
10 38
32 38
38 6
38 13
38 40
6 13
13 40
13 46
40 46
40 11...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #23:

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

input:

49 91 4 11 8
1 8
1 43
1 29
8 43
43 29
43 16
29 16
29 22
16 44
16 22
44 22
22 21
22 2
22 37
21 2
2 37
2 27
37 27
37 32
27 40
27 32
40 32
32 9
32 14
32 5
9 14
14 5
14 7
5 7
5 26
7 48
7 26
48 26
26 15
26 10
26 34
15 10
10 34
10 35
34 35
34 28
35 47
35 28
47 28
28 3
28 11
28 36
3 11
11 36
11 30
36 30
36...

output:

4

result:

ok single line: '4'

Test #24:

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

input:

50 92 4 11 8
1 18
1 24
1 44
18 24
24 44
24 5
44 5
44 31
5 38
5 31
38 31
31 39
31 41
31 32
39 41
41 32
41 46
32 46
32 9
46 33
46 9
33 9
9 19
9 10
9 30
19 10
10 30
10 35
30 35
30 14
35 42
35 14
42 14
14 36
14 11
14 37
36 11
11 37
11 29
37 29
37 15
29 17
29 15
17 15
15 40
15 48
15 26
40 48
48 26
48 13
...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #25:

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

input:

49 50 98 100 99
1 30
30 3
3 14
14 47
47 46
46 7
7 34
34 42
42 20
20 5
5 44
44 21
21 23
23 37
37 26
26 33
33 31
31 15
15 35
35 29
29 48
48 13
13 28
28 18
18 25
25 16
16 12
12 11
11 2
2 45
45 39
39 41
41 8
8 19
19 38
38 4
4 24
24 40
40 22
22 36
36 10
10 32
32 27
27 17
17 43
43 6
6 9
9 49
49 1
30 14

output:

24

result:

ok single line: '24'

Test #26:

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

input:

50 51 98 100 99
1 21
21 7
7 6
6 43
43 3
3 9
9 23
23 22
22 5
5 20
20 46
46 26
26 39
39 16
16 14
14 2
2 42
42 35
35 27
27 12
12 15
15 24
24 17
17 48
48 49
49 32
32 10
10 28
28 30
30 11
11 29
29 18
18 25
25 13
13 19
19 37
37 33
33 41
41 4
4 34
34 31
31 36
36 38
38 40
40 44
44 47
47 8
8 45
45 50
50 1
21 6

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #27:

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

input:

44 45 98 100 99
1 23
23 30
30 27
27 40
40 11
11 10
10 26
26 38
38 4
4 33
33 9
9 8
8 7
7 42
42 37
37 43
43 17
17 25
25 5
5 14
14 12
12 6
6 3
3 29
29 28
28 34
34 13
13 31
31 16
16 20
20 22
22 39
39 35
35 41
41 36
36 19
19 18
18 21
21 32
32 2
2 24
24 15
15 44
44 1
27 23

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #28:

score: 0
Accepted
time: 14ms
memory: 4596kb

input:

45 46 98 100 99
1 35
35 11
11 42
42 36
36 40
40 26
26 12
12 30
30 3
3 25
25 32
32 5
5 6
6 41
41 14
14 38
38 21
21 15
15 2
2 33
33 43
43 4
4 27
27 10
10 23
23 20
20 44
44 8
8 19
19 34
34 13
13 17
17 29
29 9
9 24
24 7
7 16
16 22
22 39
39 18
18 37
37 28
28 31
31 45
45 1
35 31

output:

2

result:

ok single line: '2'

Test #29:

score: 0
Accepted
time: 14ms
memory: 4640kb

input:

46 47 98 100 99
1 23
23 33
33 15
15 11
11 39
39 44
44 19
19 4
4 29
29 6
6 24
24 27
27 9
9 16
16 26
26 34
34 8
8 7
7 36
36 31
31 20
20 38
38 35
35 5
5 12
12 13
13 18
18 10
10 22
22 25
25 41
41 14
14 32
32 28
28 37
37 2
2 3
3 42
42 45
45 43
43 17
17 21
21 30
30 40
40 46
46 1
23 21

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #30:

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

input:

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

output:

7

result:

ok single line: '7'

Test #31:

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

input:

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

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #32:

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

input:

50 273 2 3 4
1 2
1 10
1 25
1 32
1 40
2 1
2 3
3 2
3 4
3 14
3 41
4 3
4 5
4 16
4 17
4 42
4 50
5 2
5 3
5 4
5 6
5 13
5 28
5 33
5 42
6 5
6 7
6 8
6 22
6 36
7 6
7 8
7 12
7 24
7 33
8 7
8 9
8 12
8 13
8 19
9 3
9 8
9 10
9 12
9 13
9 24
9 47
10 7
10 9
10 11
10 15
10 23
10 30
11 10
11 12
11 13
11 22
11 23
11 28
11...

output:

2

result:

ok single line: '2'

Test #33:

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

input:

50 258 2 1 2
1 2
1 3
1 4
1 15
1 34
1 47
2 1
2 3
2 5
2 17
3 1
3 2
3 4
3 5
3 12
3 22
3 28
3 30
4 3
4 5
4 6
4 39
4 48
5 4
5 6
5 9
5 15
5 16
5 20
6 5
6 7
6 8
6 35
7 5
7 6
7 8
7 37
8 7
8 9
8 18
8 19
8 23
8 36
9 8
9 10
9 11
9 12
9 44
10 8
10 9
10 11
10 12
10 34
11 4
11 10
11 12
11 14
11 16
11 18
11 27
12 ...

output:

3

result:

ok single line: '3'

Test #34:

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

input:

50 266 1 2 4
1 2
1 16
1 22
1 45
1 47
2 1
2 3
2 4
2 9
2 21
3 2
3 4
3 19
3 45
4 2
4 3
4 5
4 13
4 20
4 26
4 41
5 4
5 6
6 5
6 7
6 13
6 14
6 34
6 38
7 5
7 6
7 8
7 41
7 47
8 7
8 9
8 10
8 20
8 34
8 49
9 6
9 7
9 8
9 10
9 11
9 15
9 18
9 21
9 37
10 1
10 9
10 11
10 37
11 1
11 9
11 10
11 12
11 24
11 40
11 45
12...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #35:

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

input:

50 277 3 1 4
1 2
1 3
1 44
1 47
2 1
2 3
2 25
2 32
3 1
3 2
3 4
3 6
3 21
3 25
3 31
3 33
3 48
4 3
4 5
4 14
4 18
4 32
5 4
5 6
5 12
5 13
5 41
5 43
5 48
6 3
6 5
6 7
7 6
7 8
7 9
7 14
7 19
8 2
8 7
8 9
8 35
9 8
9 10
9 24
9 29
9 34
9 44
10 7
10 9
10 11
10 24
10 34
11 10
11 12
11 20
12 8
12 11
12 13
12 14
12 18...

output:

3

result:

ok single line: '3'

Test #36:

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

input:

50 253 1 4 3
1 2
1 14
2 1
2 3
2 15
2 24
2 32
3 2
3 4
3 29
3 31
3 33
4 3
4 5
4 10
5 1
5 4
5 6
5 25
5 28
5 33
6 5
6 7
6 26
6 38
6 43
7 3
7 4
7 6
7 8
7 30
8 7
8 9
8 20
8 21
8 44
9 3
9 8
9 10
9 11
10 9
10 11
10 17
10 20
10 32
10 49
11 7
11 10
11 12
11 14
11 46
12 11
12 13
12 14
12 16
12 24
13 9
13 12
13...

output:

3

result:

ok single line: '3'

Test #37:

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

input:

50 291 1 3 3
1 2
1 3
1 15
1 17
2 1
2 3
2 21
2 24
2 40
3 2
3 4
3 11
3 17
3 21
3 23
3 24
3 46
4 3
4 5
4 25
4 42
4 43
4 49
5 2
5 3
5 4
5 6
5 7
5 23
5 25
5 38
5 41
5 44
6 5
6 7
6 24
7 6
7 8
7 10
7 16
7 44
8 7
8 9
8 10
8 11
8 46
8 50
9 8
9 10
9 20
9 23
9 30
9 39
10 9
10 11
10 13
11 10
11 12
11 20
11 22
1...

output:

3

result:

ok single line: '3'

Test #38:

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

input:

50 279 1 1 3
1 2
1 12
1 16
2 1
2 3
2 28
2 42
3 2
3 4
3 16
3 19
3 32
3 33
3 46
4 3
4 5
4 32
4 35
4 50
5 4
5 6
5 23
6 2
6 5
6 7
6 8
6 9
6 14
7 6
7 8
7 16
7 30
8 6
8 7
8 9
8 31
9 8
9 10
9 27
9 28
9 29
9 38
10 9
10 11
10 24
10 29
11 8
11 9
11 10
11 12
11 13
11 37
11 49
12 10
12 11
12 13
12 14
13 4
13 11...

output:

4

result:

ok single line: '4'

Test #39:

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

input:

50 293 1 4 4
1 2
1 5
1 6
1 12
1 13
1 42
2 1
2 3
2 4
2 5
2 6
2 7
2 16
2 25
2 33
3 2
3 4
3 6
3 39
4 1
4 3
4 5
4 35
5 4
5 6
5 17
5 37
5 39
5 41
6 3
6 5
6 7
6 9
6 27
6 47
6 48
7 5
7 6
7 8
7 9
7 17
7 18
7 21
8 7
8 9
8 11
9 5
9 8
9 10
9 26
10 5
10 8
10 9
10 11
10 24
10 30
10 46
11 10
11 12
11 28
11 35
11 ...

output:

3

result:

ok single line: '3'

Test #40:

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

input:

50 266 4 3 2
1 2
1 42
2 1
2 3
2 16
2 22
2 35
3 2
3 4
3 10
3 14
3 27
3 28
3 33
3 49
4 3
4 5
5 4
5 6
5 8
5 15
5 23
5 28
5 33
5 42
5 47
5 50
6 5
6 7
6 23
6 24
6 30
6 42
6 46
7 6
7 8
7 13
7 25
8 7
8 9
8 30
9 5
9 7
9 8
9 10
9 11
9 19
9 49
10 9
10 11
10 12
10 14
10 44
10 48
11 7
11 10
11 12
11 18
11 28
11...

output:

2

result:

ok single line: '2'

Test #41:

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

input:

50 281 4 4 3
1 2
1 33
1 41
2 1
2 3
2 4
2 5
2 6
2 9
2 24
2 26
2 38
2 45
2 48
2 49
3 2
3 4
3 35
3 39
4 3
4 5
4 20
4 28
4 34
4 45
5 3
5 4
5 6
5 7
5 19
5 46
6 4
6 5
6 7
6 13
6 21
6 27
6 35
6 50
7 6
7 8
7 12
7 21
7 28
7 32
8 3
8 7
8 9
8 11
8 21
8 27
8 47
9 8
9 10
9 20
9 37
9 47
10 9
10 11
10 26
11 8
11 1...

output:

1

result:

ok single line: '1'

Test #42:

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

input:

50 299 15 9 13
1 2
1 5
1 23
1 30
1 36
2 1
2 3
2 5
2 18
2 23
2 26
2 28
2 33
2 37
2 46
3 2
3 4
3 25
3 44
3 49
4 3
4 5
4 6
4 14
4 46
5 4
5 6
5 11
5 40
6 3
6 4
6 5
6 7
6 11
6 45
7 4
7 6
7 8
7 9
7 36
8 7
8 9
8 12
8 25
8 26
9 8
9 10
9 13
9 21
9 30
9 37
9 41
9 49
10 7
10 9
10 11
10 12
10 36
10 46
11 5
11 6...

output:

1

result:

ok single line: '1'

Test #43:

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

input:

50 282 9 2 8
1 2
1 10
1 34
1 47
2 1
2 3
3 1
3 2
3 4
3 5
3 38
4 3
4 5
4 6
4 7
4 9
4 13
4 22
4 23
4 43
5 2
5 4
5 6
5 7
5 18
5 38
5 49
6 3
6 5
6 7
6 16
7 5
7 6
7 8
7 9
7 22
7 29
7 34
7 35
7 44
8 7
8 9
8 27
8 33
9 4
9 8
9 10
9 24
9 26
9 36
9 46
9 47
9 50
10 2
10 5
10 9
10 11
10 25
10 43
11 10
11 12
11 1...

output:

2

result:

ok single line: '2'

Test #44:

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

input:

50 289 1 13 19
1 2
1 12
2 1
2 3
2 6
2 38
3 1
3 2
3 4
3 37
3 45
4 3
4 5
4 11
4 18
4 38
4 42
5 4
5 6
5 8
5 9
5 33
6 5
6 7
6 18
6 23
6 35
6 36
7 3
7 5
7 6
7 8
7 9
7 39
7 50
8 4
8 7
8 9
8 36
8 38
8 45
8 46
9 3
9 8
9 10
9 14
9 22
9 28
9 38
9 40
9 47
10 1
10 2
10 6
10 9
10 11
10 13
10 33
10 40
11 9
11 10
...

output:

4

result:

ok single line: '4'

Test #45:

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

input:

50 268 5 2 17
1 2
1 22
1 25
1 40
1 43
2 1
2 3
2 5
2 27
2 39
3 2
3 4
3 26
4 3
4 5
4 6
4 41
4 44
5 4
5 6
5 10
5 21
5 25
6 3
6 4
6 5
6 7
6 8
6 24
6 25
6 44
7 6
7 8
7 9
7 15
7 16
7 18
7 39
8 2
8 4
8 7
8 9
8 25
8 26
8 32
8 42
9 7
9 8
9 10
9 50
10 5
10 8
10 9
10 11
10 25
10 33
10 34
11 7
11 9
11 10
11 12
...

output:

2

result:

ok single line: '2'

Test #46:

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

input:

50 281 10 6 9
1 2
1 3
1 34
1 40
1 46
1 49
2 1
2 3
2 4
2 13
2 16
2 21
2 22
2 28
2 40
3 1
3 2
3 4
3 11
3 19
3 34
4 2
4 3
4 5
4 16
4 36
4 37
4 42
5 3
5 4
5 6
5 7
5 35
5 41
6 5
6 7
6 19
6 29
6 37
7 6
7 8
7 9
7 24
7 27
7 43
8 7
8 9
8 20
8 27
8 34
8 36
9 8
9 10
9 14
9 47
10 7
10 8
10 9
10 11
10 18
10 22
1...

output:

1

result:

ok single line: '1'

Test #47:

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

input:

50 268 16 15 20
1 2
1 3
1 8
2 1
2 3
2 4
2 28
2 47
3 2
3 4
3 33
4 3
4 5
4 6
4 7
4 14
4 48
5 4
5 6
5 18
5 19
6 3
6 5
6 7
6 8
6 14
6 45
7 5
7 6
7 8
7 26
7 44
8 7
8 9
8 10
8 11
8 39
8 43
9 2
9 8
9 10
9 23
9 40
10 9
10 11
10 12
10 26
10 41
11 5
11 10
11 12
11 13
11 38
11 45
12 1
12 4
12 11
12 13
12 17
12...

output:

1

result:

ok single line: '1'

Test #48:

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

input:

50 261 6 18 14
1 2
1 23
1 39
1 40
2 1
2 3
2 13
2 45
3 2
3 4
3 12
3 25
3 27
4 3
4 5
4 24
5 4
5 6
5 19
5 20
5 24
5 36
5 47
6 3
6 4
6 5
6 7
6 8
6 16
6 44
7 6
7 8
7 14
7 18
7 25
8 7
8 9
8 10
8 43
9 5
9 6
9 8
9 10
9 26
9 39
9 49
10 9
10 11
10 13
10 17
10 24
10 40
10 42
10 47
11 9
11 10
11 12
11 33
12 10
...

output:

1

result:

ok single line: '1'

Test #49:

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

input:

50 266 13 16 14
1 2
1 4
1 36
1 37
2 1
2 3
2 4
2 23
2 27
2 47
3 2
3 4
3 6
3 15
3 22
3 34
3 37
4 3
4 5
4 19
5 3
5 4
5 6
5 19
5 28
6 5
6 7
6 9
7 6
7 8
7 9
7 39
7 46
8 7
8 9
8 11
8 14
8 17
8 21
9 8
9 10
9 33
9 39
9 46
10 4
10 9
10 11
10 12
10 25
10 30
11 10
11 12
11 26
11 44
11 45
11 47
12 3
12 11
12 13...

output:

1

result:

ok single line: '1'

Test #50:

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

input:

50 288 3 17 19
1 2
1 11
1 49
2 1
2 3
2 15
2 26
2 30
2 32
2 39
3 1
3 2
3 4
3 8
3 11
3 48
4 3
4 5
4 6
4 7
4 8
4 12
4 18
4 40
4 41
5 4
5 6
5 14
5 21
5 44
6 5
6 7
6 9
6 28
6 44
7 6
7 8
7 22
7 23
8 7
8 9
8 37
8 45
9 5
9 8
9 10
9 11
9 40
10 1
10 3
10 6
10 9
10 11
10 24
11 10
11 12
11 13
11 26
11 36
11 44
...

output:

2

result:

ok single line: '2'

Test #51:

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

input:

50 264 7 18 9
1 2
1 3
1 4
1 14
1 41
1 42
2 1
2 3
2 5
2 26
3 2
3 4
3 43
4 3
4 5
4 40
5 4
5 6
5 12
5 36
5 46
6 5
6 7
6 29
6 37
6 46
6 48
7 6
7 8
7 34
8 1
8 2
8 5
8 7
8 9
8 41
8 43
9 6
9 8
9 10
9 37
10 2
10 7
10 9
10 11
10 12
10 26
10 42
10 50
11 10
11 12
11 22
11 33
12 7
12 10
12 11
12 13
12 14
12 31
...

output:

1

result:

ok single line: '1'

Test #52:

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

input:

49 2090 1 1 1
1 41
1 10
1 26
1 35
1 4
1 14
1 20
1 15
1 48
1 30
1 3
1 13
1 34
1 32
1 28
1 24
1 6
1 5
1 37
1 7
1 36
1 17
1 22
1 16
1 18
1 21
1 23
1 19
1 11
1 43
1 33
1 44
1 2
1 47
1 42
1 8
1 25
1 46
1 49
41 10
41 40
41 27
41 35
41 4
41 14
41 20
41 15
41 48
41 39
41 30
41 3
41 13
41 34
41 32
41 28
41 2...

output:

1

result:

ok single line: '1'

Test #53:

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

input:

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

output:

1

result:

ok single line: '1'

Test #54:

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

input:

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

output:

1

result:

ok single line: '1'

Test #55:

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

input:

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

output:

1

result:

ok single line: '1'

Test #56:

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

input:

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

output:

1

result:

ok single line: '1'

Test #57:

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

input:

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

output:

1

result:

ok single line: '1'

Test #58:

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

input:

50 1846 2 1 1
1 46
1 10
1 11
1 29
1 22
1 44
1 18
1 31
1 45
1 14
1 15
1 23
1 38
1 28
1 30
1 26
1 49
1 33
1 27
1 3
1 35
1 42
1 47
1 17
1 21
1 16
1 40
1 7
1 34
1 24
1 13
1 36
1 25
1 12
1 4
1 41
1 19
46 1
46 10
46 11
46 29
46 22
46 44
46 18
46 31
46 45
46 14
46 15
46 23
46 38
46 28
46 30
46 26
46 49
46 ...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #59:

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

input:

50 1846 2 1 1
1 44
1 23
1 11
1 46
1 33
1 18
1 14
1 31
1 24
1 32
1 4
1 21
1 36
1 22
1 28
1 45
1 5
1 2
1 10
1 13
1 6
1 39
1 12
1 26
1 47
1 34
1 20
1 16
1 25
1 41
1 48
1 15
1 19
1 30
1 3
1 7
1 37
44 1
44 23
44 11
44 46
44 33
44 18
44 14
44 31
44 24
44 32
44 4
44 21
44 36
44 22
44 28
44 45
44 5
44 2
44 ...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #60:

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

input:

20 62 1 3 4
1 2
1 5
2 1
2 3
2 18
3 2
3 4
3 20
4 3
4 5
5 4
5 6
5 8
5 16
5 20
6 5
6 7
6 11
7 6
7 8
7 17
8 7
8 9
9 8
9 10
9 19
10 9
10 11
10 12
11 9
11 10
11 12
12 3
12 11
12 13
12 15
12 19
13 12
13 14
13 17
14 13
14 15
14 16
15 1
15 7
15 14
15 16
16 15
16 17
16 19
17 4
17 16
17 18
18 10
18 14
18 17
18...

output:

2

result:

ok single line: '2'

Test #61:

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

input:

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

output:

2

result:

ok single line: '2'

Test #62:

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

input:

20 66 1 4 3
1 2
2 1
2 3
3 2
3 4
3 5
4 3
4 5
4 15
4 16
4 18
5 2
5 4
5 6
6 1
6 4
6 5
6 7
7 3
7 6
7 8
7 10
7 15
8 4
8 7
8 9
8 10
8 20
9 5
9 8
9 10
9 12
9 17
10 3
10 9
10 11
11 1
11 10
11 12
11 13
12 11
12 13
12 14
13 12
13 14
13 16
14 13
14 15
15 1
15 7
15 13
15 14
15 16
15 17
16 15
16 17
16 20
17 15
1...

output:

5

result:

ok single line: '5'

Test #63:

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

input:

27 98 2 3 4
1 2
1 13
2 1
2 3
2 24
3 2
3 4
3 8
3 17
3 18
3 20
3 21
3 25
4 2
4 3
4 5
4 27
5 3
5 4
5 6
5 19
6 5
6 7
7 1
7 6
7 8
7 10
7 22
8 6
8 7
8 9
9 8
9 10
9 23
10 3
10 8
10 9
10 11
10 12
11 10
11 12
12 11
12 13
12 15
13 3
13 12
13 14
13 17
13 23
14 13
14 15
14 26
15 14
15 16
15 19
15 24
16 3
16 10
...

output:

2

result:

ok single line: '2'

Test #64:

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

input:

20 72 4 3 4
1 2
1 19
2 1
2 3
2 4
3 2
3 4
4 2
4 3
4 5
4 6
4 15
5 2
5 4
5 6
5 12
6 3
6 4
6 5
6 7
7 6
7 8
8 7
8 9
8 16
8 17
9 3
9 8
9 10
9 11
9 15
9 20
10 9
10 11
10 16
11 3
11 9
11 10
11 12
11 15
12 6
12 9
12 11
12 13
12 14
13 12
13 14
13 18
13 20
14 2
14 13
14 15
15 1
15 14
15 16
15 17
15 18
16 13
16...

output:

1

result:

ok single line: '1'

Test #65:

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

input:

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

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #66:

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

input:

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

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #67:

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

input:

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

output:

32

result:

ok single line: '32'

Test #68:

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

input:

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

output:

49

result:

ok single line: '49'

Test #69:

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

input:

10 33 97 100 94
1 4
1 8
1 6
9 4
9 8
9 6
2 4
2 8
2 6
10 4
10 8
10 6
4 3
4 5
4 7
8 3
8 5
8 7
6 3
6 5
6 7
3 1
3 9
3 2
3 10
5 1
5 9
5 2
5 10
7 1
7 9
7 2
7 10

output:

3

result:

ok single line: '3'

Test #70:

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

input:

10 33 97 100 98
1 5
1 9
1 4
8 5
8 9
8 4
6 5
6 9
6 4
10 5
10 9
10 4
5 3
5 2
5 7
9 3
9 2
9 7
4 3
4 2
4 7
3 1
3 8
3 6
3 10
2 1
2 8
2 6
2 10
7 1
7 8
7 6
7 10

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'

Test #71:

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

input:

49 800 97 100 94
1 18
1 26
1 42
1 21
1 16
1 3
1 23
1 33
1 27
1 43
1 32
1 8
1 28
1 40
1 12
1 41
25 18
25 26
25 42
25 21
25 16
25 3
25 23
25 33
25 27
25 43
25 32
25 8
25 28
25 40
25 12
25 41
7 18
7 26
7 42
7 21
7 16
7 3
7 23
7 33
7 27
7 43
7 32
7 8
7 28
7 40
7 12
7 41
11 18
11 26
11 42
11 21
11 16
11 ...

output:

3

result:

ok single line: '3'

Test #72:

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

input:

49 800 97 100 98
1 3
1 32
1 20
1 33
1 29
1 43
1 6
1 48
1 38
1 47
1 46
1 2
1 10
1 28
1 25
1 27
21 3
21 32
21 20
21 33
21 29
21 43
21 6
21 48
21 38
21 47
21 46
21 2
21 10
21 28
21 25
21 27
35 3
35 32
35 20
35 33
35 29
35 43
35 6
35 48
35 38
35 47
35 46
35 2
35 10
35 28
35 25
35 27
19 3
19 32
19 20
19 ...

output:

IMPOSSIBLE

result:

ok single line: 'IMPOSSIBLE'