Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast")
- #include <bits/stdc++.h>
- #define all(x) begin(x), end(x)
- using namespace std;
- using int64 = int64_t;
- using uint64 = uint64_t;
- #ifdef ONLINE_JUDGE
- const bool isFileInput = true;
- const string commonFileName = "m3";
- #else
- const bool isFileInput = true;
- const string commonFileName = "";
- #endif
- const bool tests = false;
- // const int mod = (1 << 30) + 1;
- // const int N = 17;
- // int dp[1 << N][303];
- // void Process(int n, int m, ostream& out) {
- // if (n == 1) {
- // int64 ans = 1;
- // for (int i = 0; i < m; i++) {
- // ans = (ans + ans) % mod;
- // }
- // out << ans;
- // return;
- // }
- // for (int i = 0; i < (1 << n); i++) {
- // dp[i][0] = 1;
- // }
- // for (int i = 1; i < m; i++) {
- // for (int prevMask = 0; prevMask < (1 << n); prevMask++) {
- // for (int curMask = 0; curMask < (1 << n); curMask++) {
- // bool bad = false;
- // for (int bit = 0; !bad && bit + 1 < n; bit++) {
- // int curMaskValue = (curMask >> bit) & 3;
- // int prevMaskValue = (prevMask >> bit) & 3;
- // if (curMaskValue == prevMaskValue && (prevMaskValue == 0 || prevMaskValue == 3)) {
- // bad = true;
- // }
- // }
- // if (!bad) {
- // dp[curMask][i] = (dp[curMask][i] + dp[prevMask][i - 1]) % mod;
- // }
- // }
- // }
- // }
- // int64 ans = 0;
- // for (int mask = 0; mask < (1 << n); mask++) {
- // ans = (ans + dp[mask][m - 1]) % mod;
- // }
- // out << ans;
- // }
- map<pair<int, int>, int> mp;
- void Solve(istream& in, ostream& out) {
- int n, m;
- in >> n >> m;
- if (n > m) swap(n, m);
- out << mp[{n, m}] << '\n';
- // for (int prod = 1; prod <= 300; prod++) {
- // for (int m = 1; m <= prod; m++) {
- // if (prod % m != 0) continue;
- // if (prod / m > m) continue;
- // memset(dp, 0, sizeof(dp));
- // int n = prod / m;
- // out << "mp[{" << n << ", " << m << "}]=";
- // Process(n, m, out);
- // out << ";\n";
- // }
- // cout << "PROD: " << prod << endl;
- // }
- }
- void Precalc() {
- mp[{1, 1}] = 2;
- mp[{1, 2}] = 4;
- mp[{1, 3}] = 8;
- mp[{2, 2}] = 14;
- mp[{1, 4}] = 16;
- mp[{1, 5}] = 32;
- mp[{2, 3}] = 50;
- mp[{1, 6}] = 64;
- mp[{1, 7}] = 128;
- mp[{2, 4}] = 178;
- mp[{1, 8}] = 256;
- mp[{3, 3}] = 322;
- mp[{1, 9}] = 512;
- mp[{2, 5}] = 634;
- mp[{1, 10}] = 1024;
- mp[{1, 11}] = 2048;
- mp[{3, 4}] = 2066;
- mp[{2, 6}] = 2258;
- mp[{1, 12}] = 4096;
- mp[{1, 13}] = 8192;
- mp[{2, 7}] = 8042;
- mp[{1, 14}] = 16384;
- mp[{3, 5}] = 13262;
- mp[{1, 15}] = 32768;
- mp[{4, 4}] = 23858;
- mp[{2, 8}] = 28642;
- mp[{1, 16}] = 65536;
- mp[{1, 17}] = 131072;
- mp[{3, 6}] = 85126;
- mp[{2, 9}] = 102010;
- mp[{1, 18}] = 262144;
- mp[{1, 19}] = 524288;
- mp[{4, 5}] = 275690;
- mp[{2, 10}] = 363314;
- mp[{1, 20}] = 1048576;
- mp[{3, 7}] = 546410;
- mp[{1, 21}] = 2097152;
- mp[{2, 11}] = 1293962;
- mp[{1, 22}] = 4194304;
- mp[{1, 23}] = 8388608;
- mp[{4, 6}] = 3185462;
- mp[{3, 8}] = 3507314;
- mp[{2, 12}] = 4608514;
- mp[{1, 24}] = 16777216;
- mp[{5, 5}] = 5735478;
- mp[{1, 25}] = 33554432;
- mp[{2, 13}] = 16413466;
- mp[{1, 26}] = 67108864;
- mp[{3, 9}] = 22512862;
- mp[{1, 27}] = 134217728;
- mp[{4, 7}] = 36806846;
- mp[{2, 14}] = 58457426;
- mp[{1, 28}] = 268435456;
- mp[{1, 29}] = 536870912;
- mp[{5, 6}] = 119310334;
- mp[{3, 10}] = 144506294;
- mp[{2, 15}] = 208199210;
- mp[{1, 30}] = 1073741824;
- mp[{1, 31}] = 1073741823;
- mp[{4, 8}] = 425288998;
- mp[{2, 16}] = 741512482;
- mp[{1, 32}] = 1073741821;
- mp[{3, 11}] = 927561722;
- mp[{1, 33}] = 1073741817;
- mp[{2, 17}] = 493452216;
- mp[{1, 34}] = 1073741809;
- mp[{5, 7}] = 334458704;
- mp[{1, 35}] = 1073741793;
- mp[{6, 6}] = 173285114;
- mp[{4, 9}] = 619085062;
- mp[{3, 12}] = 585154365;
- mp[{2, 18}] = 815897962;
- mp[{1, 36}] = 1073741761;
- mp[{1, 37}] = 1073741697;
- mp[{2, 19}] = 213372843;
- mp[{1, 38}] = 1073741569;
- mp[{3, 13}] = 635889643;
- mp[{1, 39}] = 1073741313;
- mp[{5, 8}] = 90695590;
- mp[{4, 10}] = 945426574;
- mp[{2, 20}] = 124430803;
- mp[{1, 40}] = 1073740801;
- mp[{1, 41}] = 1073739777;
- mp[{6, 7}] = 911351667;
- mp[{3, 14}] = 494452034;
- mp[{2, 21}] = 800038095;
- mp[{1, 42}] = 1073737729;
- mp[{1, 43}] = 1073733633;
- mp[{4, 11}] = 15016263;
- mp[{2, 22}] = 501492241;
- mp[{1, 44}] = 1073725441;
- mp[{5, 9}] = 291476458;
- mp[{3, 15}] = 482846928;
- mp[{1, 45}] = 1073709057;
- mp[{2, 23}] = 957069263;
- mp[{1, 46}] = 1073676289;
- mp[{1, 47}] = 1073610753;
- mp[{6, 8}] = 763177734;
- mp[{4, 12}] = 36143586;
- mp[{3, 16}] = 961174734;
- mp[{2, 24}] = 652966796;
- mp[{1, 48}] = 1073479681;
- mp[{7, 7}] = 35393966;
- mp[{1, 49}] = 1073217537;
- mp[{5, 10}] = 30793562;
- mp[{2, 25}] = 651813439;
- mp[{1, 50}] = 1072693249;
- mp[{3, 17}] = 857975995;
- mp[{1, 51}] = 1071644673;
- mp[{4, 13}] = 1071043415;
- mp[{2, 26}] = 40148434;
- mp[{1, 52}] = 1069547521;
- mp[{1, 53}] = 1065353217;
- mp[{6, 9}] = 436304595;
- mp[{3, 18}] = 623235366;
- mp[{2, 27}] = 350330355;
- mp[{1, 54}] = 1056964609;
- mp[{5, 11}] = 597448518;
- mp[{1, 55}] = 1040187393;
- mp[{7, 8}] = 167701464;
- mp[{4, 14}] = 592749523;
- mp[{2, 28}] = 57546108;
- mp[{1, 56}] = 1006632961;
- mp[{3, 19}] = 96023413;
- mp[{1, 57}] = 939524097;
- mp[{2, 29}] = 873299034;
- mp[{1, 58}] = 805306369;
- mp[{1, 59}] = 536870913;
- mp[{6, 10}] = 722829720;
- mp[{5, 12}] = 357727711;
- mp[{4, 15}] = 416276351;
- mp[{3, 20}] = 729894586;
- mp[{2, 30}] = 587505668;
- mp[{1, 60}] = 1;
- mp[{1, 61}] = 2;
- mp[{2, 31}] = 287889597;
- mp[{1, 62}] = 4;
- mp[{7, 9}] = 345325525;
- mp[{3, 21}] = 199741548;
- mp[{1, 63}] = 8;
- mp[{8, 8}] = 200727159;
- mp[{4, 16}] = 77857554;
- mp[{2, 32}] = 964938302;
- mp[{1, 64}] = 16;
- mp[{5, 13}] = 1030160836;
- mp[{1, 65}] = 32;
- mp[{6, 11}] = 711976380;
- mp[{3, 22}] = 1048602570;
- mp[{2, 33}] = 249368625;
- mp[{1, 66}] = 64;
- mp[{1, 67}] = 128;
- mp[{4, 17}] = 247689040;
- mp[{2, 34}] = 530498829;
- mp[{1, 68}] = 256;
- mp[{3, 23}] = 62341767;
- mp[{1, 69}] = 512;
- mp[{7, 10}] = 694557454;
- mp[{5, 14}] = 792068774;
- mp[{2, 35}] = 1016491912;
- mp[{1, 70}] = 1024;
- mp[{1, 71}] = 2048;
- mp[{8, 9}] = 586545036;
- mp[{6, 12}] = 968691054;
- mp[{4, 18}] = 36743464;
- mp[{3, 24}] = 972891566;
- mp[{2, 36}] = 889247919;
- mp[{1, 72}] = 4096;
- mp[{1, 73}] = 8192;
- mp[{2, 37}] = 405760281;
- mp[{1, 74}] = 16384;
- mp[{5, 15}] = 974465539;
- mp[{3, 25}] = 705944082;
- mp[{1, 75}] = 32768;
- mp[{4, 19}] = 234879760;
- mp[{2, 38}] = 848293031;
- mp[{1, 76}] = 65536;
- mp[{7, 11}] = 874948463;
- mp[{1, 77}] = 131072;
- mp[{6, 13}] = 571536179;
- mp[{3, 26}] = 587204706;
- mp[{2, 39}] = 135174180;
- mp[{1, 78}] = 262144;
- mp[{1, 79}] = 524288;
- mp[{8, 10}] = 1013558899;
- mp[{5, 16}] = 506272358;
- mp[{4, 20}] = 1024164878;
- mp[{2, 40}] = 1028366777;
- mp[{1, 80}] = 1048576;
- mp[{9, 9}] = 10014095;
- mp[{3, 27}] = 474051875;
- mp[{1, 81}] = 2097152;
- mp[{2, 41}] = 134223216;
- mp[{1, 82}] = 4194304;
- mp[{1, 83}] = 8388608;
- mp[{7, 12}] = 156109328;
- mp[{6, 14}] = 15182188;
- mp[{4, 21}] = 917369518;
- mp[{3, 28}] = 1046553554;
- mp[{2, 42}] = 311919552;
- mp[{1, 84}] = 16777216;
- mp[{5, 17}] = 643769299;
- mp[{1, 85}] = 33554432;
- mp[{2, 43}] = 130463263;
- mp[{1, 86}] = 67108864;
- mp[{3, 29}] = 84616587;
- mp[{1, 87}] = 134217728;
- mp[{8, 11}] = 803926546;
- mp[{4, 22}] = 907664205;
- mp[{2, 44}] = 1015228893;
- mp[{1, 88}] = 268435456;
- mp[{1, 89}] = 536870912;
- mp[{9, 10}] = 439395703;
- mp[{6, 15}] = 615611552;
- mp[{5, 18}] = 184304064;
- mp[{3, 30}] = 551772784;
- mp[{2, 45}] = 85387730;
- mp[{1, 90}] = 1073741824;
- mp[{7, 13}] = 560619160;
- mp[{1, 91}] = 1073741823;
- mp[{4, 23}] = 237866709;
- mp[{2, 46}] = 139137326;
- mp[{1, 92}] = 1073741821;
- mp[{3, 31}] = 397637532;
- mp[{1, 93}] = 1073741817;
- mp[{2, 47}] = 588187438;
- mp[{1, 94}] = 1073741809;
- mp[{5, 19}] = 612802952;
- mp[{1, 95}] = 1073741793;
- mp[{8, 12}] = 1027876269;
- mp[{6, 16}] = 227606139;
- mp[{4, 24}] = 338570502;
- mp[{3, 32}] = 650684895;
- mp[{2, 48}] = 969095141;
- mp[{1, 96}] = 1073741761;
- mp[{1, 97}] = 1073741697;
- mp[{7, 14}] = 422279141;
- mp[{2, 49}] = 862434824;
- mp[{1, 98}] = 1073741569;
- mp[{9, 11}] = 929525011;
- mp[{3, 33}] = 772250923;
- mp[{1, 99}] = 1073741313;
- mp[{10, 10}] = 146439608;
- mp[{5, 20}] = 149271250;
- mp[{4, 25}] = 892837304;
- mp[{2, 50}] = 230527454;
- mp[{1, 100}] = 1073740801;
- mp[{1, 101}] = 1073739777;
- mp[{6, 17}] = 60887377;
- mp[{3, 34}] = 421576034;
- mp[{2, 51}] = 268968360;
- mp[{1, 102}] = 1073737729;
- mp[{1, 103}] = 1073733633;
- mp[{8, 13}] = 96958732;
- mp[{4, 26}] = 477288610;
- mp[{2, 52}] = 194218163;
- mp[{1, 104}] = 1073725441;
- mp[{7, 15}] = 61050175;
- mp[{5, 21}] = 65198375;
- mp[{3, 35}] = 323613708;
- mp[{1, 105}] = 1073709057;
- mp[{2, 53}] = 46849384;
- mp[{1, 106}] = 1073676289;
- mp[{1, 107}] = 1073610753;
- mp[{9, 12}] = 640371992;
- mp[{6, 18}] = 1026376991;
- mp[{4, 27}] = 612578458;
- mp[{3, 36}] = 588166679;
- mp[{2, 54}] = 528984478;
- mp[{1, 108}] = 1073479681;
- mp[{1, 109}] = 1073217537;
- mp[{10, 11}] = 306237849;
- mp[{5, 22}] = 575610907;
- mp[{2, 55}] = 606910377;
- mp[{1, 110}] = 1072693249;
- mp[{3, 37}] = 435463655;
- mp[{1, 111}] = 1071644673;
- mp[{8, 14}] = 1009866334;
- mp[{7, 16}] = 638213111;
- mp[{4, 28}] = 478952083;
- mp[{2, 56}] = 731216437;
- mp[{1, 112}] = 1069547521;
- mp[{1, 113}] = 1065353217;
- mp[{6, 19}] = 775960409;
- mp[{3, 38}] = 508829076;
- mp[{2, 57}] = 186244590;
- mp[{1, 114}] = 1056964609;
- mp[{5, 23}] = 462134723;
- mp[{1, 115}] = 1040187393;
- mp[{4, 29}] = 121343276;
- mp[{2, 58}] = 947424819;
- mp[{1, 116}] = 1006632961;
- mp[{9, 13}] = 363900865;
- mp[{3, 39}] = 1035548413;
- mp[{1, 117}] = 939524097;
- mp[{2, 59}] = 1067279987;
- mp[{1, 118}] = 805306369;
- mp[{7, 17}] = 207105166;
- mp[{1, 119}] = 536870913;
- mp[{10, 12}] = 782520195;
- mp[{8, 15}] = 182299396;
- mp[{6, 20}] = 554561239;
- mp[{5, 24}] = 228866416;
- mp[{4, 30}] = 416043359;
- mp[{3, 40}] = 426399446;
- mp[{2, 60}] = 801722299;
- mp[{1, 120}] = 1;
- mp[{11, 11}] = 17440752;
- mp[{1, 121}] = 2;
- mp[{2, 61}] = 244759571;
- mp[{1, 122}] = 4;
- mp[{3, 41}] = 352416463;
- mp[{1, 123}] = 8;
- mp[{4, 31}] = 223871532;
- mp[{2, 62}] = 190239661;
- mp[{1, 124}] = 16;
- mp[{5, 25}] = 424248130;
- mp[{1, 125}] = 32;
- mp[{9, 14}] = 432021937;
- mp[{7, 18}] = 546233450;
- mp[{6, 21}] = 443333477;
- mp[{3, 42}] = 248858465;
- mp[{2, 63}] = 1060238125;
- mp[{1, 126}] = 64;
- mp[{1, 127}] = 128;
- mp[{8, 16}] = 619751064;
- mp[{4, 32}] = 690922528;
- mp[{2, 64}] = 339968222;
- mp[{1, 128}] = 256;
- mp[{3, 43}] = 623859462;
- mp[{1, 129}] = 512;
- mp[{10, 13}] = 604639267;
- mp[{5, 26}] = 39121375;
- mp[{2, 65}] = 992897266;
- mp[{1, 130}] = 1024;
- mp[{1, 131}] = 2048;
- mp[{11, 12}] = 974217644;
- mp[{6, 22}] = 907908302;
- mp[{4, 33}] = 693580115;
- mp[{3, 44}] = 563673766;
- mp[{2, 66}] = 437402767;
- mp[{1, 132}] = 4096;
- mp[{7, 19}] = 811929821;
- mp[{1, 133}] = 8192;
- mp[{2, 67}] = 76777358;
- mp[{1, 134}] = 16384;
- mp[{9, 15}] = 452562196;
- mp[{5, 27}] = 520802929;
- mp[{3, 45}] = 460936752;
- mp[{1, 135}] = 32768;
- mp[{8, 17}] = 691792110;
- mp[{4, 34}] = 247427676;
- mp[{2, 68}] = 31395783;
- mp[{1, 136}] = 65536;
- mp[{1, 137}] = 131072;
- mp[{6, 23}] = 479212655;
- mp[{3, 46}] = 1061439236;
- mp[{2, 69}] = 247742065;
- mp[{1, 138}] = 262144;
- mp[{1, 139}] = 524288;
- mp[{10, 14}] = 26783586;
- mp[{7, 20}] = 144368674;
- mp[{5, 28}] = 7662178;
- mp[{4, 35}] = 596190534;
- mp[{2, 70}] = 806017761;
- mp[{1, 140}] = 1048576;
- mp[{3, 47}] = 181647190;
- mp[{1, 141}] = 2097152;
- mp[{2, 71}] = 766053763;
- mp[{1, 142}] = 4194304;
- mp[{11, 13}] = 525573653;
- mp[{1, 143}] = 8388608;
- mp[{12, 12}] = 610837507;
- mp[{9, 16}] = 560349578;
- mp[{8, 18}] = 529044610;
- mp[{6, 24}] = 570000010;
- mp[{4, 36}] = 1030893011;
- mp[{3, 48}] = 131101869;
- mp[{2, 72}] = 688971336;
- mp[{1, 144}] = 16777216;
- mp[{5, 29}] = 43113906;
- mp[{1, 145}] = 33554432;
- mp[{2, 73}] = 377796059;
- mp[{1, 146}] = 67108864;
- mp[{7, 21}] = 39619792;
- mp[{3, 49}] = 282416137;
- mp[{1, 147}] = 134217728;
- mp[{4, 37}] = 682994543;
- mp[{2, 74}] = 363847199;
- mp[{1, 148}] = 268435456;
- mp[{1, 149}] = 536870912;
- mp[{10, 15}] = 683650588;
- mp[{6, 25}] = 116828880;
- mp[{5, 30}] = 671248249;
- mp[{3, 50}] = 650766224;
- mp[{2, 75}] = 773391890;
- mp[{1, 150}] = 1073741824;
- mp[{1, 151}] = 1073741823;
- mp[{8, 19}] = 273414395;
- mp[{4, 38}] = 168713176;
- mp[{2, 76}] = 900386418;
- mp[{1, 152}] = 1073741821;
- mp[{9, 17}] = 367985330;
- mp[{3, 51}] = 194674717;
- mp[{1, 153}] = 1073741817;
- mp[{11, 14}] = 990459439;
- mp[{7, 22}] = 114767483;
- mp[{2, 77}] = 1026717559;
- mp[{1, 154}] = 1073741809;
- mp[{5, 31}] = 698428487;
- mp[{1, 155}] = 1073741793;
- mp[{12, 13}] = 322126045;
- mp[{6, 26}] = 238799464;
- mp[{4, 39}] = 340553102;
- mp[{3, 52}] = 408031050;
- mp[{2, 78}] = 585958213;
- mp[{1, 156}] = 1073741761;
- mp[{1, 157}] = 1073741697;
- mp[{2, 79}] = 590084282;
- mp[{1, 158}] = 1073741569;
- mp[{3, 53}] = 656936178;
- mp[{1, 159}] = 1073741313;
- mp[{10, 16}] = 384011662;
- mp[{8, 20}] = 761429881;
- mp[{5, 32}] = 605930573;
- mp[{4, 40}] = 639381479;
- mp[{2, 80}] = 794685622;
- mp[{1, 160}] = 1073740801;
- mp[{7, 23}] = 272920239;
- mp[{1, 161}] = 1073739777;
- mp[{9, 18}] = 205177423;
- mp[{6, 27}] = 372438335;
- mp[{3, 54}] = 481393484;
- mp[{2, 81}] = 342999955;
- mp[{1, 162}] = 1073737729;
- mp[{1, 163}] = 1073733633;
- mp[{4, 41}] = 640433407;
- mp[{2, 82}] = 470887459;
- mp[{1, 164}] = 1073725441;
- mp[{11, 15}] = 748903144;
- mp[{5, 33}] = 618887114;
- mp[{3, 55}] = 821881863;
- mp[{1, 165}] = 1073709057;
- mp[{2, 83}] = 1024920462;
- mp[{1, 166}] = 1073676289;
- mp[{1, 167}] = 1073610753;
- mp[{12, 14}] = 475346110;
- mp[{8, 21}] = 179940286;
- mp[{7, 24}] = 352288148;
- mp[{6, 28}] = 54930246;
- mp[{4, 42}] = 631749497;
- mp[{3, 56}] = 766631974;
- mp[{2, 84}] = 795310829;
- mp[{1, 168}] = 1073479681;
- mp[{13, 13}] = 756270134;
- mp[{1, 169}] = 1073217537;
- mp[{10, 17}] = 774259418;
- mp[{5, 34}] = 661413937;
- mp[{2, 85}] = 140806111;
- mp[{1, 170}] = 1072693249;
- mp[{9, 19}] = 808714546;
- mp[{3, 57}] = 733941340;
- mp[{1, 171}] = 1071644673;
- mp[{4, 43}] = 53489874;
- mp[{2, 86}] = 939298166;
- mp[{1, 172}] = 1069547521;
- mp[{1, 173}] = 1065353217;
- mp[{6, 29}] = 813509316;
- mp[{3, 58}] = 764812936;
- mp[{2, 87}] = 952023070;
- mp[{1, 174}] = 1056964609;
- mp[{7, 25}] = 550865994;
- mp[{5, 35}] = 346952986;
- mp[{1, 175}] = 1040187393;
- mp[{11, 16}] = 146209688;
- mp[{8, 22}] = 664186020;
- mp[{4, 44}] = 443636779;
- mp[{2, 88}] = 439698242;
- mp[{1, 176}] = 1006632961;
- mp[{3, 59}] = 962470388;
- mp[{1, 177}] = 939524097;
- mp[{2, 89}] = 1915391;
- mp[{1, 178}] = 805306369;
- mp[{1, 179}] = 536870913;
- mp[{12, 15}] = 690179635;
- mp[{10, 18}] = 537331269;
- mp[{9, 20}] = 304896681;
- mp[{6, 30}] = 356006445;
- mp[{5, 36}] = 121598684;
- mp[{4, 45}] = 690053780;
- mp[{3, 60}] = 158927506;
- mp[{2, 90}] = 885142657;
- mp[{1, 180}] = 1;
- mp[{1, 181}] = 2;
- mp[{13, 14}] = 773633906;
- mp[{7, 26}] = 384666604;
- mp[{2, 91}] = 511775103;
- mp[{1, 182}] = 4;
- mp[{3, 61}] = 163866678;
- mp[{1, 183}] = 8;
- mp[{8, 23}] = 82054322;
- mp[{4, 46}] = 820968372;
- mp[{2, 92}] = 84385148;
- mp[{1, 184}] = 16;
- mp[{5, 37}] = 161045905;
- mp[{1, 185}] = 32;
- mp[{6, 31}] = 233929903;
- mp[{3, 62}] = 608783635;
- mp[{2, 93}] = 202963825;
- mp[{1, 186}] = 64;
- mp[{11, 17}] = 771657362;
- mp[{1, 187}] = 128;
- mp[{4, 47}] = 37559342;
- mp[{2, 94}] = 777661771;
- mp[{1, 188}] = 256;
- mp[{9, 21}] = 476140437;
- mp[{7, 27}] = 80158146;
- mp[{3, 63}] = 605221357;
- mp[{1, 189}] = 512;
- mp[{10, 19}] = 204608041;
- mp[{5, 38}] = 719170282;
- mp[{2, 95}] = 591429313;
- mp[{1, 190}] = 1024;
- mp[{1, 191}] = 2048;
- mp[{12, 16}] = 344242715;
- mp[{8, 24}] = 566986614;
- mp[{6, 32}] = 716092800;
- mp[{4, 48}] = 160065352;
- mp[{3, 64}] = 834978391;
- mp[{2, 96}] = 108386006;
- mp[{1, 192}] = 4096;
- mp[{1, 193}] = 8192;
- mp[{2, 97}] = 434274819;
- mp[{1, 194}] = 16384;
- mp[{13, 15}] = 415753406;
- mp[{5, 39}] = 625048610;
- mp[{3, 65}] = 239258022;
- mp[{1, 195}] = 32768;
- mp[{14, 14}] = 472559199;
- mp[{7, 28}] = 570069903;
- mp[{4, 49}] = 171240130;
- mp[{2, 98}] = 445854644;
- mp[{1, 196}] = 65536;
- mp[{1, 197}] = 131072;
- mp[{11, 18}] = 959441172;
- mp[{9, 22}] = 954803232;
- mp[{6, 33}] = 49208126;
- mp[{3, 66}] = 582556941;
- mp[{2, 99}] = 58629920;
- mp[{1, 198}] = 262144;
- mp[{1, 199}] = 524288;
- mp[{10, 20}] = 1033545328;
- mp[{8, 25}] = 416657370;
- mp[{5, 40}] = 489256484;
- mp[{4, 50}] = 48726788;
- mp[{2, 100}] = 1067599048;
- mp[{1, 200}] = 1048576;
- mp[{3, 67}] = 395675280;
- mp[{1, 201}] = 2097152;
- mp[{2, 101}] = 98831509;
- mp[{1, 202}] = 4194304;
- mp[{7, 29}] = 985682940;
- mp[{1, 203}] = 8388608;
- mp[{12, 17}] = 215929455;
- mp[{6, 34}] = 248911636;
- mp[{4, 51}] = 622955679;
- mp[{3, 68}] = 421980984;
- mp[{2, 102}] = 284208973;
- mp[{1, 204}] = 16777216;
- mp[{5, 41}] = 113674485;
- mp[{1, 205}] = 33554432;
- mp[{2, 103}] = 1050289937;
- mp[{1, 206}] = 67108864;
- mp[{9, 23}] = 50742054;
- mp[{3, 69}] = 406314212;
- mp[{1, 207}] = 134217728;
- mp[{13, 16}] = 422241885;
- mp[{8, 26}] = 86200118;
- mp[{4, 52}] = 180305821;
- mp[{2, 104}] = 498062282;
- mp[{1, 208}] = 268435456;
- mp[{11, 19}] = 406003627;
- mp[{1, 209}] = 536870912;
- mp[{14, 15}] = 634665169;
- mp[{10, 21}] = 927515784;
- mp[{7, 30}] = 865203291;
- mp[{6, 35}] = 307872842;
- mp[{5, 42}] = 18263821;
- mp[{3, 70}] = 764994014;
- mp[{2, 105}] = 373541245;
- mp[{1, 210}] = 1073741824;
- mp[{1, 211}] = 1073741823;
- mp[{4, 53}] = 792293558;
- mp[{2, 106}] = 1043006474;
- mp[{1, 212}] = 1073741821;
- mp[{3, 71}] = 669977452;
- mp[{1, 213}] = 1073741817;
- mp[{2, 107}] = 654876437;
- mp[{1, 214}] = 1073741809;
- mp[{5, 43}] = 416460804;
- mp[{1, 215}] = 1073741793;
- mp[{12, 18}] = 52411008;
- mp[{9, 24}] = 647963480;
- mp[{8, 27}] = 794597561;
- mp[{6, 36}] = 189176078;
- mp[{4, 54}] = 502583791;
- mp[{3, 72}] = 133509205;
- mp[{2, 108}] = 829416784;
- mp[{1, 216}] = 1073741761;
- mp[{7, 31}] = 85857128;
- mp[{1, 217}] = 1073741697;
- mp[{2, 109}] = 576777751;
- mp[{1, 218}] = 1073741569;
- mp[{3, 73}] = 207257733;
- mp[{1, 219}] = 1073741313;
- mp[{11, 20}] = 362547759;
- mp[{10, 22}] = 915035514;
- mp[{5, 44}] = 584606047;
- mp[{4, 55}] = 933914413;
- mp[{2, 110}] = 167941346;
- mp[{1, 220}] = 1073740801;
- mp[{13, 17}] = 575898004;
- mp[{1, 221}] = 1073739777;
- mp[{6, 37}] = 858131404;
- mp[{3, 74}] = 304119109;
- mp[{2, 111}] = 583637715;
- mp[{1, 222}] = 1073737729;
- mp[{1, 223}] = 1073733633;
- mp[{14, 16}] = 251807369;
- mp[{8, 28}] = 748856911;
- mp[{7, 32}] = 592409859;
- mp[{4, 56}] = 179642384;
- mp[{2, 112}] = 1013054012;
- mp[{1, 224}] = 1073725441;
- mp[{15, 15}] = 375125158;
- mp[{9, 25}] = 262614440;
- mp[{5, 45}] = 179752388;
- mp[{3, 75}] = 31985793;
- mp[{1, 225}] = 1073709057;
- mp[{2, 113}] = 985211991;
- mp[{1, 226}] = 1073676289;
- mp[{1, 227}] = 1073610753;
- mp[{12, 19}] = 300697745;
- mp[{6, 38}] = 1036448107;
- mp[{4, 57}] = 478994217;
- mp[{3, 76}] = 689756619;
- mp[{2, 114}] = 686776697;
- mp[{1, 228}] = 1073479681;
- mp[{1, 229}] = 1073217537;
- mp[{10, 23}] = 226228076;
- mp[{5, 46}] = 451326207;
- mp[{2, 115}] = 809528598;
- mp[{1, 230}] = 1072693249;
- mp[{11, 21}] = 71052195;
- mp[{7, 33}] = 714061793;
- mp[{3, 77}] = 405033400;
- mp[{1, 231}] = 1071644673;
- mp[{8, 29}] = 645274901;
- mp[{4, 58}] = 432516586;
- mp[{2, 116}] = 580913713;
- mp[{1, 232}] = 1069547521;
- mp[{1, 233}] = 1065353217;
- mp[{13, 18}] = 771830904;
- mp[{9, 26}] = 917205248;
- mp[{6, 39}] = 756421477;
- mp[{3, 78}] = 140531371;
- mp[{2, 117}] = 140572860;
- mp[{1, 234}] = 1056964609;
- mp[{5, 47}] = 348022766;
- mp[{1, 235}] = 1040187393;
- mp[{4, 59}] = 94441799;
- mp[{2, 118}] = 509804181;
- mp[{1, 236}] = 1006632961;
- mp[{3, 79}] = 678775188;
- mp[{1, 237}] = 939524097;
- mp[{14, 17}] = 701371007;
- mp[{7, 34}] = 59205842;
- mp[{2, 119}] = 736816438;
- mp[{1, 238}] = 805306369;
- mp[{1, 239}] = 536870913;
- mp[{15, 16}] = 367060492;
- mp[{12, 20}] = 233565932;
- mp[{10, 24}] = 261257487;
- mp[{8, 30}] = 837604474;
- mp[{6, 40}] = 496579399;
- mp[{5, 48}] = 680071760;
- mp[{4, 60}] = 544173112;
- mp[{3, 80}] = 462952966;
- mp[{2, 120}] = 8832201;
- mp[{1, 240}] = 1;
- mp[{1, 241}] = 2;
- mp[{11, 22}] = 551854612;
- mp[{2, 121}] = 426387654;
- mp[{1, 242}] = 4;
- mp[{9, 27}] = 603611462;
- mp[{3, 81}] = 238013318;
- mp[{1, 243}] = 8;
- mp[{4, 61}] = 347416906;
- mp[{2, 122}] = 223085539;
- mp[{1, 244}] = 16;
- mp[{7, 35}] = 543022393;
- mp[{5, 49}] = 200020348;
- mp[{1, 245}] = 32;
- mp[{6, 41}] = 878172140;
- mp[{3, 82}] = 385646605;
- mp[{2, 123}] = 448290100;
- mp[{1, 246}] = 64;
- mp[{13, 19}] = 1051104360;
- mp[{1, 247}] = 128;
- mp[{8, 31}] = 23808347;
- mp[{4, 62}] = 9584202;
- mp[{2, 124}] = 717299553;
- mp[{1, 248}] = 256;
- mp[{3, 83}] = 1028271827;
- mp[{1, 249}] = 512;
- mp[{10, 25}] = 994080129;
- mp[{5, 50}] = 402630107;
- mp[{2, 125}] = 900995209;
- mp[{1, 250}] = 1024;
- mp[{1, 251}] = 2048;
- mp[{14, 18}] = 956528130;
- mp[{12, 21}] = 41741104;
- mp[{9, 28}] = 234768751;
- mp[{7, 36}] = 322108598;
- mp[{6, 42}] = 966711602;
- mp[{4, 63}] = 538390806;
- mp[{3, 84}] = 408093191;
- mp[{2, 126}] = 916359258;
- mp[{1, 252}] = 4096;
- mp[{11, 23}] = 17292646;
- mp[{1, 253}] = 8192;
- mp[{2, 127}] = 256100892;
- mp[{1, 254}] = 16384;
- mp[{15, 17}] = 341142700;
- mp[{5, 51}] = 810464320;
- mp[{3, 85}] = 467114117;
- mp[{1, 255}] = 32768;
- mp[{16, 16}] = 589311468;
- mp[{8, 32}] = 334418192;
- mp[{4, 64}] = 963789131;
- mp[{2, 128}] = 453537542;
- mp[{1, 256}] = 65536;
- mp[{1, 257}] = 131072;
- mp[{6, 43}] = 198818879;
- mp[{3, 86}] = 896678796;
- mp[{2, 129}] = 799072585;
- mp[{1, 258}] = 262144;
- mp[{7, 37}] = 409199163;
- mp[{1, 259}] = 524288;
- mp[{13, 20}] = 295047889;
- mp[{10, 26}] = 26681205;
- mp[{5, 52}] = 16813230;
- mp[{4, 65}] = 176673179;
- mp[{2, 130}] = 83067364;
- mp[{1, 260}] = 1048576;
- mp[{9, 29}] = 293858488;
- mp[{3, 87}] = 596519620;
- mp[{1, 261}] = 2097152;
- mp[{2, 131}] = 773605437;
- mp[{1, 262}] = 4194304;
- mp[{1, 263}] = 8388608;
- mp[{12, 22}] = 883924328;
- mp[{11, 24}] = 45058746;
- mp[{8, 33}] = 91120010;
- mp[{6, 44}] = 298695588;
- mp[{4, 66}] = 416956597;
- mp[{3, 88}] = 1039958574;
- mp[{2, 132}] = 339467389;
- mp[{1, 264}] = 16777216;
- mp[{5, 53}] = 605304481;
- mp[{1, 265}] = 33554432;
- mp[{14, 19}] = 105566023;
- mp[{7, 38}] = 445764581;
- mp[{2, 133}] = 418129391;
- mp[{1, 266}] = 67108864;
- mp[{3, 89}] = 867243587;
- mp[{1, 267}] = 134217728;
- mp[{4, 67}] = 379436510;
- mp[{2, 134}] = 859581126;
- mp[{1, 268}] = 268435456;
- mp[{1, 269}] = 536870912;
- mp[{15, 18}] = 580898518;
- mp[{10, 27}] = 1036868276;
- mp[{9, 30}] = 89864942;
- mp[{6, 45}] = 180118652;
- mp[{5, 54}] = 130025389;
- mp[{3, 90}] = 687847054;
- mp[{2, 135}] = 193776685;
- mp[{1, 270}] = 1073741824;
- mp[{1, 271}] = 1073741823;
- mp[{16, 17}] = 610277199;
- mp[{8, 34}] = 571323539;
- mp[{4, 68}] = 996681999;
- mp[{2, 136}] = 153008657;
- mp[{1, 272}] = 1073741821;
- mp[{13, 21}] = 862006394;
- mp[{7, 39}] = 186439899;
- mp[{3, 91}] = 353928637;
- mp[{1, 273}] = 1073741817;
- mp[{2, 137}] = 846579341;
- mp[{1, 274}] = 1073741809;
- mp[{11, 25}] = 389136808;
- mp[{5, 55}] = 865727621;
- mp[{1, 275}] = 1073741793;
- mp[{12, 23}] = 729275546;
- mp[{6, 46}] = 231852617;
- mp[{4, 69}] = 472161081;
- mp[{3, 92}] = 305142160;
- mp[{2, 138}] = 698271687;
- mp[{1, 276}] = 1073741761;
- mp[{1, 277}] = 1073741697;
- mp[{2, 139}] = 566748268;
- mp[{1, 278}] = 1073741569;
- mp[{9, 31}] = 647068496;
- mp[{3, 93}] = 443202938;
- mp[{1, 279}] = 1073741313;
- mp[{14, 20}] = 754798662;
- mp[{10, 28}] = 874191076;
- mp[{8, 35}] = 381154806;
- mp[{7, 40}] = 951368892;
- mp[{5, 56}] = 396317252;
- mp[{4, 70}] = 223062477;
- mp[{2, 140}] = 949304528;
- mp[{1, 280}] = 1073740801;
- mp[{1, 281}] = 1073739777;
- mp[{6, 47}] = 84485526;
- mp[{3, 94}] = 719303184;
- mp[{2, 141}] = 760184645;
- mp[{1, 282}] = 1073737729;
- mp[{1, 283}] = 1073733633;
- mp[{4, 71}] = 949692912;
- mp[{2, 142}] = 957937516;
- mp[{1, 284}] = 1073725441;
- mp[{15, 19}] = 165309506;
- mp[{5, 57}] = 622748827;
- mp[{3, 95}] = 740176298;
- mp[{1, 285}] = 1073709057;
- mp[{13, 22}] = 779261580;
- mp[{11, 26}] = 1024474442;
- mp[{2, 143}] = 99214538;
- mp[{1, 286}] = 1073676289;
- mp[{7, 41}] = 583466840;
- mp[{1, 287}] = 1073610753;
- mp[{16, 18}] = 514185706;
- mp[{12, 24}] = 16030797;
- mp[{9, 32}] = 792399550;
- mp[{8, 36}] = 802557100;
- mp[{6, 48}] = 880130397;
- mp[{4, 72}] = 800148219;
- mp[{3, 96}] = 343852339;
- mp[{2, 144}] = 66034996;
- mp[{1, 288}] = 1073479681;
- mp[{17, 17}] = 272912734;
- mp[{1, 289}] = 1073217537;
- mp[{10, 29}] = 308020498;
- mp[{5, 58}] = 87623482;
- mp[{2, 145}] = 396534064;
- mp[{1, 290}] = 1072693249;
- mp[{3, 97}] = 697552910;
- mp[{1, 291}] = 1071644673;
- mp[{4, 73}] = 13524600;
- mp[{2, 146}] = 247930359;
- mp[{1, 292}] = 1069547521;
- mp[{1, 293}] = 1065353217;
- mp[{14, 21}] = 909861411;
- mp[{7, 42}] = 1039932676;
- mp[{6, 49}] = 217212875;
- mp[{3, 98}] = 515296406;
- mp[{2, 147}] = 463117380;
- mp[{1, 294}] = 1056964609;
- mp[{5, 59}] = 473889860;
- mp[{1, 295}] = 1040187393;
- mp[{8, 37}] = 260919957;
- mp[{4, 74}] = 796266341;
- mp[{2, 148}] = 811471033;
- mp[{1, 296}] = 1006632961;
- mp[{11, 27}] = 475155671;
- mp[{9, 33}] = 256351480;
- mp[{3, 99}] = 201765188;
- mp[{1, 297}] = 939524097;
- mp[{2, 149}] = 139422384;
- mp[{1, 298}] = 805306369;
- mp[{13, 23}] = 47478729;
- mp[{1, 299}] = 536870913;
- mp[{15, 20}] = 322193450;
- mp[{12, 25}] = 450155399;
- mp[{10, 30}] = 716405555;
- mp[{6, 50}] = 656842754;
- mp[{5, 60}] = 410709929;
- mp[{4, 75}] = 157235492;
- mp[{3, 100}] = 287632701;
- mp[{2, 150}] = 967467393;
- mp[{1, 300}] = 1;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- ifstream fin;
- ofstream fout;
- if (isFileInput) {
- const string inputFile = commonFileName.empty() ? "input.txt" : commonFileName + ".in";
- const string outputFile = commonFileName.empty() ? "output.txt" : commonFileName + ".out";
- if (!inputFile.empty()) {
- fin = ifstream(inputFile);
- if (!fin.good()) {
- fout = ofstream(inputFile);
- fout << "pu pu pu..." << endl;
- cout << "Input file created: " << inputFile << "\n";
- return 0;
- }
- }
- if (!outputFile.empty()) fout = ofstream(outputFile);
- }
- istream& in = !isFileInput ? cin : fin;
- ostream& out = !isFileInput ? cout : fout;
- in.tie(nullptr);
- out.tie(nullptr);
- Precalc();
- int t = 1;
- if (tests) in >> t;
- for (int i = 1; i <= t; i++) Solve(in, out);
- }
Advertisement
Comments
-
- can u teach me coding
- https://steamcommunity.com/profiles/76561199091249086
Add Comment
Please, Sign In to add comment
Advertisement