QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#411398#6765. Don't Really Like How The Story EndsChongQYTL 959ms135500kbJava113.8kb2024-05-15 12:43:342024-05-15 12:43:34

Judging History

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

  • [2024-05-15 12:43:34]
  • 评测
  • 测评结果:TL
  • 用时:959ms
  • 内存:135500kb
  • [2024-05-15 12:43:34]
  • 提交

answer

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static Read scanner = new Read(System.in);
    public static final long MOD = 998244353;
    public static final int MID = (int) (1 * 1e5 + 10);
    public static long[] arr = new long[MID];
    public static int N, M, n, m;
    public static long ans;
    public static int[] row = {1, -1, 0, 0};
    public static int[] cos = {0, 0, 1, -1};
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static ArrayList<Integer>[] list = new ArrayList[MID];
    public static HashSet<Integer>[] sets = new HashSet[MID];
    public static boolean[] pool = new boolean[MID];
    public static int iq = 1;

    public static void solve() {
        n = scanner.nextInt();
        int m = scanner.nextInt();
        for (int i = 0; i <= n + 1; i++) {
            list[i] = new ArrayList<>();
            sets[i] = new HashSet<>();
            pool[i] = false;
        }
        for (int i = 1; i <= m; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if (a == b) continue;
            if (a > b) {
                list[b].add(a);
                sets[b].add(a);
            } else {
                list[a].add(b);
                sets[a].add(b);
            }
        }
        list[1].add(n + 1);
        for (int i = 1; i <= n; i++) Collections.sort(list[i]);
        if (n == 1) {
            out.println(0);
            return;
        }
        iq = 1;
        ans = 0;
        dfs(1);
        out.println(Math.max(0, ans));
    }

    public static void dfs(int in) {
        if (iq > n) return;
        pool[in] = true;
        if (pool[iq]) iq++;
        for (Integer i : list[in]) {
            if (i < iq) continue;
            if (pool[i]) continue;
            if (i == iq) {
                dfs(i);
            } else {
                while (i >= iq && iq <= n) {
                    if (i == iq) {
                        dfs(iq);
                    } else {
                        ans++;
                        dfs(iq);
                    }
                }
            }
        }
    }

    public static void main(String[] args) {
        int T = scanner.nextInt();
        while (T-- != 0) {
            solve();
        }
        out.flush();
    }

    static class Read {
        BufferedReader br;
        StringTokenizer st;

        public Read(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in), 16384);
            eat("");
        }

        public void eat(String s) {
            st = new StringTokenizer(s);
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!st.hasMoreTokens()) {
                String s = nextLine();
                if (s == null)
                    return false;
                eat(s);
            }
            return true;
        }

        public String next() {
            hasNext();
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public Double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        public BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}

详细

Test #1:

score: 100
Accepted
time: 45ms
memory: 54704kb

input:

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

output:

0
2
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 895ms
memory: 109544kb

input:

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

output:

0
0
1
0
0
1
1
0
0
1
1
1
0
0
2
0
2
0
1
0
0
3
0
0
0
2
1
1
1
0
0
0
2
0
2
1
3
0
2
0
3
1
2
1
0
0
1
2
0
2
0
1
2
0
0
2
0
0
0
1
0
3
0
1
0
0
1
0
0
3
2
0
0
0
1
0
2
3
0
1
1
1
1
0
0
2
1
3
0
1
2
0
0
0
3
0
0
3
1
0
2
0
0
0
1
0
0
0
0
0
0
4
0
0
0
0
0
0
2
0
1
0
0
1
1
0
0
2
0
1
0
0
0
2
0
1
2
1
0
0
0
1
0
0
1
1
1
0
0
0
...

result:

ok 117747 lines

Test #3:

score: 0
Accepted
time: 883ms
memory: 111740kb

input:

105403
3 4
3 3
2 2
3 2
2 1
5 11
4 4
3 5
5 5
4 3
4 2
1 5
4 5
3 2
5 1
1 3
1 3
5 4
5 2
3 5
5 3
2 4
6 2
6 3
1 6
3 3
3 3
3 1
2 1
3 1
3 1
1 10
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
3 6
2 3
1 1
1 3
2 2
1 1
1 1
4 6
3 1
2 4
1 4
4 1
4 3
2 4
4 5
3 1
1 2
2 3
2 1
2 4
5 4
2 4
2 1
5 1
4 3
3 6
3 3
2 1
3 3
1 1
2 2...

output:

0
1
3
4
0
1
0
1
2
0
1
1
1
2
0
0
0
0
1
0
0
0
1
0
0
0
0
3
1
0
3
0
0
3
1
0
0
0
2
0
3
3
1
3
1
1
0
0
3
3
2
0
0
0
0
1
0
1
0
0
3
0
2
1
0
0
3
0
1
1
0
1
0
3
0
0
3
0
1
0
0
0
2
1
2
1
0
0
2
1
0
0
2
0
3
0
4
3
0
1
1
0
0
0
0
0
0
0
1
1
1
4
1
1
0
1
1
0
0
4
0
1
0
0
0
1
0
0
0
0
0
0
0
2
0
0
0
2
2
0
1
0
4
2
2
1
2
0
0
0
...

result:

ok 105403 lines

Test #4:

score: 0
Accepted
time: 893ms
memory: 106844kb

input:

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

output:

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

result:

ok 95203 lines

Test #5:

score: 0
Accepted
time: 959ms
memory: 107492kb

input:

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

output:

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

result:

ok 86815 lines

Test #6:

score: 0
Accepted
time: 824ms
memory: 106392kb

input:

79989
1 13
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
6 2
3 4
3 2
4 2
3 1
1 4
6 8
4 6
3 1
3 2
5 6
3 4
1 4
3 5
3 6
1 9
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
6 2
4 5
6 6
4 10
2 4
4 2
1 4
1 1
4 2
3 4
4 1
2 2
1 1
1 3
1 8
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
9 7
6 4
1 9
9 5
6 7
5 4
5 9
9 7
8 1
...

output:

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

result:

ok 79989 lines

Test #7:

score: 0
Accepted
time: 803ms
memory: 108344kb

input:

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

output:

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

result:

ok 74062 lines

Test #8:

score: 0
Accepted
time: 786ms
memory: 106236kb

input:

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

output:

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

result:

ok 32253 lines

Test #9:

score: 0
Accepted
time: 900ms
memory: 109212kb

input:

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

output:

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

result:

ok 16422 lines

Test #10:

score: 0
Accepted
time: 794ms
memory: 108992kb

input:

8194
63 108
17 25
57 7
56 16
2 60
56 48
7 43
54 43
48 49
4 5
17 13
44 9
3 18
26 45
47 37
60 58
12 25
9 14
6 38
5 17
54 33
49 55
56 24
31 18
52 58
13 26
10 27
58 17
59 32
12 32
2 11
49 28
22 4
29 57
11 40
27 25
18 32
19 14
11 16
19 29
49 54
8 15
21 14
2 56
37 14
11 52
14 46
34 28
3 54
14 34
54 17
5 2...

output:

53
58
13
70
0
63
64
0
53
12
34
21
33
55
54
62
18
38
1
36
40
0
47
29
47
35
60
15
33
4
53
2
5
20
71
0
0
38
0
27
51
45
8
27
64
47
17
0
29
16
55
18
49
64
15
26
33
9
77
70
45
75
56
6
74
6
14
21
39
0
35
10
29
45
9
4
3
67
56
73
43
68
16
0
69
24
3
20
51
36
38
8
54
49
50
63
29
17
1
69
0
31
56
53
0
62
67
50
1...

result:

ok 8194 lines

Test #11:

score: 0
Accepted
time: 821ms
memory: 108284kb

input:

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

output:

26
34
105
78
116
74
10
0
84
0
13
18
85
84
87
26
122
53
138
113
119
0
113
34
130
118
48
118
130
142
100
73
98
27
0
1
70
55
131
48
50
83
132
69
15
119
0
53
57
48
39
0
0
92
10
106
148
102
112
54
14
141
29
15
83
60
132
93
109
15
69
59
135
121
5
111
60
15
19
11
97
38
149
10
14
0
58
42
0
113
60
17
153
44
...

result:

ok 4093 lines

Test #12:

score: 0
Accepted
time: 873ms
memory: 103504kb

input:

2041
315 175
234 81
180 280
115 27
105 99
142 26
115 277
147 280
26 88
258 55
21 118
227 240
213 15
254 134
100 42
117 95
121 74
165 190
104 94
291 104
175 104
52 255
116 236
14 23
89 167
101 237
23 172
109 270
303 30
25 90
102 58
50 265
124 216
183 200
267 299
22 234
131 18
183 38
2 159
20 116
299 ...

output:

307
15
282
60
298
310
144
22
110
250
266
165
0
290
41
245
308
133
99
63
56
136
4
256
29
295
131
287
9
59
159
276
88
74
218
268
257
49
257
246
195
249
259
266
290
0
301
174
216
9
176
282
112
234
109
198
234
247
193
216
123
57
206
70
189
198
48
183
3
180
82
305
82
144
75
80
173
295
0
209
119
75
15
290...

result:

ok 2041 lines

Test #13:

score: 0
Accepted
time: 862ms
memory: 103164kb

input:

1137
460 304
424 252
67 46
306 437
2 332
22 85
420 452
197 221
73 250
329 313
349 295
337 190
206 327
440 199
197 288
133 35
309 200
397 277
267 255
292 295
432 347
340 124
394 159
373 370
23 329
336 240
156 240
395 33
267 150
58 12
33 274
302 257
393 447
296 34
284 112
366 404
47 126
415 266
236 93...

output:

454
308
157
152
62
49
95
371
48
565
0
492
328
0
325
198
490
191
149
0
333
377
405
135
420
380
60
465
0
414
43
71
538
83
561
425
474
471
494
492
100
310
155
335
339
172
302
308
21
412
220
554
496
529
250
548
31
126
11
416
12
554
255
76
553
2
410
14
479
1
217
110
587
344
504
410
329
148
425
109
508
33...

result:

ok 1137 lines

Test #14:

score: 0
Accepted
time: 894ms
memory: 107532kb

input:

652
170 1906
34 127
38 86
125 128
156 29
27 45
23 153
78 5
165 106
163 92
130 165
6 5
116 6
56 32
67 9
3 22
71 137
151 103
51 50
103 53
27 127
159 71
146 111
97 1
65 103
170 88
13 34
27 165
152 41
121 112
45 103
27 63
15 130
95 72
35 43
43 85
86 66
117 52
54 153
64 28
136 82
43 23
8 70
142 20
144 16...

output:

142
614
477
762
272
211
1
844
678
94
482
732
576
460
913
336
905
340
961
611
6
138
65
564
18
388
965
443
680
852
492
551
653
623
895
480
905
622
861
340
67
813
328
648
81
227
852
704
104
87
281
918
177
917
401
563
767
795
220
255
297
239
966
378
911
285
2
468
369
0
904
912
449
666
258
438
535
776
80...

result:

ok 652 lines

Test #15:

score: 0
Accepted
time: 845ms
memory: 111852kb

input:

71
6433 15466
4352 5871
2180 1276
4734 3588
5284 4840
585 1017
1093 3813
6122 4891
5191 5758
1868 1014
3962 3642
4766 3371
4489 6198
973 2020
6210 1022
2193 2064
3238 868
4430 4229
1492 2666
6288 1768
2584 4768
927 884
4648 620
4182 277
5321 5010
5227 1439
3699 4350
389 5472
4979 4661
4893 418
4853 ...

output:

6418
4244
9589
9384
4650
3461
8702
1977
6556
1980
4106
2614
7781
5014
6198
3686
9940
3507
6796
4603
4302
9157
7231
5871
795
1404
2468
8321
5439
3212
1835
2246
559
2525
8841
5528
6419
691
4707
1638
9820
5352
8456
8012
180
1742
5951
7204
1327
9091
9063
7960
7810
2193
9942
5994
2086
1703
2209
8497
2035...

result:

ok 71 lines

Test #16:

score: 0
Accepted
time: 806ms
memory: 106560kb

input:

32
2829 32606
88 652
522 1008
1411 2447
2363 1268
630 940
1946 2132
1175 2425
378 1017
2570 876
2346 1075
1792 1699
250 465
2539 977
2469 1922
1027 283
292 1446
118 786
1263 969
104 105
1548 738
2649 1114
303 2425
633 833
1046 1358
2797 51
846 1885
1415 118
2100 794
600 2210
1032 1453
2636 2007
1454...

output:

2795
7618
9289
1400
4737
1626
5799
15613
16801
19701
7551
1149
1867
12942
8249
11063
11680
18512
10995
15194
18351
14204
12720
9121
776
13167
11791
4389
796
2611
14891
11839

result:

ok 32 lines

Test #17:

score: 0
Accepted
time: 951ms
memory: 118352kb

input:

22
26521 10962
24039 2867
11784 14563
5836 257
25414 26411
20341 18994
113 22616
25448 3427
1105 15078
769 1991
3973 1859
24907 15797
9479 17398
25066 24605
4183 11157
3621 4129
12315 617
23413 22647
12551 10463
24956 7083
26493 10554
26136 21498
18143 14209
18793 8418
14385 14140
7772 220
19817 121...

output:

26511
2487
6276
9224
29415
8322
10180
15058
1204
12804
12503
17086
13254
15459
2964
18440
26141
16226
22082
22683
20916
20745

result:

ok 22 lines

Test #18:

score: 0
Accepted
time: 891ms
memory: 129096kb

input:

19
2918 28102
817 1088
2053 435
2727 241
757 2494
823 2529
2223 471
2422 1098
2031 354
1929 1178
52 1342
237 935
2259 1599
2906 938
2022 49
2781 1315
2669 1273
2316 639
2509 632
2676 2804
2764 1730
2067 599
294 1109
1988 865
1812 1333
1908 1441
1657 1273
2484 1904
700 2870
340 2038
1007 407
1944 814...

output:

2893
30063
15978
17057
6807
35006
39980
7194
8762
13211
17451
8781
24634
3349
25062
5809
33296
21221
307

result:

ok 19 lines

Test #19:

score: 0
Accepted
time: 835ms
memory: 135500kb

input:

14
28361 78944
9166 23401
19149 3685
14574 17889
20858 20753
21388 2864
21606 1214
12607 25649
23763 13936
26282 20903
24171 20863
23924 20224
366 27657
5466 16368
18548 8961
5221 2033
20346 10259
6813 18557
19314 22085
12600 24520
24849 14626
13617 22664
9687 13113
24360 17019
15064 15776
6685 2184...

output:

28349
37701
4054
31585
32262
30884
3256
23891
46087
14585
20027
23759
42856
35547

result:

ok 14 lines

Test #20:

score: -100
Time Limit Exceeded

input:

9
86095 79416
84511 13009
53685 11570
29295 26471
63969 3196
37176 49719
48858 17975
20376 19173
73509 74609
37138 16713
59253 70866
19610 16305
67633 33320
21118 19269
79306 22980
63351 79416
27580 20616
18800 62779
13454 21187
941 40992
30280 36048
44626 10435
4328 52182
37852 46013
77423 1236
813...

output:

86079
45720
62292
26282
46723
2828
84358
39682
99571

result: