QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#387249#8569. Generalized Collatz Conjecturehos_lyricAC ✓3673ms689692kbC++148.7kb2024-04-12 11:02:182024-04-12 11:02:18

Judging History

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

  • [2024-04-12 11:02:18]
  • 评测
  • 测评结果:AC
  • 用时:3673ms
  • 内存:689692kb
  • [2024-04-12 11:02:18]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


#include <ext/pb_ds/assoc_container.hpp>
using __gnu_pbds::gp_hash_table;


template <class T> T power(T a, long long e, T m) {
  for (T b = 1; ; (a *= a) %= m) {
    if (e & 1) (b *= a) %= m;
    if (!(e >>= 1)) return b;
  }
}

long long gcd(long long a, long long b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  if (a == 0) return b;
  if (b == 0) return a;
  const int s = __builtin_ctzll(a | b);
  a >>= __builtin_ctzll(a);
  do {
    b >>= __builtin_ctzll(b);
    if (a > b) swap(a, b);
    b -= a;
  } while (b);
  return a << s;
}

bool isPrime(long long n) {
  if (n <= 1 || n % 2 == 0) return (n == 2);
  const int s = __builtin_ctzll(n - 1);
  const long long d = (n - 1) >> s;
  // http://miller-rabin.appspot.com/
  for (const long long base : {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) {
    __int128 a = base % n;
    if (a == 0) continue;
    a = power<__int128>(a, d, n);
    if (a == 1 || a == n - 1) continue;
    bool ok = false;
    for (int i = 0; i < s - 1; ++i) {
      (a *= a) %= n;
      if (a == n - 1) {
        ok = true;
        break;
      }
    }
    if (!ok) return false;
  }
  return true;
}

// n >= 3, odd
void factorizeRec(long long n, vector<long long> &ps) {
  static constexpr int BLOCK = 256;
  if (isPrime(n)) {
    ps.push_back(n);
  } else {
    for (long long c = 2; ; ++c) {
      long long x, y = 2, y0, z = 1, d = 1;
      for (int l = 1; d == 1; l <<= 1) {
        x = y;
        for (int i = 0; i < l; ++i) y = (static_cast<__int128>(y) * y + c) % n;
        for (int i = 0; i < l; i += BLOCK) {
          y0 = y;
          for (int j = 0; j < BLOCK && j < l - i; ++j) {
            y = (static_cast<__int128>(y) * y + c) % n;
            z = (static_cast<__int128>(z) * (y - x)) % n;
          }
          if ((d = gcd(z, n)) != 1) break;
        }
      }
      if (d == n) {
        for (y = y0; ; ) {
          y = (static_cast<__int128>(y) * y + c) % n;
          if ((d = gcd(y - x, n)) != 1) break;
        }
      }
      if (d != n) {
        factorizeRec(d, ps);
        factorizeRec(n / d, ps);
        return;
      }
    }
  }
}

vector<pair<long long, int>> factorize(long long n) {
  vector<pair<long long, int>> pes;
  if (n >= 2) {
    const int s = __builtin_ctzll(n);
    if (s) pes.emplace_back(2, s);
    if (n >> s >= 2) {
      vector<long long> ps;
      factorizeRec(n >> s, ps);
      std::sort(ps.begin(), ps.end());
      const int psLen = ps.size();
      for (int i = 0, j = 0; i < psLen; i = j) {
        for (; j < psLen && ps[i] == ps[j]; ++j) {}
        pes.emplace_back(ps[i], j - i);
      }
    }
  }
  return pes;
}

vector<long long> divisors(long long n) {
  const auto pes = factorize(n);
  vector<long long> ds{1};
  for (const auto &pe : pes) {
    const int len0 = ds.size();
    const int len1 = len0 * (pe.second + 1);
    ds.resize(len1);
    for (int i = len0; i < len1; ++i) ds[i] = ds[i - len0] * pe.first;
  }
  std::sort(ds.begin(), ds.end());
  return ds;
}

////////////////////////////////////////////////////////////////////////////////


constexpr int LIM_SIEVE = (1 << 27) + 1010;
constexpr int LIM_SIEVE_PI = 8'000'000;
int lpf[LIM_SIEVE + 1];
int primesLen;
int primes[LIM_SIEVE_PI];
void sieve() {
  for (int n = 2; n <= LIM_SIEVE; ++n) {
    if (lpf[n] == 0) {
      lpf[n] = n;
      primes[primesLen++] = n;
    }
    for (int i = 0; i < primesLen && primes[i] <= lpf[n] && primes[i] * n <= LIM_SIEVE; ++i) {
      lpf[primes[i] * n] = primes[i];
    }
  }
}


char Ome[LIM_SIEVE + 1];

constexpr int LIM_A = 64;

namespace exper {
constexpr int LIM_N = (1 << 21) + 10;
char ans[LIM_N + 1];
void run() {
  for (int a = 1; a <= LIM_A; ++a) {
    memcpy(ans, Ome, (LIM_N + 1) * sizeof(char));
    for (int src = 2; src <= LIM_N; ++src) {
      queue<pair<int, Int>> que;
      gp_hash_table<Int, int> dist;
      que.emplace(dist[src] = 0, src);
      for (; que.size(); ) {
        const int c = que.front().first;
        const Int u = que.front().second;
        que.pop();
        if (u <= LIM_N) chmin<char>(ans[src], c + ans[u]);
        if (ans[src] <= c + ((u < src) ? ans[u] : 0)) continue;
        auto reach = [&](Int v) -> void {
          if (dist.find(v) != dist.end()) {
            //
          } else {
            que.emplace(dist[v] = c + 1, v);
          }
        };
        if (u <= LIM_SIEVE) {
          for (int uu = u; uu > 1; ) {
            const int p = lpf[uu];
            do { uu /= p; } while (uu % p == 0);
            reach(u / p);
          }
        } else {
          const auto pes = factorize(u);
          for (const auto &pe : pes) reach(u / pe.first);
        }
        reach(a * u + 1);
      }
      if (ans[src] >= 6) {
        printf("%d %d %d\n", a, src, (int)ans[src]);
        fflush(stdout);
      }
    }
    int mx = 0;
    for (int n = 1; n <= LIM_N; ++n) chmax<int>(mx, ans[n]);
    cerr << "a = " << a << ": mx = " << mx << endl;
  }
}

void embed() {
  freopen("E.txt", "r", stdin);
  vector<int> nss[LIM_A + 1];
  for (int a, n, c; ~scanf("%d%d%d", &a, &n, &c); ) {
    assert(c == 6);
    nss[a].push_back(n);
  }
  for (int a = 0; a <= LIM_A; ++a) {
    printf("{");
    for (const int n : nss[a]) printf("%d,", n);
    printf("},\n");
  }
}
}  // exper


const set<int> PRE6[LIM_A + 1] = {
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{776576,},
{},
{},
{},
{1091151,1343709,1800063,},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{1273563,1718253,},
{},
{1903993,},
{},
{},
{},
{1607445,},
{},
{},
{},
{},
{},
{1151415,1384047,1436373,},
{},
{1233837,2075949,},
{},
{},
{},
{178929,288603,2045169,},
{},
{634375,},
{},
{},
{},
{720171,905175,1005939,1080675,1180737,1279395,1516995,1597779,1647675,1720251,1858869,},
{},
{},
{},
{},
{},
{441088,686313,950589,1279744,1377536,1629952,1669376,1699072,1972125,1974256,2076416,},
{},
{1180544,1782784,},
{},
{},
{},
};


int M;
vector<int> A;

template <int D> bool able(Int n) {
  if (n <= LIM_SIEVE) {
    if (Ome[n] <= D) return true;
    if (D >= 3) {
      for (int nn = n; nn > 1; ) {
        const int p = lpf[nn];
        do { nn /= p; } while (nn % p == 0);
        if (able<D - 1>(n / p)) return true;
      }
    }
  } else {
    const auto pes = factorize(n);
    for (const auto &pe : pes) if (able<D - 1>(n / pe.first)) return true;
  }
  for (const int a : A) if (able<D - 1>(a * n + 1)) return true;
  return false;
}
template <> bool able<0>(Int n) {
  return (n == 1);
}
template <> bool able<1>(Int n) {
  return (n <= LIM_SIEVE) ? (Ome[n] <= 1) : isPrime(n);
}

int solve(int n) {
  if (A.size() == 1 && PRE6[A[0]].count(n)) return 6;
  if (able<0>(n)) return 0;
  if (able<1>(n)) return 1;
  if (able<2>(n)) return 2;
  if (able<3>(n)) return 3;
  if (able<4>(n)) return 4;
  return 5;
}

int main() {
  sieve();
cerr<<"|primes| = "<<primesLen<<endl;
  for (int n = 2; n <= LIM_SIEVE; ++n) {
    Ome[n] = 1 + Ome[n / lpf[n]];
  }
  
  // exper::run(); return 0;
  // exper::embed(); return 0;
  
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    Int N;
    scanf("%lld%d", &N, &M);
    A.resize(M);
    for (int i = 0; i < M; ++i) {
      scanf("%d", &A[i]);
    }
    
    const int ans = solve(N);
    printf("%d\n", ans);
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 982ms
memory: 689228kb

input:

2
84 2 3 6
18588 3 18 25 44

output:

3
4

result:

ok 2 tokens

Test #2:

score: 0
Accepted
time: 3673ms
memory: 688932kb

input:

262144
1576395 1 37
1190799 2 11 17
520479 1 29
1676079 1 49
1202944 2 41 47
1906335 2 25 47
1862541 1 47
1879366 1 19
1225773 1 17
1819737 1 59
205155 1 53
1498304 1 61
818565 1 43
1482543 2 41 61
228771 1 59
758241 2 11 23
815056 1 59
576153 1 53
458541 1 35
950211 2 5 29
1495625 1 53
1962415 1 59...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
2
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
...

result:

ok 262144 tokens

Test #3:

score: 0
Accepted
time: 2815ms
memory: 689232kb

input:

262144
1492393 1 27
1517074 1 23
819009 1 35
1064505 1 3
991575 1 49
489969 1 31
1653561 1 59
1673625 1 19
443385 1 53
1789641 1 39
481915 1 5
1751715 2 5 53
602651 1 61
1721685 1 61
1032795 1 41
605493 1 47
1672192 3 16 29 58
325809 1 39
896704 1 17
1688067 1 61
567520 1 31
2082915 1 23
1879551 1 2...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
...

result:

ok 262144 tokens

Test #4:

score: 0
Accepted
time: 1778ms
memory: 689692kb

input:

262144
1078425 3 35 54 59
1954665 4 43 47 51 59
857175 3 27 49 59
1725032 3 28 31 55
1252611 3 17 53 64
1786023 4 17 27 48 51
1895925 3 53 59 64
1801202 3 25 43 64
1299429 4 17 31 47 63
1467315 3 30 41 47
1094205 3 14 19 23
1430433 3 17 50 53
1142019 3 21 23 53
376155 3 23 38 53
858141 4 11 47 56 62...

output:

3
3
4
3
4
3
3
3
3
3
3
3
3
2
3
3
4
3
3
3
3
2
4
3
3
3
3
3
3
4
3
4
3
3
4
3
3
4
3
3
3
3
3
4
4
4
3
4
2
3
4
3
3
4
3
2
4
3
3
3
2
3
3
3
3
4
3
3
4
2
3
4
2
4
2
2
2
3
3
2
3
4
3
3
4
3
4
3
3
4
3
4
3
3
3
3
4
2
3
4
4
3
2
3
3
3
3
3
3
2
3
2
3
4
3
3
4
3
3
4
3
3
3
4
3
3
3
2
4
4
3
3
2
3
4
2
3
2
2
3
2
4
4
3
2
3
3
4
4
3
...

result:

ok 262144 tokens

Test #5:

score: 0
Accepted
time: 1357ms
memory: 688964kb

input:

262144
580864 3 52 61 63
1709461 3 28 42 55
1572864 2 38 39
1632915 2 49 53
1022625 2 29 59
1883136 8 5 11 19 21 27 35 45 55
596835 3 30 49 62
196587 3 21 42 55
1272750 6 21 27 37 41 45 51
1081593 2 32 55
1757775 2 49 63
1811556 7 22 25 28 29 59 60 62
1698435 2 33 49
140625 2 19 50
1732992 2 8 48
12...

output:

2
2
3
4
4
2
3
3
2
3
4
3
3
4
3
2
4
4
4
3
3
3
2
3
3
3
3
2
2
3
3
2
3
3
3
3
3
2
3
3
4
3
2
3
3
2
3
3
3
4
4
2
2
3
3
3
3
3
3
2
3
3
2
4
4
3
3
4
3
3
4
4
2
3
2
2
4
3
3
3
3
3
3
3
2
2
4
3
3
3
3
3
3
4
4
3
4
2
2
3
4
3
3
3
3
3
3
4
2
3
3
2
3
3
2
3
3
3
3
3
3
4
3
2
3
2
3
2
2
3
4
2
3
3
3
3
3
4
4
3
4
3
4
3
3
3
2
4
2
3
...

result:

ok 262144 tokens

Test #6:

score: 0
Accepted
time: 1093ms
memory: 688932kb

input:

262144
2044416 3 5 17 33
1531872 5 21 27 31 51 55
2035886 2 3 37
1032750 6 29 37 41 49 53 57
910224 4 29 45 51 55
730944 3 23 35 45
993408 2 28 43
1606144 2 23 28
1636633 2 13 37
1875968 1 37
1633800 2 33 47
1519616 2 13 59
1609728 3 23 27 41
1792000 8 3 7 25 27 29 49 53 63
844050 1 14
1269504 1 13
...

output:

2
3
3
2
3
3
3
2
2
4
2
3
3
2
3
4
3
2
3
4
3
3
2
4
2
2
3
3
3
3
2
3
3
2
3
3
2
2
2
2
3
3
3
2
3
2
4
2
4
2
4
2
3
3
3
3
4
2
2
3
2
2
2
2
2
2
4
3
2
3
2
2
3
2
3
3
3
3
2
2
3
4
3
2
3
3
4
2
2
3
3
3
2
2
3
4
3
2
2
2
3
2
3
3
3
2
2
3
4
3
3
2
2
3
2
3
4
3
3
3
3
2
3
2
2
2
2
4
2
3
2
2
2
3
2
3
4
3
3
2
3
2
3
3
3
3
3
2
2
3
...

result:

ok 262144 tokens

Test #7:

score: 0
Accepted
time: 1107ms
memory: 688936kb

input:

262144
1081344 8 35 41 43 47 51 57 59 61
2062976 8 33 37 49 51 53 55 57 59
1798304 8 35 39 41 43 51 57 59 61
1341856 8 35 37 41 45 47 51 55 61
817600 8 15 17 21 29 37 41 45 59
1576788 8 33 39 51 53 55 57 59 63
1843875 8 33 39 43 49 53 55 61 63
1647360 8 33 37 41 47 49 57 59 63
546848 8 33 39 45 51 5...

output:

2
2
2
2
2
3
3
2
2
3
2
2
3
3
3
2
2
3
2
2
3
2
2
2
2
2
2
2
2
3
2
2
2
2
3
2
2
2
2
3
2
2
2
2
2
2
2
3
2
2
2
2
2
3
2
2
2
2
2
2
3
2
3
2
3
2
3
2
2
2
3
2
3
3
2
2
3
2
2
2
2
2
2
2
2
3
3
2
2
2
2
2
3
3
3
3
3
3
2
2
2
2
2
3
3
2
3
2
2
2
3
2
2
3
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
3
2
2
2
3
2
2
2
...

result:

ok 262144 tokens

Test #8:

score: 0
Accepted
time: 999ms
memory: 688908kb

input:

262144
74 2 18 57
682 3 20 31 47
1141614 2 11 62
178 2 7 35
940 2 31 58
1280 2 39 53
2097151 2 28 41
225 2 34 42
574 1 29
225 2 3 26
584 3 20 24 41
948 3 28 29 44
386 3 24 45 62
763 2 14 35
2097097 1 35
954 4 9 15 33 53
42 1 5
225 2 4 33
304 5 7 16 34 55 56
2097138 2 13 37
112 2 6 38
89 2 17 36
938 ...

output:

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

result:

ok 262144 tokens

Test #9:

score: 0
Accepted
time: 1004ms
memory: 688936kb

input:

262144
873 2 36 51
2097090 6 4 23 26 43 46 54
713 1 51
94 2 40 43
1110 3 6 26 42
188 2 26 36
2097077 3 20 23 35
52 3 12 46 61
56 2 20 63
418 4 33 49 59 61
245 2 38 57
114 2 15 39
171 2 16 26
388 7 41 45 48 55 59 60 62
844 3 26 28 30
644 3 23 25 28
493 2 36 50
62 2 12 21
418 3 2 36 60
697 2 29 57
276...

output:

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

result:

ok 262144 tokens

Test #10:

score: 0
Accepted
time: 987ms
memory: 688968kb

input:

262144
40 2 17 55
692 3 17 52 61
27 2 51 61
119 2 32 50
382 3 50 52 56
530 3 14 46 55
476032 2 21 49
726 2 2 5
1071 2 34 44
159 5 5 31 47 57 61
200 2 47 59
554 2 1 41
209 2 26 40
235 2 29 64
40 2 14 50
1517568 3 27 35 61
124 2 1 62
562 2 5 58
1485912 7 33 39 41 43 45 51 61
888 1 18
774 3 18 39 55
98...

output:

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

result:

ok 262144 tokens

Test #11:

score: 0
Accepted
time: 1011ms
memory: 689224kb

input:

262144
450 3 9 26 35
31 2 22 60
85 2 43 55
234 2 12 60
263 2 2 51
21 2 11 37
460 1 8
2097150 2 19 50
1098 1 63
884736 2 21 57
199 2 13 37
1574144 3 22 48 50
1083 2 21 36
2097088 3 6 9 13
2097149 2 11 35
974 3 36 46 49
2097080 3 28 43 48
222 2 39 43
31 3 15 18 56
234 2 50 55
175 2 1 25
482 3 16 37 54...

output:

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

result:

ok 262144 tokens

Test #12:

score: 0
Accepted
time: 1015ms
memory: 689000kb

input:

262144
672 2 53 63
1061 3 33 49 57
806208 1 57
170 2 7 28
976896 2 1 19
1723392 1 33
50 2 19 40
57 3 6 31 32
221 2 34 45
221 2 25 45
2097062 3 25 33 58
1757184 2 27 60
60 2 38 46
428032 8 21 23 25 35 45 47 61 63
88 2 34 39
1221120 1 42
183 2 26 52
259 2 23 50
1096 5 7 10 22 38 44
179 2 61 63
76 8 20...

output:

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

result:

ok 262144 tokens

Test #13:

score: 0
Accepted
time: 1045ms
memory: 689232kb

input:

262144
1757479 1 37
2044621 8 33 37 41 43 51 57 61 63
1833763 7 33 37 39 43 49 55 57
1335647 1 35
1219433 2 37 45
1852171 7 17 21 39 41 47 49 63
1272281 6 35 47 49 55 59 61
1061129 1 41
1820629 2 43 59
1950323 1 59
580471 1 37
1555907 2 17 55
657707 3 36 41 59
1937917 5 19 31 32 34 51
1397861 3 33 5...

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
4
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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 262144 tokens

Test #14:

score: 0
Accepted
time: 1029ms
memory: 688880kb

input:

262144
475249 7 37 45 51 53 57 61 63
849074 7 36 38 40 41 46 53 56
1457041 4 23 25 47 49
989474 1 35
75121 1 49
1966457 1 37
729033 4 33 37 41 63
1793533 1 51
1997439 4 33 43 57 59
233986 2 33 43
1658191 6 1 15 21 37 47 51
191206 6 13 41 43 55 59 63
1580539 4 41 42 46 61
881501 1 37
1107065 8 33 43 ...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 262144 tokens

Test #15:

score: 0
Accepted
time: 1061ms
memory: 688928kb

input:

262144
1780798 1 49
1789949 8 33 35 39 43 47 53 55 63
2046821 7 17 33 39 45 47 61 63
1223889 5 1 39 43 49 59
1342617 3 33 39 53
1931975 5 39 41 43 59 61
1883454 8 35 38 40 43 45 53 54 56
530049 1 47
2031474 4 35 41 53 57
1915235 1 39
94030 3 47 51 57
985970 3 29 57 63
138515 5 5 19 23 33 45
1879066 ...

output:

2
3
3
3
3
3
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
2
3
2
3
3
3
2
2
3
3
3
3
3
3
3
3
3
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
2
3
3
3
3
3
3
2
3
3
3
2
3
3
2
3
3
3
3
2
3
3
3
3
3
2
3
3
3
3
2
3
3
3
2
3
3
3
3
3
2
3
3
3
3
3
2
3
3
2
3
2
3
3
2
2
3
3
3
3
3
3
2
3
3
3
3
3
3
3
3
3
3
3
2
3
3
3
2
3
3
3
3
2
2
3
3
3
3
3
...

result:

ok 262144 tokens

Test #16:

score: 0
Accepted
time: 1293ms
memory: 689232kb

input:

262144
29272 1 55
1899573 3 36 40 56
1694145 5 46 51 56 57 61
1507390 4 35 47 57 59
1913469 3 57 59 63
1830846 2 41 50
1638766 3 35 43 47
1037738 5 33 41 47 59 63
1635590 7 37 39 43 47 51 53 55
742743 8 37 39 41 47 51 57 59 61
1486070 7 33 35 41 43 47 53 59
1094196 3 41 51 55
900604 3 43 45 49
37847...

output:

3
3
3
3
3
3
3
2
2
3
2
3
3
3
3
4
3
3
3
2
3
2
3
3
2
3
3
3
3
3
3
4
3
4
3
4
4
3
3
2
3
3
2
3
2
2
2
3
3
2
3
2
3
3
2
3
3
3
2
2
3
4
3
3
3
2
3
2
2
2
3
3
3
3
2
3
3
3
2
2
3
4
3
3
4
3
2
3
2
2
3
2
4
2
2
3
2
3
4
3
2
3
3
4
4
2
4
2
4
3
2
3
4
3
2
3
3
2
3
3
4
3
3
4
3
4
3
3
3
3
3
4
3
3
3
2
3
2
2
2
3
2
4
2
3
2
2
3
2
3
...

result:

ok 262144 tokens

Test #17:

score: 0
Accepted
time: 1254ms
memory: 688952kb

input:

262144
1750554 1 45
283311 8 37 41 43 47 51 55 57 59
157339 1 43
1567436 4 41 43 49 59
1529380 1 37
525182 2 33 41
1927140 4 33 44 57 58
1579525 3 45 51 55
1969374 7 33 35 43 45 51 57 63
1726242 3 7 11 27
985308 2 41 61
140568 7 33 35 43 55 57 59 61
1477422 1 33
1484632 7 39 41 45 47 59 61 63
196828...

output:

3
3
4
3
3
3
3
3
2
2
3
2
3
2
3
2
4
2
3
2
3
2
2
2
3
2
3
2
3
3
3
4
4
2
2
2
3
3
3
4
2
2
3
2
3
4
2
3
3
3
2
3
2
2
3
2
3
3
4
3
2
3
3
3
4
3
3
2
3
2
3
3
3
3
4
3
3
3
3
3
2
2
3
3
3
4
2
3
3
3
3
3
3
3
3
2
3
3
3
3
3
3
3
3
2
3
2
3
4
2
2
2
3
3
3
4
3
2
3
3
3
3
3
2
2
3
3
3
2
2
4
2
3
3
3
3
3
3
2
3
3
2
2
2
3
4
4
2
3
2
...

result:

ok 262144 tokens

Test #18:

score: 0
Accepted
time: 1050ms
memory: 689224kb

input:

262144
1575517 8 37 43 49 51 55 57 61 63
1409957 8 37 45 53 55 57 59 61 63
1288769 8 37 41 43 47 49 51 57 59
1929607 8 33 35 41 43 55 57 59 63
1896331 8 37 41 47 51 53 57 61 63
473009 8 8 16 21 23 32 45 53 61
287821 8 35 39 43 45 47 49 57 61
732889 8 39 40 51 52 53 55 59 64
1430089 8 35 39 41 45 49 ...

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

result:

ok 262144 tokens

Test #19:

score: 0
Accepted
time: 1057ms
memory: 689228kb

input:

262144
2068397 8 35 41 43 49 51 55 59 61
2007935 8 41 43 45 49 51 53 57 59
1484547 8 33 35 38 43 45 49 52 53
1382969 8 33 35 37 41 45 49 53 59
2002379 8 3 17 19 33 35 47 57 61
2043139 8 17 19 29 33 51 53 55 63
2085239 8 33 35 39 47 55 57 59 61
1781797 8 37 41 43 45 47 53 57 59
1220721 8 33 35 41 45 ...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 262144 tokens

Test #20:

score: 0
Accepted
time: 1065ms
memory: 688932kb

input:

262144
1540382 5 8 22 35 38 41
1075954 1 9
315357 1 9
1753332 2 8 35
1740559 2 8 50
1655255 2 36 62
950813 1 21
1362719 1 7
1663869 6 1 6 13 32 61 62
1743262 4 9 24 26 57
1842557 2 7 55
810834 5 14 17 21 52 56
1835988 3 26 27 34
1653549 1 41
642676 2 20 21
944378 4 17 23 34 56
1957034 3 21 54 55
191...

output:

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

result:

ok 262144 tokens

Test #21:

score: 0
Accepted
time: 1049ms
memory: 688884kb

input:

262141
1765576 1 5
995873 2 21 30
894245 4 1 11 23 26
893593 5 3 13 14 27 32
1717612 1 5
413456 2 17 28
295956 3 15 27 32
356817 3 20 22 29
65121 5 11 13 14 15 18
893840 3 5 16 18
203629 2 20 21
928467 3 4 12 15
612032 1 14
1163038 2 10 23
1992866 1 18
255902 3 17 21 29
146825 1 7
531108 3 1 8 22
18...

output:

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

result:

ok 262141 tokens

Test #22:

score: 0
Accepted
time: 1081ms
memory: 688900kb

input:

262142
2037564 4 33 53 54 63
697482 2 41 57
408390 1 34
1199739 5 34 40 46 50 58
938094 3 54 59 62
964319 7 45 50 52 55 56 59 62
214917 1 45
1308020 1 64
283389 1 46
117497 1 35
1034111 2 43 56
1667640 3 37 43 58
555910 6 44 47 48 49 62 63
1657795 1 50
206804 1 33
1788261 6 34 42 52 56 59 60
1057631...

output:

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

result:

ok 262142 tokens

Test #23:

score: 0
Accepted
time: 1163ms
memory: 688932kb

input:

262141
471200 1 53
249329 4 35 41 59 61
450598 1 49
1096921 2 53 59
1421607 1 43
926740 2 33 59
1527280 4 41 47 57 59
344274 5 35 37 43 45 55
47512 2 39 49
36626 5 33 37 39 47 59
1155924 2 51 63
664099 2 35 55
972545 1 45
1416432 5 33 35 37 47 59
165306 3 49 51 61
1091065 1 53
1286366 2 33 59
288469...

output:

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

result:

ok 262141 tokens

Test #24:

score: 0
Accepted
time: 1106ms
memory: 688948kb

input:

262140
1508641 7 28 31 34 36 43 61 62
1759322 7 1 22 34 37 48 57 62
329439 7 2 19 24 26 37 41 51
2082019 8 8 11 16 30 47 51 56 58
824802 7 6 18 24 31 35 38 59
1894470 7 8 15 24 26 31 39 57
787377 7 2 4 5 21 23 52 62
1242303 7 1 4 6 35 47 51 62
2082172 7 4 8 12 14 23 28 34
19868 8 9 23 27 35 36 40 46...

output:

3
2
3
1
2
2
2
2
2
2
2
2
3
1
3
3
2
3
2
2
2
2
3
2
2
1
3
3
1
3
3
3
2
3
2
3
2
2
2
3
2
2
2
2
2
3
2
1
2
2
2
3
1
3
3
3
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
3
1
1
2
1
3
2
2
3
2
3
1
2
2
2
3
2
2
2
1
2
1
2
2
1
3
1
1
2
3
2
2
3
2
2
1
2
2
2
2
2
2
2
3
3
2
2
3
2
2
3
3
2
2
2
3
2
3
2
3
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
...

result:

ok 262140 tokens

Test #25:

score: 0
Accepted
time: 1067ms
memory: 689232kb

input:

262063
846837 4 20 37 53 55
907056 6 8 26 39 43 49 57
333809 2 29 35
734788 3 11 31 55
433196 4 15 31 58 64
57181 1 51
992982 5 15 20 24 29 61
236676 5 2 10 32 42 49
871320 3 22 48 60
761494 2 15 29
370290 6 5 13 32 40 60 62
897382 2 46 58
1005520 1 5
15551 6 1 7 20 27 46 63
303266 1 8
736582 2 35 4...

output:

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

result:

ok 262063 tokens

Test #26:

score: 0
Accepted
time: 1046ms
memory: 688944kb

input:

262124
1846841 2 28 48
1919199 4 11 20 23 53
1083016 1 36
1155633 2 44 45
1278282 2 9 48
1860121 5 3 37 48 49 56
1886674 1 37
1073824 3 20 35 58
1923778 3 4 34 50
1355623 6 1 39 42 45 51 56
1751908 4 20 23 49 54
1153008 2 10 37
1453477 2 56 61
1721600 3 30 43 62
1666095 1 15
1214047 4 23 31 42 51
19...

output:

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

result:

ok 262124 tokens

Test #27:

score: 0
Accepted
time: 1028ms
memory: 688936kb

input:

262133
1849834 1 6
75455 2 1 41
1323543 1 23
1331735 1 4
1585945 1 3
791053 1 62
1868546 1 63
1467670 2 40 52
244703 1 32
1243005 2 41 51
321897 1 43
915154 1 40
575914 1 49
328420 1 20
1704229 1 4
1246125 1 23
2025723 1 23
2014366 1 57
166168 2 1 17
1735167 1 36
588547 1 23
1375773 1 6
1942224 1 27...

output:

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

result:

ok 262133 tokens

Test #28:

score: 0
Accepted
time: 2056ms
memory: 688932kb

input:

262143
1197576 6 9 38 42 59 62 64
456036 3 28 29 39
429870 2 46 54
1032784 6 27 31 39 40 41 50
1533936 6 11 32 47 49 51 57
1464528 4 7 24 48 59
506175 6 29 31 34 39 45 61
611760 3 26 28 38
1954620 3 16 25 56
2066324 6 13 17 22 28 35 47
846832 6 8 14 20 38 56 64
873639 6 5 11 17 21 46 47
176988 5 15 ...

output:

4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
...

result:

ok 262143 tokens

Test #29:

score: 0
Accepted
time: 2711ms
memory: 689012kb

input:

262143
667032 7 2 27 34 37 41 51 59
1329732 7 12 25 37 38 41 50 51
555148 7 23 43 47 53 54 56 63
577449 7 3 5 41 52 53 55 63
521696 7 14 28 34 35 44 45 48
1830888 7 9 29 30 35 43 58 63
1916352 7 17 23 36 37 43 47 57
871792 7 2 5 25 38 41 57 61
1996544 7 17 19 31 40 47 58 64
1066268 7 4 18 21 35 40 4...

output:

4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
...

result:

ok 262143 tokens

Test #30:

score: 0
Accepted
time: 3165ms
memory: 688940kb

input:

262143
269240 8 25 29 37 40 43 50 57 64
691540 8 1 23 24 40 47 56 57 59
1779320 8 4 8 27 28 31 41 49 59
1124648 8 1 16 28 31 46 49 59 61
1392024 8 3 14 19 25 26 31 45 47
394821 8 1 3 11 13 23 29 49 50
648464 8 10 29 31 32 43 52 53 59
1361325 8 11 15 43 44 45 53 55 57
332992 8 10 21 28 29 37 45 52 61...

output:

4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
...

result:

ok 262143 tokens

Test #31:

score: 0
Accepted
time: 1417ms
memory: 689236kb

input:

262143
1461825 3 11 23 49
1181568 1 58
729306 1 15
1483160 1 36
1674808 1 20
825632 3 19 22 57
813967 3 5 32 41
710040 1 2
35144 1 5
898821 1 63
136125 1 37
560600 1 64
368433 1 45
1885580 1 29
429375 2 17 29
932496 1 47
1819827 3 5 27 53
1671390 1 45
343860 1 9
1979955 1 60
298035 3 5 23 43
1139944...

output:

4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
...

result:

ok 262143 tokens

Extra Test:

score: 0
Extra Test Passed