QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#478760#4927. Bounded Spanning Treeyjs48 1530ms240228kbC++145.5kb2024-07-15 10:53:062024-07-15 10:53:07

Judging History

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

  • [2024-07-15 10:53:07]
  • 评测
  • 测评结果:48
  • 用时:1530ms
  • 内存:240228kb
  • [2024-07-15 10:53:06]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<vector>
#define mkp(a,b) make_pair(a,b)
#define pr pair<int,int>
using namespace std;
const int aaa=500010;
const int LOG=20;
const int inf=0x3f3f3f3f;
int n,m,s,l[aaa],i,j,t,u[aaa],v[aaa],r[aaa],dep[aaa],x,fa[aaa][LOG+1],mal[aaa][LOG+1],val[aaa],out[aaa],id[aaa];
queue<int>q;
vector<int>inser[aaa];
vector<int>delet[aaa];
vector<pr >ve[aaa];
vector<pr >to[aaa];
multiset<int>gl[aaa];
priority_queue<pr,vector<pr >,greater<pr > >zgl;
void updatemi(int &x,int y)
{
    x=min(x,y);
}
void updatema(int &x,int y)
{
    x=max(x,y);
}
pr LCA(int x,int y)
{
    // cout<<"XY"<<x<<" "<<y<<endl;
    if(dep[x]<=dep[y])
        swap(x,y);
    int i,ans=0;
    for(i=LOG;i>=0;i--)
        if(dep[fa[x][i]]>=dep[y])
        {
            updatema(ans,mal[x][i]);
            x=fa[x][i];
        }
    if(x==y)
        return mkp(x,ans);
    for(i=LOG;i>=0;i--)
        if(fa[x][i]!=fa[y][i])
        {
            updatema(ans,max(mal[x][i],mal[y][i]));
            x=fa[x][i];
            y=fa[y][i];
        }
    updatema(ans,max(mal[x][0],mal[y][0]));
    return mkp(fa[x][0],ans);
}
int dfs(int x,int fa)
{
    int i;
    // cout<<"x"<<x<<endl;
    id[x]=x;
    for(i=0;i<to[x].size();i++)
    {
        int y=to[x][i].first;
        if(y!=fa)
        {
            r[to[x][i].second]=dfs(to[x][i].first,x);
            // cout<<to[x][i].second<<" "<<r[to[x][i].second]<<endl;
            if(gl[id[x]].size()<gl[id[y]].size())
            {
                while(!gl[id[x]].empty())
                {
                    gl[id[y]].insert(*gl[id[x]].begin());
                    gl[id[x]].erase(gl[id[x]].begin());
                }
                id[x]=id[y];
            }
            else
            {
                while(!gl[id[y]].empty())
                {
                    gl[id[x]].insert(*gl[id[y]].begin());
                    gl[id[y]].erase(gl[id[y]].begin());
                }
            }
        }
    }
    for(i=0;i<inser[x].size();i++)
        gl[id[x]].insert(inser[x][i]);
    for(i=0;i<delet[x].size();i++)
        gl[id[x]].erase(gl[id[x]].find(delet[x][i]));
    if(!gl[id[x]].empty())
        updatemi(val[x],*gl[id[x]].begin());
        // for(i=1;i<=m;i++)
        // {
        //     cout<<i<<" "<<l[i]<<" "<<r[i]<<endl;
        // }
    return val[x];
}
void ALLCLEAR()
{
    for(int i=1;i<=m;i++)
    {
        id[i]=0;
        dep[i]=val[i]=out[i]=0;
        for(int j=0;j<=LOG;j++)
            fa[i][j]=mal[i][j]=0;
        inser[i].clear();
        delet[i].clear();
        ve[i].clear();
        to[i].clear();
        gl[i].clear();
    }
    while(!q.empty())
        q.pop();
    while(!zgl.empty())
        zgl.pop();
}
int main()
{
    scanf("%d",&t);
    for(;t>=1;t--)
    {
        scanf("%d%d",&n,&m);
        for(i=1;i<=m;i++)
        {
            scanf("%d%d%d%d",&u[i],&v[i],&l[i],&r[i]);
            if(i<n)
            {
                to[u[i]].push_back(mkp(v[i],i));
                to[v[i]].push_back(mkp(u[i],i));
            }
        }
        dep[1]=1;
        q.push(1);
        while(!q.empty())
        {
            int x=q.front();
            // cout<<"X"<<x<<endl;
            q.pop();
            for(i=0;i<to[x].size();i++)
            {
                // cout<<to[x][i].first<<endl;
                if(dep[to[x][i].first])
                    continue;
                int y=to[x][i].first;
                dep[y]=dep[x]+1;
                q.push(y);
                val[y]=r[to[x][i].second];
                // cout<<"ZGL"<<y<<" "<<val[y]<<endl;
                fa[y][0]=x;
                mal[y][0]=l[to[x][i].second];
                for(j=1;j<=LOG;j++)
                {
                    fa[y][j]=fa[fa[y][j-1]][j-1];
                    mal[y][j]=max(mal[fa[y][j-1]][j-1],mal[y][j-1]);
                }
            }
        }
        // for(i=1;i<=n;i++)
        //     printf("%d ",dep[i]);
        // puts("");
        for(i=n;i<=m;i++)
        {
            pr lca=LCA(u[i],v[i]);
            updatema(l[i],lca.second);
            inser[u[i]].push_back(r[i]);
            inser[v[i]].push_back(r[i]);
            delet[lca.first].push_back(r[i]);
            delet[lca.first].push_back(r[i]);
            // printf("%d %d\n",lca.first,lca.second);
        }
        // for(i=1;i<=n;i++)
        //     cout<<val[i]<<" ";
        // puts("");
        // for(i=1;i<=m;i++)
        // {
        //     cout<<"QWQ"<<i<<" "<<l[i]<<" "<<r[i]<<endl;
        // }
        dfs(1,0);
        // for(i=1;i<=n;i++)
        //     cout<<val[i]<<" ";
        // puts("");
        // for(i=1;i<=m;i++)
        // {
        //     cout<<"QAQ"<<i<<" "<<l[i]<<" "<<r[i]<<endl;
        // }
        for(i=1;i<=m;i++)
            ve[l[i]].push_back(mkp(r[i],i));
        // cout<<zgl.size()<<endl;
        for(i=1;i<=m;i++)
        {
            for(j=0;j<ve[i].size();j++)
                zgl.push(ve[i][j]);
            if(zgl.empty())
                break;
            pr x=zgl.top();
            zgl.pop();
            if(x.first<i)
                break;
            out[x.second]=i;
        }
        if(i<=m)
        {
            puts("NO");
            ALLCLEAR();
            continue;
        }
        puts("YES");
        for(i=1;i<=m;i++)
            printf("%d ",out[i]);
        puts("");
        ALLCLEAR();
    }
}

详细

Subtask #1:

score: 4
Accepted

Test #1:

score: 4
Accepted
time: 556ms
memory: 206356kb

input:

1
500001 500000
254401 281557 349855 349855
181158 183050 7695 7695
168649 393239 182447 182447
275491 426002 407013 407013
412840 430191 81351 81351
180729 474744 468590 468590
167128 233022 352396 352396
56562 410078 411755 411755
28611 28934 27783 27783
250615 303207 495889 495889
348947 377767 2...

output:

YES
349855 7695 182447 407013 81351 468590 352396 411755 27783 495889 279148 126532 371490 46443 75037 440945 17872 376183 227217 256463 268704 93994 142674 221161 313215 423148 348655 110097 61558 138416 182869 460629 101134 233433 485321 293910 161637 31401 388370 43691 103888 258050 186588 285649...

result:

ok all is ok (1 test case)

Test #2:

score: 0
Accepted
time: 759ms
memory: 206384kb

input:

1
300001 500000
146540 236321 23350 23350
110737 197257 49315 49315
87807 244200 2878 2878
27529 179675 90834 90834
39761 204225 209751 209751
175226 239307 945 945
25136 248902 243667 243667
215811 229229 48401 48401
152882 243088 63537 63537
136220 210273 244339 244339
31127 43815 196573 196573
31...

output:

YES
23350 49315 2878 90834 209751 945 243667 48401 63537 244339 196573 170759 346610 33502 342292 86136 71174 153543 40008 300022 342991 305551 95289 63927 127147 133670 78873 57350 134796 242512 238031 153963 69392 220900 21326 171023 3218 211851 322418 63540 88200 109095 157709 6644 136208 86952 2...

result:

ok all is ok (1 test case)

Test #3:

score: 0
Accepted
time: 818ms
memory: 223584kb

input:

1
250001 500000
68287 196901 480106 480106
49342 196901 304518 304518
22416 49342 304522 304522
22416 155670 304523 304523
64466 155670 298516 298516
64466 91061 298511 298511
91061 107764 270019 270019
107764 145633 270023 270023
9967 145633 270022 270022
9967 74786 270020 270020
35298 74786 260981...

output:

YES
480106 304518 304522 304523 298516 298511 270019 270023 270022 270020 260981 260987 260975 260980 260999 260988 260553 260552 260551 255267 255249 255252 255206 255247 255246 255192 255270 255224 255251 255255 255296 255277 255189 255254 255245 255239 255217 255250 255289 255190 255276 255223 25...

result:

ok all is ok (1 test case)

Test #4:

score: 0
Accepted
time: 977ms
memory: 206896kb

input:

1
200001 500000
98193 105041 166701 166701
27762 114229 186133 186133
75089 79073 10507 10507
17865 143051 14801 14801
61475 66112 65966 65966
95929 145141 111474 111474
48331 68416 51667 51667
84658 174834 185681 185681
58072 88891 182212 182212
70612 148690 33041 33041
16155 127708 166666 166666
6...

output:

YES
166701 186133 10507 14801 65966 111474 51667 185681 182212 33041 166666 174410 126973 124348 104 167323 109299 22852 163302 119217 152431 288663 55933 2494 119959 58498 108854 313804 18466 166913 48980 9910 343607 193963 105226 272155 404993 191288 158308 131805 92742 84214 63930 160422 96427 12...

result:

ok all is ok (1 test case)

Test #5:

score: 0
Accepted
time: 1078ms
memory: 216292kb

input:

1
100001 500000
27575 40895 44938 44938
3625 19411 38012 38012
3655 84852 11318 11318
1152 91041 28632 28632
221 39962 65491 65491
35918 79361 78583 78583
41888 68339 40937 40937
82334 93242 62129 62129
66333 67583 113798 113798
75883 82560 2019 2019
43643 57947 122462 122462
16229 42734 54831 54831...

output:

YES
44938 38012 11318 28632 65491 78583 40937 62129 113798 2019 122462 54831 63084 16263 70129 58780 69845 51401 33811 865 27448 134237 60986 98507 57992 123479 8086 75165 12759 68854 23507 138812 87299 48771 33602 41920 53104 17098 132939 44566 25731 172500 15616 100033 9986 83815 20839 27119 1501 ...

result:

ok all is ok (1 test case)

Test #6:

score: 0
Accepted
time: 338ms
memory: 96864kb

input:

100
2501 4850
1396 1781 772 772
1019 1580 1529 1529
1146 2063 2944 2944
1883 1912 158 158
443 1995 1378 1378
450 871 504 504
1737 2297 2571 2571
447 1804 3367 3367
1159 1917 1789 1789
1478 2444 2775 2775
1783 2412 479 479
2245 2412 2839 2839
73 1403 4729 4729
747 2463 1469 1469
1107 2377 2034 2034
1...

output:

YES
772 1529 2944 158 1378 504 2571 3367 1789 2775 479 2839 4729 1469 2034 2085 1526 747 1638 1356 2158 979 1042 290 919 1304 1555 430 1380 301 1100 2407 900 4497 1318 958 878 432 667 594 1152 763 552 642 3625 463 2885 2992 1630 851 4742 893 2265 1999 83 348 2176 212 3311 629 3246 1360 2114 186 1457...

result:

ok all is ok (100 test cases)

Test #7:

score: 0
Accepted
time: 266ms
memory: 93596kb

input:

1000
251 483
203 224 371 371
75 104 172 172
147 218 64 64
65 94 6 6
123 131 122 122
17 238 119 119
59 151 27 27
157 239 133 133
67 246 225 225
169 220 138 138
63 212 103 103
2 9 33 33
55 201 191 191
103 181 91 91
12 134 62 62
124 227 315 315
106 243 4 4
158 246 49 49
62 142 202 202
2 139 178 178
133...

output:

YES
371 172 64 6 122 119 27 133 225 138 103 33 191 91 62 315 4 49 202 178 199 182 139 234 284 201 75 156 28 101 143 290 129 233 286 44 160 231 208 25 90 73 104 461 15 56 287 429 83 106 45 115 128 194 17 311 24 71 95 70 50 92 67 111 65 358 80 99 282 382 66 167 147 21 52 125 43 195 48 162 57 170 326 2...

result:

ok all is ok (1000 test cases)

Test #8:

score: 0
Accepted
time: 205ms
memory: 93600kb

input:

10000
26 52
6 26 13 13
8 22 23 23
1 4 8 8
12 26 19 19
2 25 6 6
4 23 3 3
7 11 9 9
8 16 5 5
7 20 7 7
2 5 29 29
12 15 1 1
10 21 10 10
4 16 21 21
4 24 2 2
7 25 30 30
14 15 24 24
17 22 22 22
6 13 18 18
18 24 14 14
15 24 12 12
9 24 43 43
3 20 49 49
7 15 4 4
19 20 11 11
10 18 16 16
21 24 20 20
13 20 45 45
...

output:

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

result:

ok all is ok (10000 test cases)

Test #9:

score: 0
Accepted
time: 177ms
memory: 93820kb

input:

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

output:

YES
8 4 7 1 2 3 12 6 9 5 11 10 
YES
2 3 1 4 5 8 11 12 10 6 9 7 
YES
1 3 2 6 5 7 4 
YES
4 3 5 1 2 7 6 9 8 10 
YES
2 4 5 3 1 10 6 9 11 7 8 
YES
2 6 5 4 1 8 7 10 3 9 
YES
1 6 3 5 2 7 10 12 9 8 4 11 
YES
3 1 10 4 2 7 9 5 11 8 12 6 
YES
5 4 2 8 1 10 7 9 3 11 6 
YES
2 1 5 3 6 4 7 
YES
2 7 1 5 3 8 4 6 
NO
...

result:

ok all is ok (50000 test cases)

Test #10:

score: 0
Accepted
time: 854ms
memory: 203944kb

input:

1
250001 500000
58145 72387 235237 235237
58145 124192 125607 125607
61444 72387 20858 20858
58145 210560 75907 75907
15080 61444 417136 417136
58145 144891 443143 443143
61444 113315 217104 217104
113315 219614 495886 495886
31702 210560 453336 453336
72387 147061 299803 299803
72387 234856 355629 ...

output:

NO

result:

ok all is ok (1 test case)

Test #11:

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

input:

1
3 4
1 2 1 1
2 3 2 2
1 3 4 4
1 3 4 4

output:

NO

result:

ok all is ok (1 test case)

Test #12:

score: 0
Accepted
time: 722ms
memory: 208196kb

input:

1
350001 500000
51970 181661 167074 167074
51970 326555 193867 193867
181661 197260 75401 75401
181661 229687 137191 137191
147797 326555 47018 47018
326555 336123 115700 115700
178220 197260 115089 115089
177064 197260 127762 127762
229687 286501 113990 113990
118842 229687 25034 25034
85794 147797...

output:

YES
167074 193867 75401 137191 47018 115700 115089 127762 113990 25034 173325 57068 115719 140380 141783 1164 68154 113245 51496 114298 74156 98738 32453 179503 5043 72618 117146 17085 114789 62367 79201 175046 113082 38555 6883 160158 137354 89534 102294 84811 112280 144778 53617 55541 80021 131091...

result:

ok all is ok (1 test case)

Test #13:

score: 0
Accepted
time: 658ms
memory: 206912kb

input:

1
350001 500000
1 2 91619 91619
1 3 97604 97604
2 4 107881 107881
2 5 105480 105480
3 6 43453 43453
3 7 96271 96271
4 8 182260 182260
4 9 133967 133967
5 10 70321 70321
5 11 17915 17915
6 12 37981 37981
6 13 153439 153439
7 14 100312 100312
7 15 190436 190436
8 16 27817 27817
8 17 124568 124568
9 18...

output:

YES
91619 97604 107881 105480 43453 96271 182260 133967 70321 17915 37981 153439 100312 190436 27817 124568 58307 123433 138047 186140 80734 119093 57462 38052 41558 25990 109748 53006 88030 115853 29102 55929 190897 53226 154772 68399 176247 43649 162208 193175 167849 59192 67049 132375 71215 14642...

result:

ok all is ok (1 test case)

Test #14:

score: 0
Accepted
time: 994ms
memory: 205596kb

input:

1
250001 500000
55167 234232 55638 55638
3684 234232 68427 68427
55167 55500 57038 57038
55167 104654 71138 71138
3684 97251 86152 86152
3684 51545 57935 57935
55500 187343 17112 17112
17560 55500 26990 26990
104654 207657 94625 94625
5109 104654 39135 39135
32358 97251 60733 60733
24234 97251 83100...

output:

YES
55638 68427 57038 71138 86152 57935 17112 26990 94625 39135 60733 83100 89950 80785 49587 25806 51060 1477 66287 82731 24961 93687 61061 65681 55974 37373 46924 37873 46135 93431 72032 91960 40585 33082 66193 49669 4930 11237 43217 57226 64344 26400 81344 49776 95307 335 29041 56487 78400 46678 ...

result:

ok all is ok (1 test case)

Test #15:

score: 0
Accepted
time: 916ms
memory: 207376kb

input:

1
250001 500000
1 2 94951 94951
1 3 117117 117117
2 4 23480 23480
2 5 33084 33084
3 6 93826 93826
3 7 78212 78212
4 8 34019 34019
4 9 18988 18988
5 10 18835 18835
5 11 79631 79631
6 12 64796 64796
6 13 85774 85774
7 14 19026 19026
7 15 96932 96932
8 16 114480 114480
8 17 90135 90135
9 18 116267 1162...

output:

YES
94951 117117 23480 33084 93826 78212 34019 18988 18835 79631 64796 85774 19026 96932 114480 90135 116267 117794 21150 57905 122132 43553 2465 113385 4839 20753 77276 59088 12016 58544 82267 27230 37192 95528 33142 102861 5463 52787 26363 64907 76455 25780 17549 8290 33840 33909 62173 119910 1147...

result:

ok all is ok (1 test case)

Test #16:

score: 0
Accepted
time: 1235ms
memory: 204936kb

input:

1
150001 500000
33562 137263 4731 4731
3140 33562 51401 51401
123261 137263 13746 13746
127268 137263 47614 47614
3140 112499 25919 25919
3140 123022 40262 40262
118183 123261 41486 41486
59636 123261 44743 44743
56726 127268 41422 41422
9584 127268 1382 1382
2765 112499 29621 29621
102477 112499 32...

output:

YES
4731 51401 13746 47614 25919 40262 41486 44743 41422 1382 29621 32059 26038 41052 35788 57790 39066 10908 26717 15676 13120 26818 53095 11623 35576 22385 36743 48593 50832 7489 43311 2469 16826 32832 16329 42185 31352 45205 36247 11975 37630 47545 40573 44458 17185 56813 12443 50754 17613 4489 5...

result:

ok all is ok (1 test case)

Test #17:

score: 0
Accepted
time: 1198ms
memory: 202792kb

input:

1
150001 500000
1 2 9865 9865
1 3 50922 50922
2 4 72636 72636
2 5 5342 5342
3 6 68517 68517
3 7 2682 2682
4 8 16233 16233
4 9 23462 23462
5 10 42691 42691
5 11 63709 63709
6 12 49292 49292
6 13 47024 47024
7 14 15678 15678
7 15 29782 29782
8 16 26150 26150
8 17 24947 24947
9 18 31097 31097
9 19 3616...

output:

YES
9865 50922 72636 5342 68517 2682 16233 23462 42691 63709 49292 47024 15678 29782 26150 24947 31097 36162 58970 15209 20815 39494 42015 20539 30622 17608 4149 26738 6917 24820 38438 44236 58408 61349 54552 54008 19297 55622 24871 21553 73059 68664 45106 7196 36073 72990 46145 18832 40855 25322 44...

result:

ok all is ok (1 test case)

Test #18:

score: 0
Accepted
time: 1395ms
memory: 204544kb

input:

1
100001 500000
32137 73071 8126 8126
30836 32137 8678 8678
33499 73071 28319 28319
54215 73071 10859 10859
13497 30836 14357 14357
20308 30836 20193 20193
33499 64930 32136 32136
33499 72955 10467 10467
4952 54215 13756 13756
54215 78914 7496 7496
13497 87217 18638 18638
13497 32815 12785 12785
203...

output:

YES
8126 8678 28319 10859 14357 20193 32136 10467 13756 7496 18638 12785 33440 30465 20187 38022 18080 35068 23543 32162 24620 13544 21454 32848 27770 1018 6270 26133 3075 7242 25247 32332 11951 28208 291 38575 25325 22264 19792 19256 20532 28167 35356 8949 16733 17298 25951 14904 12881 1026 8766 13...

result:

ok all is ok (1 test case)

Test #19:

score: 0
Accepted
time: 1379ms
memory: 209288kb

input:

1
100001 500000
1 2 47454 47454
1 3 24116 24116
2 4 5212 5212
2 5 34333 34333
3 6 37903 37903
3 7 24157 24157
4 8 7647 7647
4 9 46362 46362
5 10 39307 39307
5 11 417 417
6 12 11637 11637
6 13 7943 7943
7 14 31697 31697
7 15 25556 25556
8 16 26719 26719
8 17 2858 2858
9 18 38629 38629
9 19 15877 1587...

