QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#301904#324. Passportsxztmax67100 ✓677ms36464kbC++141.9kb2024-01-10 14:11:412024-01-10 14:11:42

Judging History

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

  • [2024-01-10 14:11:42]
  • 评测
  • 测评结果:100
  • 用时:677ms
  • 内存:36464kb
  • [2024-01-10 14:11:41]
  • 提交

answer

#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
#define pb push_back 
using namespace std;
const int N=22,inf=0x3f3f3f3f;
int n,P;
struct Seg{int l,r,t,id;}l[N],L[N];
int f[1<<N],fr[1<<N],pos[N];
int ans[N][2];
void get(int p,int s)
{
	if(!s)return;
	get(p,fr[s]);
	int pos=__lg(s^fr[s]);
	ans[l[pos].id][0]=p;ans[l[pos].id][1]=f[s]-l[pos].t;
}
signed main()
{
	scanf("%d%d",&n,&P);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d%d",&l[i].l,&l[i].r,&l[i].t),l[i].r+=l[i].l-1,l[i].id=i;
		L[i]=l[i];
	}
	sort(L,L+n,[&](const Seg&x,const Seg&y){return x.l<y.l;});
	sort(l,l+n,[&](const Seg&x,const Seg&y){return x.t<y.t;});
	for(int i=0;i<n;i++)pos[l[i].id]=i;
	memset(f,0x3f,sizeof(f));
	f[0]=1;fr[0]=-1;
//	for(int k=0;k<n;k++)cout<<L[k].fi<<" "<<L[k].se<<endl;
	for(int s=0;s<(1<<n)-1;s++)
	{
		int p1=0,p2=0,now=f[s];
//		cout<<s<<' '<<f[s]<<endl; 
		for(int j=0;j<n;j++)if(!(s&(1<<j)))
		{
//			p1=p2=0;
			int T=l[j].t;
			while(1)
			{
				int lst=now;
//				for(int k=0;k<n;k++)
//				{
//					if(s&(1<<pos[L[k].id])&&now<=L[k].l&&now+l[j].t>=L[k].l)
//						now=max(now,L[k].r+1);
//					if(L[k].l<=now&&now<=L[k].r)now=max(now,L[k].r+1);
//				}
				for(;p1<n&&L[p1].l<=now;p1++)now=max(now,L[p1].r+1);
				for(;p2<n&&now+T>=L[p2].l;p2++)if((1<<pos[L[p2].id])&s)now=max(now,L[p2].r+1);
				if(lst==now)break;
			}
			
//			cout<<s<<" "<<j<<" "<<now<<" "<<T<<" "<<l[j].l<<endl;
			if(now+T<l[j].l&&now+T<f[s|(1<<j)])
			{
				f[s|(1<<j)]=now+T,fr[s|(1<<j)]=s;
			}
		}
//		if(s==5)exit(0);
	}
