QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#129702#4818. Inverse Line GraphDerekFengTL 6651ms102652kbC++232.5kb2023-07-22 22:21:142023-07-22 22:21:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-22 22:21:15]
  • 评测
  • 测评结果:TL
  • 用时:6651ms
  • 内存:102652kb
  • [2023-07-22 22:21:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int N=3e5+4,M=3e6+4;
int n,m,A[N],B[N],S,tot;vector<int>gr[N],vec;
bool vis[N];int cnt[N],ls[N],num;
vector<int>v[N];map<pii,int>mp;int dfn[N],tg;
void dfs(int x){
	vis[x]=1,S+=gr[x].size(),vec.emplace_back(x);
	for(auto&y:gr[x])if(!vis[y])dfs(y);
}
bool check(int x,vector<int>a,vector<int>b){
	for(auto&i:vec)cnt[i]=0;
	for(int i=3;i<gr[x].size();i++){
		int y=gr[x][i];
		if(mp.count({a[1],y})&&mp.count({a[2],y}))a.emplace_back(y);
		else b.emplace_back(y);
	}
	cnt[x]=2;queue<int>que;
	for(auto&y:gr[x])cnt[y]=1,que.push(y);
	num=0;v[++num]=a,v[++num]=b;
	for(auto&x:a)ls[x]=1;for(auto&x:b)ls[x]=2;
	while(!que.empty()){
		int u=que.front();que.pop();if(cnt[u]>1)continue;
		cnt[u]++;if(v[ls[u]].size()-1>gr[u].size())return 0;
		++tg;for(auto&w:v[ls[u]])dfn[w]=tg;
		v[++num]={u};for(auto&w:gr[u])if(dfn[w]!=tg){
			v[num].emplace_back(w),ls[w]=num,cnt[w]++;
			if(cnt[w]<2)que.push(w);
		}
	}
	for(auto&i:vec)if(cnt[i]!=2)return 0;
	long long sum=0;
	for(int i=1;i<=num;i++)sum+=(long long)(v[i].size()-1)*v[i].size();
	if(sum!=S)return 0;
	map<pii,int>pm;
	for(int i=1;i<=num;i++)for(auto&u:v[i])for(auto&w:v[i]){
		if(u<w&&(!mp.count({u,w})||pm.count({u,w})))return 0;
		pm[{u,w}]=1;
	}
	return 1;
}
void calc(){
	for(auto&x:vec)cnt[x]=0;
	for(int i=1;i<=num;i++)for(auto&x:v[i]){
		if(cnt[x]==0)A[x]=tot+i;
		if(cnt[x]==1)B[x]=tot+i;
		cnt[x]++;
	}
	tot+=num;
}
void sol(){
	cin>>n>>m,tot=0;
	for(int i=1;i<=n;i++)gr[i].clear(),vis[i]=0;
	mp.clear();while(m--){
		int u,v;cin>>u>>v;mp[{u,v}]=mp[{v,u}]=1;
		gr[u].emplace_back(v),gr[v].emplace_back(u);
	}
	for(int i=1;i<=n;i++)if(!vis[i]){
		vec.clear(),S=0,dfs(i);
		if(gr[i].size()==0){A[i]=++tot,B[i]=++tot;continue;}
		if(gr[i].size()==1)if(check(i,{i,gr[i][0]},{i})){calc();continue;}
		if(gr[i].size()==2){
			if(check(i,{i,gr[i][0],gr[i][1]},{i})){calc();continue;}
			if(check(i,{i,gr[i][0]},{i,gr[i][1]})){calc();continue;}
		}
		if(gr[i].size()>2){
			if(check(i,{i,gr[i][0],gr[i][1],gr[i][2]},{i})){calc();continue;}
			if(check(i,{i,gr[i][0],gr[i][1]},{i,gr[i][2]})){calc();continue;}
			if(check(i,{i,gr[i][0],gr[i][2]},{i,gr[i][1]})){calc();continue;}
			if(check(i,{i,gr[i][1],gr[i][2]},{i,gr[i][0]})){calc();continue;}
		}
		cout<<"No\n";
		return;
	}
	cout<<"Yes\n"<<tot<<' '<<n<<'\n';
	for(int i=1;i<=n;i++)cout<<A[i]<<' '<<B[i]<<'\n';
}
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int tc;cin>>tc;while(tc--)sol();
}

详细

Test #1:

score: 100
Accepted
time: 6ms
memory: 22504kb

input:

6
5 6
1 2
1 3
1 4
3 4
2 5
4 5
1 0
2 1
1 2
3 3
1 2
1 3
2 3
4 3
1 2
1 3
1 4
5 6
1 2
2 3
2 4
3 4
3 5
4 5

output:

Yes
5 5
1 2
2 3
1 4
1 5
3 5
Yes
2 1
1 2
Yes
3 2
1 2
1 3
Yes
4 3
1 2
1 3
1 4
No
Yes
5 5
1 2
1 3
3 4
3 5
4 5

result:

ok that's great! (sum n = 20, sum m = 19) (6 test cases)

Test #2:

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

input:

5
6 5
3 4
1 6
1 5
2 5
5 6
2 0
1 0
5 3
2 3
3 4
2 4
6 4
5 6
4 5
1 6
2 4

output:

Yes
8 6
1 2
4 5
6 7
6 8
1 4
1 3
Yes
4 2
1 2
3 4
Yes
2 1
1 2
Yes
8 5
1 2
3 4
3 5
3 6
7 8
Yes
8 6
1 2
5 6
7 8
4 5
3 4
1 3