output:

YES
47454 24116 5212 34333 37903 24157 7647 46362 39307 417 11637 7943 31697 25556 26719 2858 38629 15877 9949 2664 11319 38601 3830 28522 35313 47973 36161 33118 36164 32490 10857 777 1309 33735 18396 3663 40300 22986 1204 23229 25140 11139 5272 12659 6822 23629 24396 27547 49065 22096 2187 13626 3...

result:

ok all is ok (1 test case)

Test #20:

score: 0
Accepted
time: 1399ms
memory: 204992kb

input:

1
50001 500000
11097 17004 6702 6702
11097 46242 6571 6571
9283 17004 14181 14181
17004 49249 3806 3806
16332 46242 12037 12037
23662 46242 620 620
9283 10658 16283 16283
9283 26166 4973 4973
12663 49249 9227 9227
39719 49249 14946 14946
6988 16332 7002 7002
16332 17234 8382 8382
21939 23662 6435 64...

output:

YES
6702 6571 14181 3806 12037 620 16283 4973 9227 14946 7002 8382 6435 8918 17999 2391 14264 14326 2400 19351 12275 3267 6860 2683 12585 3536 7244 17401 3138 19139 10062 18804 1804 17830 1334 9404 13005 13291 5769 2385 12046 9699 2957 11928 4790 2415 2254 8634 17482 11871 16931 2023 11959 11719 854...

result:

ok all is ok (1 test case)

Test #21:

score: 0
Accepted
time: 1530ms
memory: 212824kb

input:

1
50001 500000
1 2 9300 9300
1 3 18013 18013
2 4 199 199
2 5 5439 5439
3 6 3410 3410
3 7 12409 12409
4 8 23362 23362
4 9 3502 3502
5 10 2909 2909
5 11 15885 15885
6 12 7701 7701
6 13 12244 12244
7 14 15582 15582
7 15 1562 1562
8 16 23437 23437
8 17 1520 1520
9 18 7605 7605
9 19 13720 13720
10 20 163...

output:

YES
9300 18013 199 5439 3410 12409 23362 3502 2909 15885 7701 12244 15582 1562 23437 1520 7605 13720 16361 605 17871 19668 13644 6113 23475 7978 9645 20419 21421 13609 4107 10853 838 20375 9212 6717 24799 7554 21582 4914 3456 20389 8124 4843 2321 8741 5613 18728 15007 16075 3688 13565 14034 3848 204...

result:

ok all is ok (1 test case)

Subtask #2:

score: 6
Accepted

Test #22:

score: 6
Accepted
time: 8ms
memory: 93268kb

input:

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

output:

YES
3 8 5 2 1 6 10 9 7 4 

result:

ok all is ok (1 test case)

Test #23:

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

input:

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

output:

YES
1 7 6 2 3 5 4 8 9 

result:

ok all is ok (1 test case)

Test #24:

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

input:

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

output:

YES
9 1 6 3 4 2 8 5 10 7 

result:

ok all is ok (1 test case)

Test #25:

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

input:

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

output:

YES
8 3 5 2 1 4 9 6 7 

result:

ok all is ok (1 test case)

Test #26:

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

input:

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

output:

YES
2 9 3 5 1 6 10 7 8 4 

result:

ok all is ok (1 test case)

Test #27:

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

input:

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

output:

YES
8 5 1 4 2 9 3 6 7 

result:

ok all is ok (1 test case)

Test #28:

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

input:

2
4 5
2 3 1 1
2 4 2 3
1 2 5 5
2 3 3 3
2 4 4 5
4 5
2 3 1 2
1 2 1 2
1 4 3 3
3 4 4 4
1 3 5 5

output:

YES
1 2 5 3 4 
YES
1 2 3 4 5 

result:

ok all is ok (2 test cases)

Test #29:

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

input:

3
3 3
1 3 1 2
1 2 3 3
1 2 1 2
3 3
1 2 1 1
1 3 2 3
2 3 3 3
3 3
2 3 3 3
1 2 2 3
2 3 1 1

output:

NO
YES
1 2 3 
NO

result:

ok all is ok (3 test cases)

Test #30:

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

input:

1
4 4
1 2 1 3
2 3 1 4
3 4 4 4
2 3 2 2

output:

YES
3 1 4 2 

result:

ok all is ok (1 test case)

Test #31:

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

input:

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

output:

YES
10 3 2 1 8 6 4 9 5 7 

result:

ok all is ok (1 test case)

Test #32:

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

input:

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

output:

YES
7 1 3 5 10 4 2 9 8 6 

result:

ok all is ok (1 test case)

Subtask #3:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #33:

score: 10
Accepted
time: 4ms
memory: 92144kb

input:

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

output:

YES
2 3 1 5 4 6 
NO
YES
1 2 3 6 4 5 

result:

ok all is ok (3 test cases)

Test #34:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Test #35:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Test #36:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Test #37:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Test #38:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Test #39:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Test #40:

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

input:

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

output:

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

result:

ok all is ok (2 test cases)

Test #41:

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

input:

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

output:

NO
YES
6 2 3 1 5 4 
NO

result:

ok all is ok (3 test cases)

Test #42:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Test #43:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Test #44:

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

input:

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

output:

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

result:

ok all is ok (1 test case)

Subtask #4:

score: 0
Memory Limit Exceeded

Test #45:

score: 10
Accepted
time: 8ms
memory: 92324kb

input:

1
501 500
127 170 433 434
26 98 284 285
179 379 82 82
136 270 253 254
100 391 474 476
175 393 170 171
247 311 223 225
32 318 270 270
87 434 294 294
335 417 308 310
249 356 292 294
327 331 42 44
325 498 334 336
73 133 260 262
276 394 493 495
74 289 330 331
29 83 244 245
7 486 482 483
115 368 90 90
22...

output:

YES
433 284 82 254 476 170 224 270 294 308 293 44 336 261 494 331 244 482 90 277 32 115 416 106 240 386 479 444 125 500 488 306 399 86 474 408 455 458 15 87 42 141 24 128 33 383 29 342 333 381 448 214 346 365 2 25 397 13 499 357 326 310 391 139 366 487 449 361 498 285 436 153 481 412 83 328 84 187 3...

result:

ok all is ok (1 test case)

Test #46:

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

input:

1
501 500
129 176 247 250
72 179 289 289
170 435 422 422
135 320 255 256
126 397 150 150
25 112 29 29
341 422 112 112
68 176 419 421
83 208 266 267
111 470 144 149
212 488 163 165
109 261 468 468
457 478 500 500
298 426 427 432
61 408 459 464
235 440 297 302
114 117 307 307
132 448 37 38
128 380 219...

output:

YES
247 289 422 255 150 29 112 419 266 146 163 468 500 431 462 299 307 37 220 428 358 166 11 122 66 265 416 413 435 483 13 317 83 406 454 242 52 94 397 202 195 4 56 62 291 456 135 310 143 252 264 487 54 363 118 366 256 467 286 244 1 22 73 180 196 229 386 472 475 383 250 238 153 49 104 233 486 414 23...

result:

ok all is ok (1 test case)

Test #47:

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

input:

1
501 500
277 399 197 204
33 426 390 390
202 417 268 272
223 466 15 23
195 379 85 94
100 203 16 22
184 245 142 144
188 474 117 122
195 353 139 143
62 373 412 416
383 390 319 327
40 108 143 153
67 366 53 56
18 325 172 182
272 314 135 137
51 86 237 247
77 313 399 408
22 199 29 36
18 132 422 423
97 345...

output:

YES
201 390 270 20 89 16 142 121 139 414 325 150 53 176 135 242 404 31 422 355 12 313 39 468 292 120 99 491 211 289 88 169 437 32 497 371 205 314 3 19 180 128 295 2 331 421 101 223 360 241 488 143 66 212 474 118 367 258 158 387 285 483 219 348 484 369 342 475 480 271 244 339 405 441 264 226 332 402 ...

result:

ok all is ok (1 test case)

Test #48:

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

input:

1
501 500
212 481 169 188
28 427 404 420
339 466 43 62
229 281 111 126
89 143 234 238
333 444 160 168
288 484 431 451
177 432 441 453
384 407 418 427
146 340 118 118
92 249 467 479
53 469 396 398
63 70 174 180
54 367 8 19
285 360 153 164
67 389 286 291
91 442 99 104
1 455 58 67
207 309 453 472
286 4...

output:

YES
182 413 57 117 235 166 442 445 420 118 472 396 175 13 159 288 99 62 467 23 82 44 494 432 167 153 4 401 25 473 362 119 146 202 270 490 203 220 302 200 223 477 247 71 395 199 116 398 114 227 233 367 154 83 105 284 439 245 400 485 340 410 163 342 5 470 226 46 155 321 304 231 177 421 360 389 333 438...

result:

ok all is ok (1 test case)

Test #49:

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

input:

1
501 500
183 475 152 172
6 264 94 97
102 116 454 461
332 436 250 258
275 339 11 23
109 383 491 500
12 251 156 165
409 496 253 282
319 386 465 469
130 292 121 123
30 333 21 23
40 194 254 255
86 345 338 348
73 434 99 118
119 450 221 228
246 350 35 51
186 255 99 102
182 279 392 413
206 332 247 250
128...

output:

YES
165 94 454 251 13 491 156 277 465 121 21 254 339 107 224 40 99 405 247 197 478 248 404 199 161 269 148 363 412 371 453 444 481 426 296 283 73 316 189 297 244 354 169 246 341 488 436 245 448 280 179 220 500 68 6 7 298 358 227 406 343 119 437 39 391 51 411 252 142 88 475 62 382 345 266 291 83 309 ...

result:

ok all is ok (1 test case)

Test #50:

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

input:

1
501 500
56 261 38 63
139 152 248 251
173 435 92 131
254 445 21 36
74 246 202 208
52 442 422 447
328 340 434 466
179 434 92 126
200 241 127 132
48 294 183 203
72 271 147 172
42 382 245 265
330 466 349 368
59 216 120 125
279 443 359 381
469 478 292 309
51 100 21 39
186 475 275 299
94 495 420 429
323...

output:

YES
45 248 121 26 202 437 451 110 127 193 164 253 354 120 366 298 28 287 421 319 179 461 445 394 220 350 27 302 464 244 83 12 61 443 95 59 432 257 395 138 488 42 429 477 372 13 328 76 406 224 460 499 104 133 492 315 209 195 19 277 55 428 208 472 474 483 11 223 390 270 376 410 156 20 462 311 409 300 ...

result:

ok all is ok (1 test case)

Test #51:

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

input:

1
501 500
317 393 166 174
219 415 120 143
11 28 409 436
197 470 35 76
401 460 189 236
201 230 45 94
211 461 319 359
211 220 246 255
283 343 81 125
211 258 121 162
261 270 350 376
210 226 405 411
449 477 131 167
360 464 161 204
35 416 237 247
85 408 272 306
105 437 163 194
110 267 167 196
17 237 482 ...

output:

YES
168 132 420 62 217 73 339 247 110 145 360 405 148 191 237 289 178 180 482 481 165 318 319 398 223 269 306 457 399 453 81 232 364 195 203 477 108 197 298 352 340 299 33 2 162 254 463 287 258 454 38 301 233 341 268 78 206 396 293 170 204 235 192 321 353 154 414 455 439 408 45 255 21 312 25 236 323...

result:

ok all is ok (1 test case)

Test #52:

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

input:

1
501 500
66 362 223 231
19 173 108 146
267 468 15 84
269 309 295 302
438 462 348 415
132 187 474 498
91 416 92 191
141 161 71 169
142 309 153 177
59 390 139 220
57 203 359 449
172 362 463 466
226 463 444 495
344 369 1 68
122 266 320 336
293 326 316 358
108 207 34 114
14 140 153 182
339 383 363 383
...

output:

YES
223 120 48 295 377 475 165 143 154 184 412 463 471 30 320 329 84 156 363 123 159 260 431 121 125 423 28 218 57 440 336 272 398 224 415 393 445 306 359 166 347 425 314 335 67 16 18 7 39 104 95 436 350 382 308 197 101 270 477 318 92 353 366 351 418 285 262 36 483 133 396 446 362 220 432 213 474 46...

result:

ok all is ok (1 test case)

Test #53:

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

input:

1
501 500
419 457 238 270
52 410 93 141
101 172 97 163
146 274 112 149
277 448 127 325
435 440 46 195
375 380 159 299
107 306 326 359
31 441 188 346
6 55 174 197
74 340 16 123
38 437 1 72
265 366 178 255
203 442 1 105
42 119 215 281
54 65 1 85
72 213 14 208
358 392 301 302
210 359 125 197
142 293 27...

output:

YES
238 93 102 112 273 140 247 326 293 174 61 25 205 47 230 39 151 301 141 272 211 388 144 66 378 249 319 70 148 375 4 135 448 434 1 443 294 18 317 255 444 27 69 321 420 265 234 49 439 158 198 131 417 397 430 75 362 307 337 412 414 92 366 282 324 427 128 170 173 74 331 30 445 342 437 407 178 308 446...

result:

ok all is ok (1 test case)

Test #54:

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

input:

1
501 500
153 365 163 163
123 153 196 196
123 282 30 33
282 361 105 110
85 361 466 471
85 126 290 290
43 126 8 9
43 273 423 425
273 357 101 101
142 357 62 63
142 499 336 341
22 499 493 495
22 408 125 127
54 408 124 129
54 355 85 88
315 355 113 116
60 315 198 200
60 309 37 42
309 369 53 57
95 369 144...

output:

YES
163 196 31 107 470 290 8 424 101 62 341 494 125 128 85 114 198 39 54 144 130 71 222 489 221 202 388 246 217 339 19 467 10 5 299 72 429 360 165 44 183 55 333 328 172 82 335 308 407 317 495 219 230 291 375 463 46 161 56 274 104 347 297 91 226 310 304 157 9 243 466 180 208 439 106 302 98 454 440 16...

result:

ok all is ok (1 test case)

Test #55:

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

input:

1
501 500
23 115 137 146
23 68 233 249
53 68 53 59
53 342 321 335
11 342 342 356
11 279 281 295
76 279 401 414
76 236 441 448
236 454 468 484
325 454 240 253
287 325 418 423
287 351 423 435
14 351 318 331
14 141 206 208
141 404 309 312
166 404 53 64
84 166 270 283
84 311 42 57
205 311 347 357
161 20...

output:

YES
138 242 53 329 351 291 411 441 475 248 418 428 322 206 309 59 278 48 352 263 37 249 220 54 448 75 376 24 333 357 454 389 73 393 302 456 88 117 253 449 159 419 87 149 104 193 30 494 306 458 266 8 165 421 414 74 26 183 124 392 148 388 315 287 135 284 493 367 400 179 349 96 455 406 412 252 386 182 ...

result:

ok all is ok (1 test case)

Test #56:

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

input:

1
501 500
106 202 458 492
36 202 180 230
36 327 245 293
133 327 448 463
133 174 211 216
174 256 73 89
256 278 82 113
111 278 242 292
111 194 15 42
194 480 188 211
432 480 473 500
161 432 191 193
55 161 290 320
7 55 347 390
7 28 17 25
28 418 188 197
408 418 48 91
389 408 52 69
297 389 459 486
268 297...

output:

YES
476 217 280 453 211 73 99 277 26 199 489 191 302 378 17 189 72 56 468 223 320 85 322 234 341 422 418 59 479 61 213 376 282 269 260 480 203 63 287 212 144 10 490 113 481 129 65 242 19 492 165 146 298 69 470 97 464 58 290 123 429 283 395 437 198 122 207 116 136 153 304 333 68 225 316 491 252 190 1...

result:

ok all is ok (1 test case)

Test #57:

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

input:

1
501 500
128 431 134 232
62 431 214 243
118 431 68 159
194 431 157 213
422 431 297 355
226 431 377 461
208 431 112 196
179 431 202 288
46 431 1 72
302 431 68 110
353 431 313 313
197 431 1 17
233 431 111 162
12 431 443 500
234 431 167 234
387 431 466 500
35 431 244 332
397 431 487 500
204 431 430 49...

output:

YES
202 215 132 179 328 440 167 260 41 87 313 5 137 474 207 475 300 488 464 18 254 384 7 121 339 60 421 77 33 494 36 52 198 43 438 31 168 495 62 255 275 24 131 445 442 473 341 175 123 111 352 476 8 194 63 399 344 373 46 57 222 312 400 53 187 264 477 219 433 409 82 39 345 269 274 372 320 333 308 85 2...

result:

ok all is ok (1 test case)

Test #58:

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

input:

1
501 500
22 209 135 163
22 127 290 314
22 45 167 197
22 333 178 195
22 275 131 163
22 346 137 139
22 382 177 202
22 48 126 154
22 253 405 440
22 415 466 492
22 168 112 119
22 252 445 465
22 337 46 68
22 98 170 192
22 87 314 338
22 448 473 488
22 93 276 287
22 259 459 488
22 77 194 222
22 277 208 21...

output:

YES
153 303 184 183 154 137 191 142 430 482 112 453 58 177 328 473 276 474 207 208 104 455 431 475 122 253 500 219 436 203 14 165 29 463 192 169 140 258 283 348 450 442 313 74 96 123 205 82 353 263 393 467 265 241 146 83 49 368 366 167 129 327 323 480 386 185 148 407 68 319 35 489 378 468 432 239 23...

result:

ok all is ok (1 test case)

Test #59:

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

input:

1
501 500
124 342 261 323
7 124 103 106
124 439 303 341
124 443 316 342
81 124 456 458
124 429 24 53
124 413 205 262
75 124 54 91
124 336 348 382
124 433 412 452
124 147 349 401
124 180 91 150
124 501 385 434
124 133 191 247
124 447 152 220
18 124 469 493
124 271 67 76
124 316 395 457
124 279 260 29...

output:

YES
302 103 318 319 456 39 241 71 363 432 385 125 415 226 199 469 67 438 275 346 374 54 313 179 376 440 213 478 143 457 265 479 280 354 122 36 89 321 30 190 82 335 408 152 373 453 222 131 205 377 309 238 114 433 345 132 81 406 204 198 468 160 351 398 142 170 177 64 144 323 69 21 359 365 337 20 186 1...

result:

ok all is ok (1 test case)

Test #60:

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

input:

1
501 500
233 402 267 276
144 233 313 315
156 233 23 33
233 266 9 15
19 233 297 310
233 324 106 116
233 493 402 402
233 323 357 372
16 233 142 147
134 233 448 455
171 233 164 164
37 233 150 159
233 245 387 397
233 432 229 230
233 272 275 276
145 233 188 201
109 233 166 172
233 482 476 477
233 464 24...

output:

YES
272 313 27 13 305 113 402 368 144 450 164 156 391 229 275 193 167 476 256 152 231 135 171 468 276 338 46 14 247 428 194 48 273 496 29 15 370 471 441 344 107 291 495 65 406 353 125 120 49 19 429 308 158 497 192 378 321 100 139 91 357 318 2 278 440 405 367 334 252 102 137 479 204 5 24 241 359 33 2...

result:

ok all is ok (1 test case)

Test #61:

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

input:

1
501 500
156 217 398 408
56 217 92 93
145 217 57 62
217 399 350 355
82 217 470 474
217 308 311 321
31 217 227 227
217 476 314 324
217 289 386 398
122 217 289 296
217 501 217 229
217 398 328 329
217 458 462 472
217 357 192 199
132 217 266 271
131 217 136 137
152 217 365 374
121 217 375 386
217 358 2...

output:

YES
403 92 58 352 470 317 227 320 395 289 225 328 466 197 268 136 369 380 270 263 350 112 341 87 100 416 46 135 196 338 35 300 459 161 479 81 434 312 49 219 9 311 256 340 119 218 51 111 461 22 314 362 417 386 375 351 398 221 293 418 258 142 247 309 149 273 406 327 354 93 378 373 27 175 66 107 332 43...

result:

ok all is ok (1 test case)

Test #62:

score: -10
Memory Limit Exceeded

input:

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

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 20
Accepted

Test #93:

score: 20
Accepted
time: 169ms
memory: 94328kb

input:

1000
500 500
100 331 2 8
162 182 272 276
133 415 393 397
144 176 499 500
64 273 47 55
37 463 424 428
96 481 127 127
115 341 333 336
79 95 246 248
266 473 473 476
117 140 113 120
112 309 323 330
251 438 39 45
22 339 275 285
83 474 264 266
185 212 282 291
377 425 25 31
42 436 351 357
35 69 173 182
159...

output:

YES
6 272 394 499 51 424 127 333 246 474 114 327 40 279 266 283 28 354 177 485 151 12 14 350 359 267 18 81 343 375 199 480 461 407 216 86 482 112 277 192 153 493 129 224 159 268 356 372 315 393 33 103 444 396 284 94 208 340 188 242 385 200 303 362 214 95 371 21 304 116 373 346 165 399 88 314 42 369 ...

result:

ok all is ok (1000 test cases)

Test #94:

score: 0
Accepted
time: 177ms
memory: 92928kb

input:

1000
500 500
263 445 23 34
78 313 146 154
230 479 442 449
30 422 402 413
203 491 298 313
211 353 266 276
336 449 412 428
39 200 291 315
333 344 15 30
77 227 472 475
166 435 90 115
338 471 223 236
237 287 203 213
226 457 17 32
7 179 441 454
130 447 344 359
5 302 376 383
75 329 423 424
76 386 172 190
...

output:

YES
29 146 442 407 307 267 417 311 25 472 103 223 204 28 441 351 376 423 181 487 164 185 374 302 239 111 345 70 431 321 372 149 143 184 316 464 395 415 340 236 333 209 460 268 79 373 3 82 432 466 142 495 289 290 251 8 291 85 416 334 16 327 300 92 77 119 394 455 213 398 40 320 341 386 113 253 457 444...

result:

ok all is ok (1000 test cases)

Test #95:

score: 0
Accepted
time: 188ms
memory: 96540kb

input:

100
5000 5000
1050 3257 3679 3683
1611 2666 4834 4845
452 3180 4411 4415
1500 4067 2424 2437
989 3394 3014 3023
3098 4437 4722 4727
1309 3218 1175 1177
4456 4719 3394 3404
3064 4235 533 549
2422 3362 1097 1104
3526 4419 4206 4219
1349 3646 4192 4200
889 3142 3836 3852
1429 2797 180 194
941 971 2333 ...

output:

YES
3679 4840 4411 2425 3021 4724 1175 3394 544 1102 4215 4196 3844 187 2341 3681 11 3939 4881 731 1638 4778 1179 4621 4902 4339 471 3647 2920 2227 3584 2028 2816 1005 1766 449 2921 1977 1046 3898 1378 2209 1272 650 1230 1989 3837 3936 255 3471 2070 3572 1573 140 4731 1795 1419 2380 4288 909 1505 20...

result:

ok all is ok (100 test cases)

Test #96:

score: 0
Accepted
time: 183ms
memory: 95592kb

input:

100
5000 5000
896 1568 2762 2764
896 3943 4810 4813
896 4703 1309 1311
698 896 3724 3727
896 4466 145 146
896 1510 3366 3367
896 3907 787 791
412 896 1161 1163
896 1144 2699 2702
896 4397 2012 2014
896 1197 486 487
896 1959 3032 3040
896 3782 4002 4010
896 4120 2053 2061
896 2848 1007 1016
29 896 29...

output:

YES
2762 4811 1309 3726 146 3366 788 1161 2701 2012 486 3035 4009 2058 1010 2918 694 511 2323 47 4535 1722 2994 4505 1153 4795 1203 3628 595 2286 238 3357 997 412 1970 1244 4320 1535 144 1316 167 1579 1743 2038 543 3811 1850 840 3110 1255 2270 4635 3835 4592 4782 4641 3534 265 1542 2805 2905 4902 25...

result:

ok all is ok (100 test cases)

Test #97:

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

input:

10
50000 50000
16923 41334 36220 36274
3707 16923 25007 25485
16923 43183 18327 19460
3707 36130 39723 39849
3236 43183 43590 44645
33673 36130 25151 25263
40317 43183 17958 18364
9548 40317 5313 5322
29972 33673 38913 40387
16923 46964 13196 14120
16660 43183 40309 40886
3690 3707 18129 19025
40317...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO

result:

ok all is ok (10 test cases)

Test #98:

score: 0
Accepted
time: 230ms
memory: 104056kb

input:

10
50000 50000
19424 19639 22452 23092
17278 19424 13463 13527
19639 38736 24509 24517
35080 38736 37348 37649
17278 40728 2919 3352
17278 35971 19193 19722
36585 40728 8570 9388
17278 38949 40307 40923
10426 40728 24206 24940
19639 26173 5971 6142
15699 19639 38641 38923
40728 43932 48259 48361
104...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO

result:

ok all is ok (10 test cases)

Test #99:

score: 0
Accepted
time: 245ms
memory: 105872kb

input:

10
50000 50000
1192 40512 19190 19355
1192 16647 1596 2390
40512 48981 30014 31493
1192 9477 8494 9679
9477 22370 44252 44582
1192 49956 12853 14527
9477 19578 690 971
22370 28423 49462 49885
9477 11391 7432 8311
11129 28423 47638 48233
11129 36670 35712 36687
11391 43704 27626 27746
9210 16647 4193...

output:

NO
NO
YES
10919 4286 22556 18192 12664 45720 37072 15891 23836 16863 12179 49468 3210 19964 42189 30492 4529 28004 34461 38913 15570 22859 9379 33781 1410 22248 40436 17383 11606 4829 43921 27454 44301 2282 12161 1606 2751 13376 41181 48810 14989 33619 8628 15318 48582 24708 26478 45344 39472 1245 3...

result:

ok all is ok (10 test cases)

Test #100:

score: 0
Accepted
time: 259ms
memory: 104588kb

input:

10
50000 50000
8304 12932 23665 23670
31403 41968 33812 33813
887 47837 30167 30169
4286 33182 16863 16864
15786 46808 1393 1398
25570 41476 25789 25793
19043 25829 6368 6373
7945 23399 36512 36516
23197 41637 7759 7764
5884 20309 42710 42712
29776 33891 8302 8303
303 13274 23488 23488
11277 42596 2...

output:

YES
23666 33812 30168 16863 1396 25790 6372 36514 7760 42711 8302 23488 23450 15391 7985 5569 32205 39712 44705 22122 31531 39199 36174 28644 49333 18168 21380 25398 15386 23007 9200 33699 15470 16102 8140 29491 35104 37063 19440 46764 9962 22766 47857 1385 45028 32840 49399 36840 33725 1557 19859 5...

result:

ok all is ok (10 test cases)

Test #101:

score: 0
Accepted
time: 264ms
memory: 109992kb

input:

10
50000 50000
41913 47632 6512 6531
42921 47632 29876 29880
8920 42921 6329 6347
8920 39871 34643 34650
3075 39871 13399 13410
3075 6883 4479 4519
6883 30250 17021 17029
30250 39228 31042 31060
25475 39228 26931 26965
2053 25475 27846 27888
2053 48494 16104 16127
18975 48494 38780 38788
10606 18975...

output:

YES
6519 29876 6335 34643 13400 4501 17022 31042 26943 27874 16114 38780 46693 6232 47659 39203 9643 31589 20261 1661 24298 2183 33459 5508 33752 30094 35436 1761 46636 39962 17184 47456 37668 14814 18119 23661 14429 10821 37973 9676 3173 32746 7819 45168 42232 35999 16646 42647 23098 7417 12093 117...

result:

ok all is ok (10 test cases)

Test #102:

score: 0
Accepted
time: 242ms
memory: 106684kb

input:

10
50000 50000
10553 28226 10181 10228
28220 28226 32714 32718
28226 33586 32521 32567
9269 28226 24833 24857
28226 36323 982 1018
28226 40190 9044 9090
28226 35742 31493 31529
16603 28226 28112 28118
28226 39725 40404 40445
28226 49320 39524 39541
28226 46425 12829 12875
5045 28226 9623 9661
28226 ...

output:

YES
10214 32714 32549 24843 1003 9076 31520 28112 40430 39530 12865 9643 35501 31645 17122 31247 19322 15982 42327 4449 13842 17004 11881 39195 15937 9284 2807 41320 28451 9709 43143 21566 45475 11976 16246 19822 32553 25526 1648 27659 20447 5902 29152 45763 47968 36316 13042 13348 39668 39538 27 45...

result:

ok all is ok (10 test cases)

Test #103:

score: 0
Accepted
time: 421ms
memory: 201292kb

input:

1
500000 500000
27666 296099 287454 287528
296099 415922 259068 259374
296099 301662 57883 58173
28795 296099 309225 309359
296099 355135 22964 23140
191694 296099 414455 414547
160041 296099 234036 234134
296099 353155 398700 398868
296099 298124 442893 443032
240081 296099 171054 171138
296099 358...

output:

YES
287455 259281 58078 309263 23049 414463 234036 398778 442928 171055 365327 311066 188970 488697 486460 400080 362957 71237 130249 17816 429928 340627 359318 351227 153741 1459 384749 228822 192485 23255 329131 277406 348014 474016 474276 492008 96160 361873 264949 283780 387947 260976 267887 231...

result:

ok all is ok (1 test case)

Test #104:

score: 0
Accepted
time: 289ms
memory: 105280kb

input:

10
50000 50000
2715 37650 11708 11709
2715 7532 46196 46197
4084 37650 16713 16714
30801 37650 1701 1701
7532 31471 26778 26778
7532 34624 16332 16333
4084 43204 26048 26049
4084 32302 32591 32591
30801 36788 22361 22362
4089 30801 45840 45841
31471 43181 9452 9452
15650 31471 579 579
14765 34624 35...

output:

YES
11708 46196 16713 1701 26778 16333 26049 32591 22362 45840 9452 579 3550 10696 29167 25804 15820 15196 24279 7215 25924 36931 43147 4990 23823 20887 1095 41396 4017 24589 8829 43375 47414 48351 446 35535 47420 23561 11918 41243 5689 28158 37269 9099 6226 18014 5364 46581 6564 32140 43683 30843 3...

result:

ok all is ok (10 test cases)

Test #105:

score: 0
Accepted
time: 414ms
memory: 202156kb

input:

1
500000 500000
350978 384616 431612 431835
183860 384616 144521 144592
189058 350978 112130 112217
350978 421982 421775 421905
166742 183860 325651 325730
62982 183860 114103 114341
186049 189058 291937 291966
189058 418793 430553 430555
279130 421982 65908 65962
421982 464192 301183 301325
166742 ...

output:

YES
431743 144521 112131 421806 325651 114230 291937 430553 65908 301219 488297 187132 347259 3004 274919 305045 188404 451989 388542 167227 266680 172844 29182 76302 359991 199040 3149 61194 385675 443319 39994 424388 257013 74819 45130 366306 279531 52200 291544 323046 495134 221397 150572 114554 ...

result:

ok all is ok (1 test case)

Test #106:

score: 0
Accepted
time: 461ms
memory: 230248kb

input:

1
500000 500000
215604 482720 9336 9336
187347 482720 339886 339888
127935 187347 56645 56645
95810 127935 167534 167536
95810 106925 464539 464540
106925 478623 69726 69727
381224 478623 124767 124773
345415 381224 312846 312846
345415 358809 353961 353961
212260 358809 334239 334240
212260 448751 ...

output:

YES
9336 339886 56645 167534 464539 69726 124772 312846 353961 334239 291070 498775 416183 450083 449445 334967 394624 239686 494137 300572 228466 294880 439585 233830 57832 161980 390982 118668 333697 319695 472166 311996 72746 80564 461295 362601 202296 186250 41816 144861 236031 70844 199238 3055...

result:

ok all is ok (1 test case)

Test #107:

score: 0
Accepted
time: 554ms
memory: 239980kb

input:

1
500000 500000
215308 293000 367250 368060
35529 215308 284644 285572
35529 210118 63073 63315
210118 306690 131612 131786
306690 381648 235581 235735
126047 381648 298060 298580
126047 364413 269204 270075
204485 364413 376275 377262
178874 204485 474702 475038
82671 178874 77500 78183
82671 35422...

output:

YES
367787 285302 63073 131615 235581 298315 269776 376972 474750 77913 195862 140328 12955 95407 11299 31205 345818 269615 485255 205266 440079 369989 494861 483179 267434 381857 303204 141647 185528 383783 376565 368230 239946 367950 487826 271062 121684 305655 282892 166614 160516 285502 55432 28...

result:

ok all is ok (1 test case)

Test #108:

score: 0
Accepted
time: 491ms
memory: 235684kb

input:

1
500000 500000
172091 389900 27256 28457
172091 414155 373461 374077
404244 414155 452626 453468
187718 404244 19899 20264
16984 187718 352185 354628
16984 295130 427098 429377
108258 295130 163767 164461
108258 398510 228318 228525
398510 403200 77965 78842
195873 403200 462094 462963
195873 45981...

output:

YES
27723 373461 452747 19899 353899 428651 163767 228319 78096 462186 346685 162297 46295 418160 64334 313791 15598 273722 68119 182482 274573 247605 446826 275988 69003 408852 91159 494103 317251 342293 207358 338991 491202 455991 375463 327913 498741 421361 482293 442436 431862 437351 486654 3761...

result:

ok all is ok (1 test case)

Test #109:

score: 0
Accepted
time: 474ms
memory: 240228kb

input:

1
500000 500000
259214 291911 390684 390743
259214 322337 211259 211382
322337 461511 401096 401230
461511 464732 219531 219776
219473 464732 6740 6899
213993 219473 13536 13682
159931 213993 333656 333753
159931 482231 111461 111488
266344 482231 306012 306300
236983 266344 307800 307838
236983 317...

output:

YES
390684 211300 401143 219686 6818 13610 333656 111462 306223 307800 344675 497498 318796 67359 435671 151706 353835 70289 70262 200874 333557 14913 290902 379180 241984 427471 442316 451875 365166 435173 46243 91205 369046 464059 234784 271948 258404 4684 230366 248564 255983 492767 423448 298366...

result:

ok all is ok (1 test case)

Test #110:

score: 0
Accepted
time: 478ms
memory: 222644kb

input:

1
500000 500000
330795 392574 203480 203694
392574 423123 383760 383767
28684 423123 60917 61538
28684 273674 335604 336392
273674 275630 3002 3378
96288 275630 95317 96382
96288 203576 297246 297270
61790 203576 306939 307694
61790 325062 471295 471508
292782 325062 344917 345630
157134 292782 4150...

output:

YES
203480 383760 61224 336100 3060 96067 297246 307381 471295 345316 415543 108607 3072 154186 116103 45715 276049 417073 462317 441498 448480 236319 244141 314497 57996 125816 470305 56640 368678 453896 141560 461413 119990 211213 82760 38557 283842 349430 137694 382197 417036 94911 434808 308898 ...

result:

ok all is ok (1 test case)

Test #111:

score: 0
Accepted
time: 482ms
memory: 224460kb

input:

1
500000 500000
39491 299185 30782 30812
39491 259353 352840 352861
259353 309986 67425 67473
83919 309986 146968 146975
83919 451788 208822 208827
290913 451788 415298 415370
211766 290913 490586 490586
211766 480666 87152 87224
399866 480666 396990 397040
114518 399866 416966 416991
114518 300894 ...

output:

YES
30790 352842 67447 146968 208822 415349 490586 87205 397019 416971 465025 111519 153696 399543 197544 483126 150215 396055 84349 8879 244841 388301 482548 389486 371363 216775 219928 309490 100623 138195 386754 342762 65575 396136 376389 306399 13543 457574 426644 380863 355672 37810 494150 9730...

result:

ok all is ok (1 test case)

Test #112:

score: 0
Accepted
time: 524ms
memory: 226888kb

input:

1
500000 500000
46754 452678 187210 198104
46754 52740 267995 281250
52740 203135 456552 466128
203135 325773 300828 306314
260560 325773 182631 196201
187766 260560 36270 45197
187766 431045 354969 356331
195199 431045 178056 187365
195199 300882 215021 226238
280096 300882 318941 337636
214694 280...

output:

YES
192051 275045 459897 300828 190121 38888 354969 181156 220100 331430 87134 330131 179120 282416 93423 387542 120335 259160 128118 109220 244290 157559 10354 185748 277953 239662 224126 307920 34265 204454 178106 267299 183028 317898 471271 202513 486799 184763 7505 424467 209176 39188 62511 3241...

result:

ok all is ok (1 test case)

Test #113:

score: 0
Accepted
time: 512ms
memory: 233860kb

input:

1
500000 500000
53242 159837 143382 165897
159837 178075 463092 467188
178075 376948 109964 120038
317015 376948 46105 50064
218707 317015 365093 385513
218707 401056 109454 110280
67695 401056 177350 188475
67695 238732 477719 479372
200407 238732 2173 10807
98168 200407 399100 404322
76728 98168 3...

output:

YES
158966 463092 113159 46105 378619 109454 181692 477719 4901 399100 346565 205490 222795 51103 337059 235985 132535 397228 351162 368 188731 95760 76143 328736 94208 290686 85664 368738 432829 329299 377353 409198 394862 426253 263336 197526 381077 425879 106824 248156 52156 24126 272185 165889 3...

result:

ok all is ok (1 test case)

Test #114:

score: 0
Accepted
time: 497ms
memory: 237824kb

input:

1
500000 500000
30447 392104 328309 341822
324482 392104 288339 415393
324482 489567 148351 175123
209566 489567 390045 500000
209566 454111 263808 265043
174167 454111 1 70691
174167 482851 19761 127055
256337 482851 62004 184861
241343 256337 226890 306358
133127 241343 124234 242562
133127 448511...

output:

YES
328309 377963 148352 462850 263808 36184 89938 147666 269026 205320 495069 275502 423666 369132 92609 437824 330654 102370 277235 307414 75926 398396 17002 236940 350163 300940 377984 29688 343863 306103 466029 154254 167015 75550 87878 462852 232999 210471 300316 319466 233672 303809 107716 987...

result:

ok all is ok (1 test case)

Test #115:

score: 0
Accepted
time: 494ms
memory: 237472kb

input:

1
500000 500000
67846 259403 74455 144057
67846 158710 36496 48157
158710 312920 90296 135809
312920 456455 129093 170164
274089 456455 252193 318771
274089 477473 319023 372332
73790 477473 324544 380438
73790 249305 188384 234755
5339 249305 452449 500000
5339 131597 373648 500000
131597 389121 31...

output:

YES
96139 36496 90297 129093 271223 324469 332442 188384 452449 452003 344822 138858 291543 155300 136708 412147 331281 69730 406494 365715 228742 4337 312207 333383 452004 161798 406654 426685 294616 115989 16790 58726 141924 97322 188 424228 143293 452005 149039 191236 452006 464763 317056 343943 ...

result:

ok all is ok (1 test case)

Test #116:

score: 0
Accepted
time: 507ms
memory: 237864kb

input:

1
500000 500000
173238 218038 1 204189
138674 173238 461175 500000
138674 140818 182274 188110
140818 251738 274707 450965
145722 251738 252282 500000
145722 219492 4555 18640
196427 219492 249106 315295
104805 196427 1 286655
93782 104805 288839 474951
93782 123242 401034 500000
123242 405402 63940...

output:

YES
100772 461175 182274 336385 385433 4555 249107 173699 360450 401034 263326 119427 343734 406284 385434 414311 385435 191149 70261 111312 29991 336482 71406 109849 385436 83309 169281 305150 197041 322896 385438 380008 480894 197718 169438 117038 9461 111542 243577 262536 67875 299271 311886 1416...

result:

ok all is ok (1 test case)

Test #117:

score: 0
Accepted
time: 517ms
memory: 221900kb

input:

1
500000 500000
262797 287497 266004 500000
74071 287497 111845 189535
72024 74071 56694 334218
72024 407057 304263 500000
368670 407057 15423 143366
292638 368670 238985 441703
289963 292638 297047 438044
289963 301094 15853 206514
301094 336492 312942 401505
182881 336492 14591 319500
182881 48961...

output:

YES
404039 111846 238506 404040 63133 345804 342137 115065 312942 223888 404041 453716 381166 323727 404042 347618 60248 110932 428710 278229 134745 465656 209275 117998 174679 441948 404043 16869 275116 292104 404044 215397 358911 404048 404051 205491 404052 269371 233316 239061 132009 345429 43959...

result:

ok all is ok (1 test case)

Test #118:

score: 0
Accepted
time: 455ms
memory: 231816kb

input:

1
500000 500000
2924 134417 1 500000
134417 432445 1 500000
432445 464203 1 500000
383628 464203 1 500000
383628 398462 1 500000
398462 444300 1 500000
159908 444300 1 500000
159908 384395 1 500000
296118 384395 1 373314
193297 296118 1 500000
156479 193297 1 500000
156479 459696 19285 500000
253458...

output:

YES
54499 54500 54501 54502 54503 54504 54505 54506 32490 54507 54508 54509 4099 54510 54511 54512 54513 54514 54515 54516 54517 54518 38566 54520 54521 54522 54523 34863 54524 54525 54526 54528 54529 54530 54531 54532 54597 54533 54534 54535 54536 54538 54539 54540 54541 14189 54542 54543 54544 545...

result:

ok all is ok (1 test case)

Subtask #7:

score: 0
Skipped

Dependency #3:

100%
Accepted

Dependency #4:

0%

Subtask #8:

score: 8
Accepted

Test #143:

score: 8
Accepted
time: 229ms
memory: 92220kb

input:

1000
251 500
1 2 280 287
2 3 251 256
3 4 249 249
4 5 252 253
5 6 252 256
6 7 250 250
7 8 254 261
8 9 245 256
9 10 123 127
10 11 45 49
11 12 122 128
12 13 164 167
13 14 153 156
14 15 210 217
15 16 53 64
16 17 205 208
17 18 136 149
18 19 132 135
19 20 24 27
20 21 45 51
21 22 21 30
22 23 5 7
23 24 178 ...

output:

YES
282 253 249 252 254 250 257 255 123 46 125 164 153 214 58 205 145 132 24 47 26 5 179 86 78 215 187 106 216 23 181 109 21 32 121 8 221 27 127 207 141 36 217 42 11 184 150 66 68 146 167 211 162 142 90 159 134 61 28 172 85 115 137 54 76 165 30 147 101 3 105 75 139 177 188 1 14 73 209 35 192 33 124 ...

result:

ok all is ok (1000 test cases)

Test #144:

score: 0
Accepted
time: 189ms
memory: 92284kb

input:

1000
351 500
1 2 62 69
2 3 225 227
3 4 160 166
4 5 172 177
5 6 118 120
6 7 35 42
7 8 92 100
8 9 82 87
9 10 222 230
10 11 234 239
11 12 141 145
12 13 213 217
13 14 110 116
14 15 154 157
15 16 280 280
16 17 243 250
17 18 124 132
18 19 20 29
19 20 328 329
20 21 41 48
21 22 189 192
22 23 241 249
23 24 4...

output:

YES
64 225 163 174 118 39 95 83 226 234 141 213 115 156 280 248 130 25 328 43 189 247 49 157 70 214 255 284 9 140 235 28 282 149 26 334 216 123 249 86 134 139 313 170 323 220 78 72 110 217 151 268 128 238 30 41 330 294 48 45 186 111 343 253 54 180 66 97 107 348 340 318 19 125 87 312 63 91 162 37 303...

result:

ok all is ok (1000 test cases)

Test #145:

score: 0
Accepted
time: 224ms
memory: 92136kb

input:

1000
251 500
1 2 175 184
2 3 74 76
3 4 134 143
4 5 63 69
5 6 18 19
6 7 258 258
7 8 216 221
8 9 157 163
9 10 224 229
10 11 220 227
11 12 115 115
12 13 187 189
13 14 209 216
14 15 1 4
15 16 10 10
16 17 82 83
17 18 75 84
18 19 146 148
19 20 233 238
20 21 80 87
21 22 134 136
22 23 59 59
23 24 228 238
24...

output:

YES
182 74 138 65 18 258 218 159 226 221 115 187 212 1 10 82 79 146 234 86 136 59 235 112 121 83 216 68 34 93 28 53 215 196 143 217 58 201 106 27 155 56 148 54 41 124 94 84 170 228 51 63 69 78 21 175 153 3 70 174 134 242 157 95 6 162 26 44 99 36 198 149 119 241 220 132 13 161 186 80 120 231 118 229 ...

result:

ok all is ok (1000 test cases)

Test #146:

score: 0
Accepted
time: 247ms
memory: 93244kb

input:

1000
151 500
1 2 198 198
2 3 165 167
3 4 1 10
4 5 121 125
5 6 114 117
6 7 131 136
7 8 134 141
8 9 97 103
9 10 90 94
10 11 133 135
11 12 118 123
12 13 51 60
13 14 139 147
14 15 61 61
15 16 46 49
16 17 33 40
17 18 62 62
18 19 70 76
19 20 65 69
20 21 114 122
21 22 1 1
22 23 71 71
23 24 5 5
24 25 2 5
25...

output:

YES
198 166 7 123 115 135 137 97 91 133 120 57 143 61 46 35 62 70 65 118 1 71 5 4 18 96 6 89 78 19 68 20 107 40 134 76 101 66 69 98 112 100 121 136 142 85 51 80 86 138 103 125 31 32 114 132 43 117 92 77 58 110 144 104 49 2 64 127 50 75 25 41 30 53 8 99 87 131 109 47 74 28 79 88 124 12 116 130 128 11...

result:

ok all is ok (1000 test cases)

Test #147:

score: 0
Accepted
time: 553ms
memory: 224860kb

input:

1
250001 500000
1 2 232634 232778
2 3 439147 439210
3 4 242069 242195
4 5 123158 123260
5 6 404204 404219
6 7 148853 149029
7 8 128047 128105
8 9 241218 241219
9 10 396066 396078
10 11 431745 431863
11 12 265898 265945
12 13 358860 358915
13 14 154751 154864
14 15 346376 346465
15 16 251154 251293
1...

output:

NO

result:

ok all is ok (1 test case)

Test #148:

score: 0
Accepted
time: 552ms
memory: 225296kb

input:

1
250001 500000
1 2 372249 373236
2 3 351474 352579
3 4 241138 242185
4 5 435154 435927
5 6 401961 403137
6 7 173100 173817
7 8 155176 156484
8 9 63955 64214
9 10 311244 312461
10 11 48185 49366
11 12 431470 431604
12 13 276348 276648
13 14 371291 372298
14 15 304170 305042
15 16 493375 493860
16 17...

output:

NO

result:

ok all is ok (1 test case)

Test #149:

score: 0
Accepted
time: 550ms
memory: 224972kb

input:

1
250001 500000
1 2 277031 302631
2 3 272854 285543
3 4 424143 468447
4 5 396355 403233
5 6 289295 307306
6 7 285064 314710
7 8 379021 381726
8 9 487091 490187
9 10 398992 426493
10 11 1 5954
11 12 26437 62862
12 13 424015 464639
13 14 325754 338143
14 15 330349 346931
15 16 189161 202399
16 17 1842...

output:

NO

result:

ok all is ok (1 test case)

Test #150:

score: 0
Accepted
time: 386ms
memory: 109124kb

input:

10
25001 50000
1 2 31358 31509
2 3 28901 28919
3 4 28884 28946
4 5 25217 25746
5 6 25276 25394
6 7 24956 25369
7 8 25000 25224
8 9 25095 25337
9 10 24823 25407
10 11 12565 12923
11 12 24691 25012
12 13 24252 24380
13 14 24735 25027
14 15 23497 23937
15 16 5156 5690
16 17 24729 25155
17 18 24723 2507...

output:

YES
31358 28901 28884 25561 25276 25218 25064 25187 25253 12732 24907 24252 24915 23742 5494 24986 24951 23296 22151 8887 25003 17031 7675 24875 24892 9426 25005 12140 12329 7603 24934 2384 24953 14898 19981 24589 24893 29 13728 9389 17975 18941 25006 5123 24988 25007 24304 23100 24922 23251 24888 2...

result:

ok all is ok (10 test cases)

Test #151:

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

input:

10
25001 50000
1 2 36781 37518
2 3 25466 26238
3 4 25463 26245
4 5 24868 25339
5 6 25182 25355
6 7 25214 25517
7 8 25226 25304
8 9 25216 25519
9 10 25042 25053
10 11 24931 25199
11 12 8625 8773
12 13 1430 1507
13 14 3117 3652
14 15 24886 25407
15 16 19619 20184
16 17 24890 25270
17 18 24663 25471
18...

output:

YES
37271 25852 25854 25138 25182 25275 25226 25282 25042 24957 8625 1430 3404 24958 19956 24959 24960 24963 25031 17429 4220 6860 24868 14938 24134 2975 24241 6454 21996 3075 21143 24964 10522 8945 6017 9087 13245 4148 19704 24901 24965 17835 13055 24995 11114 23116 11507 24966 21386 23761 12799 46...

result:

ok all is ok (10 test cases)

Test #152:

score: 0
Accepted
time: 649ms
memory: 224352kb

input:

1
250001 500000
1 2 259518 259754
2 3 259411 259762
3 4 259296 259689
4 5 259454 259620
5 6 259524 259607
6 7 259550 259599
7 8 259385 259626
8 9 259461 259565
9 10 259337 259617
10 11 259505 259631
11 12 259318 259632
12 13 259403 259672
13 14 259530 259577
14 15 259424 259657
15 16 259569 259620
1...

output:

YES
259551 259552 259554 259513 259525 259550 259517 259461 259505 259520 259526 259555 259530 259556 259569 259557 259558 259559 259561 259533 259495 250327 250252 250321 250476 250507 250492 250467 250262 250421 250367 250384 250260 250361 250362 250261 250227 250297 250313 250269 250318 250346 25...

result:

ok all is ok (1 test case)

Test #153:

score: 0
Accepted
time: 424ms
memory: 239200kb

input:

1
400001 500000
1 2 499992 500000
2 3 452848 454137
3 4 420800 422040
4 5 420925 422118
5 6 420333 421827
6 7 421677 423163
7 8 418884 422170
8 9 420655 422958
9 10 420170 423002
10 11 421663 421694
11 12 411459 412764
12 13 410515 412117
13 14 410180 412346
14 15 411512 412666
15 16 411542 412255
1...

output:

YES
499992 453113 421025 421118 420819 422165 421179 421976 422018 421663 411460 411095 411234 411513 411542 411235 411426 411237 410883 411382 403496 403498 403676 404159 403499 403887 403858 404075 400785 400786 400787 401027 401231 400790 400791 400792 401140 401363 400793 400797 400538 401191 40...

result:

ok all is ok (1 test case)

Test #154:

score: 0
Accepted
time: 585ms
memory: 229880kb

input:

1
300001 500000
1 2 339269 339579
2 3 324668 325565
3 4 321466 321470
4 5 299249 299913
5 6 299754 299847
6 7 299923 300237
7 8 299616 300640
8 9 300215 300951
9 10 300072 300486
10 11 299083 299983
11 12 299618 300104
12 13 299784 300253
13 14 300145 300416
14 15 299778 300125
15 16 299760 300402
1...

output:

YES
339269 325198 321466 299660 299754 299924 300277 300462 300114 299704 299787 299916 300145 299800 300040 299756 300102 300138 300094 300456 299628 300152 300171 300275 300463 299975 300038 299948 300101 300464 299869 300465 300177 299657 299808 299824 299727 299986 300099 299865 300001 299974 30...

result:

ok all is ok (1 test case)

Test #155:

score: 0
Accepted
time: 660ms
memory: 220364kb

input:

1
200001 500000
1 2 291127 291234
2 3 215988 216316
3 4 216222 216239
4 5 216223 216246
5 6 210689 211053
6 7 210583 210897
7 8 210707 211069
8 9 206674 206847
9 10 206840 206975
10 11 206830 206839
11 12 206669 206840
12 13 206808 206835
13 14 201717 202102
14 15 201744 201945
15 16 201642 201704
1...

output:

YES
291128 216131 216222 216223 210695 210697 210708 206726 206855 206830 206715 206808 201717 201744 201642 201673 201720 201732 201670 201700 201674 201704 201690 201765 201739 201675 201676 201647 201748 201681 201753 201683 201680 201686 201632 201733 201694 201654 201657 201691 201695 201756 20...

result:

ok all is ok (1 test case)

Test #156:

score: 0
Accepted
time: 762ms
memory: 212532kb

input:

1
100001 500000
1 2 106900 106990
2 3 106914 106929
3 4 102586 103228
4 5 102360 103034
5 6 102946 103436
6 7 103000 103064
7 8 102872 103107
8 9 102424 103010
9 10 102740 103144
10 11 102983 103111
11 12 101525 102150
12 13 101652 101915
13 14 101672 102072
14 15 101590 101934
15 16 99832 100435
16...

output:

YES
106900 106914 102996 102804 103174 103000 102872 102772 102899 102983 101720 101652 101721 101675 100052 100088 100101 99911 100053 100054 99895 99962 100055 99773 99979 99821 99973 100059 100056 99881 100193 100057 5315 100058 100061 99958 100104 99991 99866 99781 100062 99930 99912 99956 99844...

result:

ok all is ok (1 test case)

Test #157:

score: 0
Accepted
time: 664ms
memory: 224312kb

input:

1
250001 500000
1 2 253823 263332
2 3 251831 266180
3 4 259436 277518
4 5 257822 267868
5 6 254226 263360
6 7 259551 264281
7 8 258893 263282
8 9 245573 263476
9 10 254781 265360
10 11 254967 263374
11 12 256384 258542
12 13 254347 273470
13 14 253167 258046
14 15 252893 254807
15 16 253990 254608
1...

output:

YES
257404 257405 259436 257823 257407 259551 258893 257408 257411 254967 256384 254347 253451 252893 253990 253878 253049 253418 251209 252222 253419 253420 253421 252788 252483 253143 254356 253422 253423 253425 254042 253294 253426 250113 250931 249939 250829 250044 251031 251032 250515 250797 25...

result:

ok all is ok (1 test case)

Test #158:

score: 0
Accepted
time: 517ms
memory: 234632kb

input:

1
350001 500000
1 2 370625 372357
2 3 371765 375069
3 4 370971 408071
4 5 347060 383450
5 6 324223 379821
6 7 360800 380086
7 8 369915 404768
8 9 341388 360376
9 10 330962 355384
10 11 350251 388901
11 12 346582 378673
12 13 344231 367257
13 14 338495 365138
14 15 348533 357515
15 16 349429 387685
1...

output:

YES
370625 371765 381826 367951 364829 365044 371036 351427 350764 351428 351429 351430 351435 351421 351438 351439 351237 350122 351440 350349 350350 350351 350352 350353 350228 350354 350355 350356 350357 350358 350359 350360 350361 350363 350364 350365 350366 350367 350368 350369 350370 350371 35...

result:

ok all is ok (1 test case)

Test #159:

score: 0
Accepted
time: 637ms
memory: 224300kb

input:

1
250001 500000
1 2 245600 252151
2 3 250694 256517
3 4 249052 255422
4 5 251032 252053
5 6 247385 252929
6 7 248560 253843
7 8 249914 255109
8 9 251325 259962
9 10 247587 253220
10 11 249044 251391
11 12 251107 251644
12 13 247411 252788
13 14 249389 258014
14 15 248208 251587
15 16 249754 253916
1...

output:

YES
250429 252582 252583 251032 250977 251548 252522 252584 251140 250050 251107 250885 252585 250140 251601 250208 251054 252586 252587 251147 251862 250083 250622 249666 250445 249726 250249 250604 251268 249691 250279 249830 251272 250013 250314 249755 251273 251070 251274 251278 249701 250808 25...

result:

ok all is ok (1 test case)

Test #160:

score: 0
Accepted
time: 545ms
memory: 234332kb

input:

1
350001 500000
1 2 363278 376120
2 3 342099 390684
3 4 345866 444221
4 5 335918 417280
5 6 327208 438347
6 7 349874 359171
7 8 346272 385180
8 9 298319 361357
9 10 278803 359384
10 11 349708 359940
11 12 331584 361952
12 13 348075 358429
13 14 286557 372895
14 15 344970 364576
15 16 284271 383850
1...

output:

YES
363278 361746 361747 351336 351337 351079 351338 351339 349990 349991 349992 349993 349994 349995 349996 349997 349998 349999 350000 350001 350002 350003 350004 350005 350006 350007 350008 350009 350010 350011 350012 350013 350014 350015 350016 350017 350018 191835 350020 350021 350022 350023 20...

result:

ok all is ok (1 test case)

Test #161:

score: 0
Accepted
time: 643ms
memory: 224108kb

input:

1
250001 500000
1 2 282631 282932
2 3 207353 405027
3 4 281869 282231
4 5 263660 291326
5 6 254291 500000
6 7 252423 418013
7 8 209027 289085
8 9 201898 490514
9 10 139664 288456
10 11 215892 268964
11 12 220031 255971
12 13 209011 254709
13 14 248889 255949
14 15 182378 278918
15 16 232592 379548
1...

output:

YES
282631 282494 281869 263660 282495 282496 257213 282498 257022 251986 250099 250001 250094 254247 258633 250152 258634 251664 249906 249907 249908 249910 249911 249912 249913 249914 249915 249916 249917 249918 249919 249920 249921 249922 249923 249924 65446 249925 249926 249927 249928 60900 2499...

result:

ok all is ok (1 test case)

Test #162:

score: 0
Accepted
time: 533ms
memory: 233600kb

input:

1
350001 500000
1 2 384079 465239
2 3 344477 478991
3 4 265262 500000
4 5 237986 500000
5 6 357142 388714
6 7 204917 413624
7 8 252959 472380
8 9 290029 435736
9 10 342714 365342
10 11 177346 414518
11 12 275489 429003
12 13 339805 500000
13 14 285847 500000
14 15 332488 475269
15 16 240662 500000
1...

output:

YES
394686 364616 364617 353045 357142 353046 353047 353048 351383 353049 353050 353051 353053 353054 353055 351110 353056 353057 353058 351308 351309 351310 351311 351312 351313 350334 351314 351315 351316 351317 351318 182793 139470 160337 350169 224218 351319 351320 351321 136586 351323 81464 798...

result:

ok all is ok (1 test case)

Test #163:

score: 0
Accepted
time: 674ms
memory: 224188kb

input:

1
250001 500000
1 2 92881 429699
2 3 190528 301684
3 4 226959 350913
4 5 249455 287469
5 6 59760 320597
6 7 197844 463609
7 8 201699 268567
8 9 236739 500000
9 10 216916 500000
10 11 249499 297685
11 12 239876 259752
12 13 247942 266668
13 14 160239 276471
14 15 93393 431866
15 16 101539 390853
16 1...

output:

YES
274292 258602 258603 255335 251420 251421 251422 251423 251424 251425 250287 251201 251426 251427 251428 249859 250713 251429 251430 250178 250093 251431 250805 251432 251433 251434 251435 251436 251437 251438 251439 251440 251441 251442 251443 251444 251445 251446 249764 251447 251448 251449 25...

result:

ok all is ok (1 test case)

Test #164:

score: 0
Accepted
time: 99ms
memory: 120664kb

input:

1
50001 100000
1 2 56411 56441
2 3 56426 56436
3 4 56419 56450
4 5 56420 56440
5 6 56398 56436
6 7 50484 50513
7 8 50490 50492
8 9 50474 50507
9 10 23208 23210
10 11 47609 47634
11 12 46446 46461
12 13 14117 14130
13 14 49533 49571
14 15 6656 6681
15 16 15724 15758
16 17 43071 43113
17 18 19796 1982...

output:

YES
56429 56426 56430 56431 56421 50484 50490 50483 23208 47621 46451 14122 49559 6670 15746 43102 19818 24340 14957 22880 13512 35510 18999 13304 33808 4647 49560 17810 37516 41786 49913 8386 26002 49922 44916 13583 30943 3645 29458 35832 33739 29925 37710 40996 17975 37977 18333 27830 37988 41053 ...

result:

ok all is ok (1 test case)

Test #165:

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

input:

1
60001 100000
1 2 65167 65239
2 3 1502 1718
3 4 7989 8408
4 5 21291 21640
5 6 5615 5685
6 7 3239 3528
7 8 40636 41042
8 9 23954 24229
9 10 46567 46586
10 11 55537 55756
11 12 14255 14332
12 13 11262 11411
13 14 6322 6451
14 15 56665 56833
15 16 19212 19354
16 17 59654 59973
17 18 11657 11925
18 19 ...

output:

YES
65167 1583 8291 21489 5615 3394 40914 24079 46567 55616 14255 11287 6324 56711 19237 59920 11780 47581 43590 9490 57126 48383 8817 11024 15082 36965 49088 34048 54017 59949 52899 1372 8353 15480 16870 38549 16652 28056 58066 9409 45408 45473 34242 22714 19316 3144 20291 59985 19968 43848 47213 1...

result:

ok all is ok (1 test case)

Test #166:

score: 0
Accepted
time: 125ms
memory: 117728kb

input:

1
20001 100000
1 2 23088 23487
2 3 22951 23269
3 4 23051 23211
4 5 21607 21936
5 6 21486 21946
6 7 21801 22456
7 8 21841 22752
8 9 21838 21855
9 10 20838 21019
10 11 20556 20965
11 12 20791 21166
12 13 20363 21088
13 14 20181 20525
14 15 20354 20876
15 16 20249 20517
16 17 19807 20678
17 18 19876 20...

output:

YES
23223 23003 23051 21644 21645 21801 21841 21838 20838 20612 20791 20363 20269 20354 20270 20271 20272 20355 10889 2601 10824 14071 9631 13699 404 330 7399 6542 12648 1491 9710 17125 6915 12276 3326 4742 1817 6593 14490 17097 774 12989 12416 17333 3717 11569 13282 4316 19488 10041 19348 19990 184...

result:

ok all is ok (1 test case)

Test #167:

score: 0
Accepted
time: 121ms
memory: 117688kb

input:

1
30001 100000
1 2 38420 40575
2 3 33273 37195
3 4 29410 32244
4 5 30299 32360
5 6 30611 31883
6 7 31660 32239
7 8 29611 32425
8 9 28874 33245
9 10 29970 33183
10 11 29502 31340
11 12 30119 30576
12 13 30108 32235
13 14 30002 30169
14 15 29736 33957
15 16 29809 34220
16 17 29016 30507
17 18 29966 31...

output:

YES
39167 33274 31079 31173 30789 31660 31224 31305 31308 30453 30119 30108 30002 29835 29836 29837 29966 29838 30045 29947 29839 29841 29842 30128 29845 29846 29840 29748 29847 29848 29788 29849 29850 29901 29851 29852 29853 29854 29855 29856 29754 29755 29756 29699 29757 29758 15453 6655 23871 649...

result:

ok all is ok (1 test case)

Test #168:

score: 0
Accepted
time: 96ms
memory: 120372kb

input:

1
50001 100000
1 2 64505 65250
2 3 48787 51354
3 4 49210 51701
4 5 50399 51475
5 6 49921 53074
6 7 50616 52285
7 8 50118 51225
8 9 50703 51032
9 10 49111 52060
10 11 49260 50545
11 12 49693 51538
12 13 49522 51645
13 14 48983 50362
14 15 26179 29312
15 16 13140 15706
16 17 40707 42455
17 18 43136 44...

output:

YES
64505 50576 50827 50659 50907 50908 50490 50703 50909 50114 50713 50079 50018 28335 14692 41517 43873 2453 7700 10927 46676 32822 50080 8696 33278 23382 38271 9304 33743 22429 27298 36822 15329 25348 35240 40536 43371 33652 46077 41056 17892 13006 43045 50081 32199 11154 34375 7493 32016 32691 3...

result:

ok all is ok (1 test case)

Test #169:

score: 0
Accepted
time: 90ms
memory: 120812kb

input:

1
50001 100000
1 2 1 100000
2 3 1 100000
3 4 1 100000
4 5 1 100000
5 6 1 83312
6 7 1 100000
7 8 1 100000
8 9 1 65009
9 10 49114 100000
10 11 32569 51371
11 12 1 100000
12 13 1 100000
13 14 1 100000
14 15 1 100000
15 16 1 100000
16 17 1 100000
17 18 45545 100000
18 19 1 100000
19 20 1 100000
20 21 86...

output:

YES
54997 54998 54999 55000 52480 53261 53262 50590 51780 47786 51781 49791 49792 49793 49794 49795 49796 49797 49798 49799 49800 49801 49802 49803 49804 49805 49806 49807 49808 49809 49810 49811 49812 49813 49814 49815 49816 49817 49818 49819 49820 49821 49822 49823 49824 4962 49825 49826 41754 498...

result:

ok all is ok (1 test case)

Subtask #9:

score: 0
Skipped

Dependency #7:

0%

Subtask #10:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%