//	cout<<f[(1<<n)-1]<<endl;
	if(P==1) 
	{
		if(f[(1<<n)-1]==inf)return puts("NO"),0;
		get(1,(1<<n)-1);
	}
	else 
	{
		int pd=0;
		for(int i=0;i<(1<<n);i++)if(f[i]!=inf&&f[((1<<n)-1)^i]!=inf)
			{pd=1;get(1,i);get(2,((1<<n)-1)^i);break;}
		if(!pd)return puts("NO"),0;
	}
	puts("YES");
	for(int i=0;i<n;i++)printf("%d %d\n",ans[i][0],ans[i][1]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

1 1
3 1 1

output:

YES
1 1

result:

ok YES

Test #2:

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

input:

1 1
50 1 49

output:

NO

result:

ok NO

Test #3:

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

input:

2 1
5 1 3
10 1 3

output:

YES
1 1
1 6

result:

ok YES

Test #4:

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

input:

2 1
10 1 5
14 1 5

output:

NO

result:

ok NO

Test #5:

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

input:

2 1
33 2 3
52 3 3

output:

YES
1 1
1 4

result:

ok YES

Subtask #2:

score: 8
Accepted

Dependency #1:

100%
Accepted

Test #6:

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

input:

10 1
11 2 3
14 3 3
26 2 3
36 2 3
46 1 3
55 2 3
69 1 3
80 2 3
95 1 3
97 3 3

output:

YES
1 1
1 4
1 7
1 17
1 20
1 28
1 31
1 38
1 41
1 47

result:

ok YES

Test #7:

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

input:

10 1
4 2 4
19 4 4
26 2 4
32 3 4
44 7 4
54 1 4
65 2 4
70 4 4
80 7 4
90 9 4

output:

NO

result:

ok NO

Test #8:

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

input:

1 1
4 1 2

output:

YES
1 1

result:

ok YES

Test #9:

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

input:

2 1
6 2 2
8 3 2

output:

YES
1 1
1 3

result:

ok YES

Test #10:

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

input:

3 1
11 3 3
14 3 3
17 1 3

output:

YES
1 1
1 4
1 7

result:

ok YES

Test #11:

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

input:

4 1
8 2 3
10 3 3
17 4 3
25 4 3

output:

YES
1 1
1 4
1 13
1 21

result:

ok YES

Test #12:

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

input:

5 1
10 2 4
34 2 4
21 4 4
12 4 4
36 2 4

output:

YES
1 1
1 25
1 16
1 5
1 29

result:

ok YES

Test #13:

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

input:

6 1
38 2 4
31 4 4
6 3 4
22 4 4
45 4 4
35 3 4

output:

YES
1 9
1 13
1 1
1 17
1 40
1 26

result:

ok YES

Test #14:

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

input:

7 1
32 1 4
17 2 4
14 3 4
19 4 4
40 3 4
48 1 4
33 2 4

output:

YES
1 23
1 1
1 5
1 9
1 35
1 43
1 27

result:

ok YES

Test #15:

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

input:

8 1
16 4 1
23 2 1
27 3 1
11 2 1
30 1 1
7 4 1
31 1 1
20 3 1

output:

YES
1 1
1 2
1 3
1 4
1 13
1 5
1 25
1 14

result:

ok YES

Test #16:

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

input:

9 1
21 4 1
30 1 1
25 2 1
11 3 1
17 4 1
31 1 1
27 3 1
14 3 1
32 4 1

output:

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

result:

ok YES

Test #17:

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

input:

10 1
66 1 4
56 4 4
62 4 4
14 2 4
60 1 4
47 1 4
37 4 4
48 3 4
41 1 4
61 1 4

output:

YES
1 1
1 5
1 16
1 9
1 20
1 24
1 28
1 42
1 32
1 51

result:

ok YES

Subtask #3:

score: 7
Accepted

Dependency #2:

100%
Accepted

Test #18:

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

input:

10 2
2 1 1
9 1 1
13 3 1
25 1 1
29 3 1
53 1 1
56 1 1
87 1 1
90 1 1
94 2 1

output:

NO

result:

ok NO

Test #19:

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

input:

10 2
6 1 1
10 1 1
12 1 1
14 1 1
28 9 1
44 3 1
49 9 1
66 3 1
84 1 1
92 1 1

output:

YES
2 1
2 2
2 3
2 4
2 7
2 8
2 15
2 16
2 17
2 18

result:

ok YES

Test #20:

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

input:

1 2
6 3 4

output:

YES
2 1

result:

ok YES

Test #21:

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

input:

2 2
6 2 1
4 2 1

output:

YES
2 1
2 2

result:

ok YES

Test #22:

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

input:

3 2
3 4 1
11 3 1
7 4 1

output:

YES
1 1
2 1
2 2

result:

ok YES

Test #23:

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

input:

4 2
13 3 1
6 4 1
12 1 1
3 3 1

output:

YES
1 1
1 2
2 10
2 1

result:

ok YES

Test #24:

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

input:

5 2
10 4 2
19 2 2
21 1 2
14 2 2
8 2 2

output:

YES
1 1
2 1
2 16
2 3
2 5

result:

ok YES

Test #25:

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

input:

6 2
20 2 2
15 4 2
11 1 2
12 3 2
6 2 2
19 1 2

output:

YES
1 1
1 3
1 5
2 1
2 3
2 8

result:

ok YES

Test #26:

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

input:

7 2
28 3 3
23 2 3
25 3 3
13 3 3
5 4 3
16 3 3
31 4 3

output:

YES
1 1
1 4
2 9
1 9
2 1
2 12
2 19

result:

ok YES

Test #27:

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

input:

8 2
23 1 3
32 1 3
33 4 3
24 4 3
19 4 3
28 4 3
17 2 3
14 3 3

output:

YES
1 1
1 4
1 7
1 10
2 1
2 4
2 7
2 10

result:

ok YES

Test #28:

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

input:

9 2
19 3 3
33 2 3
32 1 3
35 2 3
22 2 3
24 4 3
18 1 3
28 4 3
17 1 3

output:

YES
1 1
1 4
1 7
1 10
2 1
2 4
2 7
2 10
2 13

result:

ok YES

Test #29:

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

input:

10 2
11 2 2
8 3 2
24 4 2
30 4 2
34 3 2
20 4 2
45 4 2
13 4 2
42 3 2
28 2 2

output:

YES
1 1
1 3
1 5
2 1
2 3
2 5
2 37
2 7
2 39
2 17

result:

ok YES

Subtask #4:

score: 12
Accepted

Dependency #2:

100%
Accepted

Test #30:

score: 12
Accepted
time: 3ms
memory: 20140kb

input:

16 1
1 2 1
15 3 1
20 1 3
47 1 1
49 2 3
63 1 2
65 3 1
69 1 3
70 1 3
72 1 2
73 2 2
75 1 2
80 3 3
83 3 3
91 3 2
95 2 3

output:

NO

result:

ok NO

Test #31:

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

input:

16 1
6 4 8
21 6 4
29 1 7
31 8 10
40 1 9
43 2 3
46 2 5
50 2 10
54 1 8
58 1 6
61 1 6
63 6 6
69 1 8
72 4 8
76 5 9
89 1 9

output:

NO

result:

ok NO

Test #32:

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

input:

10 1
44 1 1
41 2 1
35 4 2
33 2 1
30 3 2
43 1 4
45 3 1
39 2 1
15 3 4
18 3 4

output:

YES
1 1
1 2
1 21
1 3
1 23
1 25
1 4
1 5
1 6
1 10

result:

ok YES

Test #33:

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

input:

11 1
63 4 4
54 2 2
19 2 1
39 3 4
51 3 4
37 2 2
59 4 2
25 3 3
56 3 2
33 4 4
16 3 1

output:

YES
1 42
1 3
1 1
1 11
1 46
1 5
1 7
1 21
1 9
1 28
1 2

result:

ok YES

Test #34:

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

input:

12 1
19 3 3
24 3 4
55 1 3
61 4 3
56 2 4
67 3 1
32 4 4
22 2 3
58 3 3
70 4 3
51 4 2
36 2 1

output:

YES
1 2
1 14
1 5
1 8
1 46
1 65
1 27
1 11
1 40
1 43
1 38
1 1

result:

ok YES

Test #35:

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

input:

13 1
67 2 3
59 3 4
44 3 3
55 4 4
54 1 3
28 2 1
30 4 1
65 2 1
47 2 4
25 3 1
49 3 4
62 3 1
52 2 2

output:

YES
1 7
1 16
1 10
1 20
1 13
1 1
1 2
1 3
1 35
1 4
1 39
1 34
1 5

result:

ok YES

Test #36:

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

input:

14 1
32 4 2
47 4 1
46 1 1
57 1 1
37 1 4
38 2 2
36 1 2
41 2 1
43 3 1
31 1 2
40 1 1
53 4 1
17 3 3
51 2 3

output:

YES
1 7
1 1
1 2
1 3
1 26
1 9
1 11
1 4
1 5
1 21
1 6
1 20
1 13
1 23

result:

ok YES

Test #37:

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

input:

15 1
37 1 4
38 2 4
60 2 2
74 2 3
50 3 3
68 2 3
63 3 1
62 1 2
54 2 4
56 4 3
47 3 1
66 2 1
70 4 3
53 1 1
40 4 2

output:

YES
1 24
1 28
1 5
1 9
1 12
1 15
1 1
1 44
1 32
1 18
1 2
1 3
1 21
1 4
1 7

result:

ok YES

Test #38:

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

input:

16 1
45 4 3
52 2 3
25 3 2
49 3 1
75 3 3
70 3 1
65 2 2
54 4 3
42 3 1
60 2 3
69 1 1
67 2 3
62 3 3
58 1 3
73 2 3
59 1 1

output:

YES
1 9
1 12
1 5
1 1
1 15
1 2
1 7
1 18
1 3
1 21
1 4
1 29
1 32
1 35
1 38
1 28

result:

ok YES

Test #39:

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

input:

10 1
88 1 1
91 1 9
89 1 2
85 1 13
86 1 10
87 1 19
84 1 4
29 1 7
90 1 13
92 1 2

output:

YES
1 1
1 9
1 30
1 38
1 18
1 64
1 34
1 2
1 51
1 32

result:

ok YES

Test #40:

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

input:

11 1
85 1 4
91 1 12
36 1 1
82 1 1
83 1 13
88 1 14
86 1 7
89 1 5
87 1 10
84 1 6
90 1 5

output:

YES
1 3
1 42
1 1
1 2
1 54
1 67
1 18
1 7
1 25
1 12
1 37

result:

ok YES

Test #41:

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

input:

12 1
79 1 8
82 2 11
85 1 3
86 1 15
81 1 4
80 1 3
90 1 15
84 1 2
87 1 2
88 1 3
35 1 5
89 1 4

output:

YES
1 40
1 23
1 5
1 48
1 14
1 8
1 63
1 1
1 3
1 11
1 18
1 36

result:

ok YES

Test #42:

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

input:

13 1
75 1 5
81 1 2
41 1 2
77 1 3
89 1 7
76 1 15
88 1 5
83 4 14
78 1 1
80 1 4
82 1 1
87 1 11
79 1 1

output:

YES
1 12
1 4
1 6
1 42
1 22
1 59
1 17
1 45
1 1
1 8
1 2
1 29
1 3

result:

ok YES

Test #43:

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

input:

14 1
76 1 2
80 1 3
77 1 3
78 2 12
87 1 4
85 1 4
74 1 14
88 1 2
86 1 2
82 1 4
83 2 7
81 1 3
75 1 2
19 1 8

output:

YES
1 1
1 7
1 22
1 47
1 28
1 32
1 59
1 3
1 5
1 36
1 40
1 25
1 20
1 10

result:

ok YES

Test #44:

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

input:

15 1
72 4 7
77 1 2
81 1 7
84 1 4
79 1 6
76 1 1
71 1 4
30 1 8
83 1 1
78 1 2
80 1 4
87 1 2
85 1 5
82 1 13
86 1 1

output:

YES
1 43
1 3
1 50
1 9
1 37
1 1
1 13
1 21
1 2
1 5
1 17
1 7
1 32
1 57
1 31

result:

ok YES

Test #45:

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

input:

16 1
85 1 7
86 1 8
76 1 4
81 4 10
74 1 4
80 1 1
44 1 2
77 1 4
69 1 3
78 1 1
75 1 3
72 1 3
73 1 4
79 1 1
71 1 8
70 1 2

output:

YES
1 28
1 35
1 16
1 58
1 20
1 1
1 3
1 24
1 7
1 2
1 10
1 13
1 46
1 45
1 50
1 5

result:

ok YES

Subtask #5:

score: 13
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #46:

score: 13
Accepted
time: 8ms
memory: 20360kb

input:

16 2
5 2 3
7 3 1
16 2 1
19 2 1
23 2 1
26 2 2
35 3 1
40 1 2
42 2 2
57 1 3
68 1 2
72 1 1
85 2 3
87 1 2
91 3 3
95 3 1

output:

YES
2 1
1 1
2 10
2 11
2 12
2 13
2 21
2 28
2 30
2 47
2 32
2 38
2 50
2 45
2 53
2 44

result:

ok YES

Test #47:

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

input:

16 2
5 1 7
10 2 4
16 7 3
23 6 4
34 2 10
36 1 2
38 1 6
40 6 4
47 2 2
50 5 10
59 1 3
61 1 1
66 4 7
75 2 8
79 3 3
86 5 6

output:

NO

result:

ok NO

Test #48:

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

input:

10 2
37 5 5
42 4 1
18 3 1
13 5 2
51 1 4
21 5 2
31 5 4
48 3 3
36 1 2
46 2 4

output:

YES
2 12
1 1
1 2
1 3
2 4
1 5
2 8
2 1
1 7
2 26

result:

ok YES

Test #49:

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

input:

11 2
42 2 4
33 3 2
32 1 5
19 3 2
47 1 2
28 2 5
36 5 3
44 3 3
17 2 3
41 1 3
30 2 5

output:

YES
2 7
1 1
2 11
1 3
1 5
2 16
1 7
2 1
1 10
2 4
2 22

result:

ok YES

Test #50:

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

input:

12 2
23 4 2
53 5 5
27 3 3
39 3 5
37 2 5
47 3 3
34 3 1
20 3 2
50 2 5
52 1 1
42 5 3
30 4 3

output:

YES
1 3
2 4
1 7
2 9
2 14
1 10
1 1
1 5
2 19
1 2
1 13
2 1

result:

ok YES

Test #51:

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

input:

13 2
57 5 2
67 2 1
47 5 3
42 2 4
52 4 3
33 4 2
44 3 2
28 4 4
56 1 4
32 1 4
64 3 2
62 2 5
37 5 1

output:

YES
1 3
1 1
1 9
2 6
2 3
1 5
1 7
2 10
2 14
2 18
2 1
2 22
1 2

result:

ok YES

Test #52:

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

input:

14 2
53 2 4
63 5 2
14 3 1
38 5 4
43 5 4
68 4 2
13 1 2
8 1 1
37 1 1
59 1 1
55 4 4
48 5 3
17 3 1
60 3 5

output:

YES
2 5
1 5
1 1
2 20
2 24
2 1
2 3
1 2
1 3
1 4
2 28
2 9
1 9
2 32

result:

ok YES

Test #53:

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

input:

15 2
62 4 5
79 5 3
52 2 2
74 5 1
27 5 5
17 4 4
54 1 5
71 3 2
46 3 5
59 3 4
13 4 2
66 5 3
55 4 3
84 4 1
49 3 4

output:

YES
2 6
1 6
1 2
1 1
2 11
2 2
2 21
1 21
2 40
2 32
1 4
1 9
1 23
2 1
2 36

result:

ok YES

Test #54:

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

input:

16 2
45 2 5
26 2 2
65 1 1
42 3 3
28 4 4
56 3 5
12 4 1
59 5 5
3 1 1
64 1 3
66 2 3
16 2 3
32 5 2
68 5 5
24 2 4
37 5 1

output:

YES
2 5
1 5
1 47
1 20
2 18
2 10
1 4
2 22
1 1
1 48
2 47
2 2
1 18
2 50
1 7
2 1

result:

ok YES

Test #55:

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

input:

16 2
29 1 10
30 1 7
31 1 13
67 1 14
68 1 4
69 1 6
70 1 3
71 1 31
72 1 8
73 1 5
74 1 6
75 1 5
76 1 8
91 1 13
92 1 4
93 1 15

output:

YES
2 4
1 14
2 14
1 51
1 1
1 37
2 1
2 38
1 21
1 9
2 32
1 32
1 43
1 77
1 5
2 77

result:

ok YES

Subtask #6:

score: 15
Accepted

Dependency #4:

100%
Accepted

Test #56:

score: 15
Accepted
time: 26ms
memory: 21052kb

input:

18 1
683279 4194 60575
1912856 79790 90245
2054820 18099 91793
2597751 53188 76115
3419910 25173 20087
4089311 42852 92182
4291765 29314 92781
5916407 32705 9347
6046607 71811 43050
7080934 12651 49598
7373524 42761 19575
7421993 75751 84157
8215487 26851 56063
8725165 94280 56939
8866773 42824 9047...

output:

YES
1 97134
1 317981
1 498699
1 157709
1 696820
1 972866
1 590492
1 687473
1 745977
1 789027
1 1
1 233824
1 838625
1 40195
1 408226
1 716907
1 894688
1 19576

result:

ok YES

Test #57:

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

input:

18 1
307199 431381 606237
786815 7813 100057
937530 309185 335083
1269337 256532 415772
1600505 78439 615377
3439131 40341 56311
3843522 159751 915475
4250619 149907 406249
4403022 181218 203333
4938430 54142 563703
5012206 298681 698174
5390106 127269 213239
5698169 19791 515147
5785886 424105 5234...

output:

NO

result:

ok NO

Test #58:

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

input:

18 1
86229 1 86227
193882 1 107651
248212 1 54328
332327 1 84113
437324 1 104995
566945 1 129619
653431 1 86484
851898 1 198465
1109240 1 96814
1264920 1 160526
1476394 1 75604
1713346 1 69548
2046902 1 189085
2046903 1 135868
2046904 1 144469
2046905 1 86130
2046906 1 153476
2046907 1 83474

output:

YES
1 1
1 86230
1 193883
1 248213
1 332328
1 437325
1 566946
1 653432
1 851899
1 948713
1 1264921
1 1109241
1 1857816
1 1340525
1 1713347
1 1178789
1 1559869
1 1476395

result:

ok YES

Test #59:

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

input:

18 1
134465 1 134463
271884 1 137417
453637 1 181751
520434 1 66795
880891 1 175611
1243575 1 193166
1561651 1 144133
1682595 1 58894
1813262 1 62048
2059190 1 72079
2314160 1 58586
2314161 1 169516
2314162 1 86805
2314163 1 159121
2314164 1 184844
2314165 1 98824
2314166 1 156144
2314167 1 173941

output:

YES
1 1
1 134466
1 271885
1 453638
1 520435
1 1050408
1 1243576
1 1561652
1 1620546
1 1741182
1 1682596
1 880892
1 1813263
1 1900068
1 696046
1 2059191
1 2158015
1 1387709

result:

ok YES

Test #60:

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

input:

18 1
343813 1 195001
655308 1 135369
810160 1 88021
1019190 1 51866
1308705 1 126872
1604370 1 98496
1926937 1 192360
2173164 1 162641
2448210 1 197167
2448211 1 112252
2448212 1 133973
2448213 1 130205
2448214 1 66829
2448215 1 177194
2448216 1 97850
2448217 1 157162
2448218 1 176124
2448219 1 148810

output:

YES
1 148811
1 343814
1 722138
1 810161
1 1019191
1 1308706
1 1734576
1 1146063
1 1407202
1 1926938
1 2039190
1 1604371
1 655309
1 2271015
1 2173165
1 862027
1 479183
1 1

result:

ok YES

Test #61:

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

input:

18 1
262856 1 178108
288592 1 5966
311484 1 19768
333583 1 11151
354871 1 14136
382914 1 15580
405300 1 84746
421452 1 10690
453290 1 12649
453291 1 10946
453292 1 11489
453293 1 5460
453294 1 19187
453295 1 17657
453296 1 10895
453297 1 5233
453298 1 12461
453299 1 7150

output:

YES
1 84747
1 262857
1 268823
1 322431
1 340734
1 367333
1 1
1 410761
1 421453
1 311485
1 393810
1 405301
1 434102
1 293826
1 382915
1 288593
1 354872
1 333584

result:

ok YES

Test #62:

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

input:

18 1
107565 1 107563
162712 1 8674
253921 1 18702
296208 1 5827
323475 1 9017
323476 1 16571
323477 1 18933
323478 1 19986
323479 1 18294
323480 1 12582
323481 1 8935
323482 1 16995
323483 1 9712
323484 1 8217
323485 1 14974
323486 1 6140
323487 1 13725
323488 1 8618

output:

YES
1 1
1 121610
1 144009
1 107566
1 253922
1 181435
1 215001
1 233934
1 277913
1 168853
1 304827
1 198006
1 313762
1 113393
1 262939
1 162713
1 130284
1 296209

result:

ok YES

Test #63:

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

input:

18 1
520311 1 174303
529248 1 8935
554523 1 14951
584170 1 10322
593518 1 16273
668671 1 75151
684218 1 15545
694551 1 163091
710375 1 15822
721501 1 10331
915041 1 193538
942033 1 13552
950365 1 182915
950366 1 13438
950367 1 11124
950368 1 13372
950369 1 8330
950370 1 9346

output:

YES
1 163092
1 520312
1 539571
1 529249
1 567896
1 593519
1 668672
1 1
1 694552
1 684219
1 721502
1 928480
1 337395
1 915042
1 710376
1 554524
1 942034
1 584171

result:

ok YES

Test #64:

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

input:

18 1
3003342 1 46
1000138 1 1000086
2001211 1 10023
6015653 1 991048
4006440 1 20091
9036894 1 982037
7021701 1 30076
9036896 1 973014
5010543 1 40027
8028809 1 964068
9036897 1 50081
9036900 1 955022
9036893 1 60009
9036895 1 946032
9036899 1 70058
9036901 1 937040
9036898 1 80025
9036891 1 928050

output:

YES
1 1
1 47
1 1000139
1 1010162
1 2001212
1 2021303
1 3003343
1 3033419
1 4006441
1 4046468
1 5010544
1 5060625
1 6015654
1 6075663
1 7021702
1 7091760
1 8028810
1 8108835

result:

ok YES

Test #65:

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

input:

10 1
9545 164 995
2727 592 197
1285 259 17
8307 715 465
8036 271 712
7089 885 271
9022 523 65
6156 933 320
7974 62 520
5189 967 772

output:

YES
1 289
1 1544
1 1
1 1741
1 3704
1 18
1 3319
1 3384
1 2206
1 4416

result:

ok YES

Test #66:

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

input:

10 1
222246 43596 59903
908688 36624 70675
834061 15568 11280
535424 37666 49550
849629 59059 44650
956058 3373 28869
265842 96771 88822
826440 7621 25518
945312 10746 86462
735375 91065 91609

output:

YES
1 73520
1 573090
1 362613
1 399411
1 28870
1 1
1 133423
1 373893
1 448961
1 643765

result:

ok YES

Test #67:

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

input:

10 1
996462 49 58494
998510 1424 141030
980290 16025 4504
998355 47 15096
998402 108 180343
996511 1844 198953
976786 3504 167531
999934 26 27139
181890 92 181888
996315 147 1713

output:

YES
1 230434
1 288928
1 183695
1 188199
1 597489
1 777832
1 429958
1 203295
1 1
1 181982

result:

ok YES

Test #68:

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

input:

11 1
13161 6 982
6008 922 863
8726 749 802
9475 947 462
2077 949 590
6930 583 157
8141 585 627
4741 403 755
13167 655 951
1253 824 199
13822 316 805

output:

YES
1 12178
1 5144
1 3938
1 200
1 662
1 3026
1 7513
1 3183
1 11227
1 1
1 10422

result:

ok YES

Test #69:

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

input:

11 1
912240 6979 36317
895916 16324 34185
564918 85286 42815
794643 88313 38380
745271 26226 85958
771497 23146 94245
919219 72122 39008
706878 38393 20450
306565 56386 9156
882956 12960 74477
650204 56674 33538

output:

YES
1 63145
1 362951
1 436144
1 99462
1 478959
1 212319
1 397136
1 9157
1 1
1 137842
1 29607

result:

ok YES

Test #70:

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

input:

11 1
990253 810 125354
974994 3 16939
991063 144 137850
991207 1832 168149
990252 1 1610
990245 5 159057
567968 2 157478
993039 6953 10582
974997 14366 87550
989363 882 98059
990250 2 12361

output:

YES
1 690582
1 1
1 104490
1 399818
1 567970
1 815936
1 242340
1 569580
1 16940
1 592523
1 580162

result:

ok YES

Test #71:

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

input:

12 1
9641 167 340
8186 704 739
12102 734 500
8890 751 598
13545 648 392
7211 975 983
10025 593 596
6587 624 677
9808 217 334
12836 709 527
10886 791 267
11677 425 899

output:

YES
1 335
1 3965
1 1067
1 2690
1 675
1 5603
1 2094
1 3288
1 1
1 1567
1 10618
1 4704

result:

ok YES

Test #72:

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

input:

12 1
516435 81535 58410
750431 31059 77209
719144 31287 46398
652579 66565 6187
1004293 70280 35953
808542 9088 67878
1074573 6371 62684
781490 27052 40621
817630 99426 6099
917056 87237 660
597970 52705 96808
650675 1904 17526

output:

YES
1 153445
1 342417
1 107047
1 6760
1 30473
1 274539
1 211855
1 66426
1 661
1 1
1 419626
1 12947

result:

ok YES

Test #73:

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

input:

12 1
533745 39 165370
753530 199 62532
751427 665 36692
787890 66 132669
763498 24392 4692
752092 1438 23106
753750 7700 1368
749623 1804 139393
753729 21 144325
749608 15 7292
761450 2048 16064
787956 211893 16063

output:

YES
1 368374
1 22124
1 580246
1 616938
1 1369
1 557140
1 1
1 84656
1 224049
1 533784
1 541076
1 6061

result:

ok YES

Test #74:

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

input:

13 1
6017 16 858
6033 918 672
7048 591 142
11517 954 578
8861 429 687
10594 923 249
12471 890 234
8458 180 818
9871 723 648
9290 142 368
9432 439 520
8638 223 145
6951 97 914

output:

YES
1 4244
1 2885
1 1
1 1659
1 3557
1 522
1 288
1 7639
1 2237
1 771
1 1139
1 143
1 5102

result:

ok YES

Test #75:

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

input:

13 1
670865 40646 35029
978958 51439 194
297554 1774 83471
567708 85791 50800
795731 21967 71680
714700 43901 17069
758601 37130 34350
817698 67651 86526
1030397 63212 61480
885349 93609 65004
1093609 69625 19273
653499 17366 34218
711511 3189 6837

output:

YES
1 333872
1 299328
1 214082
1 368901
1 142402
1 6838
1 299522
1 481181
1 419701
1 77398
1 23907
1 43180
1 1

result:

ok YES

Test #76:

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

input:

13 1
961974 2178 122353
967408 23557 39103
964852 2555 38339
990965 309 50866
967407 1 75830
964815 1 74765
991274 8716 30639
964818 34 42617
181170 3653 140198
964816 1 2631
961973 1 142394
964817 1 58622
964152 663 139960

output:

YES
1 557265
1 215462
1 2632
1 297182
1 481435
1 406670
1 184823
1 254565
1 40971
1 1
1 819578
1 348048
1 679618

result:

ok YES

Test #77:

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

input:

14 1
11938 887 267
13294 880 468
8811 656 877
10451 872 777
14314 185 48
8532 279 601
6279 862 64
14174 140 12
11323 94 877
5660 619 336
11417 160 629
11577 361 900
9709 742 956
9467 242 704

output:

YES
1 113
1 12825
1 2049
1 7754
1 1
1 7153
1 49
1 7141
1 2926
1 380
1 716
1 3803
1 4703
1 1345

result:

ok YES

Test #78:

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

input:

14 1
826656 89401 33
1111986 3505 5156
734999 46621 85502
916057 30429 69295
334829 82937 4793
1146334 53625 92979
794926 31730 99981
946486 80846 32378
1115491 30843 72946
781620 13306 63870
1027332 84654 34248
72969 27636 21
1199959 81287 26783
1281246 85701 36437

output:

YES
1 100605
1 417766
1 649496
1 580201
1 100638
1 141868
1 234847
1 449705
1 22
1 516331
1 482083
1 1
1 422922
1 105431

result:

ok YES

Test #79:

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

input:

14 1
999988 1 11002
999981 1 14627
999977 4 71687
854070 145643 83489
999985 3 52522
853977 92 68518
999983 1 109426
149954 1 60600
999976 1 36830
999713 263 66766
999982 1 60386
853940 37 113236
854069 1 102272
999984 1 2575

output:

YES
1 152530
1 163532
1 373829
1 445516
1 36831
1 305311
1 631277
1 89353
1 1
1 238545
1 178159
1 740703
1 529005
1 149955

result:

ok YES

Test #80:

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

input:

15 1
5425 88 753
16061 57 789
10863 873 959
9301 602 887
13697 995 856
16118 886 764
7366 351 72
12709 988 546
4101 570 6
11736 398 571
12134 575 978
15421 640 358
14692 729 989
17004 275 148
7717 150 420

output:

YES
1 4671
1 6576
1 9903
1 8413
1 1277
1 513
1 5513
1 7867
1 1
1 6005
1 2133
1 155
1 3111
1 7
1 5585

result:

ok YES

Test #81:

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

input:

15 1
1172506 43890 15967
830662 2138 69490
984730 788 82998
924226 60504 60420
985518 74765 63025
832800 91426 92712
1128846 27918 69499
518238 22757 49274
1060283 19605 36179
1156764 15742 37187
1293001 66389 5731
1216396 66658 34292
1079888 48958 38867
1283054 9947 21165
540995 72310 58786

output:

YES
1 613305
1 761171
1 342527
1 700751
1 210003
1 425525
1 273028
1 101943
1 26897
1 663564
1 1
1 629272
1 63076
1 5732
1 151217

result:

ok YES

Test #82:

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

input:

15 1
987028 1 104515
990079 169 76209
990253 1 132757
987027 1 131401
990256 1 2421
990075 4 7019
999984 4 87535
999983 1 56612
990254 2 75032
544970 24 3361
999928 55 83828
990257 9671 66656
987029 1 18525
987030 3045 126592
990248 5 14537

output:

YES
1 623162
1 165996
1 854269
1 413568
1 1
1 544994
1 326033
1 566550
1 90964
1 2422
1 242205
1 24308
1 5783
1 727677
1 552013

result:

ok YES

Test #83:

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

input:

16 1
8357 635 365
8992 686 66
12400 791 375
14542 677 356
5877 46 146
10468 214 463
13638 904 709
5923 332 760
10682 798 109
9678 577 765
10255 213 783
2629 460 187
6255 244 964
11480 246 7
13191 447 776
11726 674 440

output:

YES
1 6499
1 1
1 254
1 3351
1 3205
1 629
1 6864
1 1092
1 3096
1 4147
1 7573
1 67
1 4912
1 3089
1 1852
1 3707

result:

ok YES

Test #84:

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

input:

16 1
1671770 27323 15939
1234987 60995 96877
1550367 90633 17609
837891 55321 54257
1641000 30770 48997
226889 96738 74336
780016 57875 53478
1167915 67072 65266
992679 59898 65962
1346178 77887 9651
1295982 50196 86589
893212 99467 96668
1475999 56758 14763
1424065 51934 34132
667677 58860 12778
16...

output:

YES
1 1052577
1 570799
1 1532757
1 419874
1 370877
1 65963
1 726537
1 1102648
1 1
1 323627
1 140299
1 474131
1 356114
1 1068516
1 343336
1 333278

result:

ok YES

Test #85:

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

input:

16 1
999497 1 204
999511 474 92386
999509 1 113305
999499 1 64178
384538 3 17480
999510 1 18968
999502 3 64849
999985 1 44246
999501 1 5958
999496 1 109475
999495 1 19162
999508 1 112884
999498 1 117261
999500 1 38094
999986 1 86503
999505 3 94536

output:

YES
1 1
1 589792
1 886189
1 460765
1 6163
1 384541
1 524943
1 23643
1 205
1 776714
1 403509
1 154392
1 267276
1 422671
1 67889
1 682178

result:

ok YES

Test #86:

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

input:

17 1
14944 898 729
17949 824 862
15842 691 330
16533 818 153
4166 62 665
10278 995 856
8410 873 935
13560 434 380
17495 454 270
13994 950 361
17351 144 492
9950 328 773
9283 93 699
18773 21 472
9376 574 251
12603 957 588
8091 319 539

output:

YES
1 11873
1 6293
1 11543
1 4228
1 1871
1 3309
1 7155
1 4742
1 11273
1 4381
1 252
1 2536
1 5594
1 5122
1 1
1 1283
1 744

result:

ok YES

Test #87:

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

input:

17 1
676782 42559 66771
862135 59480 40414
1327737 55790 25119
1199056 82173 74181
784727 8703 83098
1471461 61480 28231
1106660 13018 58504
216161 87950 23590
1070585 36075 33383
1281229 21388 46262
793430 28290 89812
1383527 71641 1021
1119678 79378 73994
1532941 45262 10475
719341 65386 37466
921...

output:

YES
1 363106
1 821720
1 1302617
1 141979
1 503871
1 950466
1 1012080
1 1
1 978697
1 95717
1 586969
1 938970
1 429877
1 939991
1 58251
1 304111
1 23591

result:

ok YES

Test #88:

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

input:

17 1
999368 1 67202
999686 1 6546
999754 232 1113
999685 1 115702
999369 130 114820
991373 1 1473
104080 1 104078
999501 164 100159
988589 2783 106176
991374 330 43817
991704 1 25243
999499 1 13494
991705 7663 92011
999665 20 56685
991372 1 103692
999687 67 22538
999500 1 13836

output:

YES
1 288826
1 106667
1 104081
1 872886
1 758066
1 105194
1 1
1 448039
1 651890
1 188324
1 163081
1 113213
1 356028
1 232141
1 548198
1 140543
1 126707

result:

ok YES

Test #89:

score: 0
Accepted
time: 33ms
memory: 20984kb

input:

18 1
14650 244 747
4305 738 242
11539 431 650
11970 737 881
5819 411 584
5043 776 433
1748 111 142
18573 146 215
3631 674 918
13715 935 805
3619 12 227
17674 899 229
15696 568 931
13005 710 297
17637 37 663
14894 802 515
17035 602 127
16264 771 504

output:

YES
1 8174
1 587
1 6861
1 9726
1 3034
1 2086
1 1
1 143
1 829
1 8921
1 1859
1 358
1 10607
1 12707
1 7511
1 2519
1 6230
1 6357

result:

ok YES

Test #90:

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

input:

18 1
682900 22793 72843
705693 48996 53468
1073107 57965 11940
1026702 46405 54158
1395858 8449 38421
1565876 52595 44868
1404307 60563 45058
1383852 12006 46850
1277145 6805 61236
1753139 42190 78246
1464870 59537 32628
1131072 51809 50251
1283950 26189 94080
1524407 41469 85748
1182881 94264 23379...

output:

YES
1 351982
1 237278
1 1
1 883036
1 754689
1 793110
1 837978
1 140177
1 290746
1 424825
1 35320
1 187027
1 588819
1 503071
1 11941
1 67948
1 937194
1 101247

result:

ok YES

Test #91:

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

input:

18 1
989504 1 16139
999958 26 30148
989506 1 11002
999957 1 76128
989497 3 110131
999984 1 9404
976519 1 59962
972649 3870 64580
343566 4 92375
976535 12962 70340
989500 4 84977
989510 6 88230
999946 11 32569
989505 1 28348
976520 15 17950
989507 3 98268
989516 9 820
989525 10421 81271

output:

YES
1 364796
1 409283
1 353794
1 175062
1 862517
1 344390
1 50520
1 110482
1 251190
1 439431
1 591042
1 676019
1 17951
1 380935
1 1
1 764249
1 343570
1 509771

result:

ok YES

Test #92:

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

input:

18 1
85156 1 4303
134103 1 10178
134110 1 10527
134097 1 8021
134100 1 2926
134111 1 10279
134108 1 6145
134104 1 3927
134105 1 2625
134112 1 6038
134106 1 8770
134098 1 7252
134109 1 5952
134099 1 11568
134102 1 6379
134101 1 8636
134107 1 7872
134096 1 12694

output:

YES
1 5552
1 52882
1 63060
1 103101
1 2626
1 111122
1 89084
1 85157
1 1
1 15807
1 44112
1 28224
1 9855
1 73587
1 21845
1 35476
1 95229
1 121401

result:

ok YES

Subtask #7:

score: 15
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #93:

score: 15
Accepted
time: 23ms
memory: 21044kb

input:

18 2
131814 93062 60437
929788 73431 24242
2683264 47223 52877
3567691 99565 55630
3882730 75888 11627
4407974 88549 17392
4526930 90013 88544
5331922 37832 89757
6547429 67129 62101
6695087 97295 96884
7342909 77636 51100
7930118 10882 77053
8356878 57206 16001
8667289 47703 98530
9002255 6474 6979...

output:

YES
2 70841
2 240877
2 301101
2 1054319
2 1
2 11628
2 645764
2 1109949
2 353978
2 734308
2 1003219
2 485877
2 224876
2 831192
2 416079
2 29020
2 265119
2 562930

result:

ok YES

Test #94:

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

input:

18 2
1033219 237280 172731
1295699 346042 482549
1700228 50897 192262
1821111 999421 100123
3064077 179348 952898
3498658 362873 305466
3886527 146452 84912
4168851 560612 544076
4798568 605465 335280
5801501 257698 948964
6144220 16122 76416
6490021 38748 581902
6778085 79811 877762
7655710 51739 6...

output:

YES
1 1
1 508012
2 1
1 1641741
2 736339
1 2896948
2 2820532
2 192263
1 172732
2 1751125
1 2820532
2 3243425
2 4729463
1 1751125
1 3861531
2 6857896
2 6059199
2 7432618

result:

ok YES

Test #95:

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

input:

18 2
141726 1 141724
141727 1 141725
236906 53072 95177
289978 1 148249
380645 97606 90665
478251 1 188271
594172 1 115919
594173 1 115920
729454 6046 135279
735500 1 141325
844428 61666 108926
906094 1 170592
979990 32208 73894
1012198 1 106102
1122574 1 110374
1122575 1 110375
1216038 104918 93461...

output:

YES
1 1
2 1
1 141728
2 141728
1 289979
2 289979
1 478252
2 478252
1 594174
2 594174
1 735501
2 735501
1 906095
2 906095
1 1012199
2 1012199
1 1122576
2 1122576

result:

ok YES

Test #96:

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

input:

18 2
105030 1 105028
105031 1 105029
116136 1 11103
116137 1 11104
122521 4710 6382
127231 1 11092
141327 1 14094
141328 1 14095
149156 1 7826
149157 1 7827
164096 4579 14937
168675 1 19516
182657 1 13980
182658 1 13981
190815 379 8155
191194 1 8534
202659 895 11463
203554 1 12358

output:

YES
1 1
2 1
1 105032
2 105032
1 116138
2 116138
1 127232
2 127232
1 141329
2 141329
1 149158
2 149158
1 168676
2 168676
1 182659
2 182659
1 191195
2 191195

result:

ok YES

Test #97:

score: 0
Accepted
time: 33ms
memory: 20640kb

input:

18 2
212109 75397 68777
287506 1 130734
317393 1 11163
317394 1 12582
317395 1 29887
330076 8877 12679
338953 1 6132
352297 14 13342
352311 1 13356
352312 1 6140
380076 16249 19723
396325 1 15424
396326 1 14982
396327 1 143330
396328 1 9554
396329 1 156770
396330 1 8039
396331 1 19475

output:

YES
1 1
2 1
1 293647
1 304810
2 287507
1 317396
2 317396
1 338954
2 338954
1 287507
2 360352
2 323528
1 361867
1 68778
1 352313
2 130735
2 352313
1 376849

result:

ok YES

Test #98:

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

input:

10 2
5378 508 800
7360 192 22
3604 937 940
4882 496 940
5886 704 42
7951 291 318
7552 249 208
6590 770 676
4541 341 455
7801 150 868

output:

YES
2 43
1 1
2 1711
2 2651
2 1
1 231
1 23
1 1004
1 549
2 843

result:

ok YES

Test #99:

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

input:

10 2
752692 16666 47961
333718 32787 26313
932604 21884 99192
374276 75361 61719
634481 55917 94578
746892 5800 78140
848430 84174 90265
366505 7771 69376
769358 79072 97715
690398 56494 48777

output:

YES
1 26314
1 1
2 261670
1 123052
2 69377
2 449637
2 527777
2 1
2 163955
1 74275

result:

ok YES

Test #100:

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

input:

11 2
3981 751 832
5762 895 191
8265 784 13
6657 876 112
3475 506 924
3335 140 848
9342 672 718
3007 328 610
4957 805 224
9049 234 785
9283 59 762

output:

YES
2 304
2 113
1 1
2 1
2 1984
2 1136
2 7533
1 238
1 14
2 4732
2 8251

result:

ok YES

Test #101:

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

input:

11 2
214404 74667 13003
96694 35288 8271
571224 64964 17498
703113 42898 66924
802434 37433 90218
312491 72221 23419
756139 46295 63536
384712 52313 17729
746011 10128 70692
498130 73094 61104
131982 82422 56073

output:

YES
2 1
1 1
2 289071
2 636188
2 94269
1 8272
2 30733
2 13004
2 306569
2 437025
1 31691

result:

ok YES

Test #102:

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

input:

12 2
12062 178 438
7593 899 406
4950 819 395
8791 870 298
4026 924 536
10613 466 306
11079 41 894
7052 541 375
9661 952 907
1199 716 791
11755 307 736
11120 635 719

output:

YES
2 2310
2 1
2 1915
1 1
2 2748
1 299
2 5769
1 605
2 6663
2 407
2 3284
2 8492

result:

ok YES

Test #103:

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

input:

12 2
955960 63399 10243
128253 92839 33333
765757 22959 94918
221092 97426 77361
732030 33727 43931
668119 63911 44068
863657 92303 54458
434546 67116 52260
788716 55639 42606
501662 78457 78168
844355 19302 3687
318518 63767 29695

output:

YES
1 1
1 39939
2 634577
2 47619
2 3688
1 73272
2 580119
2 382285
1 382285
2 124980
2 1
1 10244

result:

ok YES

Test #104:

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

input:

13 2
5858 921 82
9015 854 811
7916 65 301
8687 328 112
353 432 269
4862 996 929
7981 706 805
7142 774 589
11251 216 754
11747 252 231
6779 363 918
10841 410 971
11467 280 328

output:

YES
1 1
2 2149
1 1128
1 785
1 83
2 3878
2 1
2 806
2 1395
1 897
2 2960
2 9869
1 1429

result:

ok YES

Test #105:

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

input:

13 2
701841 45849 31424
604181 32328 51225
883685 25494 51403
257810 34006 82586
538343 65838 38608
444906 93437 13806
636509 65332 13468
853659 30026 68031
385659 59247 13683
995296 66957 33270
291816 93843 64058
909179 86117 65934
838020 15639 90329

output:

YES
1 40958
1 105652
1 156877
2 172574
2 1
1 27152
1 1
2 104543
1 13469
1 72382
1 208280
2 38609
2 747690

result:

ok YES

Test #106:

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

input:

14 2
5703 22 112
4924 779 771
8997 515 477
4748 176 654
8874 123 223
10057 466 817
7284 746 917
8030 844 432
453 648 451
2354 491 258
10523 20 500
9512 545 922
5725 209 895
2201 153 618

output:

YES
2 1204
2 433
1 2845
2 1316
1 1101
2 6434
2 2865
2 1
1 1
1 1324
2 5934
2 3782
2 1970
1 1582

result:

ok YES

Test #107:

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

input:

14 2
486425 65245 97671
1028657 93572 91452
1021877 6780 8183
668392 72395 34189
1122229 78823 64730
593367 75025 31752
919863 5166 59417
551670 41697 42647
1201052 91725 16588
1292777 61855 24378
399234 72740 99136
797278 63167 39902
471974 14451 85347
925029 96848 62243

output:

YES
2 200908
2 765165
2 1
1 48341
2 50831
1 16589
1 122432
2 8184
1 1
2 740787
2 298579
1 82530
2 115561
2 860445

result:

ok YES

Test #108:

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

input:

15 2
2889 583 307
11199 224 512
9403 59 495
8273 178 349
6271 983 985
10277 922 594
5998 273 115
7254 669 722
11423 476 220
3472 147 241
4142 755 953
8451 456 475
9462 815 108
3619 523 197
2384 505 928

output:

YES
1 547
2 7923
1 1203
1 854
2 5012
2 9127
2 4897
1 1698
2 8907
1 306
2 1404
2 1
1 1
1 109
2 476

result:

ok YES

Test #109:

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

input:

15 2
1266217 8624 88397
1098319 87482 75374
651832 7454 71488
507535 59578 96235
1185801 80416 39822
745788 71793 17153
1005900 17044 95923
567113 84719 81659
1274841 28349 96229
817581 92395 42143
659286 86502 59487
1303190 7765 24097
418691 88844 24197
1316638 51446 70995
1310955 5683 84914

output:

YES
2 226061
2 1022944
1 218408
2 410687
1 65448
1 1
2 909976
2 59488
2 314458
1 105270
2 1
1 17154
1 41251
1 147413
2 141147

result:

ok YES

Test #110:

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

input:

16 2
5326 110 416
6045 610 839
5436 609 933
5110 216 404
9966 466 781
8354 11 624
9200 655 668
6655 23 926
7999 355 266
6678 442 76
7120 879 527
8365 120 921
9855 111 524
8485 715 998
10432 388 739
2151 516 302

output:

YES
1 2933
2 1
2 3468
1 379
2 2687
1 783
1 4400
2 1761
1 2667
1 1
1 3873
2 840
1 3349
2 4401
1 1407
1 77

result:

ok YES

Test #111:

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

input:

16 2
413907 55237 52631
1094116 35797 31606
1129913 20241 36937
366975 46932 330
245982 34001 17524
208466 37516 73451
984102 90256 61150
1150154 99098 81204
834928 57201 68576
279983 34030 65647
1074358 19758 95025
892129 14712 32429
956556 27546 4166
469144 70411 117
906841 49715 47288
1249252 190...

output:

YES
2 4284
1 17855
1 81890
1 1
1 331
2 122562
2 539555
2 669281
2 600705
2 56915
2 314013
1 49461
2 118
2 1
1 118827
2 750485

result:

ok YES

Test #112:

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

input:

17 2
10185 247 240
5017 809 318
7650 948 166
10432 934 534
6860 790 737
9903 282 254
1721 657 780
2471 840 92
8598 102 628
8700 317 375
9737 166 888
11366 769 245
3505 942 103
9711 26 939
9017 694 876
12135 193 296
4447 570 476

output:

YES
1 5826
1 1
2 3311
1 1170
2 6122
1 6311
2 1
1 2378
1 1704
1 319
2 2378
1 6066
1 3311
2 781
2 3477
2 5826
1 694

result:

ok YES

Test #113:

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

input:

17 2
885542 66615 62305
737451 47970 61875
509210 57366 22704
1343295 97934 3106
653964 83487 73827
978901 72747 95011
1243202 92972 67220
566576 13560 71517
836533 49009 15786
1051648 1129 44318
1230555 12647 64769
785421 51112 13070
1336174 7121 69910
1052777 95955 25390
952157 26744 93126
1182302...

output:

YES
2 42223
1 139281
1 46869
2 1
2 580136
2 471070
2 169297
2 306427
1 13071
1 94963
2 104528
1 1
2 236517
1 69573
2 377944
2 3107
1 28857

result:

ok YES

Test #114:

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

input:

18 2
8019 489 740
13922 293 452
11029 402 778
1136 377 257
13138 784 239
9901 325 832
10226 803 957
11431 563 736
12294 844 391
9319 185 137
11994 300 148
9504 397 292
8508 811 960
14215 146 436
6707 368 383
7075 700 211
2295 116 973
7775 244 500

output:

YES
2 3363
2 2411
2 4103
1 451
1 212
2 4881
2 5713
2 1558
1 708
1 1513
2 1
1 1650
2 6670
2 149
1 1942
1 1
2 585
2 2863

result:

ok YES

Test #115:

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

input:

18 2
1049994 30112 22335
1240953 10083 17419
372534 45023 57815
898597 80306 66925
1251036 44638 72467
749171 82500 96928
371196 1338 58213
417557 50601 14908
1189171 51782 63891
1094894 30799 89729
1080106 14788 49512
468158 75002 73510
1125693 39067 82201
1164760 24411 10132
978903 71091 8661
6333...

output:

YES
2 1
1 543160
1 130980
1 247008
2 86883
2 315061
1 188795
1 18794
2 831671
2 895562
1 81468
2 159350
2 232860
1 8662
1 1
2 543160
1 33702
2 22336

result:

ok YES

Subtask #8:

score: 15
Accepted

Dependency #7:

100%
Accepted

Test #116:

score: 15
Accepted
time: 101ms
memory: 24112kb

input:

20 2
32774807 3739199 5003113
39587091 5354823 7970036
72028468 5046698 4410507
132113238 6996454 7441026
148767706 3956177 4070396
156741605 4165228 4253917
164253855 5557273 9562340
172618864 6969829 7966023
443844454 4199531 4928005
467328356 3015135 7807946
506746111 8314538 8446111
529179585 28...

output:

YES
2 5609513
2 24795792
2 49344448
2 91720994
2 77075166
2 81145562
2 62452094
2 16829769
2 681508
2 99162020
2 106969966
2 10612626
2 37442331
2 85399479
2 36961609
2 115416077
2 44941914
2 53754955
2 36514006
2 1

result:

ok YES

Test #117:

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

input:

20 2
14717925 18125502 19979927
84092340 28669811 29671882
113282247 2236976 27536075
134055738 8672395 52449935
154674605 8396586 41521530
255196580 11483092 28147891
289109799 43910930 18905659
338321482 15127759 55978277
360613757 1913298 33006688
441808423 18702263 90857712
527558072 102406 3296...

output:

NO

result:

ok NO

Test #118:

score: 0
Accepted
time: 149ms
memory: 22920kb

input:

20 2
193227 1 193225
193228 1 193226
249073 101613 55843
350686 1 157456
437904 20360 87216
458264 1 107576
568072 56869 109806
624941 1 166675
799865 1 174922
799866 1 174923
980363 1 180495
980364 1 180496
1078211 67860 97845
1146071 1 165705
1341408 1 195335
1341409 1 195336
1421788 824 80377
142...

output:

YES
1 1
2 1
1 193229
2 193229
1 350687
2 350687
1 458265
2 458265
1 624942
2 624942
1 799867
2 799867
1 980365
2 980365
1 1146072
2 1146072
1 1341410
2 1341410
1 1422613
2 1422613

result:

ok YES

Test #119:

score: 0
Accepted
time: 165ms
memory: 22512kb

input:

20 2
95304 1 95302
95305 1 95303
102533 2123 7226
104656 1 9349
121771 1 17113
121772 1 17114
128038 8404 6264
136442 1 14668
150296 1 13852
150297 1 13853
161124 6639 10825
167763 1 17464
185529 1 17764
185530 1 17765
191385 10942 5853
202327 1 16795
211789 7224 9460
219013 1 16684
228791 6039 9776...

output:

YES
1 1
2 1
1 95306
2 95306
1 104657
2 104657
1 121773
2 121773
1 136443
2 136443
1 150298
2 150298
1 167764
2 167764
1 185531
2 185531
1 202328
2 202328
1 219014
2 219014

result:

ok YES

Test #120:

score: 0
Accepted
time: 159ms
memory: 22500kb

input:

20 2
302733 57090 169425
359823 1 180056
380613 16160 12956
396773 1 17914
396774 1 19034
419731 1 15893
419732 1 5680
437067 1 8419
437068 1 133306
437069 1 7832
437070 3624 7062
440694 1 15665
463643 1 9632
463644 1 13736
463645 1 179765
463646 1 13315
463647 1 8914
463648 1 5295
463649 1 17276
46...

output:

YES
1 133307
2 179766
1 367656
2 359824
2 377738
1 403837
2 396775
1 419733
1 1
1 359824
1 396775
2 425028
1 440695
2 449907
2 1
1 450327
1 428152
2 419733
2 402455
2 440695

result:

ok YES

Test #121:

score: 0
Accepted
time: 117ms
memory: 24236kb

input:

20 1
1000076 1 35
2001178 1 1000040
7021656 1 10009
3003322 1 991084
10045994 1 20072
5010463 1 982069
6015618 1 30024
4006367 1 973012
10045984 1 40014
10045988 1 964077
10045989 1 50064
8028785 1 955083
9036891 1 60002
10045992 1 946028
10045987 1 70039
10045991 1 937084
10045993 1 80034
10045990 ...

output:

NO

result:

ok NO

Test #122:

score: 0
Accepted
time: 77ms
memory: 22076kb

input:

19 2
131198275 6056385 8149112
96512654 368456 7613695
117026220 2289432 281761
26257646 6472050 8349070
59495862 7927005 9093418
105913622 6758510 9032511
112672132 2174900 4674404
114847032 2179188 419875
72853077 314365 6957456
137254660 6938248 7582404
128816984 2381291 3726798
144192908 5749836...

output:

YES
2 88363541
2 80749846
2 1
2 7659093
2 50402443
2 96881110
1 2582931
2 281762
2 701637
2 73167442
2 46675645
2 35277890
1 7257335
1 13038007
1 50675391
1 46675645
1 35277890
1 1
2 16008163

result:

ok YES

Test #123:

score: 0
Accepted
time: 147ms
memory: 22896kb

input:

20 2
19199837 5471953 9314739
84202521 3929801 7362434
153833689 3041716 8795563
136046608 9353904 3811336
40127335 8476178 7758076
118400335 8301169 1873678
8469133 5111241 8469131
110170196 934330 4200082
126701504 9345104 7794681
117826021 574314 3175585
98944046 1755476 2016160
67272202 7352648 ...

output:

YES
2 7362435
2 1
2 74624850
1 30341640
2 32369258
1 13580374
1 1
1 34152976
2 90347558
1 27166055
1 25149895
1 15454052
2 88132322
2 98142239
1 18055631
2 32156020
1 38353058
2 16677174
2 24671790
2 25937474

result:

ok YES

Test #124:

score: 0
Accepted
time: 72ms
memory: 21892kb

input:

19 2
83474649 3138025 6035538
35100969 802033 8182045
45373100 2957211 3646220
127256457 2077070 1850105
53423097 9997368 6441307
117358017 9898440 5709329
96981624 3850603 6671566
63420465 3248362 3549904
112489915 1504384 568478
100832227 5200574 2534644
35903002 7091992 2129623
43043699 2329401 1...

output:

YES
1 23226080
2 18475707
2 292911
1 259407
1 29261618
1 17516751
2 3939131
1 4239135
1 66668827
1 67237305
1 2109512
1 117033
1 1
2 66668827
2 26657752
2 10610697
1 7789039
1 12456473
2 1

result:

ok YES

Test #125:

score: 0
Accepted
time: 152ms
memory: 24196kb

input:

20 2
146032506 3616560 5896991
140351367 5681139 8803968
56622062 1720758 3095293
150853895 6197572 1095434
95111251 1254045 4498941
83582686 7861809 2968994
149649066 1204829 4705849
96365296 5413390 9210675
122511609 832693 5738943
101778686 6190629 7745473
48720710 7901352 4068246
80687635 289505...

output:

YES
2 12297903
2 123344302
1 5205847
2 1
1 27911883
1 2236853
1 32410824
2 39024219
2 6558960
2 31278746
1 15363606
1 8301140
2 1095435
2 48234894
2 24675703
2 18194894
1 1
1 11691774
1 19431852
1 23593174

result:

ok YES

Test #126:

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

input:

19 2
116931828 3490623 7045493
161810710 2858632 8803550
80762084 6542621 545287
155980876 5829834 8325863
115525277 1406551 76944
150129207 5851669 2442861
105993454 9531823 8144617
87304705 7291271 5994433
136763545 9689496 4822585
69153574 2838816 4261905
129874584 1790684 5976823
56214717 256300...

output:

YES
2 98812104
2 63168588
1 1
2 20115874
2 94595976
1 1745065
2 11971257
2 5976824
1 14675848
1 10413943
2 1
2 28441737
1 7161083
2 37190192
1 545288
2 56471017
1 4187926
2 46498206
2 94672920

result:

ok YES

Test #127:

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

input:

20 2
128359744 2008373 3988087
69014110 6700010 8604068
123028848 5330896 1543447
114954231 8074617 9347311
75714120 1053239 9357493
130368117 8925446 8991212
81222956 46271 5721066
61173666 7840444 1939821
45606965 434567 9667361
101998473 6383790 7960145
90039004 8879816 1180998
49889905 3128347 1...

output:

YES
2 110289126
1 31236260
1 1180999
2 49436836
2 16951358
2 7960146
1 17118511
1 6268445
2 35756964
2 1
1 1
1 4359894
1 13687634
1 10735540
2 26308851
1 8208266
2 46041532
1 2724446
1 22839577
2 108382263

result:

ok YES

Test #128:

score: 0
Accepted
time: 61ms
memory: 22300kb

input:

19 2
172040199 3137166 8285790
138264895 3218338 8386742
159411689 2131728 9642665
171841245 198954 9541436
18577051 8266467 4980330
187926665 4540051 6574436
46171148 596222 8341369
134182671 4082224 1595329
161543417 9402610 1886333
133107829 275898 9149296
46767370 9985795 9099927
123543090 95647...

output:

YES
2 141483233
2 87755231
2 105291269
2 149769023
1 8887610
2 175177365
2 28729851
1 1
2 26843518
2 96141973
2 37071220
2 67549080
1 4263875
2 56753165
2 73961575
2 61953541
2 80826642
1 1595330
2 1

result:

ok YES

Test #129:

score: 0
Accepted
time: 152ms
memory: 24280kb

input:

20 2
47389943 4344448 5946000
86287482 4471754 9047893
83749752 2537730 8375513
63065761 1267168 5503134
90759236 73672 2423845
82688435 1061317 8963443
112898813 8099600 8385126
138601058 3298071 4397476
64332929 3987236 5067456
129334021 9267037 2085433
90832908 8635546 9574142
44165266 3224677 50...

output:

YES
2 5067457
2 28352413
2 11013457
1 26575024
1 4622751
2 19388970
2 103865930
2 99468454
2 1
1 2537318
2 37400306
1 21565445
1 1151424
2 69304141
1 16941719
1 9781129
1 1
1 32078158
1 12993704
1 7046596

result:

ok YES

Test #130:

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

input:

19 2
145815126 9322048 6383115
117759085 6684764 2891196
96172299 8666140 6327045
59181063 3521954 4600316
116352617 1406468 2246538
52754975 6426088 8802896
124443849 8851683 5967062
133295532 4148428 3982786
160740457 8844424 9959289
32022679 3683746 4722493
35706425 8886409 3985076
62703017 63986...

output:

YES
2 88848461
1 8572258
2 82521416
2 1
1 3647991
2 4600317
2 76554354
2 72571568
2 31863658
1 21283513
1 17298437
1 11463454
1 5894529
1 1
2 69101658
1 1509996
2 13403213
2 22402854
1 14358902

result:

ok YES

Test #131:

score: 0
Accepted
time: 134ms
memory: 23940kb

input:

20 2
26924141 982084 608694
131759079 9344692 6631194
58420263 5817445 9726554
79524213 2801956 2854733
71352973 6025815 7691801
100647489 4562593 6671403
117744505 9438650 3907942
69372455 1980518 5864671
106288872 7515071 6720179
113803943 2880770 7077840
98418920 1228348 345836
116684713 1059792 ...

output:

YES
1 1
1 13613527
2 48598975
1 608695
2 24585368
1 20244721
2 1
1 28399011
2 3907943
2 17507528
1 28053175
1 8129826
1 40227629
1 34263682
2 40015318
1 3463428
1 27906225
1 46229241
2 32277169
2 10628122

result:

ok YES

Test #132:

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

input:

19 1
85905237 43 1506378
83995347 1243 3990685
85800095 1 8700689
83996950 1790629 2038028
79543382 1 2575022
85800096 105141 3706629
85787579 12516 9446212
83996804 146 9755229
85905662 399 10289206
83996803 1 1585473
85905280 382 5465356
95310708 1 889013
83994558 789 4451174
85906061 9202 1426217...

output:

YES
1 2903180
1 22928447
1 32384488
1 5995031
1 10558121
1 19221818
1 50052734
1 59498946
1 69254175
1 4409558
1 26919132
1 587950
1 79543383
1 1476963
1 8033059
1 41085177
1 15858371
1 13133143
1 1

result:

ok YES

Test #133:

score: 0
Accepted
time: 97ms
memory: 24344kb

input:

20 1
95679290 151 4908982
95685536 3370456 8743875
95096984 1 8307505
95097002 35 4466851
95063096 52 2270869
99999945 36 7644902
99999981 1 930963
99056008 943937 450435
95063148 33836 6627609
95679441 5452 8810303
34118045 1 2929478
95684895 641 4896143
99056006 2 2176968
95097037 139 7712358
9905...

output:

YES
1 44761010
1 86319220
1 78011715
1 40294159
1 3558367
1 62654455
1 450436
1 1
1 18680132
1 25307741
1 5829236
1 8758714
1 1381399
1 70299357
1 49669992
1 55304352
1 35179527
1 13654857
1 37707777
1 34118046

result:

ok YES

Test #134:

score: 0
Accepted
time: 111ms
memory: 24356kb

input:

20 1
185223 1 8371
185224 1 9773
185219 1 593
185214 1 5475
185221 1 11405
185213 1 10121
185216 1 10046
185218 1 7299
185222 1 13888
115286 1 12218
75693 1 13302
185220 1 15552
185217 1 11689
185215 1 9485
165680 1 8040
46837 1 8625
3733 1 1158
152163 1 1980
185225 1 9198
185226 1 16981

output:

YES
1 3734
1 115287
1 1
1 152164
1 92191
1 125060
1 175166
1 75694
1 32948
1 20730
1 46838
1 60140
1 103596
1 165681
1 157639
1 12105
1 594
1 1752
1 82993
1 135181

result:

ok YES

Subtask #9:

score: 10
Accepted

Dependency #8:

100%
Accepted

Test #135:

score: 10
Accepted
time: 440ms
memory: 36416kb

input:

22 2
21531559 3750460 8635391
54798322 674581 6215433
62131214 9470271 7063376
195032851 1018938 9046870
213468113 5382512 5240122
263957913 6579038 1373737
296955110 23342 9323706
345125201 8454557 3643353
515830933 5665185 5549611
566133260 9419575 7428501
592622980 7804302 282440
600566180 153528...

output:

YES
2 12895428
2 25282019
2 5832052
2 109175699
2 84120522
2 71601485
2 118222569
2 58460425
2 282441
2 37911971
2 1
2 56597509
2 45340472
2 79061916
2 72975222
2 55472903
2 55586849
2 31497452
2 89360644
2 75487133
2 100526438
2 94671757

result:

ok YES

Test #136:

score: 0
Accepted
time: 665ms
memory: 26256kb

input:

22 2
34753831 26053338 12474618
73275955 32716979 60610872
131006453 19700032 94556137
164567762 11145719 28071519
181015106 12214730 4542590
194940868 20606812 10181832
216440872 37259976 43244122
280725945 7567131 78273894
298850059 20364608 71251445
355115743 4364731 89241331
388548844 8985563 68...

output:

NO

result:

ok NO

Test #137:

score: 0
Accepted
time: 677ms
memory: 27960kb

input:

22 2
176022 1 176020
176023 1 176021
236937 88305 60912
325242 1 149217
505028 1 179784
505029 1 179785
621959 1 116928
621960 1 116929
784899 1 162937
784900 1 162938
930281 22660 145379
952941 1 168039
1043141 101080 90198
1144221 1 191278
1211574 26749 67351
1238323 1 94100
1342034 26496 103709
1...

output:

YES
1 1
2 1
1 176024
2 176024
1 325243
2 325243
1 505030
2 505030
1 621961
2 621961
1 784901
2 784901
1 952942
2 952942
1 1144222
2 1144222
1 1238324
2 1238324
1 1368531
2 1368531
1 1494907
2 1494907

result:

ok YES

Test #138:

score: 0
Accepted
time: 670ms
memory: 29344kb

input:

22 2
167452 1 167450
167453 1 167451
183476 1 16021
183477 1 16022
188721 13617 5242
202338 1 18859
216352 1 14012
216353 1 14013
234952 1 18597
234953 1 18598
240679 1 5724
240680 1 5725
250944 1 10262
250945 1 10263
256978 5710 6031
262688 1 11741
270246 7196 7556
277442 1 14752
292717 1 15273
292...

output:

YES
1 1
2 1
1 167454
2 167454
1 183478
2 183478
1 202339
2 202339
1 216354
2 216354
1 234954
2 234954
1 240681
2 240681
1 250946
2 250946
1 262689
2 262689
1 277443
2 277443
1 292719
2 292719

result:

ok YES

Test #139:

score: 0
Accepted
time: 633ms
memory: 28772kb

input:

22 2
332430 1 79534
332431 1 332429
361700 1 13844
361701 1 12939
361702 1 54261
404196 1 15227
404197 1 12873
404198 1 121452
404199 1 8677
404200 1 6466
404201 1 12193
404202 1 8785
416451 14753 12247
431204 1 7886
444997 6188 13791
451185 1 21625
451186 1 6638
451187 1 7926
451188 1 19979
451189 ...

output:

YES
1 131443
2 1
1 347855
2 332432
1 1
1 388968
1 376095
1 210977
2 361703
1 361703
2 370380
1 339070
1 404203
2 404203
1 431205
2 382573
1 332432
1 368169
2 431205
2 412089
1 54262
2 345371

result:

ok YES

Test #140:

score: 0
Accepted
time: 456ms
memory: 36388kb

input:

22 1
1000091 1 27
2001247 1 1000059
11056271 1 10072
5010634 1 991074
11056269 1 20082
3003420 1 982085
6015808 1 30024
4006466 1 973013
8029091 1 40065
11056272 1 964093
11056262 1 50097
11056265 1 955074
11056270 1 60075
7021909 1 946019
9037170 1 70090
11056264 1 937082
11056267 1 80071
11056263 ...

output:

YES
1 1
1 28
1 1000092
1 1010164
1 2001248
1 2021330
1 3003421
1 3033445
1 4006467
1 4046532
1 5010635
1 5060732
1 6015809
1 6075884
1 7021910
1 7092000
1 8029092
1 8109163
1 9037171
1 9127180
1 10046224
1 10146228

result:

ok YES

Test #141:

score: 0
Accepted
time: 311ms
memory: 28212kb

input:

21 2
117223923 134246 352980
88955109 9746857 4319028
164313528 7710136 9662997
123553672 5068425 8824638
128622097 9563240 552429
44301620 228837 1618922
110242972 6980951 2163938
61559715 7180106 5558166
68739821 5423819 575547
85905102 3050007 6032301
59248204 2311511 4813351
145312639 9770239 48...

output:

YES
1 24225311
1 1
2 143203141
2 98701966
2 44530457
2 24800858
1 24578291
2 26419780
2 24225311
2 31977946
1 26742229
1 4319029
2 38010247
2 45082886
1 14497990
2 140447584
2 1
1 9184083
2 107526604
2 51596825
2 5824867

result:

ok YES

Test #142:

score: 0
Accepted
time: 607ms
memory: 32484kb

input:

22 2
120925219 4382270 9488075
74119394 3027572 4430319
114642991 6282228 4282203
30305663 2024625 7956410
125307489 3775935 8057325
144210508 4932050 465023
135877741 8332767 34623
54481215 9915594 6536648
52130926 2350289 3358256
85404363 9898435 2311715
77146966 8257397 1210214
32330288 4399157 3...

output:

YES
2 42026014
2 37595695
1 17048970
2 14141978
2 22098388
1 1
2 1
1 25751335
1 5964426
1 3652711
1 1159604
1 13125866
1 9322682
2 34624
1 465024
2 149142558
2 36729445
1 21331173
2 6789666
1 2369818
1 149142558
1 36729445

result:

ok YES

Test #143:

score: 0
Accepted
time: 270ms
memory: 27092kb

input:

21 2
131521464 5740780 8582839
142726084 4876081 5136347
94671131 4487916 1018393
24459261 8227918 6199789
64762016 2209094 7474614
32687179 7394618 432179
102521251 8028617 921090
85656473 6694065 4134261
77383628 1740625 2559340
40081797 1845965 3925520
73169390 4214238 493951
66971110 6198280 587...

output:

YES
2 15719116
1 48204727
2 41927762
1 18255632
2 49368986
1 1
1 42458656
1 8250116
2 1
1 4324596
1 41964705
1 12384377
1 43379746
1 432180
2 2559341
2 8530826
1 41927762
2 42946155
2 56843600
2 24301955
1 2361729

result:

ok YES

Test #144:

score: 0
Accepted
time: 548ms
memory: 36408kb

input:

22 2
155311505 5991238 235678
134941825 6931790 4899004
141912180 9299963 4816559
25107023 2557346 7703658
127889115 6623819 1345951
92614230 2740686 5990062
51495502 6364892 8756523
95354916 5476448 8346721
155202823 108682 2764893
100831364 4245720 9314742
117845879 8910723 3332250
10811581 659178...

output:

YES
2 106192992
2 73225209
2 30650572
2 17403364
1 17403364
2 78124213
2 42723186
2 84114275
1 18749315
2 7890109
1 3715733
1 7047983
2 3435716
1 21514208
1 1
1 845996
2 106428670
2 110387781
2 117688825
2 27664369
2 35467131
2 1

result:

ok YES

Test #145:

score: 0
Accepted
time: 304ms
memory: 28200kb

input:

21 2
104217807 8027982 8526634
136128060 2945428 4286865
90484121 5207051 4119084
140936969 4848984 934644
88945639 1538482 2197261
112245789 6407179 1328776
154935662 5566699 2549840
132921543 988809 7984839
74390782 8272291 9739911
151909607 3026055 9230034
86433251 2512388 6805410
67977658 641312...

output:

YES
2 95691172
1 19099117
1 10767300
1 1
1 2733549
2 1
1 4930810
2 13400138
2 56757721
2 37929814
2 6594728
2 21384977
2 29646857
1 23385982
2 47159848
2 1328777
1 14886384
1 28170891
1 7480650
1 934645
2 145785953

result:

ok YES

Test #146:

score: 0
Accepted
time: 638ms
memory: 36284kb

input:

22 2
97581159 3390536 5105603
107683826 7459747 8870052
57419529 9819720 2315810
151392822 4978516 7649172
37449928 524047 6516915
31323691 6126237 9154639
115143573 1932706 3633892
100971695 6712131 7579808
85212385 3593765 4689513
134307137 1829475 7910781
117076279 6475512 2185900
94212346 336881...

output:

YES
1 20419074
2 57284863
1 41124142
2 6516916
2 1
2 22034779
1 2777579
2 80822014
1 10664798
2 49374082
1 591679
2 41124142
1 15354311
1 25524677
2 42600695
1 43439952
2 73272208
1 1
2 14166088
2 123639436
1 6411471
1 31199393

result:

ok YES

Test #147:

score: 0
Accepted
time: 273ms
memory: 27936kb

input:

21 2
7137536 5207251 2365315
82390291 3830022 3643675
22819164 1534692 3217479
71671238 1463184 9185984
136687809 8254315 1128544
86220313 8864965 5421932
106018916 7015593 7273905
152852226 8004839 9061569
163939537 779758 6497200
133110162 3577647 2148222
124128456 8981706 272779
113034509 7958294...

output:

YES
1 1529644
1 25482400
1 3894959
2 36652499
1 24353856
1 29126075
2 5203410
2 27590930
1 40402636
1 12344787
2 1
2 45838483
2 19851364
2 272780
2 55608889
1 14493009
1 1
1 17792108
2 12477315
1 34548007
2 160857065

result:

ok YES

Test #148:

score: 0
Accepted
time: 543ms
memory: 33832kb

input:

22 2
104642147 5922060 532621
120236530 8819686 227153
84465455 122232 1168632
171266202 596107 6992671
96926049 7716098 3446876
110564207 9672323 2084263
152320338 9362686 5798554
129056216 7241593 697640
47295036 5660692 4496858
177422365 8998498 29961
52955728 8682236 5521661
186420863 9560361 76...

output:

YES
1 227154
1 1
2 29962
2 17654196
1 9376681
1 4481195
1 28029559
1 759775
1 12823557
2 1
1 22507898
2 39502246
2 1198594
1 2462417
2 32011501
1 1457415
2 24646867
1 17320415
2 47113235
1 6565458
2 10673336
2 4813660

result:

ok YES

Test #149:

score: 0
Accepted
time: 251ms
memory: 28208kb

input:

21 2
161725809 2172125 7568315
108908010 6309108 2991136
115217118 609214 493614
68409920 4397180 8697465
95230865 6121562 5346986
129975631 4680689 6013486
62927887 5482033 1710409
134656320 8595906 3002928
158416540 3309269 8797070
72807100 1925049 3652902
120060977 2305579 4017964
101352427 75555...

output:

YES
2 82068677
1 3000863
2 1
2 59562916
1 20372218
2 38501229
1 1290454
1 5991999
2 89636992
1 8994927
1 16354254
1 32960342
2 44514715
2 74732149
2 5455275
2 493615
1 1
2 51637802
2 12453307
1 12647829
2 32960342

result:

ok YES

Test #150:

score: 0
Accepted
time: 591ms
memory: 33792kb

input:

22 2
87580981 3163985 1183830
61599097 4114458 9614003
139986534 2112689 9066519
69596372 1874890 7839238
52813420 6272334 1317220
73351289 7390500 4915026
71471262 1880027 412397
147141114 9205097 1920576
59085754 2513343 6497555
129242497 1623547 5489450
90744966 7665219 6331821
108332913 7583184 ...

output:

YES
1 2232990
2 26620370
2 8251636
2 412398
1 36670780
1 12325173
2 1
1 3416820
1 45061704
1 39572254
1 22657398
1 5337396
2 115916097
1 1078648
1 8131489
1 28989219
1 1
1 37988000
1 17240199
2 36234373
2 17318155
1 95974

result:

ok YES

Test #151:

score: 0
Accepted
time: 201ms
memory: 28448kb

input:

21 1
99886917 7 137531
99981046 114 3411955
99922117 736 6941080
99999975 6 1006942
99890237 2051 4130467
99996139 3749 7601557
99999888 87 4350651
99922857 58189 1285807
99987653 9 724869
99988120 1331 8615809
99981160 6493 7519808
99892288 56 8316748
99989451 6688 4113486
99987662 458 9500423
9989...

output:

YES
1 99886
1 9153661
1 31308257
1 962286
1 16679102
1 52774016
1 20809569
1 1969228
1 237417
1 76923245
1 45254208
1 68606497
1 12565616
1 85539054
1 60375573
1 38249337
1 25160220
1 3255035
1 95039578
1 5794853
1 1

result:

ok YES

Test #152:

score: 0
Accepted
time: 403ms
memory: 36396kb

input:

22 1
99813593 1 2866845
99875150 4431 8024236
99879827 1 7847774
99804934 8385 2669639
99995719 1 4141745
99813319 1 2413508
99995720 1 2439954
99813594 60332 2218692
99995763 1 100454
99879828 115891 4086329
99879581 243 4712351
99879824 1 2813336
99879825 2 7075681
99873928 1222 5781198
99998778 1...

output:

YES
1 16591650
1 75565440
1 91957159
1 11108675
1 23544824
1 6255213
1 8668721
1 1676102
1 1
1 19458495
1 32214071
1 13778314
1 60716070
1 48053478
1 67791751
1 100455
1 83589676
1 27686569
1 36926422
1 3894794
1 42477267
1 53834676

result:

ok YES

Test #153:

score: 0
Accepted
time: 449ms
memory: 36464kb

input:

22 1
73620 1 240
174053 1 12232
174058 1 12305
174054 1 9258
174049 1 12241
174065 1 9862
174050 1 8238
174063 1 3387
40608 1 14010
174055 1 8529
174062 1 9064
174057 1 7271
174056 1 5702
174061 1 831
130614 1 275
174064 1 9003
174052 1 6821
110618 1 5331
174060 1 10736
71468 1 11796
174059 1 804
17...

output:

YES
1 71469
1 149511
1 161743
1 110619
1 59226
1 84654
1 141273
1 130615
1 26597
1 1
1 17533
1 134002
1 78952
1 72788
1 71709
1 8530
1 40609
1 73621
1 119877
1 47430
1 71984
1 94516

result:

ok YES

Extra Test:

score: 0
Extra Test Passed