result:

ok that's great! (sum n = 20, sum m = 12) (5 test cases)

Test #3:

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

input:

14
5 3
2 5
1 5
1 2
4 3
2 4
1 2
1 3
5 6
2 3
1 5
4 5
2 4
1 2
1 3
3 0
6 5
3 4
1 5
2 6
5 6
2 3
4 4
1 2
3 4
1 4
2 3
6 7
1 3
5 6
3 6
1 2
3 5
1 6
2 6
1 0
5 5
1 2
2 4
2 5
3 5
4 5
4 0
2 0
3 0
1 0
1 0

output:

Yes
8 5
1 2
1 4
5 6
7 8
1 3
Yes
5 4
1 2
1 3
2 4
3 5
Yes
5 5
1 2
1 4
1 5
3 4
2 3
Yes
6 3
1 2
3 4
5 6
Yes
7 6
1 2
4 5
5 6
6 7
1 3
3 4
Yes
4 4
1 2
1 3
3 4
2 4
Yes
7 6
1 2
1 4
2 3
6 7
3 5
1 3
Yes
2 1
1 2
Yes
6 5
1 2
1 3
5 6
3 4
3 5
Yes
8 4
1 2
3 4
5 6
7 8
Yes
4 2
1 2
3 4
Yes
6 3
1 2
3 4
5 6
Yes
2 1
1 2
...

result:

ok that's great! (sum n = 50, sum m = 33) (14 test cases)

Test #4:

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

input:

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

output:

No
Yes
8 9
1 2
4 5
7 8
6 8
4 7
1 5
3 6
2 4
1 3
Yes
4 2
1 2
3 4
Yes
7 5
1 2
6 7
1 3
3 4
4 5
Yes
3 2
1 2
1 3

result:

ok that's great! (sum n = 23, sum m = 19) (5 test cases)

Test #5:

score: 0
Accepted
time: 148ms
memory: 22284kb

input:

61395
7 0
1 0
5 1
1 2
3 1
1 3
7 11
2 4
2 5
1 6
5 7
1 4
1 5
2 7
3 7
1 2
3 5
4 5
9 10
2 7
4 5
5 9
1 8
1 3
2 6
6 7
2 4
3 7
6 8
1 0
8 10
2 6
6 8
1 4
1 8
4 6
2 4
2 3
1 2
4 8
1 3
9 12
3 7
4 7
7 9
1 6
3 8
2 5
5 9
3 4
4 6
4 8
5 7
7 8
6 5
2 6
1 2
4 5
2 3
1 3
3 1
1 2
2 0
1 0
4 2
1 2
2 4
3 3
1 2
2 3
1 3
1 0
9 ...

output:

Yes
14 7
1 2
3 4
5 6
7 8
9 10
11 12
13 14
Yes
2 1
1 2
Yes
9 5
1 2
1 3
4 5
6 7
8 9
Yes
5 3
1 2
4 5
1 3
Yes
7 7
1 2
1 6
5 7
1 4
1 5
2 3
5 6
Yes
9 9
1 2
5 6
2 4
6 7
7 8
3 5
4 5
1 3
8 9
Yes
2 1
1 2
Yes
9 8
1 2
2 3
2 5
1 3
6 7
3 4
8 9
1 4
Yes
10 9
1 2
9 10
4 6
3 4
5 9
1 3
4 5
4 7
5 8
Yes
8 6
1 2
1 3
1 4
...

result:

ok that's great! (sum n = 300000, sum m = 223451) (61395 test cases)

Test #6:

score: 0
Accepted
time: 291ms
memory: 22424kb

input:

38520
8 8
1 2
3 5
3 7
4 8
1 4
7 8
2 5
1 8
11 18
4 5
1 5
1 6
1 9
7 8
10 11
6 9
7 10
4 9
2 11
4 6
1 4
8 10
3 6
2 9
3 5
7 11
3 4
12 26
10 11
1 2
5 11
2 10
6 8
1 7
2 12
2 7
6 9
3 6
5 8
8 10
5 9
4 11
1 11
5 6
1 4
5 12
8 11
7 12
3 8
6 12
1 12
5 10
9 12
3 4
4 2
3 4
1 4
14 30
4 9
9 10
4 6
3 11
11 13
12 14
6...

output:

Yes
9 8
1 2
2 3
6 7
1 4
3 6
8 9
5 7
1 5
Yes
9 11
1 2
5 6
3 4
1 3
2 3
1 4
7 9
8 9
1 5
7 8
6 7
Yes
9 12
1 2
1 3
6 8
2 6
5 7
7 8
1 4
5 8
7 9
3 5
2 5
1 7
Yes
6 4
1 2
5 6
3 4
1 3
Yes
10 14
1 2
1 3
2 3
9 10
2 5
7 10
4 6
1 4
6 9
7 9
3 7
5 6
3 8
2 6
Yes
14 11
1 2
5 7
1 3
11 12
7 9
1 5
13 14
4 6
6 8
1 4
8 10...

result:

ok that's great! (sum n = 300000, sum m = 439705) (38520 test cases)

Test #7:

score: 0
Accepted
time: 392ms
memory: 22000kb

input:

