QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#416490#8343. 玩游戏2745518585100 ✓15ms5596kbC++202.4kb2024-05-21 21:38:532024-05-21 21:38:57

Judging History

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

  • [2024-05-21 21:38:57]
  • 评测
  • 测评结果:100
  • 用时:15ms
  • 内存:5596kb
  • [2024-05-21 21:38:53]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include<vector>
namespace Solve
{
    using namespace std;
    typedef long long ll;
    const int N=1000001;
    int n;
    bool h[N];
    void init(int _n)
    {
        n=_n;
    }
    int sum(ll x)
    {
        return (x%(n*2+1)+(n*2+1))%(n*2+1);
    }
    pair<int,int> encode(vector<int> a)
    {
        for(int i=0;i<=n*2;++i) h[i]=false;
        int s=0;
        for(auto i:a) s=sum(s+i);
        for(auto i:a) h[sum(i-s)]=true;
        auto mp=[&](int x,int y)
        {
            return make_pair(sum(x+s),sum(y+s));
        };
        for(pair<int,int> i:vector<pair<int,int>>{{0,1},{0,n*2},{n,2},{n,n*2-1},{4,n+1},{n*2-3,n+1}})
        {
            if(h[i.first]&&h[i.second]) return mp(i.first,i.second);
        }
        for(int i=1;i<=n-1;++i)
        {
            if(h[i]&&h[(n*2+1)-i])
            {
                if(n%2==0) return mp((n*2+1)-i,i);
                else return mp(i,(n*2+1)-i);
            }
        }
    }
    int decode(pair<int,int> a,pair<int,int> b)
    {
        auto solve=[&](int x1,int x2)
        {
            for(pair<int,int> i:vector<pair<int,int>>{{0,1},{0,n*2},{n,2},{n,n*2-1},{4,n+1},{n*2-3,n+1}})
            {
                if(sum(i.second-i.first)==sum(x2-x1))
                {
                    return sum((ll)((x1+x2)-(i.first+i.second))*(n+1));
                }
            }
            return sum((ll)(x1+x2)*(n+1));
        };
        int s1=solve(a.first,a.second),s2=solve(b.first,b.second);
        return sum(-s1-s2);
    }
}
void init(int n)
{
    return Solve::init(n);
}
std::pair<int, int> encode(std::vector<int> a)
{
    return Solve::encode(a);
}
int decode(std::pair<int, int> a, std::pair<int, int> b)
{
    return Solve::decode(a,b);
}

// int main()
// {
//     int T,n;
//     scanf("%d%d",&T,&n);
//     Solve::init(n);
//     while(T--)
//     {
//         std::vector<int> a,b;
//         for(int i=1;i<=n*2;++i)
//         {
//             int x;
//             scanf("%d",&x);
//             if(i<=n) a.push_back(x);
//             else b.push_back(x);
//         }
//         scanf("%*d");
//         auto xa=Solve::encode(a);
//         printf("%d %d\n",xa.first,xa.second);
//         auto xb=Solve::encode(b);
//         printf("%d %d\n",xb.first,xb.second);
//         int x=Solve::decode(xa,xb);
//         printf("%d\n",x);
//     }
//     return 0;
// }

详细

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 13ms
memory: 5596kb

input:

6 16666 16807

output:

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

input:

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

output:

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

result:

ok passed (16666 test cases)

Test #2:

score: 30
Accepted
time: 9ms
memory: 5448kb

input:

7 14285 282475249

output:

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

input:

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

output:

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

result:

ok passed (14285 test cases)

Test #3:

score: 30
Accepted
time: 11ms
memory: 5176kb

input:

8 12500 1622650073

output:

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

input:

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

output:

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

result:

ok passed (12500 test cases)

Test #4:

score: 30
Accepted
time: 10ms
memory: 5040kb

input:

9 11111 984943658

output:

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

input:

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

output:

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

result:

ok passed (11111 test cases)

Test #5:

score: 30
Accepted
time: 15ms
memory: 4856kb

input:

10 10000 1144108930

output:

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

input:

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

output:

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

result:

ok passed (10000 test cases)

Subtask #2:

score: 30
Accepted

Test #6:

score: 30
Accepted
time: 2ms
memory: 4756kb

input:

68876 1 470211272

output:

68876 1
105480 105479
96099 96098

input:

68876 1
105480 105479
96099 96098

output:

73927

result:

ok passed (1 test case)

Test #7:

score: 30
Accepted
time: 3ms
memory: 4400kb

input:

58538 1 101027544

output:

58538 1
44241 44247
69295 69296

input:

58538 1
44241 44247
69295 69296

output:

3538

result:

ok passed (1 test case)

Test #8:

score: 30
Accepted
time: 3ms
memory: 4600kb

input:

50603 1 1457850878

output:

50603 1
33820 84428
41099 91701

input:

50603 1
33820 84428
41099 91701

output:

76887

result:

ok passed (1 test case)

Test #9:

score: 30
Accepted
time: 5ms
memory: 4728kb

input:

33045 3 1458777923

output:

33045 3
52970 19921
57210 57209
36402 3361
270 271
56777 23728
60186 60184

input:

33045 3
52970 19921
57210 57209
36402 3361
270 271
56777 23728
60186 60184

output:

22006
29415
15224

result:

ok passed (3 test cases)

Test #10:

score: 30
Accepted
time: 4ms
memory: 4156kb

input:

20970 4 2007237709

output:

20970 4
4632 4633
32005 32004
6082 6083
2421 2431
16888 16894
11552 11562
11916 11917
13845 34814

input:

20970 4
4632 4633
32005 32004
6082 6083
2421 2431
16888 16894
11552 11562
11916 11917
13845 34814

output:

5304
33433
13493
37150

result:

ok passed (4 test cases)

Test #11:

score: 30
Accepted
time: 4ms
memory: 4672kb

input:

40786 2 823564440

output:

40786 2
8868 8869
48994 48995
55560 55568
29737 70526

input:

40786 2
8868 8869
48994 48995
55560 55568
29737 70526

output:

23711
37058

result:

ok passed (2 test cases)

Test #12:

score: 30
Accepted
time: 3ms
memory: 4480kb

input:

59198 1 1115438165

output:

59198 1
28252 87453
27613 86814

input:

59198 1
28252 87453
27613 86814

output:

62531

result:

ok passed (1 test case)

Test #13:

score: 30
Accepted
time: 5ms
memory: 5192kb

input:

92994 1 1784484492

output:

92994 1
149305 149309
185890 92894

input:

92994 1
149305 149309
185890 92894

output:

129775

result:

ok passed (1 test case)

Test #14:

score: 30
Accepted
time: 5ms
memory: 5448kb

input:

95914 1 74243042

output:

95914 1
127195 31285
12383 108300

input:

95914 1
127195 31285
12383 108300

output:

148161

result:

ok passed (1 test case)

Test #15:

score: 30
Accepted
time: 3ms
memory: 4352kb

input:

56585 1 114807987

output:

56585 1
40899 97483
104813 104814

input:

56585 1
40899 97483
104813 104814

output:

24044

result:

ok passed (1 test case)

Test #16:

score: 30
Accepted
time: 5ms
memory: 4800kb

input:

49131 2 1137522503

output:

49131 2
35126 35124
993 50127
58623 9488
65616 65614

input:

49131 2
35126 35124
993 50127
58623 9488
65616 65614

output:

13013
72292

result:

ok passed (2 test cases)

Test #17:

score: 30
Accepted
time: 3ms
memory: 4492kb

input:

58330 1 1441282327

output:

58330 1
115850 57516
104374 104375

input:

58330 1
115850 57516
104374 104375

output:

13102

result:

ok passed (1 test case)

Test #18:

score: 30
Accepted
time: 2ms
memory: 5488kb

input:

95899 1 16531729

output:

95899 1
90671 90670
19169 19168

input:

95899 1
90671 90670
19169 19168

output:

81959

result:

ok passed (1 test case)

Test #19:

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

input:

59202 1 823378840

output:

59202 1
64228 64229
110914 51708

input:

59202 1
64228 64229
110914 51708

output:

61672

result:

ok passed (1 test case)

Test #20:

score: 30
Accepted
time: 2ms
memory: 5284kb

input:

91350 1 143542612

output:

91350 1
175208 175209
88383 88384

input:

91350 1
175208 175209
88383 88384

output:

101811

result:

ok passed (1 test case)

Test #21:

score: 30
Accepted
time: 4ms
memory: 4576kb

input:

37397 2 896544303

output:

37397 2
32584 32583
6319 6301
56749 19354
70128 70127

input:

37397 2
32584 32583
6319 6301
56749 19354
70128 70127

output:

35901
60110

result:

ok passed (2 test cases)

Test #22:

score: 30
Accepted
time: 3ms
memory: 4372kb

input:

51165 1 1474833169

output:

51165 1
60146 60147
15037 15038

input:

51165 1
60146 60147
15037 15038

output:

27148

result:

ok passed (1 test case)

Test #23:

score: 30
Accepted
time: 4ms
memory: 4788kb

input:

61423 1 1264817709

output:

61423 1
78782 78752
107837 46410

input:

61423 1
78782 78752
107837 46410

output:

59094

result:

ok passed (1 test case)

Test #24:

score: 30
Accepted
time: 4ms
memory: 4276kb

input:

15177 6 1998097157

output:

15177 6
20910 5735
14875 30049
4431 4427
12748 27922
2294 17470
5869 21051
3237 18411
20377 20376
6537 6538
26687 11514
28228 28229
12091 12089

input:

15177 6
20910 5735
14875 30049
4431 4427
12748 27922
2294 17470
5869 21051
3237 18411
20377 20376
6537 6538
26687 11514
28228 28229
12091 12089

output:

9751
13182
7010
6745
27482
20392

result:

ok passed (6 test cases)

Test #25:

score: 30
Accepted
time: 2ms
memory: 5176kb

input:

91469 1 1817129560

output:

91469 1
103276 11805
169672 169673

input:

91469 1
103276 11805
169672 169673

output:

1460

result:

ok passed (1 test case)

Test #26:

score: 30
Accepted
time: 5ms
memory: 4148kb

input:

7001 14 1131570933

output:

7001 14
13841 6838
8168 1165
13441 6436
11680 11679
11698 4695
6337 6338
2564 9562
11643 4646
6162 13166
7424 7422
12659 5656
313 314
2320 2318
489 7489
547 537
13652 13653
3881 10881
2285 2286
1714 1712
2771 2770
7705 706
5826 12826
11367 4368
5592 5591
11168 11169
6488 13492
8813 1814
6321 6320

input:

7001 14
13841 6838
8168 1165
13441 6436
11680 11679
11698 4695
6337 6338
2564 9562
11643 4646
6162 13166
7424 7422
12659 5656
313 314
2320 2318
489 7489
547 537
13652 13653
3881 10881
2285 2286
1714 1712
2771 2770
7705 706
5826 12826
11367 4368
5592 5591
11168 11169
6488 13492
8813 1814
6321 6320

output:

5996
2889
2969
13799
7419
8032
4193
13812
835
9519
471
4045
3348
5870

result:

ok passed (14 test cases)

Test #27:

score: 30
Accepted
time: 5ms
memory: 4188kb

input:

13730 7 197493099

output:

13730 7
16985 16986
15854 2126
8643 8644
2572 2573
8230 21963
2052 2054
8970 22703
14501 14517
18969 18970
15312 1584
23019 9285
1663 1667
14084 14085
20575 6843

input:

13730 7
16985 16986
15854 2126
8643 8644
2572 2573
8230 21963
2052 2054
8970 22703
14501 14517
18969 18970
15312 1584
23019 9285
1663 1667
14084 14085
20575 6843

output:

8352
16246
3447
17712
6910
2781
6532

result:

ok passed (7 test cases)

Test #28:

score: 30
Accepted
time: 5ms
memory: 3880kb

input:

5908 16 1404280278

output:

5908 16
11347 11351
6940 1030
8190 8192
32 34
6335 6336
9311 9312
7163 7164
1001 1003
12 16
1163 1175
7785 1879
6342 6344
1371 1372
7575 1671
84 85
795 794
453 6360
4388 4392
2366 2367
5696 11607
8076 8090
2632 8543
964 6871
4730 4731
11683 5779
11133 11141
5881 11792
7855 1951
6684 6685
4754 4755
4...

input:

5908 16
11347 11351
6940 1030
8190 8192
32 34
6335 6336
9311 9312
7163 7164
1001 1003
12 16
1163 1175
7785 1879
6342 6344
1371 1372
7575 1671
84 85
795 794
453 6360
4388 4392
2366 2367
5696 11607
8076 8090
2632 8543
964 6871
4730 4731
11683 5779
11133 11141
5881 11792
7855 1951
6684 6685
4754 4755
4...

output:

11253
3593
7988
3652
10634
3597
2867
10938
1065
9663
7010
214
810
3985
379
1438

result:

ok passed (16 test cases)

Test #29:

score: 30
Accepted
time: 3ms
memory: 4396kb

input:

53685 1 893351816

output:

53685 1
76992 23311
54628 947

input:

53685 1
76992 23311
54628 947

output:

83114

result:

ok passed (1 test case)

Test #30:

score: 30
Accepted
time: 4ms
memory: 4640kb

input:

29258 3 1505795335

output:

29258 3
23302 23310
54070 54071
29516 260
15931 15930
30957 30973
57117 27861

input:

29258 3
23302 23310
54070 54071
29516 260
15931 15930
30957 30973
57117 27861

output:

39658
42328
58210

result:

ok passed (3 test cases)

Subtask #3:

score: 40
Accepted

Test #31:

score: 40
Accepted
time: 5ms
memory: 4588kb

input:

18 5555 1954899097

output:

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

input:

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

output:

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

result:

ok passed (5555 test cases)

Test #32:

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

input:

995 100 1636807826

output:

995 100
1068 1069
656 655
198 1192
241 1233
175 1167
1239 1238
32 1030
1395 402
71 1063
1102 1100
1303 306
1341 1342
1026 1025
61 62
1279 288
511 1505
1293 1279
213 197
102 101
944 943
1258 1259
1196 1195
294 293
653 1651
156 154
1071 80
1497 1498
825 826
999 6
1156 1154
47 1041
1730 731
1407 414
15...

input:

995 100
1068 1069
656 655
198 1192
241 1233
175 1167
1239 1238
32 1030
1395 402
71 1063
1102 1100
1303 306
1341 1342
1026 1025
61 62
1279 288
511 1505
1293 1279
213 197
102 101
944 943
1258 1259
1196 1195
294 293
653 1651
156 154
1071 80
1497 1498
825 826
999 6
1156 1154
47 1041
1730 731
1407 414
15...

output:

267
560
581
563
823
342
904
1192
500
945
1528
48
761
1660
832
1213
1052
600
15
804
483
470
1042
360
1595
876
1656
664
314
266
776
1554
1365
1889
719
477
540
1796
1606
56
966
1487
90
345
1117
1828
1128
554
1210
170
1018
898
1357
1650
18
1041
188
1257
68
926
1607
359
669
404
1419
1641
762
1307
657
813...

result:

ok passed (100 test cases)

Test #33:

score: 40
Accepted
time: 5ms
memory: 4076kb

input:

909 110 563613512

output:

909 110
194 178
640 639
1171 1170
1111 198
1396 1395
823 824
232 230
7 913
583 582
1401 1402
818 817
1620 1621
1645 740
992 85
320 321
1446 1438
820 796
1563 1564
566 562
715 714
682 1588
1644 1643
818 819
789 790
1095 182
730 1636
1224 313
48 962
241 1153
662 663
1788 1789
1111 1110
569 1477
1153 2...

input:

909 110
194 178
640 639
1171 1170
1111 198
1396 1395
823 824
232 230
7 913
583 582
1401 1402
818 817
1620 1621
1645 740
992 85
320 321
1446 1438
820 796
1563 1564
566 562
715 714
682 1588
1644 1643
818 819
789 790
1095 182
730 1636
1224 313
48 962
241 1153
662 663
1788 1789
1111 1110
569 1477
1153 2...

output:

993
1360
1419
1585
1654
1200
87
57
1267
540
1316
212
2
1452
6
739
96
953
735
152
163
1576
593
265
470
1253
914
1079
184
1499
855
56
1031
1203
172
534
857
907
1040
924
1600
1775
1461
1009
440
1015
1042
1755
1694
123
820
176
1389
754
973
1181
508
1507
707
1573
1549
846
1361
1388
720
563
303
54
1534
46...

result:

ok passed (110 test cases)

Test #34:

score: 40
Accepted
time: 5ms
memory: 3912kb

input:

748 133 101929267

output:

748 133
1400 1404
211 212
377 378
1262 510
1202 452
484 496
347 351
168 919
570 1317
571 581
835 839
1107 357
44 48
1063 1062
294 1039
298 1049
53 804
514 1261
1206 454
475 474
456 457
381 382
1082 1083
156 160
414 1159
517 518
722 1475
1098 1099
378 1125
136 883
331 337
121 122
670 671
958 206
803 ...

input:

748 133
1400 1404
211 212
377 378
1262 510
1202 452
484 496
347 351
168 919
570 1317
571 581
835 839
1107 357
44 48
1063 1062
294 1039
298 1049
53 804
514 1261
1206 454
475 474
456 457
381 382
1082 1083
156 160
414 1159
517 518
722 1475
1098 1099
378 1125
136 883
331 337
121 122
670 671
958 206
803 ...

output:

1381
1359
553
231
1099
301
388
160
929
1317
660
257
570
1170
982
1042
1370
481
1274
746
291
1168
341
182
1143
561
482
1053
1087
899
1359
498
834
708
1130
823
840
225
595
365
425
356
338
343
790
53
621
496
533
166
110
1366
828
1429
263
203
587
965
94
623
777
523
418
48
711
504
923
522
773
1460
644
10...

result:

ok passed (133 test cases)

Test #35:

score: 40
Accepted
time: 2ms
memory: 3880kb

input:

703 142 1580723810

output:

703 142
203 199
304 305
821 813
1204 497
1216 1217
951 952
298 299
1291 584
1337 636
162 161
997 296
1073 1072
600 1302
493 1199
352 350
1145 1144
970 971
322 320
1028 1029
1393 686
74 75
1102 1103
1345 1344
1171 1172
554 1254
1206 499
866 165
161 155
761 54
187 188
573 1279
389 1089
97 803
1067 366...

input:

703 142
203 199
304 305
821 813
1204 497
1216 1217
951 952
298 299
1291 584
1337 636
162 161
997 296
1073 1072
600 1302
493 1199
352 350
1145 1144
970 971
322 320
1028 1029
1393 686
74 75
1102 1103
1345 1344
1171 1172
554 1254
1206 499
866 165
161 155
761 54
187 188
573 1279
389 1089
97 803
1067 366...

output:

902
797
647
1229
611
40
313
1318
116
397
231
298
1062
1086
463
1152
242
390
30
481
397
1170
1355
155
736
1256
1057
908
497
61
209
443
616
28
474
180
1196
56
258
237
505
357
1367
668
1333
313
383
1191
30
180
320
1038
247
223
1081
1064
1340
1008
330
965
963
746
22
1122
816
726
119
1012
305
843
598
941...

result:

ok passed (142 test cases)

Test #36:

score: 40
Accepted
time: 5ms
memory: 3996kb

input:

268 373 704877633

output:

268 373
374 102
331 330
56 58
178 449
55 322
188 189
350 351
257 269
237 238
417 418
85 356
206 205
220 219
180 182
49 320
481 482
274 273
427 157
414 150
247 248
46 84
189 460
118 391
23 22
33 32
223 488
413 143
84 355
378 380
228 495
14 281
78 84
357 91
86 87
81 82
404 138
64 65
519 253
473 474
27...

input:

268 373
374 102
331 330
56 58
178 449
55 322
188 189
350 351
257 269
237 238
417 418
85 356
206 205
220 219
180 182
49 320
481 482
274 273
427 157
414 150
247 248
46 84
189 460
118 391
23 22
33 32
223 488
413 143
84 355
378 380
228 495
14 281
78 84
357 91
86 87
81 82
404 138
64 65
519 253
473 474
27...

output:

373
33
25
461
420
514
136
275
104
409
14
392
285
39
198
173
362
320
222
57
7
248
114
136
479
24
202
501
291
6
396
83
253
268
47
285
61
72
394
405
353
443
281
121
51
145
309
496
362
65
233
51
0
148
207
312
143
196
375
136
70
458
493
190
347
529
524
241
72
401
118
388
521
219
95
103
180
266
455
22
476...

result:

ok passed (373 test cases)

Test #37:

score: 40
Accepted
time: 5ms
memory: 3904kb

input:

171 584 1358580979

output:

171 584
147 321
269 270
163 155
18 19
68 67
10 11
238 65
332 165
182 178
111 281
73 74
53 54
12 11
300 296
82 256
159 157
273 274
193 18
14 8
122 106
326 320
246 247
299 300
197 191
107 108
292 119
199 200
231 227
56 55
278 277
246 245
309 142
236 235
308 307
286 287
247 246
108 109
162 330
270 95
2...

input:

171 584
147 321
269 270
163 155
18 19
68 67
10 11
238 65
332 165
182 178
111 281
73 74
53 54
12 11
300 296
82 256
159 157
273 274
193 18
14 8
122 106
326 320
246 247
299 300
197 191
107 108
292 119
199 200
231 227
56 55
278 277
246 245
309 142
236 235
308 307
286 287
247 246
108 109
162 330
270 95
2...

output:

98
166
265
283
223
217
33
274
224
218
117
193
115
258
9
127
142
153
77
140
60
290
107
67
223
210
254
73
21
156
257
173
132
25
167
332
0
261
26
55
72
137
99
282
5
126
341
32
109
307
68
130
167
173
182
244
128
332
5
132
154
247
320
62
79
13
124
342
332
225
64
136
134
218
307
334
328
294
31
236
42
327
...

result:

ok passed (584 test cases)

Test #38:

score: 40
Accepted
time: 5ms
memory: 4552kb

input:

70 1428 1624379149

output:

70 1428
12 81
69 71
4 77
44 119
80 81
111 119
115 116
98 99
49 61
106 110
70 72
112 116
38 39
72 6
91 23
52 62
50 51
58 57
59 58
13 14
112 46
125 127
67 66
73 74
85 13
41 79
99 107
56 60
67 140
137 69
93 94
91 103
26 27
90 22
31 39
38 48
69 1
90 24
29 102
108 110
2 6
118 117
57 67
54 55
58 57
126 54...

input:

70 1428
12 81
69 71
4 77
44 119
80 81
111 119
115 116
98 99
49 61
106 110
70 72
112 116
38 39
72 6
91 23
52 62
50 51
58 57
59 58
13 14
112 46
125 127
67 66
73 74
85 13
41 79
99 107
56 60
67 140
137 69
93 94
91 103
26 27
90 22
31 39
38 48
69 1
90 24
29 102
108 110
2 6
118 117
57 67
54 55
58 57
126 54...

output:

129
18
87
69
119
97
27
63
33
69
40
1
66
121
77
92
95
63
48
73
19
25
27
6
14
78
8
45
12
85
80
44
84
107
6
6
138
38
25
114
99
69
86
13
39
137
3
138
114
45
128
100
97
16
58
44
69
24
98
131
50
112
116
54
25
67
79
52
116
95
93
19
21
63
134
42
118
7
122
57
40
50
43
42
26
78
0
76
35
55
66
105
56
13
33
123
...

result:

ok passed (1428 test cases)

Test #39:

score: 40
Accepted
time: 5ms
memory: 3828kb

input:

950 105 2128236579

output:

950 105
1360 406
1826 878
464 465
1614 1615
1214 266
1316 1317
50 51
136 1083
1854 906
1067 119
1813 1812
1378 1377
652 653
1460 1459
928 940
1328 380
101 117
515 516
1545 1601
206 205
1736 788
1271 323
1067 113
311 319
482 1429
1677 1678
944 945
827 826
1817 1833
1394 1395
1017 1016
434 1387
1640 1...

input:

950 105
1360 406
1826 878
464 465
1614 1615
1214 266
1316 1317
50 51
136 1083
1854 906
1067 119
1813 1812
1378 1377
652 653
1460 1459
928 940
1328 380
101 117
515 516
1545 1601
206 205
1736 788
1271 323
1067 113
311 319
482 1429
1677 1678
944 945
827 826
1817 1833
1394 1395
1017 1016
434 1387
1640 1...

output:

1570
1724
321
1719
880
611
1690
589
1277
122
794
523
1647
130
583
1400
680
853
538
1877
672
966
1468
652
150
601
1874
1121
489
1862
1694
217
1408
1023
1854
1533
1379
1658
1158
16
130
1021
866
966
1302
1847
864
552
922
579
1180
618
1627
1579
1576
1612
1081
224
604
972
361
349
1579
960
372
1571
552
82...

result:

ok passed (105 test cases)

Test #40:

score: 40
Accepted
time: 5ms
memory: 4012kb

input:

780 128 784558821

output:

780 128
1123 1139
1348 570
532 533
280 1057
568 1351
785 787
1227 1243
1401 1400
463 462
1462 1461
36 37
242 1027
548 1331
657 1434
328 1111
369 368
325 337
1216 1217
1442 1443
601 602
207 208
952 951
1485 1497
62 63
17 18
508 1291
1284 508
185 184
173 950
1472 1480
967 969
350 351
633 1410
1178 118...

input:

780 128
1123 1139
1348 570
532 533
280 1057
568 1351
785 787
1227 1243
1401 1400
463 462
1462 1461
36 37
242 1027
548 1331
657 1434
328 1111
369 368
325 337
1216 1217
1442 1443
601 602
207 208
952 951
1485 1497
62 63
17 18
508 1291
1284 508
185 184
173 950
1472 1480
967 969
350 351
633 1410
1178 118...

output:

1423
753
987
486
1197
1279
1140
83
14
1079
402
8
255
88
1477
243
1313
1105
1502
221
58
1409
1375
524
1306
89
610
80
1288
454
1292
297
1219
1454
1148
923
1293
625
1166
829
226
214
1382
1154
696
1352
541
912
1181
855
470
1097
108
1042
860
1540
1538
836
198
1544
942
719
482
1271
996
1351
791
881
462
11...

result:

ok passed (128 test cases)

Test #41:

score: 40
Accepted
time: 5ms
memory: 3928kb

input:

489 204 530511967

output:

489 204
746 740
606 605
729 715
757 739
295 296
17 18
191 189
773 771
377 375
949 941
318 317
319 320
144 636
796 309
530 531
893 406
589 587
264 756
917 915
265 266
564 565
426 920
526 527
751 264
351 345
789 787
329 330
61 60
357 843
745 258
828 810
503 504
744 257
543 541
74 568
194 193
859 372
6...

input:

489 204
746 740
606 605
729 715
757 739
295 296
17 18
191 189
773 771
377 375
949 941
318 317
319 320
144 636
796 309
530 531
893 406
589 587
264 756
917 915
265 266
564 565
426 920
526 527
751 264
351 345
789 787
329 330
61 60
357 843
745 258
828 810
503 504
744 257
543 541
74 568
194 193
859 372
6...

output:

609
488
667
17
637
342
38
45
616
777
964
191
822
589
370
636
182
707
914
703
370
200
257
948
233
662
319
368
350
164
634
471
667
524
720
806
459
104
977
847
202
50
40
463
672
852
865
539
658
893
532
944
896
95
492
577
962
940
139
566
40
81
929
412
757
547
245
576
637
89
185
719
510
387
418
161
427
8...

result:

ok passed (204 test cases)

Test #42:

score: 40
Accepted
time: 5ms
memory: 4056kb

input:

879 113 2110010672

output:

879 113
105 103
1086 203
250 251
1520 643
959 960
894 895
171 1053
1188 307
290 1168
61 62
192 193
1298 1297
554 1436
494 1378
252 236
1209 1203
1517 636
523 1401
1139 256
991 110
1457 1449
13 5
589 583
1255 1229
1583 1584
1095 212
1719 844
72 948
1461 578
1509 1505
1043 166
1117 1118
1669 1670
251 ...

input:

879 113
105 103
1086 203
250 251
1520 643
959 960
894 895
171 1053
1188 307
290 1168
61 62
192 193
1298 1297
554 1436
494 1378
252 236
1209 1203
1517 636
523 1401
1139 256
991 110
1457 1449
13 5
589 583
1255 1229
1583 1584
1095 212
1719 844
72 948
1461 578
1509 1505
1043 166
1117 1118
1669 1670
251 ...

output:

573
868
1665
399
528
269
1586
309
1477
512
297
1690
844
1727
554
478
1602
386
1227
1297
55
1409
1622
1756
880
1590
384
898
933
1664
206
143
829
895
314
1008
1231
168
1296
1273
623
612
319
1191
1147
1442
841
1608
455
353
806
1073
711
416
1520
270
516
359
852
1617
885
162
1417
1631
896
1055
885
674
20...

result:

ok passed (113 test cases)

Test #43:

score: 40
Accepted
time: 5ms
memory: 3904kb

input:

520 192 1551901393

output:

520 192
1014 1015
678 679
292 293
755 759
110 627
463 982
23 29
214 215
452 462
38 37
689 699
1003 1004
1018 1019
1033 1034
576 58
514 516
812 296
629 633
945 949
764 765
885 369
464 472
22 541
499 1022
664 670
285 286
70 587
354 358
738 739
259 263
21 25
972 982
634 633
371 372
1017 1018
849 325
34...

input:

520 192
1014 1015
678 679
292 293
755 759
110 627
463 982
23 29
214 215
452 462
38 37
689 699
1003 1004
1018 1019
1033 1034
576 58
514 516
812 296
629 633
945 949
764 765
885 369
464 472
22 541
499 1022
664 670
285 286
70 587
354 358
738 739
259 263
21 25
972 982
634 633
371 372
1017 1018
849 325
34...

output:

390
1033
992
801
546
385
31
470
635
371
725
519
89
619
42
41
36
220
66
680
866
650
122
221
589
947
939
887
197
91
433
70
935
404
481
523
831
789
889
483
264
672
294
434
140
502
15
804
619
217
69
656
854
717
60
459
691
783
713
224
965
935
893
1025
186
437
289
559
632
862
73
1025
578
757
786
778
632
9...

result:

ok passed (192 test cases)

Test #44:

score: 40
Accepted
time: 5ms
memory: 3876kb

input:

647 154 1617819336

output:

647 154
1294 0
1167 1163
1219 570
1239 594
931 932
17 1
322 972
641 1291
489 483
428 429
822 821
876 877
350 342
1026 375
966 315
218 862
248 898
758 115
887 236
72 62
78 60
88 738
1212 1213
647 2
105 103
433 1077
682 37
602 1246
559 533
512 511
1192 1193
797 796
1140 1114
1265 622
1116 1115
255 256...

input:

647 154
1294 0
1167 1163
1219 570
1239 594
931 932
17 1
322 972
641 1291
489 483
428 429
822 821
876 877
350 342
1026 375
966 315
218 862
248 898
758 115
887 236
72 62
78 60
88 738
1212 1213
647 2
105 103
433 1077
682 37
602 1246
559 533
512 511
1192 1193
797 796
1140 1114
1265 622
1116 1115
255 256...

output:

131
131
355
331
381
892
1222
119
932
345
490
83
762
662
237
601
194
1219
951
1141
97
1189
657
471
524
106
333
909
1242
572
474
964
1093
244
524
1171
540
429
374
755
681
562
865
802
1047
589
314
341
403
319
855
528
594
59
869
251
347
712
1289
180
1194
1109
713
1289
57
869
2
379
823
459
911
78
1208
17...

result:

ok passed (154 test cases)

Test #45:

score: 40
Accepted
time: 5ms
memory: 3856kb

input:

327 305 1399125485

output:

327 305
502 486
181 505
461 459
409 407
171 170
110 100
301 300
365 34
597 596
156 152
482 481
306 307
256 586
345 344
570 569
481 461
109 108
300 301
431 432
177 176
130 116
341 12
410 411
643 318
640 639
418 93
32 356
347 333
436 435
82 412
550 225
559 228
77 71
128 126
621 290
556 225
413 409
395...

input:

327 305
502 486
181 505
461 459
409 407
171 170
110 100
301 300
365 34
597 596
156 152
482 481
306 307
256 586
345 344
570 569
481 461
109 108
300 301
431 432
177 176
130 116
341 12
410 411
643 318
640 639
418 93
32 356
347 333
436 435
82 412
550 225
559 228
77 71
128 126
621 290
556 225
413 409
395...

output:

639
442
379
648
559
522
381
269
246
47
518
584
579
287
464
532
454
141
508
379
535
604
44
161
163
489
56
281
607
446
585
76
522
585
75
116
385
350
437
63
152
399
286
558
485
532
352
547
444
386
114
468
382
201
262
37
455
295
155
119
432
96
24
11
70
1
301
444
15
351
64
289
555
570
615
169
175
306
648...

result:

ok passed (305 test cases)

Test #46:

score: 40
Accepted
time: 5ms
memory: 3932kb

input:

595 168 156091745

output:

595 168
717 120
866 275
274 275
1175 1171
39 38
1085 486
416 408
647 648
142 734
807 808
818 219
679 80
126 720
757 758
466 465
459 1051
828 229
241 833
185 184
430 1022
949 945
1122 1123
487 486
186 174
775 776
820 818
210 208
529 1129
1185 1184
1167 1161
1093 1094
1036 445
908 902
181 781
323 315
...

input:

595 168
717 120
866 275
274 275
1175 1171
39 38
1085 486
416 408
647 648
142 734
807 808
818 219
679 80
126 720
757 758
466 465
459 1051
828 229
241 833
185 184
430 1022
949 945
1122 1123
487 486
186 174
775 776
820 818
210 208
529 1129
1185 1184
1167 1161
1093 1094
1036 445
908 902
181 781
323 315
...

output:

199
935
71
132
246
893
903
270
130
580
313
524
788
449
33
249
101
937
957
910
101
888
167
317
496
976
1143
702
210
1018
753
342
994
992
912
769
357
963
240
958
420
880
690
1086
819
230
223
1149
1096
820
246
807
139
709
1172
581
910
1183
343
338
377
1137
958
865
1020
713
676
1184
42
1175
1004
897
520...

result:

ok passed (168 test cases)

Test #47:

score: 40
Accepted
time: 5ms
memory: 3948kb

input:

676 147 1356425228

output:

676 147
232 905
1013 1012
139 140
944 272
277 281
675 676
654 653
89 762
1257 1271
184 185
972 992
247 926
648 1321
850 851
739 61
176 175
279 297
1075 401
376 1055
601 603
477 476
542 1221
279 278
510 509
685 5
90 769
1314 1313
684 685
348 360
793 115
741 69
1299 1298
860 180
253 252
1322 648
580 1...

input:

676 147
232 905
1013 1012
139 140
944 272
277 281
675 676
654 653
89 762
1257 1271
184 185
972 992
247 926
648 1321
850 851
739 61
176 175
279 297
1075 401
376 1055
601 603
477 476
542 1221
279 278
510 509
685 5
90 769
1314 1313
684 685
348 360
793 115
741 69
1299 1298
860 180
253 252
1322 648
580 1...

output:

112
266
399
614
1258
800
1212
1114
666
1051
1010
564
1258
708
882
662
244
803
1092
622
332
17
17
250
730
660
116
522
87
735
245
811
792
1210
1167
1216
1046
190
1
1187
1001
917
970
171
1319
1121
850
477
1025
57
1149
1286
734
678
556
1188
364
762
588
1165
891
680
1134
655
439
917
430
1113
352
394
124
...

result:

ok passed (147 test cases)

Test #48:

score: 40
Accepted
time: 5ms
memory: 3952kb

input:

152 657 1899894091

output:

152 657
76 75
71 70
81 236
50 60
181 180
299 298
192 44
94 104
162 14
93 250
119 120
242 92
141 145
195 45
59 60
2 157
250 251
252 98
34 183
166 168
138 137
139 145
192 193
216 60
248 247
290 5
102 259
20 21
261 262
48 47
189 191
237 238
17 166
269 273
47 202
67 216
199 198
121 272
192 191
64 65
244...

input:

152 657
76 75
71 70
81 236
50 60
181 180
299 298
192 44
94 104
162 14
93 250
119 120
242 92
141 145
195 45
59 60
2 157
250 251
252 98
34 183
166 168
138 137
139 145
192 193
216 60
248 247
290 5
102 259
20 21
261 262
48 47
189 191
237 238
17 166
269 273
47 202
67 216
199 198
121 272
192 191
64 65
244...

output:

158
16
130
10
42
96
119
91
260
108
25
206
62
179
301
183
21
42
137
49
94
206
56
189
6
193
72
151
53
215
118
127
103
245
83
145
213
265
16
88
136
15
257
21
22
100
49
121
82
116
82
243
194
295
107
218
31
42
289
105
55
245
229
292
275
168
131
206
253
291
97
95
185
173
90
5
161
207
244
58
230
185
220
16...

result:

ok passed (657 test cases)

Test #49:

score: 40
Accepted
time: 5ms
memory: 4080kb

input:

603 165 585640194

output:

603 165
206 207
362 361
866 856
1096 1097
1186 585
395 396
1045 444
911 909
689 688
263 863
1091 1092
1080 1081
425 426
1097 490
1044 1016
1188 1189
1205 1204
703 697
247 849
216 208
1046 1044
61 60
1072 467
1142 1143
1033 432
406 1014
410 404
314 315
1190 583
298 898
1132 531
223 224
834 833
1190 1...

input:

603 165
206 207
362 361
866 856
1096 1097
1186 585
395 396
1045 444
911 909
689 688
263 863
1091 1092
1080 1081
425 426
1097 490
1044 1016
1188 1189
1205 1204
703 697
247 849
216 208
1046 1044
61 60
1072 467
1142 1143
1033 432
406 1014
410 404
314 315
1190 583
298 898
1132 531
223 224
834 833
1190 1...

output:

639
457
229
1062
259
243
896
196
509
144
101
803
367
486
934
455
401
10
670
100
750
759
1038
595
664
186
407
1036
799
847
538
131
133
582
628
369
394
432
906
727
1162
73
125
1125
988
1105
323
152
1178
961
938
642
1115
556
1064
182
607
22
619
586
1076
1129
7
858
942
837
1206
986
1012
399
589
411
862
...

result:

ok passed (165 test cases)

Test #50:

score: 40
Accepted
time: 5ms
memory: 4028kb

input:

966 103 937186357

output:

966 103
852 1817
1228 1229
1273 303
1023 1022
237 238
984 20
272 273
1223 259
504 1473
508 1477
685 689
1237 1263
185 1154
779 780
1601 633
1801 1802
1007 43
1577 609
950 954
1665 1666
780 779
115 123
300 301
1478 1479
382 1345
617 625
989 25
1321 1323
348 1317
1839 1851
385 384
1556 1557
1022 1021
...

input:

966 103
852 1817
1228 1229
1273 303
1023 1022
237 238
984 20
272 273
1223 259
504 1473
508 1477
685 689
1237 1263
185 1154
779 780
1601 633
1801 1802
1007 43
1577 609
950 954
1665 1666
780 779
115 123
300 301
1478 1479
382 1345
617 625
989 25
1321 1323
348 1317
1839 1851
385 384
1556 1557
1022 1021
...

output:

819
1574
1678
1404
920
1929
2
1430
1281
1249
1034
155
934
588
706
1925
1851
1695
843
503
1553
512
1272
1682
1092
405
260
1604
36
672
1081
1216
923
1932
1294
1625
704
1356
1621
1837
62
252
1360
1199
1264
1624
1168
1904
1792
1634
790
1254
296
615
875
1884
432
945
218
1511
313
575
1416
835
1312
1699
12...

result:

ok passed (103 test cases)