QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#462777#7087. Counting PolygonsteraqqqAC ✓379ms238216kbC++146.5kb2024-07-04 03:56:042024-07-04 03:56:05

Judging History

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

  • [2024-07-04 03:56:05]
  • 评测
  • 测评结果:AC
  • 用时:379ms
  • 内存:238216kb
  • [2024-07-04 03:56:04]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int N = 10'000'228;
constexpr int M = 2*N;

int minp[N+1], fact[M+1], rfct[M+1], phi[N+1];
int rev(int a, int m = MOD) {
    return a == 1 ? 1 : m - (ll)m*rev(m%a,a)/a;
}
int c(int n, int k) {
    return 0 <= k && k <= n ? (ll)fact[n]*rfct[k]%MOD*rfct[n-k]%MOD : 0;
}

void mod_add(int& a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mod_sub(int& a, int b) {
    a -= b;
    if (a < 0) a += MOD;
}


// cnt(65, 14, 2) != 131445433 (error!)
int cnt(int n, int mp, int sn) {
    if (n < 0) return 0;
    if (sn == 2) {
        if (n % 2 == 1) {
            return (ll)2*cnt(n+1, mp+2, 0)%MOD;
        } else {
            return (cnt(n, mp+2, 0) + cnt(n+2, mp+2, 0))%MOD;
        }
    }
    if (sn) {
        int a = cnt(n, mp+1, sn-1);
        mod_add(a, cnt(n+1, mp+1, sn-1));
        return a;
    } else {
        if (!n && !mp) return 1;
        if (!n) return 0;
        if (n % 2 == 1) return 0;
        const int a = c(n/2-1, mp-1);
        // cerr << "n=" << n << ", mp=" << mp << ", a=" << a << endl;
        // cerr << c(33, 15) << endl;
        return a;
    }
}

int solve(int n, int m) {
    vector<int> divs{{1}};
    for (int j = m; j != 1; ) {
        const int p = minp[j], s = divs.size();
        // cout << j << ", p=" << p << endl;
        int k = 0;
        while (j % p == 0) j /= p, ++k;
        for (int i = 0; i < s*k; ++i)
            divs.push_back(divs[i]*p);
    }

    int ans = 0;
    for (int d : divs) {
        if (d == m) {
            mod_add(ans, c(n-1, m-1));
            ans = (ans + (ll)(MOD - m)*c(n/2, m-1))%MOD;
            // cout << "d=" << d << ": " << ans << " " << 1 << endl;
        } else {
            const int cnt = m / d;
            if (n % cnt == 0)
                ans = (ans + (ll)c(n/cnt-1, d-1)*phi[cnt])%MOD;
            // cout << "d=" << d << ": " << ans << " " << phi[cnt] << endl;
        }
    }
    // cerr << ans << " half" << endl;

    if (m % 2) {
        ans = (ans + (ll)m*cnt(n, m/2, 1))%MOD;
        ans = (ans + (ll)(MOD-m)*cnt(n/2+1, m/2, 1))%MOD;
    } else {
        ans = (ans + (ll)(m/2)*cnt(n, m/2, 0))%MOD;
        ans = (ans + (ll)(m/2)*cnt(n, m/2-1, 2))%MOD;
        ans = (ans + (ll)(MOD-m)*cnt(n/2+1, m/2-1, 2))%MOD;
    }
    // cerr << ans << "!" << endl;

    ans = (ll)ans*rev(2*m)%MOD;
    if (ans < 0) ans += MOD;
    return ans;
}

int solve_brute(int n, int m, int max, vector<int>& st) {
    if (n < m) return 0;
    if (!m) {
        if (n != 0) return 0;
        auto v = st;
        for (int t = 2; t--; ) {
            reverse(v.begin(), v.end());
            for (int i = 0; i < st.size(); ++i) {
                rotate(v.begin(), v.begin()+1, v.end());
                if (v < st) return 0;
            }
        }
        // for (int x : st) cout << x << ' ';
        // cout << endl;
        return 1;
    }
    int ans = 0;
    st.push_back(0);
    for (int x = 1; x <= n && 2*x < max; ++x) {
        st.back() = x;
        ans += solve_brute(n-x, m-1, max, st);
    }
    st.pop_back();
    return ans;
}

int solve_brute(int n, int m) {
    vector<int> st;
    int ans = solve_brute(n, m, n, st);
    return ans;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    for (int i = 2; i <= N; ++i) {
        if (minp[i]) continue;
        for (int j = i; j <= N; j += i)
            if (!minp[j]) minp[j] = i;
    }

    phi[1] = 1;
    for (int i = 2; i <= N; ++i) {
        const int p = minp[i];
        const int j = i / p;
        if (p == minp[j]) phi[i] = phi[j] * p;
        else              phi[i] = phi[j] * (p-1);
    }

    fact[0] = 1;
    for (int i = 1; i <= M; ++i) fact[i] = (ll)fact[i-1]*i%MOD;
    rfct[M] = rev(fact[M]);
    for (int i = M; i >= 1; --i) rfct[i-1] = (ll)rfct[i]*i%MOD;


    // constexpr int N = 300;
    // vector<vector<int>> sex(N+1, vector<int>(N+1));
    // sex[0][0] = 1;
    // for (int n = 1; n <= N; ++n) {
    //     sex[n][0] = 1;
    //     for (int k = 1; k <= n; ++k)
    //         sex[n][k] = (sex[n-1][k-1] + sex[n-1][k])%MOD;
    // }
    // for (int k = 0; k <= N; ++k)
    // for (int n = 0; n <= N; ++n) {
    //     assert(sex[n][k] == c(n,k));
    // }

    // // exit(0);

    // vector<vector<int>> dp(N+1, vector<int>(N+1));
    // dp[0][0] = 1;
    // for (int i = 1; i <= N; ++i) {
    //     for (int s = 1; s <= N; ++s)
    //         for (int d = 1; d <= s; ++d)
    //             mod_add(dp[i][s], dp[i-1][s-d]);
    // }

    // for (int i = 1; i <= N; ++i) {
    //     for (int s = 1; s <= N; ++s) {
    //         if (c(s-1, i-1) != dp[i][s]) {
    //             cout << "k=" << i << ", s=" << s << endl;
    //             cout << "WTF " << dp[i][s] << " vs " << c(s-1, i-1) << endl;
    //         }
    //         assert(c(s-1, i-1) == dp[i][s]);
    //     }
    // }

    // for (int i = 0; i <= 10; ++i) {
    //     for (int j = 0; j <= 10; ++j)
    //         cout << dp[i][j] << ' ';
    //     cout << endl;
    // }

    // for (int s = 0; s <= N; ++s)
    // for (int d = 0; d <= 2; ++d) {
    //     for (int k = 0; k <= N; ++k) {
    //         int cc = 0;
    //         for (int u = 0; u <= s; u += 2)
    //             cc = (cc + (ll)dp[k][u/2]*dp[d][s-u])%MOD;
    //         if (d == 0 && s % 2 == 0) assert(cc == dp[k][s/2]);
    //         int pans = cnt(s, k, d);
    //         if (cc != pans) {
    //             cout << "WA" << endl;
    //             cout << s << " " << k << " " << d << endl;
    //             cout << "pans=" << pans << endl;
    //             cout << "jans=" << cc << endl;
    //             exit(0);
    //         }
    //         assert(cc == cnt(s, k, d));
    //     }
    // }

    // for (int n = 1; n <= 20; ++n) {
    //     // cerr << "m=" << m << endl;
    //     for (int m = 3; m <= n; ++m) {
    //         int pans = solve(n, m);
    //         int jans = solve_brute(n, m);
    //         if (pans != jans) {
    //             cout << "WA!" << endl;
    //             cout << n << " " << m << endl;
    //             cout << "pans=" << pans << endl;
    //             cout << "jans=" << jans << endl;
    //             exit(0);
    //         }
    //     }
    // }

    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        int ans = solve(n, m);
        cout << ans << '\n';
    }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 323ms
memory: 237996kb

input:

4
3 3
4 3
5 3
7 4

output:

1
0
1
3

result:

ok 4 tokens

Test #2:

score: 0
Accepted
time: 329ms
memory: 238204kb

input:

10000
8708700 6531525
8062080 4031040
7068600 2356200
3659040 332640
7309575 2088450
5503680 1572480
7162848 3581424
9831360 7724640
6306300 5045040
5783400 2891700
4677120 2338560
5110560 786240
9525600 2381400
6955200 4173120
8229375 3291750
7068600 5405400
9639000 3213000
5969040 2984520
5274360 ...

output:

70575804
911063149
736112291
369575992
506078051
136771321
157961376
482306068
808445792
111975446
589376785
548955436
475354332
356837429
911546698
201203710
516058717
699547325
506234162
982243306
632144614
975420242
969330198
969225699
690742488
539447570
315722230
239132520
402932842
865811879
6...

result:

ok 10000 tokens

Test #3:

score: 0
Accepted
time: 320ms
memory: 237920kb

input:

10000
6732000 1346400
4514400 3009600
9687600 4843800
9414405 855855
5397840 771120
9384480 8043840
5544000 554400
4324320 1921920
7413120 6177600
5745600 1436400
7969500 5977125
7807800 6606600
8736000 6988800
6846840 3423420
8870400 5913600
8440740 6330555
8870400 3326400
8482320 2356200
10000000 ...

output:

706442182
488856741
168674268
73811958
857999444
793632797
337603359
642817909
98872547
112376573
711706342
503190288
512025946
852321551
457453137
484424465
459828550
995738332
1
912038864
8590632
428611028
694498340
576908091
124911099
683063775
372434319
925520356
489952965
219530475
534335843
51...

result:

ok 10000 tokens

Test #4:

score: 0
Accepted
time: 362ms
memory: 238216kb

input:

10000
4009824 2004912
6652800 3024000
6774075 4516050
4914000 3276000
9459450 6621615
8386560 6814080
8467200 3628800
7928928 3964464
8870400 7096320
8731800 7900200
3534300 2650725
4490640 1496880
7567560 3492720
6320160 4989600
7623000 1386000
8886240 4443120
8482320 5397840
6364800 1591200
687960...

output:

446560045
232333799
309547627
772473869
428497484
508151545
547192183
87720964
691649551
263038293
43005163
320476037
637499787
872097821
229415217
727862068
420449707
473877159
42041657
498501274
434530310
18199778
883285014
144261979
574306248
829905574
873740377
272819001
58543320
641378183
77859...

result:

ok 10000 tokens

Test #5:

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

input:

10000
5266800 1053360
9737280 4868640
9369360 2522520
6486480 4324320
8870400 2661120
7328880 4885920
5307120 1179360
7387200 3693600
5397840 2313360
7983360 3326400
9313920 3659040
9896040 6361740
5569200 1670760
3783780 945945
7484400 3991680
7239960 3341520
8288280 4462920
9041760 3538080
9336600...

output:

123625316
13107194
46509236
614324543
350080071
367231912
478558835
403913702
699502698
116127955
965589921
406936053
270103109
319082472
467189710
908786173
981268953
204230791
519767831
602914215
918110932
825116989
31698683
707232648
796020472
301899834
349563304
640814130
263092451
798521310
677...

result:

ok 10000 tokens

Test #6:

score: 0
Accepted
time: 326ms
memory: 237988kb

input:

10000
3326400 2993760
8925840 1912680
8845200 6879600
4612608 2306304
9593100 6395400
5765760 2162160
8957520 4478760
5197920 2227680
8426880 4915680
8953560 2984520
7308000 3654000
9230760 4615380
4127760 1179360
8553600 2138400
4626720 1542240
7775460 2827440
5925150 4937625
9480240 5266800
847665...

output:

64633872
870750845
309315714
766458326
545019764
625022656
147878708
236862886
686797034
798030764
748900691
601651869
830530562
666440680
717058655
259544464
130599676
247444523
246658669
273866252
300446451
635903644
537872709
140954808
728216140
30466799
32661833
177233289
891799944
716168116
378...

result:

ok 10000 tokens

Test #7:

score: 0
Accepted
time: 342ms
memory: 237872kb

input:

10000
6511680 4069800
3088800 1853280
3810240 1905120
4656960 3104640
9896040 8731800
8845200 884520
7207200 1108800
4989600 3492720
7539840 6911520
5860800 2930400
7534800 5023200
7197120 4626720
831600 415800
7761600 2328480
9480240 1580040
7775460 2591820
9523800 4761900
9009000 5765760
7484400 2...

output:

203005449
848502464
92800923
927746523
698361049
635571304
393832176
270191540
132419797
781179828
242998353
514096074
665387022
186120369
897829683
848039293
473034009
350643350
588116448
267329806
909022509
914558579
371508398
918952167
591441223
705907202
129505637
646066602
975681470
47786010
12...

result:

ok 10000 tokens

Test #8:

score: 0
Accepted
time: 345ms
memory: 238004kb

input:

10000
9931680 6320160
2620800 1747200
4684680 4324320
4324320 3243240
9172800 1146600
3830400 766080
6804000 4536000
8953560 4241160
6289920 5241600
6597360 2356200
6027840 3767400
9041760 3013920
887040 443520
8168160 3712800
5821200 3880800
9069840 3023280
8316000 7392000
5239080 1164240
5700240 3...

output:

571124200
683651957
424250854
836740855
190330700
489010494
846692939
184929155
612287193
407036913
494523250
539745957
616085748
679945341
74162059
241297860
95079615
208157170
46378470
181139642
303509987
625913823
605142215
986546267
504241904
761180455
628375810
617138363
805497204
561255479
165...

result:

ok 10000 tokens

Test #9:

score: 0
Accepted
time: 351ms
memory: 238144kb

input:

10000
2751840 1572480
7623000 1386000
5488560 3659040
4263840 2131920
6552000 5733000
5651100 3767400
7650720 1912680
6283200 3141600
9085440 4542720
7728000 3864000
3963960 3243240
7270560 6058800
5627160 2411640
9631440 5503680
9896040 7567560
9513504 8648640
9702000 2910600
9737280 2782080
996912...

output:

78894659
229415217
595743292
816314300
678268542
961658439
563553842
176668523
279296592
569688698
882322934
450954121
295724354
589050963
870281833
372970119
738869826
907254086
599180016
590066513
999561419
52605513
336436067
872097821
232333799
782812697
960184198
308744266
577289035
734333112
59...

result:

ok 10000 tokens

Test #10:

score: 0
Accepted
time: 341ms
memory: 237984kb

input:

10000
8467200 7620480
8316000 3326400
4193280 3669120
9563400 2494800
7371000 5733000
3931200 3144960
8953560 2106720
3175200 1587600
7001280 875160
7534800 3013920
6652800 887040
8372160 6279120
5285280 3363360
6683040 5654880
5322240 2217600
3104640 776160
4069800 813960
6713280 5034960
9253440 84...

output:

341369882
35867261
535828676
160320852
926758501
996148027
375196123
806812574
832450541
733198053
683063775
276745550
591070386
135767449
809503012
443724639
513067744
794374879
642710792
94122564
927425980
356141625
839820837
906465050
473950989
449580879
411527155
592520932
26639142
555894874
585...

result:

ok 10000 tokens

Test #11:

score: 0
Accepted
time: 325ms
memory: 238000kb

input:

10000
5654880 2328480
6781320 3013920
3255840 813960
8910720 7796880
6168960 2313360
4626720 1542240
6199200 3099600
3611520 2708640
4158000 831600
8114400 3245760
6732000 5385600
4455360 2970240
8353800 7862400
6918912 864864
7302960 4173120
8574720 4287360
8648640 6177600
8346240 927360
5997600 35...

output:

96656716
212862797
74634873
957071670
554334397
717058655
693931852
599686290
813023707
750105832
902143852
709124049
206505833
304083168
149848905
331907082
155470957
894312973
383088724
769042791
451963734
104659327
651831814
103244617
149742762
978944670
701394009
780830924
563012656
762225384
20...

result:

ok 10000 tokens

Test #12:

score: 0
Accepted
time: 339ms
memory: 237916kb

input:

10000
2512348 1884261
6767619 6767619
9236631 6157754
9297990 9297990
5212849 5212849
5575084 5575084
9288867 9288867
863025 863025
2383792 2383792
6058464 4543848
6406365 6406365
9159486 4579743
6674468 6674468
7687680 5765760
6721181 6721181
8584579 8584579
9832965 3277655
8485142 8485142
7855942 ...

output:

789634566
1
927366317
1
1
1
1
1
1
91150457
1
715010069
1
91458606
1
1
637061743
1
1
1
1
1
1
1
736398751
1
1
708251256
579022396
209588373
1
1
82825822
480093253
1
1
1
1
1
1
728525999
1
1
1
431573215
1
553611801
1
1
865480923
1
1
1
1
1
1
874009689
523017137
422863483
785066633
1
1
541699816
315613534...

result:

ok 10000 tokens

Test #13:

score: 0
Accepted
time: 344ms
memory: 238004kb

input:

10000
6322158 4214772
9375993 3125331
6074869 6074869
7900160 7900160
6988256 6988256
7363611 2881413
5806620 5806620
3552232 3552232
8113745 8113745
6770217 6770217
7741621 7741621
3678575 3678575
8535339 2845113
7272461 7272461
5116285 5116285
5357775 5357775
4182458 2091229
9344353 9344353
357218...

output:

251083787
637852151
1
1
1
205440168
1
1
1
1
1
1
895235224
1
1
1
122034159
1
1
686540552
1
738350329
1
861775363
1
1
1
896046455
1
773142749
456674509
1
1
1
603931524
232292099
1
1
1
855227502
857584924
185829390
1
241139329
698726548
1
50639242
459116555
629887030
499291200
1
7263810
1
377989779
118...

result:

ok 10000 tokens

Test #14:

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

input:

10000
8038637 3310027
7086022 7086022
5330881 5330881
7831852 5873889
4386793 4386793
7334665 7334665
9383142 9383142
7880433 2626811
6732162 6732162
6978369 6978369
2152040 269005
6927874 6927874
7676919 5117946
5831059 5026775
7982682 7982682
5802660 5802660
4171794 4171794
3453703 313973
8329986 ...

output:

850158002
1
1
910867677
1
1
1
534910968
1
1
169710980
1
28346031
116701127
1
1
1
208968115
347767951
1
1
1
1
507462166
1
1
1
92257061
227190010
892411120
978533115
603319492
62087257
968411934
49728781
1
1
1
466428730
1
1
1
1
436479562
840799149
674406851
528147343
1
1
258610593
1
1
1
1
603505435
25...

result:

ok 10000 tokens

Test #15:

score: 0
Accepted
time: 271ms
memory: 238004kb

input:

10000
4958328 4958328
8889827 8889827
9875937 9875937
7603587 7603587
9104790 3034930
8289216 2072304
7434268 5575701
6204314 3102157
6962864 3481432
2687512 2687512
7034978 7034978
4264792 2132396
4941575 988315
4472552 4472552
6767695 2460980
5548016 2774008
8674796 8674796
2889266 2889266
1143681...

output:

1
1
1
1
653190214
650803343
82491107
199394913
508913299
1
1
566616549
464395148
1
199963571
685926720
1
1
1
1
1
1
1
172459773
1
1
1
643526331
1
896353696
877921352
1
766923871
1
1
1
83920160
632154740
1
1
1
864884237
154567973
1
319417887
4569362
1
1
1
1
852064205
1
82551595
693702050
1
467286128
1...

result:

ok 10000 tokens

Test #16:

score: 0
Accepted
time: 293ms
memory: 238212kb

input:

10000
5496756 5496756
5728848 5012742
9599292 9599292
9914301 3304767
9438014 4719007
9201739 9201739
9845236 4922618
9199729 9199729
6695505 3171555
4376940 3501552
7832850 7049565
7274933 7274933
5844522 5844522
9255230 4627615
7689027 5126018
9674491 9674491
5737884 5737884
7842288 3921144
529916...

output:

1
533128351
1
816899603
145313484
1
408056235
1
949730957
498842474
361752481
1
1
920574759
987349161
1
1
201999880
1
55577806
866489973
1
226857475
381136337
164624338
1
1
1
1
813372778
1
1
1
1
618366437
1
794021094
589444595
709836012
1
525970725
897127075
812281714
1
1
1
196324846
483189176
60454...

result:

ok 10000 tokens

Test #17:

score: 0
Accepted
time: 318ms
memory: 237980kb

input:

10000
5653861 5634011
3969971 1046720
7928444 287430
3137980 2806450
1206019 411790
8526587 2929902
5702768 817489
9809168 9150551
7471263 4747917
9911665 1644989
8683072 1162563
5278393 4434642
5886735 4053703
5995756 817032
4774354 2986498
9021450 8219337
7364114 4169292
8464377 6055683
9651071 83...

output:

55499039
658535925
230188210
232252342
512026310
366787007
227592854
145147021
482588988
907905377
2573897
438421661
545140786
444040513
333770426
497524934
436756875
709109490
347377011
919085160
389665931
595189179
807366554
814324100
369384532
583880109
799166720
511415131
869873777
805566939
136...

result:

ok 10000 tokens

Test #18:

score: 0
Accepted
time: 292ms
memory: 237980kb

input:

10000
9449555 7551095
8215455 5652589
7633161 7007745
9951170 9178340
4659454 3572838
2960184 1516452
6971550 2396594
4519482 1982936
6330547 3523138
6045141 5251562
2369584 1719843
7435176 6894912
8822350 3841378
8845026 7211039
8257534 8132378
7250437 6865218
8766503 3241003
7966754 5660936
507987...

output:

237481149
671775964
203935376
523273838
367355479
208291221
29931760
946371558
376709155
538679442
439946136
7612100
470075292
403053965
56711345
236092284
957000635
8990777
924123987
306500857
348057956
186657944
450828685
295040280
695727852
254820741
571906071
684134331
403709307
369378838
492010...

result:

ok 10000 tokens

Test #19:

score: 0
Accepted
time: 321ms
memory: 237932kb

input:

10000
8910986 5188516
6885019 6296684
9165916 6783875
4794852 2081686
6376287 1106150
7877581 6052171
876956 228392
4714523 1207701
8807717 4845107
5642664 2987944
5687960 4774004
2267468 1525828
5966857 1612513
7797093 1882751
8678260 2053378
9784216 2423480
4606160 926593
8863091 4887241
9267271 3...

output:

845456308
131675737
340290275
999393908
650907256
55972897
263861711
25298640
701799590
592090210
64256054
177966267
984320349
244321010
893272656
276627556
15192398
12472344
480996451
788847125
240574818
152361674
796271668
685637866
116882357
907539390
384015360
397206483
566297647
239427957
45412...

result:

ok 10000 tokens

Test #20:

score: 0
Accepted
time: 333ms
memory: 237856kb

input:

10000
6558833 4754637
4323943 2918707
9260679 9007272
4493219 2781129
5169457 1551705
7123572 3180847
7319671 255055
6691715 4098493
8169331 3246134
2181145 527582
5606991 3361137
5430374 101408
4931403 2887022
1458123 1264424
9733409 5028991
9039864 4286365
9330731 2997152
4698093 4493143
5880851 3...

output:

54642096
405857490
167439519
915449043
20139026
486466537
762469655
394875472
836143655
283090031
506258482
490025361
866657546
509682175
123361422
817778989
32913060
540751000
740403943
708689307
597742225
901102125
985707272
463813877
862737512
101251011
816283446
867238228
116043073
62962242
1180...

result:

ok 10000 tokens

Test #21:

score: 0
Accepted
time: 325ms
memory: 238172kb

input:

10000
8778376 8664686
9641752 8762004
5368074 2088628
9243288 8032204
3992798 88224
7062667 2241158
2494201 1891326
7406121 7201658
4043825 956699
4649214 1676583
2497894 731403
4211007 1040163
9739913 150173
7607294 1868680
9468095 3308388
5915772 1609149
4065652 1624905
8308299 1760330
2257050 220...

output:

153322949
439091290
326408130
672317230
904155566
149329938
326263837
101724087
204727698
188478354
587146543
198973568
529096925
253888152
718890054
278993229
261047002
355823397
867803987
828790638
709647779
149666939
825770556
418146357
703991233
449661682
369761000
551337044
222281235
951537830
...

result:

ok 10000 tokens

Test #22:

score: 0
Accepted
time: 316ms
memory: 238000kb

input:

10000
5115602 2417477
3267342 873846
6428557 4198213
5816331 5056212
3881057 1461004
7860208 1389739
9229342 3912988
8025090 2930832
8795468 4914159
9701593 7064193
7273730 865444
5177099 4549490
7601724 1683584
8783454 435861
5974094 1792993
2549562 2470190
7538269 5542732
8346731 6868546
9946354 6...

output:

178311056
626392965
955473055
769729480
409485531
373107031
620419881
407727636
204889523
115326784
350877577
260891291
665353756
933248151
838934653
60858026
316126352
146709941
167424591
213468038
385751332
560102796
32151291
894506167
147440089
57373813
91947500
202867336
779164072
358821880
6017...

result:

ok 10000 tokens

Test #23:

score: 0
Accepted
time: 296ms
memory: 237908kb

input:

10000
2223824 1389700
9297396 1858162
5086967 255293
1639629 323576
8225339 6727189
7841356 6367699
5784796 3719187
5270263 2204970
3428204 1739153
9775625 9184171
7887837 1225060
7756547 1149244
6841573 2032235
9741298 5302291
7425824 2228127
9598997 6537019
4575003 3237665
7033026 6973085
8670722 ...

output:

615331554
777077468
164714100
153660633
448998374
738685636
316237563
812788613
503530055
923280900
892952052
630393594
240037059
682656170
731815340
264072614
871644657
525891602
91855998
814434178
912848086
613603338
524841748
465335893
504415451
243151319
366997978
901917727
888142167
442413300
4...

result:

ok 10000 tokens

Test #24:

score: 0
Accepted
time: 318ms
memory: 237912kb

input:

10000
7593309 1266320
9915242 2114711
2094438 1554215
3487452 3170653
8690393 241393
6317784 898481
6484382 2382062
9811502 7314121
5791840 3226373
9419065 465386
5514757 4515916
7923017 6210445
7461858 3284263
412186 217480
4228823 720585
7033764 404649
3744964 673177
3315781 759768
9441420 1885906...

output:

2966130
694404943
894301490
71326463
875092575
670589725
485645556
814784792
918986501
372102401
743928160
964551452
224978533
630858152
438066132
698659853
864943721
400881697
335943596
672180307
523635155
480701258
396569169
8408246
412729772
933457345
935612562
203356298
64438280
167219180
332338...

result:

ok 10000 tokens

Test #25:

score: 0
Accepted
time: 321ms
memory: 237932kb

input:

10000
5724699 5033779
9265698 3970888
1724115 839057
9698903 851166
3280129 1627749
5716272 1737299
2174300 1087807
9116536 7886413
769711 468921
2795752 2331402
7014157 4408453
2777531 1876292
8477072 1934276
9478741 3636949
9429037 1511870
1476403 1278002
4733856 2981560
7291951 5211549
8560283 78...

output:

741532211
755042074
359152131
708260362
489289179
202871033
779801133
124133677
211165721
877111785
816409957
963443507
577105615
678001428
675407594
439756524
425676201
459350508
2746927
802745136
824395765
171145161
234196190
317696784
421509753
521139045
208441921
320659028
550542014
254096296
28...

result:

ok 10000 tokens

Test #26:

score: 0
Accepted
time: 335ms
memory: 237984kb

input:

10000
5425493 673626
9468697 8616356
7889020 1834767
6215152 3243715
7233643 2524316
9838706 4308694
6862726 4541862
3562064 3225275
8446690 6584569
7298206 2962455
7649868 5700305
5178665 1759446
5733549 2137805
2123609 2013085
6510946 3164701
5216007 4220924
5130929 3254268
5177335 4920815
5770786...

output:

938517886
300916250
191198016
3430221
607400152
579724093
574087758
338596909
812698222
727316358
720757848
1772189
460607342
106150063
725594725
264775690
703357787
372567488
509843590
964706763
107172242
900988489
364084944
901204012
130395921
543253391
326368502
532092451
7618025
370391090
588130...

result:

ok 10000 tokens

Test #27:

score: 0
Accepted
time: 308ms
memory: 237984kb

input:

10000
9708735 3236245
8629815 8629815
9983502 2218556
6805732 6805732
4363662 727277
7617890 2176540
7940496 7940496
7890015 7890015
6209323 6209323
5810965 5810965
9259222 9259222
8442502 4221251
9572164 9572164
4512870 880560
5637683 5637683
6454108 3227054
5284234 5284234
5319990 5319990
8306840 ...

output:

323984208
1
970398493
1
960471756
571161989
1
1
1
1
1
705823674
1
111793448
1
171519785
1
1
543992267
1
1
1
1
1
301871797
1
1
1
1
185566275
1
1
546786361
450747772
1
155692007
1
1
1
294914036
1
1
115170425
1
1
1
1
1
1
1
1
749929208
353006623
210678666
229928545
107359684
565050443
229456716
1
1
1
35...

result:

ok 10000 tokens

Test #28:

score: 0
Accepted
time: 307ms
memory: 237912kb

input:

10000
6088167 6088167
6883707 6883707
7731356 1932839
2872636 1436318
7098417 7098417
8516686 8516686
5351915 5351915
9755017 9755017
3039716 2279787
5334477 5334477
4562949 1520983
6813698 6813698
7638020 3819010
8422098 8422098
7639256 7639256
9196796 676235
6824263 6824263
7073107 7073107
9494546...

output:

1
1
971076099
267924271
1
1
1
1
320156838
1
206999497
1
377529183
1
1
927840649
1
1
1
1
1
1
5184319
475645007
1
842932563
1
1
1
1
1
1
91471092
1
1
1
1
1
844404931
1
17363304
1
1
1
767563099
1
1
1
1
935361310
770328528
1
472054162
1
1
920840365
938727365
114835319
346303037
780390630
1
699588267
9152...

result:

ok 10000 tokens

Test #29:

score: 0
Accepted
time: 337ms
memory: 237932kb

input:

10000
6759237 4506158
9284778 1031642
8502189 8502189
6787904 6787904
7881724 3940862
4570335 2089296
6863028 6863028
9048204 6786153
8051774 8051774
4592436 3827030
7702656 6418880
6530785 6530785
3373472 3373472
9388592 9388592
6898680 3449340
7622814 7622814
4500032 4500032
9999837 9999837
705626...

output:

250243890
411999576
1
1
279817978
420255889
1
778878960
1
77175529
593738223
1
1
1
842084498
1
1
1
869056686
668440419
159999300
415008525
1
633038703
265681239
1
1
780299764
197254314
140361620
1
72960194
1
320406378
979241125
1
434376027
1
1
970250216
1
1
721151954
1
1
1
851037879
1
1
1
128473085
...

result:

ok 10000 tokens

Test #30:

score: 0
Accepted
time: 339ms
memory: 238008kb

input:

10000
9536766 4768383
5705920 3191749
9895851 9895851
9983019 3327673
9028424 9028424
1407608 1055706
2544800 1272400
7588890 5565186
7742596 3871298
9781821 9781821
6133300 6133300
7659108 3829554
6746541 4497694
7404023 7404023
5570872 5570872
1191314 1191314
3723555 3723555
4632152 4632152
662265...

output:

811547473
554795017
1
600876244
1
242596635
398640752
296790230
650230013
1
1
694556895
566718879
1
1
1
1
1
113486835
1
235942706
246289969
1
1
704979648
1
1
283046733
972464674
1
1
420217107
1
472549939
1
848520800
1
387644028
573792803
1
400116872
688728237
710215262
1
1
577786624
1
1
1
472649669
...

result:

ok 10000 tokens

Test #31:

score: 0
Accepted
time: 331ms
memory: 238208kb

input:

10000
9505352 4752676
8985081 2995027
9322762 4661381
7775469 7775469
7480884 7480884
6748197 4498798
7789307 7789307
9322671 9322671
7084926 7084926
9259334 6613810
8629645 8629645
5999488 5062068
7070055 7070055
4531934 3089955
7216092 2617602
5832330 833190
5548817 5548817
6255288 6255288
6980570...

output:

456818426
100176064
802749210
1
1
861654792
1
1
1
417806193
1
324182462
1
873962556
947968170
284794841
1
1
1
1
1
1
245690616
1
1
943449811
548407723
683617324
1
1
150428496
750589679
1
823332386
824850520
1
571223066
301058363
456716292
1
1
812860062
342543185
1
1
1
1
1
782391956
163334254
1
1
1
76...

result:

ok 10000 tokens

Test #32:

score: 0
Accepted
time: 379ms
memory: 238008kb

input:

10000
5094720 5094720
9870336 6580224
5981580 5981580
8599500 5733000
8645280 8645280
8032500 8032500
9144576 6096384
3491136 3491136
5806350 5806350
9579240 9579240
6708240 6708240
5483016 5483016
9150624 9150624
6095520 6095520
8169600 8169600
8232840 3659040
9465120 9465120
5382000 3229200
952380...

output:

1
44310545
1
929421750
1
1
414501060
1
1
1
1
1
1
1
1
298257588
1
738388403
1
1
1
1
1
1
1
1
467063827
776056976
470158788
589499385
1
1
1
290022544
1
715035962
1
1
54373157
1
1
1
55928942
1
1
92128672
1
1
1
1
226896695
1
319832335
934494536
1
1
1
942617643
1
1
1
1
1
412603971
412540425
1
1
98143181
1...

result:

ok 10000 tokens

Test #33:

score: 0
Accepted
time: 331ms
memory: 237984kb

input:

10000
6468840 6468840
9590400 9590400
9909900 3303300
8622900 8622900
6697152 6697152
7099560 7099560
4939200 4939200
5897430 5897430
9602040 9602040
5925150 5925150
7512960 3756480
6229440 2076480
9993984 2498496
8314800 8314800
6141408 6141408
9816840 9816840
6134400 6134400
8386950 8386950
515793...

output:

1
1
792714883
1
1
1
1
1
1
1
665071526
800299196
175961878
1
1
1
1
1
1
1405684
1
1
1
1
1
1
1
1
668275123
56770786
429433017
1
1
1
151411473
1
1
1
1
1
78475478
1
908734245
1
678592018
74905043
1
1
1
1
1
1
1
989929656
1
1
1
1
960791458
193666289
1
339102617
1
1
1
918242743
440963313
1
1
1
1
479411881
1...

result:

ok 10000 tokens

Test #34:

score: 0
Accepted
time: 360ms
memory: 237944kb

input:

10000
9011520 6007680
5166720 5166720
6200064 6200064
8013600 8013600
6771600 4740120
9984480 9984480
5378688 5378688
8242560 4121280
7514100 7514100
7865088 3932544
6558720 6558720
3682800 3682800
8511360 4255680
9631860 9631860
6917400 3458700
5127948 5127948
6060960 6060960
9128700 4564350
762300...

output:

56803135
1
1
1
3698178
1
1
274579394
1
303665779
1
1
712021774
1
556198242
1
1
213643131
1
887066394
201359755
1
1
1
1
1
1
339089909
1
1
1
1
1
1
949659952
1
731208739
1
1
1
1
1
1
1
1
1
517982002
728569815
1
1
1
1
1
1
1
1
1
1
1
199487762
182017690
1
1
1
472512069
379041174
1
24138752
1
35100981
1
510...

result:

ok 10000 tokens

Test #35:

score: 0
Accepted
time: 352ms
memory: 237916kb

input:

10000
9201600 9201600
3843840 2882880
6233220 6233220
7527600 2509200
9090900 9090900
8667120 4333560
9424800 9424800
4866624 4866624
6293700 6293700
8330784 8330784
6883800 6883800
9883800 4941900
5165160 5165160
9936432 9936432
9837828 9837828
9509760 9509760
6058800 6058800
9749376 6499584
984960...

output:

1
779589924
1
269675187
1
881419320
1
1
1
1
1
40620197
1
1
1
1
1
367133774
1
351660520
1
475274329
1
1
839114031
936559756
1
510160592
371707739
372770986
881642736
1
1
1
1
1
1
681484149
698964366
607766101
1
1
1
1
1
1
864334437
1
836237069
1
81922691
1
743034342
1
312731565
1
997690851
467846066
1
...

result:

ok 10000 tokens

Test #36:

score: 0
Accepted
time: 330ms
memory: 237984kb

input:

10000
6834240 3417120
8161920 4080960
9443616 9443616
6024480 6024480
8714880 8714880
6584400 6584400
5990400 4492800
9473856 9473856
9128700 6085800
7470400 7470400
8659980 8659980
6795360 6795360
5624640 5624640
8882874 8882874
5346000 5346000
6277320 6277320
9249600 9249600
8920800 8920800
523404...

output:

969501550
682253995
1
1
1
1
662451127
1
946264078
1
1
1
1
1
1
1
1
1
1
1
959335624
241820240
1
1
1
1
1
1
386700949
1
1
1
863854577
133824220
880626565
1
380112712
1
1
1
1
1
550161595
817482621
562458899
932139820
1
1
1
134621093
390883054
117932769
990516768
431896878
607346154
1
493909925
1
1
1
1
1
...

result:

ok 10000 tokens

Test #37:

score: 0
Accepted
time: 364ms
memory: 238172kb

input:

10000
6468000 924000
6683040 5110560
7862400 5765760
9424800 5890500
9189180 4594590
9378600 4689300
8996400 2698920
9979200 4490640
7854000 785400
9729720 4490640
6209280 3104640
8910720 556920
9355500 1871100
6726720 960960
5997600 1713600
2708640 902880
6639360 4979520
9172800 2751840
5100480 637...

output:

188331472
696827693
156585508
185713175
845672627
418512431
85300984
680689442
918005538
99448550
850128080
310269473
89037213
574056107
65080134
812710309
963798003
634701503
76000598
516628473
736459281
816314300
670466705
655338766
867772779
591396515
286804869
611833913
353885584
875064074
26358...

result:

ok 10000 tokens

Test #38:

score: 0
Accepted
time: 349ms
memory: 237988kb

input:

10000
8751600 546975
5446350 3501225
7567560 5360355
6535620 2723175
3808350 1904175
7702695 4621617
2650725 1472625
7624890 5990985
1237005 412335
9729720 405405
1576575 630630
5738040 3586275
2463300 1847475
6224400 5835375
9889425 4729725
8056125 2148300
6506325 3614625
7536375 1507275
9746100 73...

output:

663017469
493061872
647309034
224438110
15983633
328463771
594856720
368304346
55873084
857952983
600718023
282485373
509158178
977478789
851420671
259663278
409483916
973620403
80682411
394860996
724691481
552155943
243598364
452734445
684123854
736150405
29773969
382178720
448648061
296214540
4004...

result:

ok 10000 tokens

Test #39:

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

input:

10000
45 43
64 18
126 57
116 66
83 26
105 92
57 36
121 40
113 48
80 52
142 93
141 3
89 15
95 56
122 20
45 12
139 21
84 22
105 40
104 15
115 30
114 85
134 61
98 21
73 48
58 33
56 15
79 60
142 95
87 7
115 90
69 39
121 22
51 21
108 17
139 103
128 77
105 62
43 4
91 56
120 120
91 45
92 11
95 58
143 47
11...

output:

22
924853601
868736863
731130679
326254063
515158012
91244919
393036559
959305467
208097529
94045233
432
762350421
989372359
768623582
319239956
61500983
264699725
906370945
996159370
334000959
358886109
430293869
926990147
754582788
563908025
98682079
722199598
787442737
30539784
505049589
97027499...

result:

ok 10000 tokens

Test #40:

score: 0
Accepted
time: 326ms
memory: 237980kb

input:

10000
174 31
178 151
157 149
165 46
186 12
193 168
169 106
191 104
155 57
187 163
184 166
175 33
155 147
175 14
190 44
184 81
168 25
183 38
182 171
165 109
179 96
170 43
179 176
195 113
173 27
188 57
146 112
156 23
177 23
180 38
189 71
197 62
148 114
150 76
160 149
159 64
155 60
190 62
191 177
163 2...

output:

826225150
299692024
324417807
382137350
285207547
346753849
59144963
641894424
950317852
123941556
892252715
639122312
183734276
822336361
284141173
915648144
257861892
562518886
19214705
275456834
509608358
256077178
2670
374376826
409338706
911503961
42038757
336643796
582531917
631247570
25130358...

result:

ok 10000 tokens

Test #41:

score: 0
Accepted
time: 342ms
memory: 237928kb

input:

10000
589 345
793 590
980 24
222 132
573 104
605 439
740 615
970 461
381 269
813 106
912 613
704 528
702 474
652 303
806 207
573 242
772 90
983 844
570 276
809 10
429 318
963 824
625 187
373 105
550 256
613 393
650 579
411 67
929 345
729 220
958 760
922 412
805 24
739 338
856 445
839 839
612 281
523...

output:

530363620
383533692
96004303
906885378
721173165
894292081
709207211
514544490
668985527
991204988
702639104
975282651
754813034
56123457
877813646
291929677
187901684
371723009
170979818
931715303
847020583
434044272
476600822
979843630
710688136
951917462
530557045
479913137
216509633
41311500
550...

result:

ok 10000 tokens

Test #42:

score: 0
Accepted
time: 308ms
memory: 237872kb

input:

10000
8984 8678
5442 4556
5310 3690
4649 2157
8149 6968
7077 474
1148 1110
2423 494
3642 2492
8782 6521
4142 3574
5491 4931
1482 12
6857 5199
7940 4477
3079 2978
6605 296
5527 3669
8294 7346
2138 1263
9466 7892
8929 1132
7914 5416
1481 340
2559 1580
7077 1555
8778 4238
3187 339
5463 2100
5157 3112
1...

output:

711014829
878727198
920440472
639562592
68681212
105615602
21818255
374122372
380076611
889026237
745532290
794308094
803573294
930843243
853190968
602169037
132641665
317503743
643692938
375459272
446964588
512051764
605011122
129004581
304394406
723474890
299983604
353117636
795883096
219847797
97...

result:

ok 10000 tokens

Test #43:

score: 0
Accepted
time: 347ms
memory: 238000kb

input:

10000
44998 39577
28735 23890
32799 7054
95985 72738
45607 24984
56432 28418
21046 17633
11679 524
55521 29291
98614 9076
63359 2057
34071 9973
45683 26498
59439 47402
25399 2475
24970 15800
36315 2532
67728 10304
70065 22819
32482 11646
82102 59913
64570 4414
24620 814
94947 16625
12040 5157
99242 ...

output:

340293481
875417731
6439250
717700384
580458462
465500427
58012505
815678365
619204418
251500713
929279301
712555408
478221148
463839235
850713399
459246617
720827716
164462672
851072713
407815632
683368622
333246738
120227961
992295650
772741273
166750698
596386103
111785758
127126379
893933427
132...

result:

ok 10000 tokens

Test #44:

score: 0
Accepted
time: 321ms
memory: 238000kb

input:

10000
660570 601432
170470 86646
675279 542629
605737 253386
634132 35152
617585 367805
525628 360667
793685 141168
389062 328073
214477 24974
407727 164699
976234 812979
736010 369935
761354 295204
949633 737844
552427 496437
223339 154636
421326 172269
135182 42901
433399 21103
813180 770820
72409...

output:

471160328
195526373
751695504
996991638
202660857
284366556
687989952
778417769
939573135
566632034
477119343
509074071
727074080
404133035
703169509
634666654
432802686
906857896
478465624
977446418
610904302
746393327
550245630
943779653
464949348
247330397
657928459
105365324
872021259
894339305
...

result:

ok 10000 tokens

Test #45:

score: 0
Accepted
time: 305ms
memory: 238000kb

input:

10000
4884559 4642701
3215124 1228726
6234484 848342
9110386 5412645
9958031 4135853
7653142 6163151
4516383 3799236
8826204 7021095
2008910 2003630
9756873 7812825
5421992 5387857
8359168 564155
6432880 303782
7461527 2992677
3661868 2923740
5668869 4632968
7247824 6838487
9828355 914509
5002008 23...

output:

707753678
534586821
147197938
610396956
214357525
5476008
339124845
524778866
226071237
860991273
164766436
696644311
17770606
697912978
232710477
629789162
163956363
38129460
436370182
99605514
765223542
565376555
465317138
650167208
226800845
329430547
413975129
272712280
434454554
425832126
64333...

result:

ok 10000 tokens

Test #46:

score: 0
Accepted
time: 341ms
memory: 237808kb

input:

10000
6560401 973677
6822613 4647680
8446769 8045296
6790825 2314308
8115440 1527467
9916223 7263138
9949129 4004786
9782266 3233801
7921471 3573531
7165031 5309362
4183507 1521970
8883011 2519553
9463301 5759093
9276758 4608545
9238501 4954025
3243752 2186755
3136951 1557311
9769223 5297892
4995838...

output:

148302079
276482621
18669590
245642563
789089032
971327950
75136456
543979929
732121897
224294908
854625311
976142651
545963824
547218009
996610551
356481257
856328208
643440567
624946694
822692442
881007678
584464654
867676929
636047030
511050224
147485480
821993051
670635327
430444120
281319741
64...

result:

ok 10000 tokens

Test #47:

score: 0
Accepted
time: 312ms
memory: 238004kb

input:

10000
5521866 229127
6533689 5140721
7152289 3589388
9931553 4138427
7658301 1245341
6389969 4929818
5134681 4987683
7286369 3702963
9222613 8822541
8951506 483419
5438870 2195133
2634983 2542349
6100673 4929683
6356513 5190169
3003591 1429804
8735639 6552251
9222994 2038691
3639939 1808168
2239145 ...

output:

811288400
868609734
356933357
426229338
883080714
704617543
404170799
446482931
937782115
727605005
445668587
400471445
369149323
527542122
168374899
231954243
961924512
507418831
667341634
978393554
630263369
168355303
253664631
557124454
996106569
553614399
433640499
173758418
830593639
464839926
...

result:

ok 10000 tokens

Test #48:

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

input:

10000
7848239 952841
5836459 4268145
9089593 6379547
8594653 1773762
4406117 1508236
7742851 3884753
8357989 6105413
8784379 5516075
6210955 1454108
7623833 584928
7467851 2979626
5025333 2252665
2459263 248969
6439034 4949843
5733457 1100706
9877947 3677126
9568810 122483
7923191 2279047
9992723 28...

output:

546100266
317023606
798675898
923962127
313719795
201901585
18543948
12471773
617256256
867503033
728248001
181527675
667477739
167918048
599518741
782615465
521503587
108775817
450816597
747914148
689236459
231189340
58648804
125290521
34855202
418492204
393726612
947732728
675154540
813009776
8986...

result:

ok 10000 tokens

Test #49:

score: 0
Accepted
time: 340ms
memory: 237976kb

input:

10000
7104688 1345557
6560763 4733231
9881003 2175883
4488641 4327115
8666217 2771599
4862996 4177827
8592135 3334013
9513567 7079560
6563147 1727602
5483864 2688347
6475158 3939263
3457701 2297339
7643973 1524118
7087514 3086943
9195146 8930737
7184214 2606119
7545925 6636174
7347512 4990943
968080...

output:

637073954
63961069
568007636
878195318
918117503
373143211
428158822
496184438
624351907
883514206
740071510
973321418
921767187
654960874
883536132
921489448
692402229
718535520
162744056
911543715
832763330
813418323
218729952
776084764
278503141
406606447
494569316
513346598
661853559
543509048
2...

result:

ok 10000 tokens

Test #50:

score: 0
Accepted
time: 331ms
memory: 237916kb

input:

10000
9749862 4565521
3990705 2817608
5026355 4769282
2175337 264263
7186190 2090167
5473418 2663709
9728421 1864325
5359627 2751389
6607988 6310983
8964023 6603340
7713423 5826497
8101727 5537832
3628055 2021396
2124973 1985649
4220637 3476686
7189135 5292097
9442127 8579243
9965627 6192465
5639550...

output:

727710652
455773549
674164677
747117430
984101101
186551394
441189442
477822410
638245105
392067596
660378576
577331129
845387160
163906125
976318518
384710339
964130506
385166216
833706539
11574932
160953940
366477782
321078634
230082214
776145740
347654437
740161842
278134792
452885289
762759751
9...

result:

ok 10000 tokens

Test #51:

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

input:

10000
8951652 8951652
2107979 2107979
9455705 9455705
8535386 8535386
4028595 4028595
7898130 7898130
4908968 4908968
3347323 3347323
5611744 5611744
2239008 2239008
4831162 4831162
8965458 8965458
9004132 9004132
4257258 4257258
7020714 7020714
325228 325228
18227 18227
7184350 7184350
7881540 7881...

output:

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
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
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
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
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 10000 tokens

Test #52:

score: 0
Accepted
time: 343ms
memory: 237980kb

input:

10000
1099931 1099931
6274090 6274090
7986049 7986049
1905834 1905834
3783736 3783736
8290241 8290241
9948769 9948769
2102634 2102634
9270840 9270840
9559153 9559153
7370442 7370442
7622011 7622011
9065827 9065827
2082538 2082538
2129255 2129255
5739869 5739869
4366806 4366806
216363 216363
1027871 ...

output:

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
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
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
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
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 10000 tokens

Test #53:

score: 0
Accepted
time: 293ms
memory: 238000kb

input:

10000
6819237 6819237
75090 75090
6920602 6920602
3495350 3495350
8449394 8449394
2162806 2162806
1007003 1007003
3345610 3345610
7529984 7529984
9859247 9859247
511803 511803
6364407 6364407
9486485 9486485
7617377 7617377
4708158 4708158
96508 96508
6729535 6729535
4634002 4634002
7833477 7833477
...

output:

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
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
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
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
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 10000 tokens

Test #54:

score: 0
Accepted
time: 324ms
memory: 238136kb

input:

10000
6512212 6512212
8182330 8182330
9755308 9755308
9596079 9596079
3263533 3263533
6768315 6768315
2882467 2882467
182126 182126
4694767 4694767
7966953 7966953
9160523 9160523
7526455 7526455
7740019 7740019
1285025 1285025
1848088 1848088
8764104 8764104
831028 831028
7052493 7052493
7927739 79...

output:

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
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
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
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
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 10000 tokens

Test #55:

score: 0
Accepted
time: 327ms
memory: 238208kb

input:

10000
9562820 9562820
5989988 5989988
4871144 4871144
2229040 2229040
4498959 4498959
5077438 5077438
5938636 5938636
8353976 8353976
8249629 8249629
4743112 4743112
3843268 3843268
2885763 2885763
7304078 7304078
5705989 5705989
1092086 1092086
3179442 3179442
275691 275691
479744 479744
2235210 22...

output:

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
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
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
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
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 10000 tokens

Test #56:

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

input:

10000
189 70
278 42
665 51
524 30
519 63
828 67
743 42
903 71
433 81
293 56
539 66
493 46
707 34
375 95
188 75
877 65
167 38
103 22
354 3
379 72
915 95
653 6
579 59
846 8
636 20
540 41
981 98
186 37
405 16
847 81
349 90
524 53
821 23
349 44
658 21
937 30
550 52
408 4
234 68
781 40
313 100
920 49
766...

output:

328841568
451020369
917236160
604811249
58394921
827934638
611411434
205676109
118869398
628744943
367790815
585028776
385698694
996609638
514024569
567941229
784158869
339887494
2611
894095927
832698346
700697729
523053082
681591377
789875744
843871663
766049776
9880717
889310860
865362701
98663198...

result:

ok 10000 tokens

Test #57:

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

input:

10000
6538 9
2755 24
6215 85
6827 13
2691 9
3265 33
2787 54
6155 87
2783 37
3938 16
2616 44
6805 66
2624 68
7711 23
6288 99
5526 44
3837 58
8692 49
6507 21
7539 47
8657 83
9137 74
4512 68
8600 68
2730 58
8442 87
8002 54
3562 85
9052 66
6052 40
9236 51
3452 95
5415 42
8608 63
3032 36
8085 90
7040 17
...

output:

148374960
778239653
854899473
381965346
374894418
66933421
710435569
220991850
115999708
876576238
848822310
867357310
60241737
963244209
346215788
768860522
426450100
750062026
95026655
35486194
696116414
263728050
504654566
728254371
471341054
785902332
930898489
135050578
277043184
925889999
4656...

result:

ok 10000 tokens

Test #58:

score: 0
Accepted
time: 334ms
memory: 237976kb

input:

10000
14395 99
95301 84
32333 39
42396 12
22875 25
33219 87
30278 45
80389 6
51825 50
99789 27
27911 21
97927 27
40342 51
86215 32
90634 75
39194 99
25556 10
83180 79
96693 25
41829 59
91807 86
88183 56
13226 44
19915 54
45993 54
89411 7
44072 13
37222 17
62279 86
54385 4
67078 97
10451 92
43388 7
5...

output:

172819058
314470212
325970227
645732684
363206962
172492188
349447440
602160644
701577596
523729756
112697262
253733945
436804205
362065897
995160469
227616110
107950968
366211605
440597223
196955397
751347009
170314181
630900236
819631349
828684916
773095653
569498790
759490296
293296731
583833441
...

result:

ok 10000 tokens

Test #59:

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

input:

10000
225270 59
728563 56
226382 11
387534 9
522054 46
149631 22
257417 45
727792 41
356248 88
813502 71
537914 68
802475 21
778909 26
230142 13
282766 81
515410 28
229092 69
427934 99
579803 98
221289 81
232507 28
873120 35
929435 20
572211 92
388265 8
630060 63
171629 49
412791 93
722499 63
167137...

output:

221893331
206859192
82978593
610220820
706751705
981835406
767226402
320687432
727392170
840418861
298941473
448423535
572321825
41225980
815295879
59787753
74837593
907986830
809160716
945496858
539744278
299648976
606939624
578154464
306923161
777321740
652689789
15551983
710486297
729041045
43066...

result:

ok 10000 tokens

Test #60:

score: 0
Accepted
time: 335ms
memory: 238004kb

input:

10000
6316591 17
5557240 49
7306397 54
2175951 20
6396915 68
8512198 66
1092790 94
5932629 8
6336186 85
5983453 20
2783556 53
4123605 38
8043593 92
1063785 3
6866967 42
5254603 86
7622346 50
5891858 6
6934360 88
1788269 11
9983340 96
3283609 63
5245102 42
3820747 73
4551528 87
7050914 25
3780111 91
...

output:

831467228
742237147
989757882
836804290
76268302
175768490
784755525
205038116
142784622
531857067
901445398
619573266
621092406
575935442
307920635
217237440
90189346
543836315
959543844
158798385
426235873
377424584
300121107
585040502
159398441
760685907
909266966
327011980
308519549
585869323
96...

result:

ok 10000 tokens