29408
2 0
10 20
7 9
3 4
3 10
7 10
4 8
4 5
5 8
6 9
3 5
1 3
8 9
4 7
4 10
1 10
6 7
4 6
1 2
7 8
3 8
6 10
4 2
1 3
2 4
8 6
3 8
5 6
2 5
1 5
2 7
4 6
14 35
9 10
8 13
5 7
3 13
2 7
4 5
8 11
11 12
6 12
1 13
1 12
2 5
5 10
4 10
2 12
4 7
5 9
8 9
1 3
4 9
5 12
2 10
3 10
9 11
1 11
2 8
2 3
7 12
6 11
8 10
3 8
9 13
11 1...

output:

Yes
4 2
1 2
3 4
Yes
8 10
1 2
2 5
1 3
3 4
3 6
4 8
4 7
3 7
7 8
1 4
Yes
6 4
1 2
4 5
1 3
4 6
No
Yes
9 14
1 2
4 5
1 5
7 8
4 7
2 6
4 8
3 5
3 7
5 7
2 3
2 4
1 3
6 9
Yes
10 14
1 2
1 3
2 5
1 4
5 6
4 8
7 9
4 5
4 6
5 9
8 10
4 7
6 9
3 6
Yes
10 17
1 2
2 3
4 6
1 3
3 4
7 9
8 10
6 7
3 5
4 7
8 9
2 4
6 9
1 4
4 8
3 6
7...

result:

ok that's great! (sum n = 300000, sum m = 602206) (29408 test cases)

Test #8:

score: 0
Accepted
time: 604ms
memory: 20712kb

input:

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

output:

Yes
8 5
1 2
4 5
7 8
4 6
1 3
Yes
10 23
1 2
7 9
2 8
9 10
3 8
2 4
7 8
6 8
3 7
2 9
6 10
2 7
2 6
1 3
3 4
8 10
1 5
4 9
5 10
4 8
4 6
4 10
1 4
No
Yes
9 11
1 2
3 5
5 8
1 4
4 8
3 6
8 9
3 4
4 7
5 7
1 3
Yes
9 12
1 2
5 6
2 3
3 8
1 6
8 9
7 9
1 4
2 7
1 5
6 9
5 8
Yes
14 7
1 2
3 4
5 6
7 8
9 10
11 12
13 14
Yes
10 14
...

result:

ok that's great! (sum n = 300000, sum m = 917019) (19907 test cases)

Test #9:

score: 0
Accepted
time: 979ms
memory: 22036kb

input:

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

output:

Yes
10 39
1 2
5 9
7 9
3 5
1 9
5 6
8 10
8 9
2 6
2 10
5 8
2 9
1 10
2 5
5 7
1 7
4 8
4 9
1 4
3 7
7 8
2 8
2 4
4 5
3 6
3 4
4 7
3 9
7 10
6 10
6 9
1 8
4 6
1 3
6 7
6 8
2 7
1 5
3 8
Yes
6 3
1 2
3 4
5 6
No
Yes
10 22
1 2
4 10
1 8
6 7
3 7
6 8
3 4
7 10
7 8
6 9
1 9
4 7
5 10
1 3
9 10
3 8
1 7
1 4
3 5
5 6
2 6
2 5
Yes
...

result:

ok that's great! (sum n = 300000, sum m = 1507380) (12137 test cases)

Test #10:

score: 0
Accepted
time: 1122ms
memory: 20844kb

input:

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

output:

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

result:

ok that's great! (sum n = 300000, sum m = 1741177) (10112 test cases)

Test #11:

score: 0
Accepted
time: 1740ms
memory: 22372kb

input:

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

output:

Yes
10 19
1 2
6 10
9 10
7 10
2 9
1 4
1 3
3 9
2 7
8 10
7 9
8 9
1 8
4 6
2 5
2 6
3 8
6 9
7 8
Yes
15 81
1 2
11 13
8 10
1 12
3 9
7 11
5 14
9 13
4 11
9 10
5 11
1 9
7 12
1 8
5 13
7 14
5 6
6 15
6 14
9 14
9 15
1 5
4 14
3 12
11 12
1 6
2 3
3 14
7 13
3 10
4 8
6 11
6 10
2 4
1 11
10 11
1 15
6 13
4 6
2 13
1 13
10 ...

result:

ok that's great! (sum n = 300000, sum m = 2530246) (6175 test cases)

Test #12:

score: 0
Accepted
time: 2048ms
memory: 22668kb

input:

5039
111 1318
69 97
72 104
34 107
89 108
6 74
36 40
58 96
50 100
20 32
8 35
24 109
5 43
60 104
21 80
58 94
76 99
88 111
27 58
4 110
3 37
81 96
71 89
102 103
98 102
43 54
13 52
23 107
33 84
70 98
31 92
19 43
68 93
28 96
65 77
96 108
30 82
17 36
40 47
26 102
45 48
30 89
70 90
73 96
13 108
10 85
19 75
...

output:

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

result:

ok that's great! (sum n = 300000, sum m = 2937547) (5039 test cases)

Test #13:

score: 0
Accepted
time: 2094ms
memory: 23148kb

input:

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

output:

Yes
7 5
1 2
3 4
3 5
6 7
4 6
No
Yes
15 81
1 2
4 6
11 15
3 11
1 4
4 5
4 10
6 9
7 11
1 10
5 15
2 4
5 13
9 10
3 9
8 13
4 11
4 9
8 14
1 13
6 11
1 7
3 8
2 13
10 14
4 15
5 12
1 15
3 4
8 12
2 7
3 7
4 14
2 5
8 9
5 8
3 5
1 9
9 15
6 15
2 12
5 11
2 8
2 9
5 6
3 10
7 12
1 3
3 6
13 15
7 10
11 14
2 14
10 12
2 11
8 ...

result:

ok that's great! (sum n = 278099, sum m = 3000000) (4021 test cases)

Test #14:

score: 0
Accepted
time: 2125ms
memory: 22988kb

input:

3705
130 1346
38 108
28 45
89 123
19 93
24 50
21 42
29 61
14 28
48 116
26 71
101 113
18 80
70 92
106 108
1 4
17 71
5 65
84 92
6 121
71 129
83 126
5 77
48 123
94 104
20 58
3 128
13 65
111 128
113 118
5 116
80 129
10 15
84 107
55 89
75 100
119 122
19 99
60 87
1 18
102 128
25 80
104 128
49 79
5 115
74 ...

output:

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

result:

ok that's great! (sum n = 264646, sum m = 3000000) (3705 test cases)

Test #15:

score: 0
Accepted
time: 2125ms
memory: 22872kb

input:

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

output:

Yes
8 7
1 2
4 6
2 5
1 4
7 8
1 3
6 7
Yes
10 43
1 2
5 6
2 3
1 10
3 8
7 10
1 3
4 10
2 7
1 8
9 10
4 8
5 8
2 4
4 7
3 5
5 9
6 9
2 10
1 9
3 10
1 4
4 5
4 6
3 6
3 4
7 9
6 8
2 5
8 9
8 10
1 5
3 9
6 10
5 7
2 9
2 6
1 6
3 7
1 7
2 8
7 8
6 7
Yes
22 126
1 2
3 16
5 9
10 20
6 7
8 15
1 3
8 12
10 16
3 7
14 16
3 12
16 17...

result:

ok that's great! (sum n = 272523, sum m = 3000000) (3784 test cases)

Test #16:

score: 0
Accepted
time: 2064ms
memory: 22820kb

input:

3162
137 1468
72 136
53 128
14 22
51 105
28 137
23 32
49 66
24 56
28 89
2 101
8 62
68 104
21 90
69 136
37 114
50 127
56 67
10 129
60 63
134 135
16 78
77 102
103 106
5 68
14 95
4 72
42 137
19 93
72 110
73 92
6 61
56 85
4 69
18 83
53 126
73 136
30 35
6 25
71 106
14 129
77 131
60 92
37 49
69 91
77 78
1...

output:

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

result:

ok that's great! (sum n = 249028, sum m = 3000000) (3162 test cases)

Test #17:

score: 0
Accepted
time: 2128ms
memory: 23276kb

input:

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

output:

Yes
14 54
1 2
9 13
5 6
3 5
8 10
4 9
5 7
6 13
3 7
1 7
2 10
6 12
5 10
9 14
2 4
9 10
1 6
3 11
6 8
6 10
2 3
2 8
5 8
4 5
4 12
4 6
1 8
2 7
2 9
3 9
6 9
3 6
4 7
1 9
5 9
3 4
7 10
8 12
1 4
9 12
1 10
8 14
3 10
4 10
1 3
2 6
3 8
2 5
1 5
4 8
7 8
6 7
8 9
7 9
Yes
13 34
1 2
3 9
1 4
3 7
1 7
8 9
1 5
1 10
2 6
6 10
1 3
...

result:

ok that's great! (sum n = 260516, sum m = 3000000) (3356 test cases)

Test #18:

score: 0
Accepted
time: 2182ms
memory: 22828kb

input:

3325
68 615
24 59
7 41
20 27
31 53
45 48
40 65
48 53
39 44
35 53
23 53
25 67
12 36
8 61
35 65
59 67
12 49
46 67
4 31
28 39
6 49
5 28
20 24
53 57
52 60
32 47
19 38
12 25
26 56
4 45
27 34
38 53
15 21
7 57
2 11
6 12
11 41
14 55
7 24
21 23
38 57
13 34
29 43
45 51
17 44
30 67
20 23
46 63
31 34
31 47
6 47...

output:

Yes
15 68
1 2
7 13
7 12
6 10
2 7
1 6
8 13
1 12
1 8
10 12
13 14
6 12
7 8
2 8
11 13
10 14
8 9
1 4
3 14
3 9
11 15
2 11
3 11
9 13
2 12
1 5
1 9
2 5
1 10
3 12
9 10
9 14
7 14
7 9
3 8
9 12
12 14
3 7
5 9
1 7
6 13
1 13
10 13
9 11
7 10
4 12
6 9
10 11
6 14
8 11
6 7
8 10
3 10
1 14
2 4
1 11
3 13
3 6
5 13
6 8
8 12...

result:

ok that's great! (sum n = 261664, sum m = 3000000) (3325 test cases)

Test #19:

score: 0
Accepted
time: 2137ms
memory: 22944kb

input:

2871
163 712
160 162
26 128
15 120
147 153
99 144
33 137
30 69
107 115
12 15
9 61
82 102
50 161
156 163
48 161
73 118
110 152
2 32
3 136
36 72
99 139
34 85
3 99
26 124
33 43
135 145
4 160
8 87
64 94
29 113
125 131
80 88
17 84
103 108
80 125
45 57
31 55
64 89
46 58
97 157
136 148
69 159
9 149
16 89
6...

output:

No
Yes
9 14
1 2
2 6
1 4
1 6
2 5
3 6
6 8
4 6
4 7
7 9
1 3
4 8
3 5
5 6
Yes
56 159
1 2
24 25
5 17
4 15
3 15
8 21
8 14
7 9
13 16
17 22
8 16
2 15
3 18
7 10
11 14
3 12
6 7
2 7
14 22
11 15
9 11
1 17
6 13
14 16
5 12
3 16
9 12
1 12
5 10
10 15
9 10
7 15
6 8
2 11
17 23
3 11
1 5
9 22
2 14
6 9
26 27
7 17
2 8
3 10...

result:

ok that's great! (sum n = 244676, sum m = 3000000) (2871 test cases)

Test #20:

score: 0
Accepted
time: 2167ms
memory: 22976kb

input:

3036
72 655
16 64
10 27
24 72
1 67
17 53
7 46
35 66
21 24
9 24
4 58
24 62
19 63
11 34
11 64
13 64
23 41
20 70
21 65
10 72
38 42
5 25
4 12
11 16
61 66
21 60
9 72
25 34
28 40
34 48
42 54
45 60
34 64
12 53
5 22
8 30
15 42
35 54
42 53
15 27
21 37
7 48
19 24
17 33
14 65
27 48
61 70
8 13
28 37
62 65
2 14
...

output:

Yes
15 72
1 2
8 13
7 9
3 12
2 7
2 5
3 5
2 9
9 12
9 14
5 8
3 14
1 9
1 13
8 14
5 10
6 14
3 7
9 11
2 4
6 7
7 13
3 15
6 9
7 12
4 10
7 14
1 4
5 11
8 9
2 6
2 10
2 14
5 12
1 5
6 11
1 7
1 12
10 13
4 14
1 3
8 12
10 11
2 12
5 15
3 10
12 15
5 14
9 10
6 15
6 12
2 13
12 14
1 8
7 8
3 8
12 13
3 6
4 8
5 7
11 15
5 6...

result:

ok that's great! (sum n = 252869, sum m = 3000000) (3036 test cases)

Test #21:

score: 0
Accepted
time: 2173ms
memory: 23184kb

input:

3032
10 13
1 2
5 7
1 9
3 4
8 10
6 9
1 4
6 10
3 5
2 7
9 10
4 9
1 7
73 703
9 46
52 62
38 73
10 39
41 44
11 35
51 68
1 19
2 67
7 63
30 36
60 63
29 61
13 67
33 64
12 18
18 51
29 46
55 61
18 57
13 26
17 64
3 15
5 20
8 19
35 45
3 18
15 27
30 37
66 69
45 46
36 37
33 35
48 68
46 55
30 32
15 23
25 36
46 64
3...

output:

Yes
10 10
1 2
2 3
5 9
1 5
6 9
4 7
2 6
8 10
1 4
4 8
Yes
15 73
1 2
3 6
5 8
5 7
13 14
9 10
5 15
3 11
4 7
1 10
2 13
4 8
3 12
2 15
8 11
1 11
10 11
4 5
2 3
11 14
11 15
3 8
8 13
2 6
3 10
2 12
11 12
3 14
7 8
3 5
2 7
2 5
9 11
8 9
11 13
3 7
3 4
2 11
1 4
2 4
1 9
8 14
1 14
7 9
6 11
7 11
7 13
4 13
6 9
4 15
5 9
7...

result:

ok that's great! (sum n = 254049, sum m = 3000000) (3032 test cases)

Test #22:

score: 0
Accepted
time: 2100ms
memory: 23004kb

input:

2640
89 987
53 55
23 65
14 71
11 87
62 71
15 72
57 70
47 61
29 54
51 89
79 83
46 54
44 79
9 63
14 41
49 61
19 83
20 89
43 77
41 89
6 68
29 75
15 81
21 63
37 78
52 58
42 44
36 45
40 60
14 78
64 74
22 80
21 46
39 57
25 87
54 76
50 84
46 80
47 51
65 80
6 28
30 89
26 39
5 55
9 14
30 44
26 61
41 62
36 50...

output:

Yes
15 89
1 2
13 14
4 6
9 13
8 10
4 5
3 12
3 15
1 5
3 7
7 14
8 13
14 15
1 6
4 9
1 3
1 15
5 13
6 7
4 12
3 5
12 14
2 9
5 11
4 7
13 15
7 15
1 4
6 9
1 12
3 13
11 15
3 6
3 8
7 13
3 11
7 11
8 14
10 15
10 13
1 13
12 15
5 12
6 12
3 10
3 9
9 12
4 11
9 10
2 3
2 12
4 10
10 11
8 9
8 11
6 10
8 15
4 13
4 15
10 12...

result:

ok that's great! (sum n = 233919, sum m = 3000000) (2640 test cases)

Test #23:

score: 0
Accepted
time: 2125ms
memory: 23420kb

input:

2697
131 1677
35 128
39 47
13 84
19 67
39 127
81 102
8 65
116 117
55 65
16 97
1 26
10 95
85 93
5 130
78 87
10 18
47 49
121 131
36 120
71 122
38 116
27 111
53 59
11 121
83 109
4 31
21 71
15 19
22 58
13 64
68 99
5 110
33 115
41 96
60 63
110 127
28 78
82 127
85 114
35 90
66 106
58 99
79 99
102 115
71 1...

output:

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

result:

ok that's great! (sum n = 240904, sum m = 3000000) (2697 test cases)

Test #24:

score: 0
Accepted
time: 2212ms
memory: 23284kb

input:

2742
164 1280
105 111
70 144
12 32
35 65
106 144
25 26
1 11
12 56
19 160
149 151
20 53
92 155
117 155
40 154
30 151
100 141
64 152
105 118
103 132
25 62
17 67
48 136
45 160
91 116
68 109
120 124
54 125
30 128
33 102
105 149
136 161
106 120
30 92
98 136
24 81
24 140
90 133
62 162
73 90
62 140
21 45
2...

output:

Yes
134 164
1 2
23 24
7 13
7 11
25 26
27 28
29 30
31 32
6 11
1 6
1 3
12 13
33 34
35 36
5 8
37 38
7 9
39 40
8 9
3 14
9 11
7 8
2 5
4 9
10 15
2 15
6 15
41 42
43 44
4 13
5 13
12 15
2 6
45 46
6 12
3 6
8 15
17 18
47 48
13 15
49 50
51 52
53 54
6 8
8 11
21 22
55 56
2 13
57 58
7 14
2 4
59 60
14 15
4 11
61 62...

result:

ok that's great! (sum n = 246601, sum m = 3000000) (2742 test cases)

Test #25:

score: 0
Accepted
time: 2575ms
memory: 24764kb

input:

845
116 3941
2 90
96 116
21 57
47 87
101 113
13 55
63 75
4 79
30 93
33 68
35 69
55 56
34 46
80 111
49 68
14 71
21 101
38 107
78 92
106 115
19 25
18 115
39 78
19 55
74 79
2 72
70 105
35 94
88 110
6 80
38 116
21 39
94 101
3 65
30 81
84 115
24 30
67 84
25 75
6 31
64 109
30 39
14 50
41 104
1 53
56 108
1...

output:

No
Yes
277 358
1 2
14 18
11 23
7 10
4 11
5 15
17 23
32 33
6 18
34 35
9 13
36 37
38 39
40 41
42 43
10 21
5 6
3 21
3 8
9 11
44 45
46 47
8 10
4 14
20 23
48 49
50 51
14 19
19 23
52 53
54 55
56 57
2 10
11 20
4 7
18 19
58 59
6 16
3 11
18 21
60 61
62 63
7 22
64 65
66 67
68 69
29 30
4 15
70 71
7 16
72 73
5 ...

result:

ok that's great! (sum n = 255437, sum m = 3000000) (845 test cases)

Test #26:

score: 0
Accepted
time: 2693ms
memory: 25280kb

input:

851
213 3934
40 201
12 160
8 175
20 60
117 172
18 143
70 188
36 54
48 61
165 210
32 159
32 132
72 173
72 122
32 62
152 201
151 197
13 28
150 191
5 135
89 101
103 196
16 125
68 140
98 188
11 184
3 38
153 180
12 129
12 201
35 177
41 50
157 170
25 131
144 186
77 159
40 144
131 196
82 90
50 79
42 157
47...

output:

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

result:

ok that's great! (sum n = 249106, sum m = 3000000) (851 test cases)

Test #27:

score: 0
Accepted
time: 2716ms
memory: 24744kb

input:

865
202 3535
125 155
156 174
28 122
34 154
87 163
2 119
139 171
119 197
48 107
17 71
7 108
9 152
130 182
103 108
34 102
124 178
43 74
70 118
20 194
59 136
89 95
117 153
47 93
69 183
48 84
39 56
37 135
36 201
61 197
70 187
82 86
128 140
26 184
59 132
184 200
3 183
93 165
20 81
79 103
38 52
15 54
10 1...

output:

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

result:

ok that's great! (sum n = 260611, sum m = 3000000) (865 test cases)

Test #28:

score: 0
Accepted
time: 2575ms
memory: 24824kb

input:

763
90 1002
39 87
16 76
59 81
41 50
9 66
24 36
6 35
62 89
48 87
1 56
5 80
13 21
5 26
12 38
2 57
78 84
53 59
44 63
9 39
11 49
59 71
17 39
22 42
45 70
24 43
48 58
5 77
15 44
34 86
62 87
5 10
57 60
24 41
20 52
45 53
18 41
72 75
26 71
28 52
13 48
28 63
53 81
24 50
38 42
47 82
53 86
64 81
1 25
25 28
46 7...

output:

Yes
15 90
1 2
2 4
13 14
9 12
4 13
9 10
8 13
4 12
8 15
4 5
3 5
8 10
1 12
6 15
3 7
4 15
12 13
2 7
8 11
7 11
1 10
1 9
4 6
7 12
1 4
3 13
12 14
4 11
9 11
2 11
9 13
2 5
7 9
10 14
9 14
10 12
2 12
1 8
12 15
1 14
7 8
1 5
7 15
3 11
5 6
2 6
6 9
8 12
3 8
6 7
2 14
10 11
6 10
5 15
1 6
2 3
4 9
5 8
10 13
8 9
1 13
6...

result:

ok that's great! (sum n = 300000, sum m = 2932020) (763 test cases)

Test #29:

score: 0
Accepted
time: 2689ms
memory: 24816kb

input:

787
552 5078
68 114
107 123
182 385
17 376
255 534
302 525
147 447
6 513
147 533
239 503
102 466
345 395
33 501
287 407
248 415
79 451
224 253
196 202
315 393
164 374
17 432
64 281
345 455
2 467
107 258
217 331
106 363
154 429
293 536
211 548
9 282
258 364
100 338
278 366
321 393
48 284
72 382
2 231...

output:

No
Yes
949 752
1 2
3 4
36 37
14 18
38 39
40 41
42 43
5 29
6 13
44 45
46 47
48 49
18 22
50 51
6 19
52 53
13 22
7 21
54 55
56 57
58 59
60 61
62 63
3 11
64 65
6 17
66 67
68 69
70 71
9 25
72 73
7 28
6 8
74 75
3 22
76 77
11 28
10 16
78 79
80 81
21 27
82 83
84 85
86 87
8 21
7 20
17 20
88 89
90 91
9 14
92 ...

result:

ok that's great! (sum n = 300000, sum m = 2988551) (787 test cases)

Test #30:

score: 0
Accepted
time: 2668ms
memory: 24808kb

input:

793
233 4455
32 50
67 169
45 106
116 179
113 225
35 72
40 139
161 222
14 76
135 213
47 228
26 27
86 229
160 187
13 185
27 117
135 147
29 189
220 229
64 205
16 222
88 137
61 107
59 217
160 228
34 71
49 184
46 127
65 152
24 133
73 208
51 196
201 213
189 216
157 190
40 64
46 95
48 174
172 177
174 223
1...

output:

Yes
31 233
1 2
12 16
4 6
2 16
1 14
10 17
15 18
18 24
5 18
9 13
1 4
9 24
13 23
11 20
1 13
9 21
20 23
11 13
2 5
4 14
23 31
9 28
15 23
12 20
1 10
4 21
4 20
7 23
6 16
26 28
10 14
19 24
6 13
1 5
3 16
3 9
10 11
12 14
10 12
10 18
11 21
3 14
2 4
12 21
5 7
2 21
9 16
13 14
8 15
14 24
13 15
16 20
20 24
1 11
3 ...

result:

ok that's great! (sum n = 300000, sum m = 2918149) (793 test cases)

Test #31:

score: 0
Accepted
time: 2645ms
memory: 24244kb

input:

618
482 4657
114 226
85 115
16 226
13 22
186 414
4 246
30 296
331 473
210 458
399 402
399 449
102 338
196 267
95 196
3 267
205 305
95 424
111 135
53 154
20 234
416 432
307 355
69 458
18 315
74 180
30 443
163 307
159 313
401 454
104 109
32 300
136 355
245 408
258 420
408 478
115 274
451 454
9 63
292 ...

output:

Yes
506 482
1 2
3 4
8 16
7 15
37 38
39 40
41 42
43 44
12 22
22 28
45 46
6 25
3 5
47 48
49 50
11 18
51 52
19 23
3 7
7 20
53 54
5 26
55 56
57 58
59 60
5 18
4 26
4 25
61 62
5 7
13 23
6 21
6 16
7 8
63 64
65 66
67 68
11 13
13 28
69 70
71 72
6 28
73 74
13 25
75 76
77 78
7 13
5 8
79 80
10 22
10 23
81 82
6 ...

result:

ok that's great! (sum n = 300000, sum m = 2878189) (618 test cases)

Test #32:

score: 0
Accepted
time: 2826ms
memory: 25748kb

input:

584
699 11313
219 483
233 432
23 76
540 544
247 623
269 687
433 637
238 295
11 652
460 627
228 382
72 462
197 556
38 609
370 681
214 215
210 501
594 666
106 427
331 605
111 175
141 693
386 491
386 639
65 548
76 156
428 475
237 297
307 573
279 472
247 463
164 512
5 126
400 428
268 462
131 445
74 469
...

output:

Yes
557 699
1 2
14 15
35 36
37 38
7 16
13 19
11 18
39 40
31 32
41 42
6 10
15 33
43 44
45 46
10 27
47 48
13 31
49 50
3 7
51 52
8 16
3 16
4 16
23 30
3 28
53 54
10 28
27 33
11 33
23 31
6 27
7 9
7 13
55 56
57 58
6 19
59 60
16 20
10 11
61 62
63 64
65 66
67 68
12 17
19 33
6 22
69 70
10 24
15 30
20 26
71 7...

result:

ok that's great! (sum n = 292591, sum m = 3000000) (584 test cases)

Test #33:

score: 0
Accepted
time: 2860ms
memory: 25824kb

input:

572
559 9457
200 397
36 528
50 511
459 527
50 430
27 134
56 243
353 550
60 549
173 372
8 382
156 335
161 539
480 520
194 356
97 508
66 144
329 438
383 511
47 401
472 514
27 316
305 453
68 90
58 276
178 557
313 502
137 441
74 178
74 458
22 68
244 435
524 554
59 245
82 285
315 395
185 497
429 493
39 5...

output:

Yes
360 559
1 2
7 16
14 25
35 36
9 14
25 31
15 27
4 25
11 24
16 29
37 38
7 21
12 17
3 16
39 40
20 24
7 32
1 23
5 15
41 42
16 23
25 26
5 25
8 31
43 44
45 46
8 9
19 23
47 48
11 13
49 50
5 32
5 9
4 6
51 52
13 25
8 30
7 27
17 21
15 26
12 29
53 54
25 28
1 13
55 56
57 58
19 28
59 60
13 17
6 26
13 27
61 62...

result:

ok that's great! (sum n = 277820, sum m = 3000000) (572 test cases)

Test #34:

score: 0
Accepted
time: 5096ms
memory: 102652kb

input:

47
3291 67320
254 1488
111 2438
322 2365
689 1652
368 2650
94 2670
1233 2593
1784 3200
1296 1679
1234 3149
1828 2222
2418 3042
1988 3065
94 1275
394 2968
1328 2585
1132 3055
487 2947
2873 2975
1853 2499
216 477
1052 2382
553 1762
1938 2697
1698 2043
403 2274
35 1030
348 400
1086 1389
1616 3288
1186 ...

output:

Yes
3694 3291
1 2
13 18
55 73
75 76
25 35
77 78
5 31
79 80
7 30
81 82
83 84
28 44
28 56
85 86
87 88
18 54
89 90
91 92
19 30
93 94
95 96
6 30
97 98
99 100
101 102
10 18
4 9
103 104
105 106
107 108
11 19
21 35
109 110
111 112
19 26
113 114
115 116
117 118
119 120
121 122
17 20
1 48
123 124
20 58
125 1...

result:

ok that's great! (sum n = 98829, sum m = 3000000) (47 test cases)

Test #35:

score: 0
Accepted
time: 5779ms
memory: 87836kb

input:

52
2688 8
453 829
353 453
453 2363
750 2363
797 938
750 2612
797 2612
353 829
226 4143
72 116
94 156
8 205
13 15
44 101
54 101
26 146
2 161
114 139
123 134
24 62
30 153
157 178
65 191
101 139
33 57
148 193
146 159
29 74
70 121
109 136
45 112
112 180
67 215
18 59
82 143
8 155
181 202
55 194
128 174
1...

output:

Yes
5369 2688
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
9...

result:

ok that's great! (sum n = 107778, sum m = 3000000) (52 test cases)

Test #36:

score: 0
Accepted
time: 5928ms
memory: 95532kb

input:

41
918 34485
302 692
486 663
461 780
198 810
239 330
272 347
229 769
148 238
144 472
26 837
375 856
220 487
60 561
27 460
10 556
362 666
339 790
608 742
223 830
25 898
640 847
262 311
204 465
328 494
101 344
156 207
621 910
234 726
82 225
51 300
230 615
102 761
82 569
875 901
355 810
271 843
59 841
...

output:

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

result:

ok that's great! (sum n = 130911, sum m = 3000000) (41 test cases)

Test #37:

score: 0
Accepted
time: 6285ms
memory: 95428kb

input:

38
9054 4
1330 5030
273 6005
6005 6814
5030 7284
7641 169509
4533 6988
3960 4941
1016 5421
5007 7497
3490 5354
3370 6111
1373 6006
727 7194
108 5316
3162 6320
1096 7111
4970 6219
3490 6172
2955 6081
2270 3017
4313 6751
2341 2730
1780 6172
5197 6137
2316 7208
140 3999
820 5815
2471 6288
152 6771
2319...

output:

Yes
18104 9054
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
...

result:

ok that's great! (sum n = 207979, sum m = 3000000) (38 test cases)

Test #38:

score: 0
Accepted
time: 6488ms
memory: 95068kb

input:

32
9549 184425
3769 8881
3816 7958
2297 5867
5145 9032
3315 5678
6600 8732
8312 8352
3642 9494
5897 7519
1460 9427
1225 6410
1453 5982
1050 7961
649 1897
5873 8095
3907 5533
4687 5272
4464 9432
8738 8848
5347 7853
6529 8852
3947 7530
3319 5086
5177 8403
4198 5137
5201 8602
2370 4742
3136 4068
349 22...

output:

Yes
13712 9549
1 2
3 4
5 6
30 35
115 116
117 118
30 83
119 120
121 122
46 47
123 124
125 126
21 25
127 128
129 130
131 132
29 39
133 134
135 136
34 84
137 138
139 140
141 142
65 76
143 144
145 146
27 84
147 148
149 150
151 152
24 28
10 72
153 154
155 156
30 44
15 94
157 158
159 160
161 162
163 164
1...

result:

ok that's great! (sum n = 179588, sum m = 3000000) (32 test cases)

Test #39:

score: 0
Accepted
time: 6651ms
memory: 102428kb

input:

36
5235 159223
259 858
2592 3667
116 3140
2119 3478
1539 4429
1980 2410
186 1570
2337 4303
206 2332
1894 2176
2177 2258
281 2667
1017 1147
2061 3106
1410 1475
366 2888
845 874
4156 5147
252 4232
735 789
2278 3385
420 5119
1650 3680
472 1868
2647 3843
256 1363
226 3474
473 1770
2901 4580
2113 2119
20...

output:

Yes
5624 5235
1 2
14 41
111 112
60 70
59 64
34 70
23 55
113 114
115 116
43 69
11 51
117 118
119 120
33 95
19 50
10 30
39 62
121 122
123 124
125 126
127 128
129 130
12 38
48 59
12 68
131 132
16 26
61 66
133 134
135 136
61 62
4 60
137 138
23 41
139 140
141 142
143 144
34 60
7 51
145 146
20 60
147 148
...

result:

ok that's great! (sum n = 198942, sum m = 3000000) (36 test cases)

Test #40:

score: -100
Time Limit Exceeded

input:

33
12395 0
4142 167625
245 1626
547 3180
837 1244
193 1081
347 844
2125 2499
1833 3933
2296 4001
1162 3552
3002 3708
1454 1725
922 3895
534 1546
1424 2540
2866 3320
860 2132
3209 4130
830 3834
17 3451
655 2168
2822 3688
647 3323
3740 3751
3752 3814
1956 2497
2410 3863
2344 3761
2866 3472
535 3064
33...

output:

Yes
24790 12395
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98...

result: