#include <bits/stdc++.h>
 using namespace std;
 inline int min(int _a, int _b) { return _a < _b ? _a : _b; }
 inline int max(int _a, int _b) { return _a > _b ? _a : _b; }
 template <class _T>
 inline void rd(_T &_a) {
   int _f = 0, _ch = getchar();
   _a = 0;
   while (_ch < '0' || _ch > '9') {
     if (_ch == '-') _f = 1;
     _ch = getchar();
   }
   while (_ch >= '0' && _ch <= '9') _a = _a * 10 + _ch - '0', _ch = getchar();
   if (_f) _a = -_a;
 }
 const int inf = 0x3f3f3f3f;
 const double eps = 1e-8;
 const int mod = 1e9 + 7, N = 15;
 int mp[N][N], f[N][N], ct[N], n, m, k, ans;
 void dfs(int x, int y) {
   if (y > m) x++, y = 1;
   if (x > n) {
     ans++;
     ans %= mod;
     return;
   }
   int st = f[x - 1][y] | f[x][y - 1], pre, d = -1;
   if (n + m - x - y + 1 > k - __builtin_popcount(st)) return;
   for (int i = 1; i <= k; i++)
     if (!(st >> i - 1 & 1) && (!mp[x][y] || mp[x][y] == i)) {
       f[x][y] = st | (1 << i - 1);
       ct[i]++;
       if (ct[i] == 1) {
         if (~d)
           ans += d;
         else {
           pre = ans;
           dfs(x, y + 1);
           d = ans - pre;
         }
       } else
         dfs(x, y + 1);
       ans %= mod;
       ct[i]--;
     }
 }
 int main() {
   rd(n);
   rd(m);
   rd(k);
   if (n + m - 1 > k) return puts( 0 ), 0;
   for (int i = 1; i <= n; i++)
     for (int j = 1; j <= m; j++) {
       rd(mp[i][j]);
       if (mp[i][j]) ct[mp[i][j]]++;
     }
   dfs(1, 1);
   printf( %d , ans);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int a, b, n, m;
 int A[100010], B[100010], L[100010];
 double dis(int a, int b, int c, int d) {
   return sqrt(
       double((a - c + 0.0) * (a - c + 0.0) + (b - d + 0.0) * (b - d + 0.0)));
 }
 double getK(int y) { return 1.0 * y * a / (b * 1.0); }
 int find(double xx) {
   int x = xx;
   return upper_bound(A, A + n, x) - A;
 }
 int main() {
   int ll, rr, id;
   double ans = 0, tmp;
   scanf( %d%d%d%d , &n, &m, &a, &b);
   for (int i = 0; i < n; i++) scanf( %d , A + i);
   for (int i = 0; i < m; i++) scanf( %d , B + i);
   for (int i = 0; i < m; i++) scanf( %d , L + i);
   ll = rr = 0;
   ans = dis(0, 0, a, A[0]) + dis(a, A[0], b, B[0]) + L[0];
   for (int i = 0; i < m; i++) {
     double k = getK(B[i]);
     id = find(k);
     id = max(0, id - 2);
     for (int j = id; j < n && j <= id + 4; j++) {
       tmp = dis(0, 0, a, A[j]) + dis(a, A[j], b, B[i]) + 1.0 * L[i];
       if (tmp < ans) ans = tmp, ll = j, rr = i;
     }
   }
   printf( %d %d
 , ll + 1, rr + 1);
 }


#include <bits/stdc++.h>
 using namespace std;
 long long int base(long long int n, long long int k) {
   string res =   ;
   long long int temp = 0, i;
   while (n >= k) {
     res += to_string(n % k);
     n /= k;
   }
   res += to_string(n);
   reverse(res.begin(), res.end());
   for (i = 0; i < res.length(); i++) {
     temp = temp * 10 + (res[i] - '0');
   }
   return temp;
 }
 int main() {
   long long int n, i, j, flag = 0;
   cin >> n;
   flag = 9;
   for (i = 1; i <= n - 1; i++) {
     for (j = 1; j <= n - 1; j++) {
       cout << base(i * j, n) <<    ;
     }
     cout << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAXM = 2e5 + 3, MAXN = 2e5 + 3, MAXQ = 2e5 + 3, MAXC = 2e5 + 3,
           ADD = 1 << 18;
 int n, m, q;
 int edge_from[MAXM << 1], edge_to[MAXM << 1], edge_nex[MAXM << 1];
 int cntm = 1, head[MAXN];
 void link(int from, int to) {
   edge_from[++cntm] = from;
   edge_to[cntm] = to;
   edge_nex[cntm] = head[from];
   head[from] = cntm;
 }
 bool isb[MAXM << 1];
 int edge1_to[MAXC << 1], edge1_nex[MAXC << 1];
 int cntm1 = 0, head1[MAXC];
 void link1(int from, int to) {
   edge1_to[++cntm1] = to;
   edge1_nex[cntm1] = head1[from];
   head1[from] = cntm1;
 }
 int dfn[MAXN], low[MAXN], cntd = 0;
 void tarjan(int now, int fa) {
   low[now] = dfn[now] = ++cntd;
   for (int i = head[now]; i; i = edge_nex[i]) {
     if ((i ^ 1) == fa) continue;
     if (!dfn[edge_to[i]]) {
       tarjan(edge_to[i], i);
       if (low[edge_to[i]] > low[now]) {
         isb[i] = isb[i ^ 1] = 1;
       } else {
         low[now] = low[edge_to[i]];
       }
     } else {
       low[now] = min(low[now], low[edge_to[i]]);
     }
   }
 }
 int col[MAXN], cntc = 0, Fa[MAXC][23], Deep[MAXC], cntd1 = 0;
 void dfs(int now) {
   col[now] = cntc;
   for (int i = head[now]; i; i = edge_nex[i])
     if (!col[edge_to[i]] && !isb[i]) dfs(edge_to[i]);
 }
 void dfs2(int now) {
   for (int i = head1[now]; i; i = edge1_nex[i]) {
     if (!Deep[edge1_to[i]] && edge1_to[i] != Fa[now][0]) {
       Fa[edge1_to[i]][0] = now;
       Deep[edge1_to[i]] = Deep[now] + 1;
       dfs2(edge1_to[i]);
     }
   }
 }
 long long val1[MAXN];
 long long sum1;
 bool Arr[MAXN];
 int ans = 1;
 void dfs3(int now) {
   if (!ans) return;
   Arr[now] = 1;
   long long in1 = sum1;
   sum1 += val1[now];
   for (int i = head1[now]; i; i = edge1_nex[i])
     if (!Arr[edge1_to[i]] && ans) dfs3(edge1_to[i]);
   in1 = sum1 - in1;
   if ((in1 >> 18) && in1 - ((in1 >> 18) << 18)) ans = 0;
 }
 inline int lca(register int A, register int B) {
   if (Deep[A] < Deep[B]) swap(A, B);
   for (int i = 17; i >= 0; i--) {
     if (Deep[Fa[A][i]] >= Deep[B]) A = Fa[A][i];
   }
   if (A == B) return A;
   for (int i = 17; i >= 0; i--) {
     if (Fa[A][i] != Fa[B][i]) {
       A = Fa[A][i];
       B = Fa[B][i];
     }
   }
   if (Fa[A][0] == Fa[B][0] && Fa[A][0] != 0) return Fa[A][0];
   return -1;
 }
 int main() {
   ios::sync_with_stdio(false);
   cin >> n >> m >> q;
   for (int i = 1, U, V; i <= m; i++) {
     cin >> U >> V;
     link(U, V);
     link(V, U);
   }
   for (int i = 1; i <= n; i++)
     if (!dfn[i]) tarjan(i, 0);
   for (int i = 1; i <= n; i++)
     if (!col[i]) {
       cntc++;
       dfs(i);
     }
   for (int i = 2; i <= cntm; i++)
     if (isb[i]) link1(col[edge_from[i]], col[edge_to[i]]);
   for (int i = 1; i <= cntc; i++)
     if (!Deep[i]) {
       Deep[i] = 1;
       dfs2(i);
     }
   for (int i = 1; i <= 17; i++)
     for (int j = 1; j <= cntc; j++) Fa[j][i] = Fa[Fa[j][i - 1]][i - 1];
   for (int i = 1, i2, i3, i4; i <= q; i++) {
     cin >> i2 >> i3;
     i2 = col[i2];
     i3 = col[i3];
     if (i2 == i3) continue;
     i4 = lca(i2, i3);
     if (i4 == -1) {
       ans = 0;
       break;
     }
     val1[i2] += 1;
     val1[i4] -= 1;
     val1[i3] += ADD;
     val1[i4] -= ADD;
   }
   for (int i = 1; i <= cntc; i++)
     if (!Arr[i]) dfs3(i);
   if (ans)
     cout <<  Yes ;
   else
     cout <<  No ;
 }


#include <bits/stdc++.h>
 using namespace std;
 int adj[205][205];
 int rgraph[205][205];
 int n, m;
 int parent[205];
 bool visited[205];
 int a[105];
 int b[105];
 bool bfs(int s, int t) {
   memset(visited, 0, sizeof(visited));
   queue<int> q;
   q.push(s);
   visited[s] = true;
   parent[s] = -1;
   while (!q.empty()) {
     int u = q.front();
     q.pop();
     for (int i = 0; i <= 2 * n + 1; i++) {
       if (!visited[i] && rgraph[u][i] > 0) {
         q.push(i);
         parent[i] = u;
         visited[i] = true;
       }
     }
   }
   return visited[t] == true;
 }
 int solve(int s, int t) {
   for (int i = 0; i <= 2 * n + 1; i++) {
     for (int j = 0; j <= 2 * n + 1; j++) {
       rgraph[i][j] = adj[i][j];
     }
   }
   int max_flow = 0;
   while (bfs(0, 2 * n + 1)) {
     int path = 2000000000;
     for (int i = t; i != s; i = parent[i]) {
       int u = parent[i];
       path = min(path, rgraph[u][i]);
     }
     for (int i = t; i != s; i = parent[i]) {
       int u = parent[i];
       rgraph[u][i] -= path;
       rgraph[i][u] += path;
     }
     max_flow += path;
   }
   return max_flow;
 }
 int main() {
   cin >> n >> m;
   int suma = 0, sumb = 0;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
     adj[0][i] = a[i];
     suma += a[i];
   }
   for (int i = 1; i <= n; i++) {
     cin >> b[i];
     adj[n + i][2 * n + 1] = b[i];
     sumb += b[i];
     adj[i][n + i] = 1000000;
   }
   for (int i = 0; i < m; i++) {
     int c, d;
     cin >> c >> d;
     adj[c][n + d] = 1000000;
     adj[d][n + c] = 1000000;
   }
   int ans = solve(0, 2 * n + 1);
   if (ans == suma && ans == sumb) {
     printf( YES
 );
     for (int i = 1; i <= n; i++) {
       for (int j = 1; j <= n; j++) {
         if (rgraph[i][n + j] != 0)
           printf( %d  , 1000000 - rgraph[i][n + j]);
         else
           printf( %d  , rgraph[i][n + j]);
       }
       printf(
 );
     }
   } else {
     printf( NO
 );
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int32_t main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   long long t;
   t = 1;
   for (long long test = 1; test <= t; test++) {
     long long n;
     cin >> n;
     vector<long long> a;
     for (long long i = 0; i <= n - 1; i++) {
       long long x;
       cin >> x;
       if (x != 0) a.push_back(x);
     }
     long long bits[61] = {0};
     n = a.size();
     for (long long i = 0; i <= n - 1; i++) {
       long long temp = a[i];
       long long j = 0;
       while (temp > 0) {
         if (temp & 1) bits[j]++;
         temp = temp >> 1;
         j++;
       }
     }
     for (long long i = 0; i <= 60; i++)
       if (bits[i] >= 3) {
         cout << 3;
         exit(0);
       }
     long long cyclec = -1;
     vector<vector<long long>> adj(n);
     for (long long i = 0; i < n; i++)
       for (long long j = i + 1; j < n; j++)
         if ((a[i] & a[j]) != 0) {
           adj[i].push_back(j);
           adj[j].push_back(i);
         }
     for (long long i = 0; i <= n - 1; i++)
       if (adj[i].size() != 0) {
         vector<long long> dis(n, -1);
         vector<long long> par(n, -1);
         queue<long long> q;
         q.push(i);
         dis[i] = 0;
         par[i] = -1;
         while (!q.empty()) {
           auto x = q.front();
           q.pop();
           for (auto y : adj[x])
             if (dis[y] == -1) {
               dis[y] = 1 + dis[x];
               par[y] = x;
               q.push(y);
             } else if (y != par[x]) {
               if (cyclec == -1)
                 cyclec = (dis[y] + dis[x] + 1);
               else
                 cyclec = min(cyclec, dis[y] + dis[x] + 1);
             }
         }
       }
     cout << cyclec;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long N = 200001;
 std::vector<long long> g[N];
 long long s[N];
 long long h[N];
 long long a[N] = {0};
 bool visited[N] = {false};
 void dfs1(long long n, long long parent, long long depth) {
   h[n] = depth;
   for (long long v : g[n]) {
     if (v != parent) {
       dfs1(v, n, depth + 1);
     }
   }
 }
 void dfs2(long long n, long long parent) {
   if (h[n] % 2 == 0) {
     for (long long v : g[n]) {
       if (v != parent) {
         a[n] = s[v] - s[parent];
       }
     }
     for (long long v : g[n]) {
       if (v != parent) {
         a[n] = min(s[v] - s[parent], a[n]);
       }
     }
     s[n] = a[n] + s[parent];
   } else {
     a[n] = s[n] - s[parent];
   }
   for (long long v : g[n]) {
     if (v != parent) {
       dfs2(v, n);
     }
   }
 }
 int main() {
   long long n;
   cin >> n;
   for (long long i = 2; i <= n; i++) {
     long long parent;
     cin >> parent;
     g[parent].push_back(i);
     g[i].push_back(parent);
   }
   for (long long i = 1; i <= n; i++) {
     cin >> s[i];
   }
   dfs1(1, -1, 1);
   a[1] = s[1];
   dfs2(1, n + 1);
   long long sum = 0;
   for (long long i = 1; i <= n; i++) {
     if (a[i] < 0) {
       cout <<  -1  << endl;
       return 0;
     }
     sum += a[i];
   }
   cout << sum << endl;
 }


#include <bits/stdc++.h>
 template <typename C>
 int sz(const C &c) {
   return c.size();
 }
 using namespace std;
 int main() {
   iostream::sync_with_stdio(false);
   int64_t n;
   cin >> n;
   int k;
   cin >> k;
   int64_t maxV = 0;
   int maxI = 1;
   int64_t maxC = 0;
   for (int i = 1; i <= k; ++i) {
     int64_t a;
     cin >> a;
     if (a * (n / a) > maxV) {
       maxV = a * (n / a);
       maxI = i;
       maxC = n / a;
     }
   }
   cout << maxI <<     << maxC <<
 ;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long a[10], rest[10];
 int n, res = 1e9, pre[10], tmp, size[10], flag = 0;
 vector<int> ve[10];
 map<long long, long long> mp;
 int count(long long x) {
   if (mp[x]) return mp[x];
   long long tmp = x;
   long long res = 0;
   for (long long i = 2; i * i <= x; i++) {
     if (x % i == 0) {
       while (x % i == 0) {
         x /= i;
         res++;
       }
     }
   }
   if (x > 1) res++;
   return mp[tmp] = res;
 }
 bool prime(long long x) {
   if (x == 2 || x == 3) return true;
   for (long long i = 2; i * i <= x; i++)
     if (x % i == 0) return false;
   return true;
 }
 int isprime[10] = {0};
 void cal(int now) {
   tmp++;
   if (size[now] == 0) {
     if (!isprime[now]) tmp += count(a[now]);
     return;
   }
   if (now) {
     if (rest[now]) tmp += count(rest[now]);
   }
   for (int i = 0; i < size[now]; i++) {
     cal(ve[now][i]);
     if (flag) return;
   }
 }
 void dfs(int pos) {
   if (pos == n + 1) {
     tmp = 0;
     flag = 0;
     for (int i = 0; i <= n; i++) {
       ve[i].clear();
       size[i] = 0;
     }
     for (int i = 1; i <= n; i++) {
       size[pre[i]]++;
       ve[pre[i]].push_back(i);
     }
     cal(0);
     if (size[0] == 1) {
       tmp -= 1;
     }
     if (flag) tmp = 1e9;
     if (tmp < res) {
       res = tmp;
     }
     return;
   }
   for (int i = 0; i < pos; i++) {
     if (i && rest[i] % a[pos]) continue;
     rest[i] = rest[i] / a[pos];
     pre[pos] = i;
     dfs(pos + 1);
     rest[i] *= a[pos];
   }
 }
 int main() {
   scanf( %d , &n);
   for (int i = 1; i <= n; i++) scanf( %lld , a + i);
   sort(a + 1, a + n + 1, greater<long long>());
   for (int i = 1; i <= n; i++) {
     rest[i] = a[i];
     if (prime(a[i])) isprime[i] = 1;
   }
   dfs(1);
   printf( %d
 , res);
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m, INF = 2e9;
 vector<vector<int>> value;
 void shift_column(int j, int k) {
   vector<int> res(n);
   for (int i = 0; i < n; i++) res[(i - k + n) % n] = value[i][j];
   for (int i = 0; i < n; i++) value[i][j] = res[i];
 }
 void run() {
   cin >> n >> m;
   value.resize(n, vector<int>(m));
   for (int i = 0; i < n; i++) {
     for (int j = 0; j < m; j++) {
       cin >> value[i][j];
     }
   }
   int ans = 0;
   for (int j = 0; j < m; j++) {
     map<int, int> pos;
     vector<int> cnt(n);
     for (int i = 0; i < n; i++) pos[1 + j + i * m] = i;
     for (int i = 0; i < n; i++) {
       if (pos.find(value[i][j]) == pos.end()) continue;
       int shift = (i - pos[value[i][j]] + n) % n;
       cnt[shift]++;
     }
     auto best_shift =
         distance(cnt.begin(), max_element(cnt.begin(), cnt.end()));
     shift_column(j, best_shift);
     int best_add = INF;
     for (int i = 0; i < n; i++) best_add = min(best_add, n - cnt[i] + i);
     ans += best_add;
   }
   cout << ans;
 }
 signed main() {
   cout.setf(ios::fixed);
   cout.precision(10);
   cin.tie(0);
   cout.tie(0);
   ios::sync_with_stdio(0);
   run();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m, a[300100], b[300100], pos[300100];
 vector<pair<int, int> > ans;
 inline void ws(int xx, int yy) { ans.push_back(make_pair(xx, yy)); }
 int main() {
   scanf( %d , &n);
   for (int i = 1; i <= n; ++i) {
     scanf( %d , &a[i]);
     pos[a[i]] = i;
   }
   if (a[1] != 1) {
     int p = pos[1];
     int x = a[1];
     if (p - 1 >= n / 2) {
       ws(1, p);
       a[1] = 1;
       pos[1] = 1;
       pos[x] = p;
       a[p] = x;
     } else if (n - p >= n / 2) {
       ws(p, n);
       ws(1, n);
       ws(p, n);
       a[1] = 1;
       pos[1] = 1;
       pos[x] = p;
       a[p] = x;
     }
   }
   if (a[n] != n) {
     int p = pos[n];
     int x = a[1];
     int z = a[n];
     if (p - 1 >= n / 2) {
       ws(1, p);
       ws(1, n);
       ws(1, p);
       a[p] = z;
       pos[z] = p;
       pos[n] = n;
       a[n] = n;
     } else if (n - p >= n / 2) {
       ws(p, n);
       a[p] = z;
       pos[z] = p;
       pos[n] = n;
       a[n] = n;
     }
   }
   for (int i = 2; i < n; ++i) {
     if (pos[i] == i) continue;
     int p = pos[i];
     int x = a[1];
     int y = a[i];
     int z = a[n];
     if (p - 1 >= n / 2 && i - 1 >= n / 2) {
       ws(1, p);
       ws(1, i);
       ws(1, p);
       swap(a[i], a[pos[i]]);
       pos[y] = p;
       pos[i] = i;
     } else if (p - 1 >= n / 2 && n - i >= n / 2) {
       ws(1, p);
       ws(1, n);
       ws(i, n);
       ws(1, n);
       ws(1, p);
       swap(a[i], a[p]);
       pos[y] = p;
       pos[i] = i;
     } else if (n - p >= n / 2 && i - 1 >= n / 2) {
       ws(p, n);
       ws(1, n);
       ws(1, i);
       ws(1, n);
       ws(p, n);
       swap(a[i], a[p]);
       pos[y] = p;
       pos[i] = i;
     } else if (n - p >= n / 2 && n - i >= n / 2) {
       ws(p, n);
       ws(i, n);
       ws(p, n);
       swap(a[i], a[p]);
       pos[y] = p;
       pos[i] = i;
     }
   }
   printf( %d
 , ans.size());
   for (int i = 0; i < ans.size(); ++i) {
     printf( %d %d
 , ans[i].first, ans[i].second);
   }
 }


#include <bits/stdc++.h>
 #pragma GCC optimize( Ofast )
 #pragma GCC optimize( no-stack-protector )
 #pragma GCC optimize( unroll-loops )
 #pragma GCC target( sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native )
 #pragma GCC optimize( fast-math )
 using namespace std;
 inline void ForSpeed() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
 }
 const int MAXN = int(1e5 + 5);
 const int inf = 1e9 + 7;
 const int MOD = 998244353;
 const long long INF = (1e18 + 7);
 long long b, k, a[MAXN];
 int main() {
   ForSpeed();
   cin >> b >> k;
   for (int i = 0; i < k; i++) {
     cin >> a[i];
   }
   if (k == 1) {
     if (a[0] % 2 != 0 && b % 2 != 0) {
       cout <<  odd ;
       return 0;
     }
   }
   if (b % 2 == 0 && a[k - 1] % 2 == 0) {
     cout <<  even ;
     return 0;
   } else if (b % 2 == 0 && a[k - 1] % 2 != 0) {
     cout <<  odd ;
     return 0;
   }
   long long ch = 0;
   if (a[0] % 2 == 0) {
     ch = 1;
   }
   for (int i = 1; i < k - 1; i++) {
     if (ch == 0 && a[i] % 2 != 0) {
       ch = 1;
     } else if (ch == 1 && a[i] % 2 == 0) {
       continue;
     } else {
       ch = 0;
     }
   }
   if (ch == 1 && a[k - 1] % 2 == 0) {
     cout <<  even ;
   } else if (ch == 0 && a[k - 1] % 2 != 0) {
     cout <<  even ;
   } else {
     cout <<  odd ;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int mod =  1000000007;
 const int LIM = 100005;
 #define int long long
 #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define mem(a,b) memset(a,b,sizeof(a))
 #define all(a) a.begin() , a.end()
 #define pii pair<int,int>
 #define vi vector<int>
 #define endl '
'
 #define pb push_back
 #define sp <<   <<
 #define ss second
 #define ff first
 int power(int x, int n){
     int res = 1;
     while(n){
           if(n&1){
                 res = res * x % mod;
           }
           x = x * x % mod;
           n>>=1;
     }
     return (res%mod);
 }
 /*bool prime[1000006];
 void sieve(int n)
 {
       memset(prime, true, sizeof(prime));
       int rootn = (int)sqrt(n);
       for (int p = 2; p <= rootn; p++)
             if(prime[p] == true)
                   for(int i = p*p; i <= n; i += p)
                         prime[i] = false;
       prime[1] = 0;

 }*/
 /*
 int fac[300005];
 int ncr(int n,int r)
 {
       return fac[n]*((power(fac[n-r], mod-2)*power(fac[r], mod-2))%mod)%mod;
 }
 */
 bool check(int a[],int n)
 {
 	for(int i=1;i<n;i++)
 	{
 		if(a[i]<a[i-1])return false;
 	}
 	return true;
 }

 int32_t main()
 {
   IOS;
   int tt=1,n,x,k,y,z,i,j;
   cin>>tt;
   while(tt--){
     cin>>n>>x;
 		int a[n];
 		for(int i=0;i<n;i++)
 		{
 			cin>>a[i];
 		}
 		int ans=0;
 		for(int i=0;i<=n;i++)
 		{
 			if(check(a,n))break;
 			ans++;
 			for(int j=0;j<n;j++)
 			{
 				if(a[j]>x)
 				{
 					swap(a[j],x);
 					break;
 				}
 			}
 		}
 		if(check(a,n))cout<<ans<<endl;
 		else cout<<-1<<endl;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 bool debug = 0;
 int n, m, k;
 int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
 string direc =  RDLU ;
 long long ln, lk, lm;
 void etp(bool f = 0) {
   puts(f ?  YES  :  NO );
   exit(0);
 }
 void addmod(int &x, int y, int mod = 1000000007) {
   assert(y >= 0);
   x += y;
   if (x >= mod) x -= mod;
   assert(x >= 0 && x < mod);
 }
 void et() {
   puts( -1 );
   exit(0);
 }
 long long fastPow(long long x, long long y, int mod = 1000000007) {
   long long ans = 1;
   while (y > 0) {
     if (y & 1) ans = (x * ans) % mod;
     x = x * x % mod;
     y >>= 1;
   }
   return ans;
 }
 long long gcd1(long long x, long long y) {
   long long z = y;
   while (x % y != 0) {
     z = x % y;
     x = y;
     y = z;
   }
   return z;
 }
 int h, u[100005], dp[100005];
 vector<int> mp[100005];
 set<pair<int, int> > cs;
 void add(int x, int y) {
   if (cs.count({x, y})) return;
   cs.insert({x, y});
   mp[x].push_back(y);
 }
 int dfn[100005], sta[100005], low[100005], color, ii, cnt, belong[100005];
 bool ins[100005];
 int sz[100005];
 void tarjan(int x) {
   dfn[x] = low[x] = ++ii;
   sta[++cnt] = x;
   ins[x] = 1;
   for (auto child : mp[x]) {
     if (!dfn[child]) {
       tarjan(child);
       low[x] = min(low[x], low[child]);
     } else if (ins[child]) {
       low[x] = min(low[x], dfn[child]);
     }
   }
   if (dfn[x] == low[x]) {
     ++color;
     int t;
     do {
       t = sta[cnt];
       cnt--;
       ins[t] = 0;
       belong[t] = color;
       sz[color]++;
     } while (dfn[t] != low[t]);
   }
 }
 bool del[100005];
 void fmain(int ID) {
   scanf( %d%d%d , &n, &m, &h);
   for (int(i) = 1; (i) <= (int)(n); (i)++) {
     scanf( %d , u + i);
   }
   for (int(i) = 1; (i) <= (int)(m); (i)++) {
     int x, y;
     scanf( %d%d , &x, &y);
     if ((u[x] + 1) % h == u[y]) add(x, y);
     if ((u[y] + 1) % h == u[x]) add(y, x);
   }
   for (int(i) = 1; (i) <= (int)(n); (i)++)
     if (belong[i] == 0) tarjan(i);
   for (auto p : cs) {
     int x = belong[p.first], y = belong[p.second];
     if (x == y) continue;
     del[x] = 1;
   }
   int ans = -1;
   for (int(i) = 1; (i) <= (int)(color); (i)++)
     if (!del[i]) {
       if (ans == -1 || sz[ans] > sz[i]) ans = i;
     }
   printf( %d
 , sz[ans]);
   for (int(i) = 1; (i) <= (int)(n); (i)++)
     if (belong[i] == ans) printf( %d  , i);
 }
 int main() {
   int t = 1;
   for (int(i) = 1; (i) <= (int)(t); (i)++) {
     fmain(i);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1e5 + 10, V = 1e5;
 inline int read() {
   register int x = 0, f = 0;
   register char c = getchar();
   while (c < '0' || c > '9') f |= c == '-', c = getchar();
   while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
   return f ? -x : x;
 }
 int n, tot, top;
 struct point {
   int x, y;
 } p[N * 10], s[N * 10];
 point operator-(const point &A, const point &B) {
   return (point){A.x - B.x, A.y - B.y};
 }
 inline void add(int x, int y) {
   p[++tot].x = x;
   p[tot].y = y;
 }
 inline double accross(point A, point B) {
   return (double)A.x * B.y - (double)A.y * B.x;
 }
 inline double dis(point A, point B) {
   return (double)(A.x - B.x) * (A.x - B.x) + (double)(A.y - B.y) * (A.y - B.y);
 }
 inline bool cmp1(const point &A, const point &B) {
   return A.x == B.x ? A.y < B.y : A.x < B.x;
 }
 inline bool cmp2(const point &A, const point &B) {
   return A.x == B.x && A.y == B.y;
 }
 inline bool cmp3(const point &A, const point &B) {
   double res = accross(A - p[1], B - p[1]);
   if (res > 0)
     return true;
   else if (res == 0 && dis(A, p[1]) < dis(B, p[1]))
     return true;
   return false;
 }
 void Get_TB() {
   for (int i = 2; i <= tot; ++i)
     if (p[1].y > p[i].y || (p[1].y == p[i].y && p[1].x > p[i].x))
       swap(p[i], p[1]);
   sort(p + 2, p + tot + 1, cmp3);
   s[1] = p[1];
   s[2] = p[2];
   top = 2;
   for (int i = 3; i <= tot; ++i) {
     while (top > 1 && accross(p[i] - s[top - 1], s[top] - s[top - 1]) >= 0)
       top--;
     s[++top] = p[i];
   }
   return;
 }
 inline double len(point &A) {
   return sqrt((double)A.x * A.x + (double)A.y * A.y);
 }
 double calc(point A, point B, point C) {
   point x = A - B, y = C - B, z = C - A;
   double res = len(x) * len(y) * len(z) / (accross(y, x) * 2);
   return res;
 }
 int main() {
   n = read();
   for (int i = 1; i <= n; ++i) {
     int x = read(), y = read(), v = read();
     if (x < v)
       add(0, min(V, y + v - x)), add(0, max(0, y - v + x));
     else
       add(x - v, y);
     if (y < v)
       add(max(0, x - v + y), 0), add(min(V, x + v - y), 0);
     else
       add(x, y - v);
     if (x + v > V)
       add(V, min(V, y + x + v - V)), add(V, max(0, y - x - v + V));
     else
       add(x + v, y);
     if (y + v > V)
       add(min(V, x + y + v - V), V), add(max(0, x - y - v + V), V);
     else
       add(x, y + v);
   }
   sort(p + 1, p + 1 + tot, cmp1);
   tot = unique(p + 1, p + 1 + tot, cmp2) - p - 1;
   Get_TB();
   int id = 0;
   double ans = -1e9, tmp;
   s[0] = s[top];
   s[top + 1] = s[1];
   for (int i = 1; i <= top; ++i) {
     point a = s[i - 1], b = s[i], c = s[i + 1];
     if ((tmp = calc(a, b, c)) > ans) ans = tmp, id = i;
   }
   cout << s[id - 1].x << ' ' << s[id - 1].y << '
';
   cout << s[id].x << ' ' << s[id].y << '
';
   cout << s[id + 1].x << ' ' << s[id + 1].y << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 void init() { freopen( input.txt ,  r , stdin); }
 int abs(int x) {
   if (x < 0) {
     return -x;
   }
   return x;
 }
 int main() {
   int n, m, x1, y1, x2, y2;
   cin >> n >> m >> x1 >> y1 >> x2 >> y2;
   n = abs(x1 - x2) + 1;
   m = abs(y1 - y2) + 1;
   if ((n >= 6) || (m >= 6)) {
     cout <<  Second ;
     return 0;
   }
   if ((n <= 4) && (m <= 4)) {
     cout <<  First ;
     return 0;
   }
   if (((n == 5) || (n == 4)) && ((m == 5) || (m == 4))) {
     cout <<  Second ;
     return 0;
   }
   cout <<  First  << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int gcd(long long a, int b) {
   if (a < b) {
     return gcd(b, a);
   }
   if (b == 0) {
     return a;
   }
   return gcd(b, a % b);
 }
 class Triplet {
  public:
   long long gcd;
   long long x;
   long long y;
 };
 Triplet gcdExtendedEuclid(int a, int b) {
   if (b == 0) {
     Triplet myAns;
     myAns.gcd = a;
     myAns.x = 1;
     myAns.y = 0;
     return myAns;
   }
   Triplet smallAns = gcdExtendedEuclid(b, a % b);
   Triplet myAns;
   myAns.gcd = smallAns.gcd;
   myAns.x = smallAns.y;
   myAns.y = (smallAns.x - ((a / b) * (smallAns.y)));
   return myAns;
 }
 long long modInverse(int A, int M) {
   Triplet ans = gcdExtendedEuclid(A, M);
   return ans.x;
 }
 bool check(vector<long long>& v1, long long val, long long h) {
   long long ans = 0;
   for (long long i = 0; i < v1.size(); i++) {
     ans += v1[i] / val;
     if (v1[i] % val != 0) {
       ans += 1;
     }
   }
   if (ans > h) {
     return false;
   }
   return true;
 }
 void multiply(long long A[2][2], long long M[2][2]) {
   long long firstValue = (A[0][0] * M[0][0] + A[0][1] * M[1][0]) % 1000000007;
   long long secondValue = (A[0][0] * M[0][1] + A[0][1] * M[1][1]) % 1000000007;
   long long thirdValue = (A[1][0] * M[0][0] + A[1][1] * M[1][0]) % 1000000007;
   long long fourthValue = (A[1][0] * M[0][1] + A[1][1] * M[1][1]) % 1000000007;
   A[0][0] = firstValue;
   A[0][1] = secondValue;
   A[1][0] = thirdValue;
   A[1][1] = fourthValue;
   return;
 }
 void getpow(long long A[2][2], long long n) {
   if (n == 0 || n == 1) {
     return;
   }
   getpow(A, n / 2);
   multiply(A, A);
   if (n % 2 != 0) {
     long long first[2][2] = {{1, 1}, {1, 0}};
     multiply(A, first);
   }
   return;
 }
 long long getpow1(long long n, long long m, long long b) {
   if (m == 0) {
     return 1;
   }
   long long ans = getpow1(n, m / 2, b) % b;
   ans = (ans * ans) % b;
   if (m % 2 != 0) {
     ans = ans * n % b;
   }
   return ans % b;
 }
 long long getfib(long long n) {
   if (n == 0) {
     return 0;
   }
   long long A[2][2] = {{1, 1}, {1, 0}};
   getpow(A, n);
   long long first[1][2];
   first[0][0] = 0;
   first[0][1] = 1;
   long long ans = first[0][0] * A[0][0] + first[0][1] * A[1][0];
   return ans % 1000000007;
 }
 vector<long long>* sieve() {
   bool isprime[1000001];
   for (long long i = 0; i < 1000001; i++) {
     isprime[i] = true;
   }
   vector<long long>* primes = new vector<long long>();
   for (long long i = 2; i < 1000001; i++) {
     if (isprime[i] == true) {
       for (long long j = 2 * i; j < 1000001; j += i) {
         isprime[j] = false;
       }
     }
   }
   primes->push_back(2);
   for (long long i = 3; i < 1000001; i++) {
     if (isprime[i] == true) {
       primes->push_back(i);
     }
   }
   return primes;
 }
 long long getpow2(long long a, string& b, long long m) {
   long long mod = 1000000007;
   long long num = 1;
   for (long long i = b.size() - 1; i >= 0; i--) {
     if (b[i] == 1) {
       num = (num * a) % m;
     } else if (b[i] == 2) {
       num = ((num * a) % m * a) % m;
     }
     a = ((a * a) % m * a) % m;
   }
   return num % m;
 }
 long long arr[5000001];
 long long res[1000001];
 long long res1[1000001];
 int main() {
   long long k, n;
   cin >> k >> n;
   long long num = 0;
   long long k1 = k;
   while (k1 < n) {
     k1 *= k;
     num++;
   }
   if (k1 == n) {
     cout <<  YES  << '
';
     cout << num;
     return 0;
   }
   cout <<  NO  << '
';
   return 0;
 }


#include <bits/stdc++.h>
 const long long mod = (long long)1e9 + 7;
 const int maxn = (int)1e5 + 1;
 long long inf = 1LL << 60;
 using namespace std;
 inline void read(int &n) {
   int x = 0, f = 1;
   char ch = getchar();
   while (ch < '0' || ch > '9') {
     if (ch == '-') f = -1;
     ch = getchar();
   }
   while (ch >= '0' && ch <= '9') {
     x = 10 * x + ch - '0';
     ch = getchar();
   }
   n = x * f;
 }
 inline void read(long long &n) {
   long long x = 0, f = 1;
   char ch = getchar();
   while (ch < '0' || ch > '9') {
     if (ch == '-') f = -1;
     ch = getchar();
   }
   while (ch >= '0' && ch <= '9') {
     x = 10ll * x + ch - '0';
     ch = getchar();
   }
   n = x * f;
 }
 int a[20];
 int rule[20][20];
 long long dp[1 << 19][19];
 int bitCount(int n) {
   int count = 0;
   while (n) {
     count++;
     n &= (n - 1);
   }
   return count;
 }
 int main() {
   setlocale(LC_ALL,  Russian );
   ios_base::sync_with_stdio(0);
   int n, m, k;
   cin >> n >> m >> k;
   long long ans = 0;
   for (int i = 0; i < n; i++) {
     cin >> a[i];
   }
   for (int i = 0; i < k; i++) {
     int u, v, d;
     cin >> u >> v >> d;
     u--, v--;
     rule[u][v] = d;
   }
   for (int i = 0; i < n; i++) dp[1 << i][i] = a[i];
   for (int mask = 0; mask < 1 << n; mask++) {
     for (int i = 0; i < n; i++) {
       if (mask & (1 << i)) {
         for (int j = 0; j < n; j++) {
           if (!(mask & (1 << j))) {
             int nmask = mask | (1 << j);
             dp[nmask][j] = max(dp[nmask][j], dp[mask][i] + a[j] + rule[i][j]);
           }
         }
       }
     }
   }
   for (int mask = 0; mask < 1 << n; mask++) {
     for (int i = 0; i < n; i++) {
       if (bitCount(mask) == m) {
         ans = max(ans, dp[mask][i]);
       }
     }
   }
   cout << ans;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 #pragma comment(linker,  /STACK:1024000000,1024000000 )
 const double pi = acos(-1.0), eps = 1e-8;
 const int maxm = 1100000, inf = 0x3f3f3f3f;
 bool f[maxm];
 vector<int> v[maxm];
 int top, st[maxm];
 int a[maxm];
 void dfs(int x, int pre) {
   f[x] = true;
   int i;
   a[x] ^= 1;
   st[top++] = x;
   for (i = 0; i < v[x].size(); i++) {
     if (f[v[x][i]] == false) {
       dfs(v[x][i], x);
       st[top++] = x;
       a[x] ^= 1;
     }
   }
   if (a[x] != 0 && pre != -1) {
     st[top++] = pre;
     a[pre] ^= 1;
     st[top++] = x;
     a[x] ^= 1;
   }
 }
 int main() {
   int n, m, i, x, y, begin;
   while (scanf( %d%d , &n, &m) == 2) {
     for (i = 1; i <= n; i++) v[i].clear();
     while (m--) {
       scanf( %d%d , &x, &y);
       v[x].push_back(y);
       v[y].push_back(x);
     }
     for (i = 1; i <= n; i++) {
       scanf( %d , &a[i]);
       f[i] = false;
     }
     top = 0;
     for (i = 1; i <= n; i++) {
       if (a[i] == 1) {
         dfs(i, -1);
         begin = i;
         break;
       }
     }
     if (i == n + 1) {
       printf( 0
 );
       continue;
     }
     for (i = begin + 1; i <= n; i++) {
       if (a[i] != 0) {
         printf( -1
 );
         break;
       }
     }
     if (i <= n) continue;
     if (a[begin] == 1)
       begin = 1;
     else
       begin = 0;
     printf( %d
 , top - begin);
     for (i = begin; i < top; i++) {
       printf( %d , st[i]);
       if (i == top - 1)
         printf(
 );
       else
         printf(   );
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAX_N = 11111, MAX_M = 222222;
 class Flow_Algorithm {
  public:
   int g[MAX_M], nxt[MAX_M], flow[MAX_M], c[MAX_N], h[MAX_N], nm;
   int d[MAX_N], q[MAX_N];
   int S, T;
   void addedge(int x, int y, int w) {
     g[nm] = y;
     nxt[nm] = c[x];
     c[x] = nm;
     flow[nm] = w;
     nm++;
   }
   void add(int x, int y, int w) {
     addedge(x, y, w);
     addedge(y, x, 0);
   }
   bool bfs() {
     memset(d, -1, sizeof d);
     d[q[1] = S] = 0;
     for (int l = 1, r = 1; l <= r; ++l) {
       int i = q[l];
       for (int k = c[i]; ~k; k = nxt[k]) {
         int j = g[k];
         if (!~d[j] && flow[k]) d[q[++r] = j] = d[i] + 1;
       }
     }
     return d[T] != -1;
   }
   int dfs(int i, int now) {
     if (!now) return 0;
     if (i == T) return now;
     int w = 0;
     for (int &k = c[i]; ~k; k = nxt[k]) {
       int j = g[k];
       if (d[j] == d[i] + 1) {
         int res;
         if (flow[k] && ((res = dfs(j, min(now - w, flow[k]))) > 0)) {
           flow[k] -= res;
           flow[k ^ 1] += res;
           w += res;
           if (w == now) return w;
         }
       }
     }
     return w;
   }
   void sets(int _S, int _T) {
     S = _S;
     T = _T;
     nm = 0;
     memset(c, -1, sizeof c);
   }
   int Dinic() {
     memcpy(h, c, sizeof h);
     int ans = 0;
     while (bfs()) {
       ans += dfs(S, 1000000000);
       memcpy(c, h, sizeof c);
     }
     return ans;
   }
 } G;
 int A[55], B[55], C[55], L[55], R[55];
 int n, m;
 int nd[55][222];
 int calc(int i, int x) { return x * x * A[i] + x * B[i] + C[i]; }
 int main() {
   scanf( %d%d , &n, &m);
   for (int i = (1); i <= (n); ++i) scanf( %d%d%d , &A[i], &B[i], &C[i]);
   for (int i = (1); i <= (n); ++i) scanf( %d%d , &L[i], &R[i]);
   int tot = 0;
   for (int i = (1); i <= (n); ++i)
     for (int j = (L[i] - 1); j <= (R[i]); ++j) nd[i][j + 100] = ++tot;
   int S = tot + 1, T = tot + 2;
   G.sets(S, T);
   for (int i = (1); i <= (n); ++i) {
     G.add(S, nd[i][L[i] - 1 + 100], 1000000000);
     for (int j = (L[i]); j <= (R[i]); ++j)
       G.add(nd[i][j - 1 + 100], nd[i][j + 100], 20000000 - calc(i, j));
     G.add(nd[i][R[i] + 100], T, 1000000000);
   }
   for (int i = (1); i <= (m); ++i) {
     int u, v, d;
     scanf( %d%d%d , &u, &v, &d);
     for (int j = (L[u] - 1); j <= (R[u]); ++j) {
       int p = j - d, pt = 0;
       if (p < L[v])
         pt = nd[v][L[v] - 1 + 100];
       else
         pt = nd[v][p + 100];
       G.add(nd[u][j + 100], pt, 1000000000);
     }
   }
   int ans = G.Dinic();
   ans = n * 20000000 - ans;
   printf( %d
 , ans);
 }


#include <bits/stdc++.h>
 using namespace std;
 constexpr int N = 2e5 + 3;
 vector<int> c[N];
 vector<int> e[N];
 int main() {
   ios_base::sync_with_stdio(false);
   int n, m, q;
   cin >> n >> m >> q;
   for (int it = 0; it < q; ++it) {
     int r, C;
     cin >> r >> C;
     c[r].push_back(C);
   }
   for (int i = 1; i <= n; ++i) {
     int esz = c[i].size();
     for (int j = 1; j < esz; ++j) {
       int prev = c[i][j - 1], now = c[i][j];
       e[prev].push_back(now);
       e[now].push_back(prev);
     }
   }
   vector<int> vis(m + 1, 0);
   int cc = 0;
   for (int i = 1; i <= m; ++i) {
     if (vis[i] == 0) {
       ++cc;
       function<void(int)> dfs = [&](int i) {
         assert(i >= 1 && i <= m);
         if (vis[i] != 0) {
           assert(vis[i] == cc);
           return;
         }
         vis[i] = cc;
         for (int v : e[i]) {
           dfs(v);
         }
       };
       dfs(i);
     }
   }
   int cnt_empty_r = 0;
   for (int i = 1; i <= n; ++i) {
     if (c[i].empty()) {
       ++cnt_empty_r;
     }
   }
   cout << cnt_empty_r + cc - 1 << '
';
 }


#include <bits/stdc++.h>
 using namespace std;
 static const int INF = 0x3f3f3f3f;
 static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
 template <typename T>
 T mulmod(T a, T b, T m) {
   long long int q =
       (long long int)(((long double)a * (long double)b) / (long double)m);
   long long int r = a * b - q * m;
   if (r > m) r %= m;
   if (r < 0) r += m;
   return r;
 }
 template <typename T>
 T MOD(T a, T b) {
   return (a < b ? a : a % b);
 }
 template <typename T>
 T expo(T e, T n) {
   T x = 1, p = e;
   while (n) {
     if (n & 1) x = x * p;
     p = p * p;
     n >>= 1;
   }
   return x;
 }
 template <typename T>
 T power(T e, T n, T m) {
   T x = 1, p = e;
   while (n) {
     if (n & 1) x = mulmod(x, p, m);
     p = mulmod(p, p, m);
     n >>= 1;
   }
   return x;
 }
 template <typename T>
 T gcd(T a, T b) {
   if (a % b) return gcd(b, a % b);
   return b;
 }
 template <typename T>
 T lcm(T a, T b) {
   return (a * (b / gcd(a, b)));
 }
 template <typename T>
 T add(T a, T b, T Mod) {
   a += b;
   return (a >= Mod ? a - Mod : a);
 }
 template <typename T>
 T sub(T a, T b, T Mod) {
   a -= b;
   return (a < 0 ? a + Mod : a);
 }
 const int Mod = 1000000007;
 const int N = 100005;
 int MX = 1000001;
 int a[N];
 struct segmentTree {
   int tree[6 * N];
   int lazy[6 * N];
   void modify(int node, int v) {
     tree[node] += v;
     lazy[node] += v;
   }
   void update(int node, int x, int y, int p, int q, int val) {
     if (lazy[node]) {
       modify(node << 1, lazy[node]);
       modify(node << 1 | 1, lazy[node]);
       lazy[node] = 0;
     }
     if (x >= p and y <= q) {
       modify(node, val);
       return;
     }
     int mid = x + y >> 1;
     if (p <= mid) update(node << 1, x, mid, p, q, val);
     if (q > mid) update(node << 1 | 1, mid + 1, y, p, q, val);
     tree[node] = max(tree[node << 1], tree[node << 1 | 1]);
   }
   int query(int node, int x, int y) {
     if (lazy[node]) {
       modify(node << 1, lazy[node]);
       modify(node << 1 | 1, lazy[node]);
       lazy[node] = 0;
     }
     if (tree[node] <= 0) return -1;
     if (x == y) return a[x];
     int mid = x + y >> 1;
     int ret = query(node << 1 | 1, mid + 1, y);
     if (ret == -1) {
       ret = query(node << 1, x, mid);
     }
     return ret;
   }
 } T;
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int m;
   cin >> m;
   for (int i = 0; i <= m - 1; i++) {
     int p, t;
     cin >> p >> t;
     if (t == 0) {
       T.update(1, 1, m, 1, p, -1);
     } else {
       int x;
       cin >> x;
       a[p] = x;
       T.update(1, 1, m, 1, p, 1);
     }
     cout << T.query(1, 1, m) <<
 ;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long N = 100005;
 const long long M = 998244353;
 long long pow1(long long a, long long b) {
   int res = 1;
   while (b > 0) {
     if (b & 1) {
       res = (res * a) % M;
     }
     a = (a * a) % M;
     b >>= 1;
   }
   return res % M;
 }
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   long long T;
   T = 1;
   cin >> T;
   while (T--) {
     long long n, m;
     cin >> n >> m;
     long long ans[n][m];
     for (long long i = 0; i < n; i++) {
       for (long long j = 0; j < m; j++) {
         long long num;
         cin >> num;
         if (num % 2 != (i + j) % 2)
           ans[i][j] = num + 1;
         else
           ans[i][j] = num;
         cout << ans[i][j] <<    ;
       }
       cout <<
 ;
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long int n, k, i, j;
   cin >> n >> k;
   long long int x = 1;
   long long int ans = n - 1;
   for (i = 0; i < k; i++) {
     vector<long long int> v;
     long long int m;
     cin >> m;
     long long int t = -1;
     for (j = 0; j < m; j++) {
       long long int y;
       cin >> y;
       if (y == 1) t = j;
       v.push_back(y);
     }
     if (t != -1) {
       for (j = t + 1; j < m; j++) {
         if (v[j] == v[j - 1] + 1)
           x++;
         else
           break;
       }
     }
     ans += m - 1;
   }
   cout << ans - (2 * (x - 1));
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int num, hight, temp, width = 0;
   cin >> num >> hight;
   vector<int> v;
   for (int i = 0; i < num; i++) {
     cin >> temp;
     v.push_back(temp);
     if (v[i] > hight)
       width += 2;
     else
       width++;
   }
   cout << width;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const double pi = 2 * acos(0);
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int q;
   cin >> q;
   while (q--) {
     int n, r;
     cin >> n >> r;
     set<int> s;
     vector<int> v;
     for (long long i = 0; i < n; i++) {
       int a;
       cin >> a;
       s.insert(a);
     }
     for (auto u : s) v.push_back(u);
     int cnt = 0;
     for (int i = v.size() - 1; i >= 0; i--) {
       if (v[i] - r * cnt > 0) cnt++;
     }
     cout << cnt <<
 ;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 100005;
 int n, a[N], b[N], posa[N], posb[N], dif[N], ans, ord[N], t1;
 multiset<int> rig, lef;
 int abss(const int i) { return i < 0 ? -i : i; }
 bool cmp(int i, int j) { return dif[i] < dif[j]; }
 int main() {
   scanf( %d , &n);
   for (int i = 1; i <= n; ++i) {
     scanf( %d , &a[i]);
     posa[a[i]] = i;
   }
   for (int i = 1; i <= n; ++i) {
     scanf( %d , &b[i]);
     posb[b[i]] = i;
   }
   ans = n;
   for (int i = 1; i <= n; ++i) {
     ans = min(ans, abss(posa[i] - posb[i]));
     dif[i] = posb[i] - posa[i];
     if (dif[i] > 0) {
       rig.insert(dif[i]);
     } else {
       lef.insert(-dif[i]);
     }
     ord[i] = i;
   }
   sort(ord + 1, ord + 1 + n, cmp);
   t1 = 1;
   printf( %d
 , ans);
   for (int i = 2; i <= n; ++i) {
     lef.erase(lef.find(posa[b[i - 1]] - i + 1));
     rig.insert(n - posa[b[i - 1]] + i - 1);
     while (rig.size() > 0 && *rig.begin() - i + 1 == 0) {
       rig.erase(rig.find(*rig.begin()));
       lef.insert((int)(-i + 1));
     }
     ans = min(*lef.begin() + i - 1,
               rig.size() > 0 ? *rig.begin() - i + 1 : n + 1);
     printf( %d
 , ans);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int INF = 0x3f3f3f3f;
 const int MAX = 100005;
 const int MAX1 = 1005;
 const int MAX2 = 105;
 const int LEN = 105;
 const int BASE = 1000000000;
 const double EPS = 1e-7;
 const int MOD = 1000000007;
 long long pow(long long a, long long b) {
   long long ans = 1;
   while (b) {
     if (b & 1) ans = (ans * a) % MOD;
     b /= 2;
     a = (a * a) % MOD;
   }
   return ans;
 }
 int main(void) {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   ifstream in(  );
   ofstream out(  );
   clock_t begin = clock();
   int q;
   cin >> q;
   while (q--) {
     int n;
     cin >> n;
     int arr[MAX];
     for (int i = (0); i < (n); ++i) {
       cin >> arr[i];
     }
     sort(arr, arr + n);
     cout << min(n - 2, arr[n - 2] - 1) << '
';
   }
   clock_t end = clock();
   double esecs = double(end - begin) / CLOCKS_PER_SEC;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <typename T>
 inline T S(T a) {
   return a * a;
 }
 template <class T>
 inline string tostring(T a) {
   ostringstream os(  );
   os << a;
   return os.str();
 }
 template <typename T>
 inline long long tolong(T a) {
   long long res;
   istringstream os(a);
   os >> res;
   return res;
 }
 template <typename T>
 inline T gcd(T a, T b) {
   if (b == 0)
     return a;
   else
     return gcd(b, a % b);
 }
 template <typename T>
 inline T bigmod(T a, T b, T m) {
   if (b == 0)
     return 1;
   else if (b % 2 == 0)
     return S(bigmod(a, b / 2, m)) % m;
   else
     return (a % m * bigmod(a, b - 1, m)) % m;
 }
 const int inf = (int)1e9 + 5;
 const long long linf = (long long)1e16 + 5;
 const long long modd = (long long)1e9 + 7;
 const int mod = 10000007;
 void pr(int f) {
   if (f == 1)
     cout <<  YES
 ;
   else
     cout <<  NO
 ;
 }
 bool isprime(long long n) {
   if (n < 2) return 0;
   if (n == 2)
     return 1;
   else {
     for (int i = 2; i * i <= n; i++)
       if (n % i == 0) return 0;
   }
   return 1;
 }
 map<int, int> mp;
 multiset<string>::iterator it;
 deque<char> q;
 const int nax = 10e6 + 5;
 int t[nax], l[100005], d[100005];
 int main() {
   ios_base::sync_with_stdio(0);
   long long int n, m;
   cin >> n >> m;
   long long int low, high;
   high = ((n - (m - 1)) * (n - m)) / 2;
   long long int quo = n / m;
   long long int rem = n % m;
   low = rem * ((quo + 1) * (quo)) / 2 + (m - rem) * (quo * (quo - 1)) / 2;
   cout << low <<     << high;
 }


#include <bits/stdc++.h>
 const int inf = (1ll << 30) - 1;
 const int maxn = (int)1e5 + 10;
 using namespace std;
 int n;
 vector<int> g[100100];
 int a[100100];
 int in[100100];
 int out[100100];
 int dp[100100];
 map<int, int> t[400400];
 int timer = 0;
 void dfs(int v) {
   in[v] = timer;
   a[timer] = v;
   timer++;
   dp[v] = 1;
   for (int i = 0; i < g[v].size(); i++) {
     int to = g[v][i];
     dfs(to);
     dp[v] += dp[to];
   }
   out[v] = timer - 1;
 }
 void build(int v, int l, int r) {
   if (l == r) {
     t[v][dp[a[l]]]++;
   } else {
     int mid = (l + r) >> 1;
     build(v * 2, l, mid);
     build(v * 2 + 1, mid + 1, r);
     for (int i = l; i <= r; i++) t[v][dp[a[i]]]++;
   }
 }
 int getu(int v, int l, int r, int tl, int tr, int x) {
   if (tl > tr) return inf;
   if (l == tl && tr == r) {
     map<int, int>::iterator pos = t[v].lower_bound(x);
     if (pos != t[v].end()) return pos->first;
     return inf;
   }
   int mid = (l + r) >> 1;
   return min(getu(v * 2, l, mid, tl, min(tr, mid), x),
              getu(v * 2 + 1, mid + 1, r, max(tl, mid + 1), tr, x));
 }
 int getd(int v, int l, int r, int tl, int tr, int x) {
   if (tl > tr) return -inf;
   if (l == tl && tr == r) {
     map<int, int>::iterator pos = t[v].lower_bound(x + 1);
     if (pos != t[v].begin()) return (--pos)->first;
     return -inf;
   }
   int mid = (l + r) >> 1;
   return max(getd(v * 2, l, mid, tl, min(tr, mid), x),
              getd(v * 2 + 1, mid + 1, r, max(tl, mid + 1), tr, x));
 }
 void ADD(int v, int l, int r, int pos, int x) {
   t[v][x]++;
   if (l == r) {
     return;
   }
   int mid = (l + r) >> 1;
   if (pos <= mid) {
     ADD(v * 2, l, mid, pos, x);
   } else
     ADD(v * 2 + 1, mid + 1, r, pos, x);
 }
 void DEL(int v, int l, int r, int pos, int x) {
   t[v][x]--;
   if (t[v][x] == 0) t[v].erase(x);
   if (l == r) {
     return;
   }
   int mid = (l + r) >> 1;
   if (pos <= mid) {
     DEL(v * 2, l, mid, pos, x);
   } else
     DEL(v * 2 + 1, mid + 1, r, pos, x);
 }
 int ans[100100];
 set<int> PA;
 void calc(int v, int szz) {
   int cv = dp[v];
   DEL(1, 0, n - 1, in[v], cv);
   PA.insert(dp[v]);
   for (int i = 0; i < g[v].size(); i++) {
     int to = g[v][i];
     cv = szz + dp[v] - dp[to];
     calc(to, szz + dp[v] - dp[to]);
   }
   PA.erase(dp[v]);
   vector<pair<int, int> > cur;
   if (szz) cur.push_back(make_pair(szz, 0));
   for (int i = 0; i < g[v].size(); i++) {
     int to = g[v][i];
     cur.push_back(make_pair(dp[to], to));
   }
   sort(cur.begin(), cur.end());
   int d = cur.size();
   if (cur.size() <= 1 || cur[d - 2].first == cur.back().first) {
     ans[v] = cur.back().first;
     ADD(1, 0, n - 1, in[v], dp[v]);
     return;
   }
   ans[v] = cur[d - 1].first;
   int sz = (cur[0].first + cur[d - 1].first) / 2 - cur[0].first;
   int xx;
   int V = cur[d - 1].second;
   if (V)
     xx = getu(1, 0, n - 1, in[V], out[V], sz);
   else {
     xx = min(getu(1, 0, n - 1, 0, in[v] - 1, sz),
              getu(1, 0, n - 1, out[v] + 1, n - 1, sz));
     set<int>::iterator it = PA.lower_bound(sz + dp[v]);
     if (it != PA.end()) xx = min(xx, *it - dp[v]);
   }
   ans[v] = min(ans[v], max(cur[d - 2].first,
                            max(cur[0].first + xx, cur[d - 1].first - xx)));
   if (V)
     xx = getd(1, 0, n - 1, in[V], out[V], sz);
   else {
     xx = max(getd(1, 0, n - 1, 0, in[v] - 1, sz),
              getd(1, 0, n - 1, out[v] + 1, n - 1, sz));
     set<int>::iterator it = PA.upper_bound(sz + dp[v]);
     if (it != PA.begin()) xx = max(xx, *(--it) - dp[v]);
   }
   ans[v] = min(ans[v], max(cur[d - 2].first,
                            max(cur[0].first + xx, cur[d - 1].first - xx)));
   ADD(1, 0, n - 1, in[v], dp[v]);
 }
 void solve() {
   scanf( %d , &n);
   int root = 0;
   for (int i = 1, x, y; i <= n; i++) {
     scanf( %d%d , &x, &y);
     if (x)
       g[x].push_back(y);
     else
       root = y;
   }
   if (n == 1) {
     printf( 0
 );
     return;
   }
   if (n == 2) {
     printf( 1
1
 );
     return;
   }
   dfs(root);
   build(1, 0, n - 1);
   calc(root, 0);
   for (int i = 1; i <= n; i++) {
     printf( %d
 , ans[i]);
   }
 }
 int main() {
   int t = 1;
   for (int i = 1; i <= t; i++) {
     solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, k;
   cin >> n >> k;
   bool zero = false;
   int *arr = new int[n];
   for (int i = 0; i < n; i++) {
     cin >> arr[i];
   }
   int neg = 0;
   for (int i = 0; i < n; i++) {
     if (arr[i] < 0) neg++;
     if (arr[i] == 0) {
       zero = true;
     }
   }
   for (int i = 0; k > 0 && i < neg;) {
     arr[i] = arr[i] * -1;
     k--;
     i++;
   }
   long long int ans = 0;
   for (int i = 0; i < n; i++) {
     ans += arr[i];
   }
   int min = INT_MAX;
   for (int i = 0; i < n; i++) {
     if (arr[i] < min) {
       min = arr[i];
     }
   }
   if (k % 2 == 0) {
     cout << ans;
   } else {
     cout << ans - 2 * min;
   }
   return 0;
 }


#include<bits/stdc++.h>
 #define fo(i, n) for(int i=0; i<n; i++)
 #define boost ios::sync_with_stdio(false); cin.tie(0)
 #define ll long long int
 using namespace std;

 int main()
 {   boost;
     int t; cin>>t;
     while(t--){
         int n, max_freq = 0, i; cin>>n;
         map<int, int> m;
         for(i=0; i<n; i++){
             int k; cin>>k;
             max_freq = max(max_freq, ++m[k]);
         }
         cout<<max_freq<<
 ;
     }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 500001;
 int arr[N];
 vector<pair<int, int> > v[N];
 int ans[N], n, m;
 int bit[N];
 map<int, int> last;
 void update(int idx, int val) {
   for (; idx <= n; idx += idx & -idx) {
     bit[idx] = min(bit[idx], val);
   }
 }
 int query(int idx) {
   int res = n + 1;
   for (; idx; idx -= idx & -idx) {
     res = min(res, bit[idx]);
   }
   return res;
 }
 int main() {
   cin >> n >> m;
   for (int i = 1; i <= n; i++) {
     scanf( %d , &arr[i]);
     bit[i] = n + 1;
   }
   for (int i = 1; i <= m; i++) {
     int x, y;
     scanf( %d %d , &x, &y);
     v[y].push_back({x, i});
   }
   for (int i = 1; i <= n; i++) {
     if (last.find(arr[i]) != last.end())
       update(n - last[arr[i]] + 1, i - last[arr[i]]);
     last[arr[i]] = i;
     int x = v[i].size();
     for (int j = 0; j < x; ++j) {
       ans[v[i][j].second] = query(n - v[i][j].first + 1);
     }
   }
   for (int i = 1; i <= m; i++) {
     printf( %d
 , (ans[i] == n + 1) ? -1 : ans[i]);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   cin.tie(NULL);
   cout.tie(NULL);
   ios_base::sync_with_stdio(false);
   long long int n, i, t, k, c, s = 0, x, sum = 0, st1 = 0, st2 = 0, curr = 0;
   cin >> n;
   vector<pair<long long int, long long int> > v;
   vector<long long int> p;
   for (i = 0; i < n; i++) {
     cin >> k >> c;
     v.push_back(make_pair(c, k));
   }
   cin >> t;
   for (i = 0; i < t; i++) {
     cin >> x;
     s = x;
     p.push_back(s);
   }
   p.push_back(100000000000000);
   sort(v.begin(), v.end());
   while (st1 < n) {
     if (curr + v[st1].second < p[st2]) {
       sum += (st2 + 1) * (v[st1].first) * (v[st1].second);
       curr += v[st1].second;
       st1++;
     } else {
       long long int rem = p[st2] - curr;
       curr += rem;
       sum += (rem) * (st2 + 1) * (v[st1].first);
       v[st1].second -= rem;
       st2++;
       if (!v[st1].second) {
         st1++;
       }
     }
   }
   cout << sum;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, k, m;
 int nt, kt, mt;
 int su[100004];
 long long sum = 0;
 double res;
 int main() {
   scanf( %d%d%d , &n, &k, &m);
   nt = n;
   kt = k;
   mt = m;
   for (int i = 0; i < n; i++) {
     scanf( %d , su + i);
     sum += su[i];
   }
   res = 1.0 * sum / n;
   sort(su, su + n);
   long long ts = 0;
   for (int i = 1; i <= n; i++) {
     ts += su[n - i];
     long long rm = m - n + i;
     long long te = i;
     long long tk = k;
     if (rm < 0) {
       continue;
     }
     res = max(res, (ts + min(rm, te * tk)) * 1.0 / te);
   }
   printf( %lf
 , res);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAXN = 2e5 + 100;
 const int MOD = 1e9 + 7;
 const int oo = 1e9 + 100;
 const long double EPS = 1e-9;
 const string DIRS =  UDLR ;
 int n, x, y;
 char str[MAXN];
 int acc[256][MAXN];
 int get(char ch, int fr, int to) {
   if (to < fr) return 0;
   return acc[ch][to] - acc[ch][fr - 1];
 }
 int main() {
   while (scanf( %d %s %d %d , &n, str + 1, &x, &y) == 4) {
     for (auto& e : DIRS) {
       acc[e][0] = 0;
       for (int i = 1; i <= n; ++i) {
         acc[e][i] = acc[e][i - 1] + (str[i] == e);
       }
     }
     int init_x = acc['R'][n] - acc['L'][n];
     int init_y = acc['U'][n] - acc['D'][n];
     if (init_x == x && init_y == y) {
       puts( 0 );
       continue;
     }
     if (abs(x) + abs(y) > n || (n - abs(x) - abs(y)) % 2 != 0) {
       puts( -1 );
       continue;
     }
     int lo = 1, hi = n;
     vector<int> aux(256);
     while (lo <= hi) {
       int mi = (lo + hi) >> 1;
       bool ok = false;
       for (int i = 1; i + mi - 1 <= n; ++i) {
         for (auto& e : DIRS) aux[e] = get(e, 1, i - 1) + get(e, i + mi, n);
         int xx = aux['R'] - aux['L'];
         int yy = aux['U'] - aux['D'];
         int rem = mi - (abs(x - xx) + abs(y - yy));
         if (rem >= 0) ok = true;
       }
       if (ok)
         hi = mi - 1;
       else
         lo = mi + 1;
     }
     printf( %d
 , lo);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int a[200010], b[200010];
 bool used[200010];
 int main() {
   int n, k = 0, i, x;
   scanf( %d , &n);
   for (i = 1; i <= n; i++) scanf( %d , &a[i]);
   for (i = 1; i <= n; i++) scanf( %d , &b[i]);
   int ans = 1 - accumulate(b + 1, b + n + 1, 0) % 2;
   for (i = 1; i <= n; i++)
     if (!used[i]) {
       used[i] = true;
       x = a[i];
       while (!used[x]) {
         used[x] = true;
         x = a[x];
       }
       k++;
     }
   if (k > 1) ans += k;
   printf( %d
 , ans);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   long long n, m, i, cnt = 0, sum = 0, ans = 0, x, j;
   string s;
   vector<string> v;
   cin >> n >> m;
   int a[m];
   for (i = 0; i < n; i++) {
     cin >> s;
     v.push_back(s);
   }
   for (i = 0; i < m; i++) cin >> a[i];
   for (i = 0; i < m; i++) {
     int arr[5] = {0};
     for (j = 0; j < n; j++) {
       x = v[j][i] - 'A';
       arr[x]++;
     }
     sort(arr, arr + 5);
     ans += arr[4] * a[i];
   }
   cout << ans;
 }


#include <bits/stdc++.h>
 using namespace std;
 void chekarre(int* arr, int n) {
   cout <<  [ ;
   for (int i = 0; i < n; i++) cout << arr[i] <<    ;
   cout <<  ]  << endl;
 }
 bool comp(int i, int j) { return (i > j); }
 int a[2000007];
 int main() {
   int n;
   long long sum = 0;
   cin >> n;
   for (int i = 0; i < n; i++) {
     cin >> a[i];
   }
   sort(a, a + n);
   reverse(a, a + n);
   while (n) {
     for (int j = 0; j < n; j++) {
       sum += a[j];
     }
     n = n / 4;
   }
   cout << sum << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, a, b;
 int ans, nn;
 char x[100010];
 int change(int t) {
   int rtn = 0, bit = 1;
   while (t) {
     rtn += (t % 10) * bit;
     bit *= ans;
     t /= 10;
   }
   return rtn;
 }
 int main() {
   scanf( %d%d , &a, &b);
   int aa = a, bb = b;
   while (aa) {
     ans = max(ans, aa % 10);
     aa /= 10;
   }
   while (bb) {
     ans = max(ans, bb % 10);
     bb /= 10;
   }
   ans += 1;
   a = change(a);
   b = change(b);
   a += b;
   while (a) {
     x[nn++] = a % ans + '0';
     a /= ans;
   }
   printf( %d , nn);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long OO = 1e8;
 const double EPS = (1e-7);
 int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
 const int N = 100;
 bool adjMatrixBool[N][N];
 int adjMatrix[N][N];
 vector<int> adjMatrixAll[N][N];
 map<pair<int, int>, int> adjMatrixMap;
 vector<vector<int> > adjList1;
 vector<vector<pair<int, int> > > adjList2;
 vector<bool> visited;
 bool valid(int i, int j) { return 1; }
 char arr[303][303], x, b;
 bool prime(long long n) {
   long long i;
   for (i = 2; i <= sqrt(n); i++) {
     if (n % i == 0) return false;
   }
   return true;
 }
 long long gcd(long long a, long long b) {
   if (b == 0) return a;
   return gcd(b, a % b);
 }
 long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
 int main() {
   ios_base::sync_with_stdio(false);
   long long n;
   cin >> n;
   string s;
   cin >> s;
   long long arr[n];
   for (int i = 0; i < n; i++) {
     cin >> arr[i];
   }
   long long ans = INT_MAX;
   for (int i = 0; i < n - 1; i++) {
     if (s[i] == 'R' and s[i + 1] == 'L')
       ans = min(ans, abs((arr[i + 1] - arr[i]) / 2));
   }
   if (ans == INT_MAX)
     cout <<  -1  << endl;
   else
     cout << ans;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const double PI = acos(-1.0);
 const long long INF = 1000 * 1000 * 1000 + 7;
 const long long LINF = INF * (long long)INF;
 const int MOD = 1000 * 1000 * 1000 + 7;
 const int MAX = 10000 + 47;
 long long F[MAX];
 vector<int> R;
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int s, k;
   cin >> s >> k;
   int p = 0;
   F[0] = 1;
   for (int i = (1); i < (MAX); i++) {
     for (int j = (max(0, i - k)); j < (i); j++) {
       F[i] += F[j];
     }
     if (F[i] > s) {
       p = i;
       break;
     }
   }
   for (int i = (p)-1; i >= (0); i--) {
     if (s >= F[i]) {
       s -= F[i];
       R.push_back(F[i]);
     }
   }
   if ((int)R.size() == 1) R.push_back(0);
   cout << (int)R.size() << endl;
   for (int i = (0); i < ((int)R.size()); i++) {
     cout << R[i] <<    ;
   }
   cout << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const double eps = 1e-9;
 const double PI = acos(-1.0);
 const long long int mod = 1e9 + 7;
 const int MAXN = 1e6 + 5;
 void cp() {
   long long int n, i, k;
   cin >> n >> k;
   long long int a[n], sum = 0;
   for (int i = 0; i < n; i++) cin >> a[i];
   sort(a, a + n);
   for (i = 1; i < n; i++) {
     if (a[i] < k) {
       sum += (k - a[i]) / a[0];
     }
   }
   cout << sum;
   cout << '
';
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   ;
   int t;
   t = 1;
   cin >> t;
   while (t--) {
     cp();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int INF = INT_MAX;
 const long long INFL = LLONG_MAX;
 int dx[] = {1, -1, 0, 0};
 int dy[] = {0, 0, 1, -1};
 int main() {
   ios_base::sync_with_stdio(0);
   cout.precision(15);
   cout << fixed;
   cout.tie(0);
   cin.tie(0);
   int n, k;
   cin >> n >> k;
   int p = 2 * n + 1;
   int a[p + 2];
   for (int i = 1; i <= p; i++) cin >> a[i];
   a[0] = -INF;
   a[p + 1] = +INF;
   for (int i = 1; i <= p && k > 0; i++)
     if (i % 2 == 0 && a[i] > a[i - 1] && a[i] > a[i + 1] &&
         a[i] - a[i - 1] > 1 && a[i] - a[i + 1] > 1) {
       k--;
       a[i]--;
     }
   for (int i = 1; i <= p; i++) cout << a[i] <<    ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long a[300005];
 long long c[300005] = {0};
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   ;
   int n;
   cin >> n;
   int i;
   for (i = 1; i <= n - 1; i++) cin >> a[i];
   long long m = 0;
   long long r = 0;
   for (i = 1; i <= n - 1; i++) {
     r += a[i];
     m = min(m, r);
   }
   m = abs(m) + 1;
   long long y = m;
   if (m > n || c[m]) {
     cout << -1;
     return 0;
   }
   c[m] = 1;
   for (i = 1; i <= n - 1; i++) {
     m += a[i];
     if (m > n || c[m]) {
       cout << -1;
       return 0;
     }
     c[m] = 1;
   }
   cout << y <<    ;
   for (i = 1; i <= n - 1; i++) {
     y += a[i];
     cout << y <<    ;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int myrand(int m) { return (rand() * (1 << 15) + rand()) % m; }
 int main() {
   srand(time(0));
   int n, ind, x;
   cin >> n >> ind >> x;
   --ind;
   vector<int> left(n);
   vector<bool> vis(n, 0);
   for (int i = 0; i < n; ++i) left[i] = i;
   vis[ind] = 1;
   random_shuffle(left.begin(), left.end());
   int best = -1;
   for (int i = 0; i < min(1000, n); ++i) {
     int v, ii = left[i];
     cout <<  ?   << ii + 1 <<
 ;
     fflush(stdout);
     cin >> v >> ii;
     if (v < x && v > best) {
       ind = left[i];
       best = max(best, v);
     }
   }
   if (ind < 0) {
     cout <<  ! -1
 ;
     fflush(stdout);
     return 0;
   }
   int itt, LIM = 999;
   for (itt = 0; itt < LIM; ++itt) {
     cout <<  ?   << ind + 1 <<
 ;
     fflush(stdout);
     int v;
     cin >> v >> ind;
     --ind;
     if (v >= x) {
       best = v;
       break;
     }
     if (ind < 0) break;
   }
   if (itt == LIM) {
     int j = 1;
     while (1) {
       j = j + 1;
     }
   }
   cout <<  !   << ((best < x) ? -1 : best) <<
 ;
   fflush(stdout);
 }


#include <bits/stdc++.h>
 using namespace std;
 int32_t main() {
   long long n;
   cin >> n;
   map<string, long long> count;
   for (long long i = 0; i < n; i++) {
     string s;
     cin >> s;
     count[s]++;
   }
   string s1 =  a , s2 =  a ;
   for (map<string, long long>::iterator it = count.begin(); it != count.end();
        ++it) {
     if (s1 ==  a )
       s1 = (*it).first;
     else
       s2 = (*it).first;
   }
   if (count[s1] > count[s2])
     cout << s1 <<
 ;
   else
     cout << s2 <<
 ;
 }


#include <bits/stdc++.h>
 using namespace std;
 int to(int x, int y) { return (x * 60) + (y); }
 long long int gcd(long long int a, long long int b) {
   return b == 0 ? a : gcd(b, a % b);
 }
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int n;
   cin >> n;
   int arr[n + 1];
   for (int i = 1; i <= n; i++) cin >> arr[i];
   int mx = 0, ans = 0;
   for (int i = 1; i <= n; i++) {
     if (arr[i] == i and mx <= i) {
       ans++;
       continue;
     }
     if (arr[i] == i) {
       continue;
     }
     mx = max(arr[i], mx);
   }
   cout << ans;
   cout << endl;
   return 0;
 }


#include <bits/stdc++.h>
 int N;
 char s[507][507];
 int rX[] = {-1, 0, 1, 0};
 int rY[] = {0, -1, 0, 1};
 int spoj[507][507];
 int rozm[1000007];
 int akt[1000007];
 int terRozm;
 int wyn;
 void dfs(int y, int x, int num) {
   spoj[y][x] = num;
   terRozm++;
   for (int i = 0; i < 4; i++) {
     int nx = x + rX[i], ny = y + rY[i];
     if (nx >= 1 && nx <= N && ny >= 1 && ny <= N) {
       if (s[ny][nx] == '.' && spoj[ny][nx] == 0) dfs(ny, nx, num);
     }
   }
 }
 void dolicz(int y1, int x1, int y2, int x2, bool kk = false) {
   for (int y = y1; y <= y2; y++) {
     if (y < 1 || y > N) continue;
     for (int x = x1; x <= x2; x++) {
       if (x < 1 || x > N) continue;
       if (s[y][x] == '.') {
         int sp = spoj[y][x];
         akt[sp]++;
         if (akt[sp] == 1) wyn += rozm[sp];
       } else if (kk) {
         wyn++;
       }
     }
   }
 }
 void odejmij(int y1, int x1, int y2, int x2, bool kk = false) {
   for (int y = y1; y <= y2; y++) {
     if (y < 1 || y > N) continue;
     for (int x = x1; x <= x2; x++) {
       if (x < 1 || x > N) continue;
       if (s[y][x] == '.') {
         int sp = spoj[y][x];
         akt[sp]--;
         if (akt[sp] == 0) wyn -= rozm[sp];
       } else if (kk) {
         wyn--;
       }
     }
   }
 }
 int main() {
   int K;
   scanf( %d%d , &N, &K);
   for (int i = 1; i <= N; i++) scanf( %s , s[i] + 1);
   int ileSpoj = 0;
   for (int i = 1; i <= N; i++)
     for (int w = 1; w <= N; w++)
       if (s[i][w] == '.' && spoj[i][w] == 0) {
         terRozm = 0;
         dfs(i, w, ++ileSpoj);
         rozm[ileSpoj] = terRozm;
       }
   int maxi = 0;
   for (int i = 1; i <= N - K + 1; i++) {
     dolicz(i, 1, i + K - 1, K, true);
     dolicz(i - 1, 1, i - 1, K);
     dolicz(i + K, 1, i + K, K);
     dolicz(i, 0, i + K - 1, 0);
     dolicz(i, K + 1, i + K - 1, K + 1);
     maxi = std::max(wyn, maxi);
     for (int x = 2; x <= N + 2; x++) {
       odejmij(i, x - 2, i + K - 1, x - 2);
       odejmij(i, x - 1, i + K - 1, x - 1, true);
       dolicz(i, x - 1, i + K - 1, x - 1);
       odejmij(i, x + K - 1, i + K - 1, x + K - 1);
       dolicz(i, x + K - 1, i + K - 1, x + K - 1, true);
       dolicz(i, x + K, i + K - 1, x + K);
       odejmij(i - 1, x - 1, i - 1, x - 1);
       dolicz(i - 1, x + K - 1, i - 1, x + K - 1);
       odejmij(i + K, x - 1, i + K, x - 1);
       dolicz(i + K, x + K - 1, i + K, x + K - 1);
       maxi = std::max(wyn, maxi);
     }
   }
   printf( %d , maxi);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m, x, c, a[200001], tin[200001], tout[200001], sz[200001], seg[524288];
 string s;
 bool lazy[524288];
 vector<int> G[200001];
 void dfs(int i) {
   tin[i] = ++c;
   ++sz[i];
   for (int j : G[i]) {
     dfs(j);
     sz[i] += sz[j];
   }
   tout[i] = c;
 }
 void upd(int l, int r, int s = 1, int e = n, int i = 1) {
   if (lazy[i]) {
     seg[i] = (e - s + 1) - seg[i];
     if (s != e) {
       lazy[2 * i] ^= 1;
       lazy[2 * i + 1] ^= 1;
     }
     lazy[i] = 0;
   }
   if (s > r || e < l) return;
   if (s >= l && e <= r) {
     seg[i] = (e - s + 1) - seg[i];
     if (s != e) {
       lazy[2 * i] ^= 1;
       lazy[2 * i + 1] ^= 1;
     }
     return;
   }
   int mid = (s + e) / 2;
   upd(l, r, s, mid, 2 * i);
   upd(l, r, mid + 1, e, 2 * i + 1);
   seg[i] = seg[2 * i] + seg[2 * i + 1];
 }
 int que(int l, int r, int s = 1, int e = n, int i = 1) {
   if (lazy[i]) {
     seg[i] = (e - s + 1) - seg[i];
     if (s != e) {
       lazy[2 * i] ^= 1;
       lazy[2 * i + 1] ^= 1;
     }
     lazy[i] = 0;
   }
   if (s > r || e < l) return 0;
   if (s >= l && e <= r) return seg[i];
   int mid = (s + e) / 2;
   return que(l, r, s, mid, 2 * i) + que(l, r, mid + 1, e, 2 * i + 1);
 }
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   cin >> n;
   for (int i = 2; i <= n; ++i) {
     cin >> x;
     G[x].push_back(i);
   }
   for (int i = 1; i <= n; ++i) cin >> a[i];
   dfs(1);
   for (int i = 1; i <= n; ++i)
     if (a[i]) upd(tin[i], tin[i]);
   cin >> m;
   while (m--) {
     cin >> s >> x;
     if (s ==  pow )
       upd(tin[x], tout[x]);
     else
       cout << que(tin[x], tout[x]) << '
';
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int INF = 1e8 + 1;
 vector<vector<int> > adj;
 vector<bool> visited;
 int contadorNodos = 0;
 void DFS(int nodo) {
   contadorNodos++;
   for (auto it : adj[nodo]) {
     DFS(it);
   }
 }
 void letras(string &s) {
   for (int i = 0; i < s.size(); i++) {
     s[i] = tolower(s[i]);
   }
 }
 int main() {
   int n;
   cin >> n;
   map<string, int> m;
   adj.resize(205);
   visited.resize(205, false);
   int j = 1;
   for (int i = 0; i < n; i++) {
     string a, b, c;
     cin >> a >> b >> c;
     letras(a);
     letras(c);
     if (m[a] == 0) {
       m[a] = j;
       j++;
     }
     if (m[c] == 0) {
       m[c] = j;
       j++;
     }
     adj[m[a]].push_back(m[c]);
   }
   int res = 0;
   for (int i = 1; i < j; i++) {
     contadorNodos = 0;
     DFS(i);
     res = max(res, contadorNodos);
   }
   cout << res << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const bool online_judge = true;
 const long long inf = 1LL << 60;
 long long toInt(string s) {
   long long res;
   stringstream ss;
   ss << s;
   ss >> res;
   return res;
 }
 string toString(long long n) {
   stringstream ss;
   ss << n;
   return ss.str();
 }
 long long w, h;
 vector<string> f;
 typedef struct {
   long long x;
   long long y;
   long long dp;
   long long cp;
 } state;
 state memo[55][55][5][5];
 long long dx[4] = {0, 1, 0, -1};
 long long dy[4] = {-1, 0, 1, 0};
 long long ex[4] = {-1, 0, 1, 0};
 long long ey[4] = {0, -1, 0, 1};
 state solve(long long y, long long x, long long dp, long long cp) {
   if (memo[y][x][dp][cp].x != -1) return memo[y][x][dp][cp];
   state ans;
   long long nx = x + dx[dp];
   long long ny = y + dy[dp];
   long long mx = x + ex[(dp + (cp ? 2 : 0)) % 4];
   long long my = y + ey[(dp + (cp ? 2 : 0)) % 4];
   if (f[ny][nx] == f[y][x]) {
     ans = solve(ny, nx, dp, cp);
   } else if (f[my][mx] == f[y][x]) {
     ans = solve(my, mx, dp, cp);
   } else {
     char c = f[ny][nx];
     if (c == '0') {
       if (cp == 0) {
         ans.y = y;
         ans.x = x;
         ans.dp = dp;
         ans.cp = 1;
       } else {
         ans.y = y;
         ans.x = x;
         ans.dp = (dp + 1) % 4;
         ans.cp = 0;
       }
     } else {
       ans.x = nx;
       ans.y = ny;
       ans.dp = dp;
       ans.cp = cp;
     }
   }
   memo[y][x][dp][cp] = ans;
   return ans;
 }
 void run() {
   long long m, n;
   cin >> m >> n;
   for (long long _ = 0; _ < m; _++) {
     string tmp;
     cin >> tmp;
     f.push_back(tmp);
   }
   w = f[0].size();
   h = m;
   for (long long i = 0; i < m; i++) {
     f[i] =  0  + f[i] +  0 ;
   }
   f.insert(f.begin(), string(w + 2, '0'));
   f.push_back(string(w + 2, '0'));
   for (long long i = 1; i <= h; i++) {
     for (long long j = 1; j <= w; j++) {
       for (long long dp = 0; dp <= 3; dp++) {
         for (long long cp = 0; cp <= 1; cp++) {
           memo[i][j][dp][cp].x = -1;
         }
       }
     }
   }
   for (long long i = 1; i <= h; i++) {
     for (long long j = 1; j <= w; j++) {
       for (long long dp = 0; dp <= 3; dp++) {
         for (long long cp = 0; cp <= 1; cp++) {
           solve(i, j, dp, cp);
         }
       }
     }
   }
   long long x = 1, y = 1, dp = 1, cp = 0;
   while (n--) {
     state next = memo[y][x][dp][cp];
     x = next.x;
     y = next.y;
     dp = next.dp;
     cp = next.cp;
   }
   cout << f[y][x] << endl;
 }
 int main(int argc, char *argv[]) {
   run();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 2e5 + 100;
 struct node {
   int flag, a, b;
   long long sum;
 } t[maxn * 8];
 int a[maxn], cnt[maxn * 2], js[maxn * 2];
 void pushdown(int x, int l, int r) {
   if (t[x].flag) {
     int num = t[x].flag;
     t[2 * x].sum += num * l;
     t[2 * x + 1].sum += num * r;
     t[2 * x].flag += num;
     t[2 * x + 1].flag += num;
     t[x].flag = 0;
   }
 }
 int ask(int x, int l, int r, int pos) {
   int mid;
   if (l == r) {
     return t[x].sum;
   }
   mid = (l + r) / 2;
   pushdown(x, mid - l + 1, r - mid);
   if (pos <= mid)
     return ask(2 * x, l, mid, pos);
   else
     return ask(2 * x + 1, mid + 1, r, pos);
 }
 void add(int x, int l, int r, int ql, int qr, int val) {
   int mid;
   if (ql == l && qr == r) {
     t[x].flag += val;
     t[x].sum += (qr - ql + 1);
     return;
   }
   mid = (l + r) / 2;
   pushdown(x, mid - l + 1, r - mid);
   if (qr <= mid) {
     add(2 * x, l, mid, ql, qr, val);
   } else {
     if (ql > mid)
       add(2 * x + 1, mid + 1, r, ql, qr, val);
     else {
       add(2 * x, l, mid, ql, mid, val);
       add(2 * x + 1, mid + 1, r, mid + 1, qr, val);
     }
   }
   t[x].sum = t[2 * x].sum + t[2 * x + 1].sum;
 }
 void build(int x, int l, int r) {
   int mid;
   t[x].flag = 0;
   t[x].sum = 0;
   if (l == r) {
     return;
   }
   mid = (l + r) / 2;
   build(2 * x, l, mid);
   build(2 * x + 1, mid + 1, r);
 }
 int top;
 node s[maxn];
 int cmp(node a, node b) { return a.sum < b.sum; }
 int main() {
   node e;
   int T, n, flag, ans, k, up;
   scanf( %d , &T);
   while (T--) {
     scanf( %d%d , &n, &k);
     for (int i = 1; i <= 2 * k; i++) {
       cnt[i] = 0;
       js[i] = 0;
     }
     build(1, 1, k * 2);
     for (int i = 1; i <= n; i++) {
       scanf( %d , &a[i]);
     }
     if (n == 2) {
       printf( 0
 );
       continue;
     }
     top = 0;
     if (n % 2)
       up = n / 2 + 1;
     else
       up = n / 2;
     for (int i = 1; i <= up; i++) {
       e.a = a[i];
       e.b = a[n - i + 1];
       if (e.a > e.b) swap(e.a, e.b);
       e.sum = e.a + e.b;
       s[++top] = e;
       js[e.sum]++;
     }
     sort(s + 1, s + top + 1, cmp);
     int last = 0;
     ans = n;
     for (int i = 1; i <= top; i++) {
       e = s[i];
       if (e.sum == last) {
         add(1, 1, 2 * k, e.a + 1, e.b + k, 1);
         continue;
       }
       cnt[e.sum] += n / 2 - js[e.sum] + i - 1 - ask(1, 1, 2 * k, e.sum);
       add(1, 1, 2 * k, e.a + 1, e.b + k, 1);
       last = e.sum;
     }
     for (int i = 1; i <= top / 2; i++) {
       swap(s[i], s[top - i + 1]);
     }
     build(1, 1, k * 2);
     last = 0;
     ans = n;
     for (int i = 1; i <= top; i++) {
       e = s[i];
       if (e.sum == last) {
         add(1, 1, 2 * k, e.a + 1, e.b + k, 1);
         continue;
       }
       cnt[e.sum] += i - 1 - ask(1, 1, 2 * k, e.sum);
       ans = min(ans, cnt[e.sum]);
       add(1, 1, 2 * k, e.a + 1, e.b + k, 1);
       last = e.sum;
     }
     for (int i = 1; i <= 2 * k; i++) {
       if (js[i]) continue;
       ans = min(ans, n - ask(1, 1, 2 * k, i));
     }
     printf( %d
 , ans);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long n, a[100001], b[100001];
 vector<long long> v[100001];
 signed main() {
   cin >> n;
   long long i;
   for (i = 1; i < n + 1; i++) {
     cin >> a[i];
     v[a[i]].push_back(i);
   }
   bool ok = 1;
   long long clr = 1;
   for (i = 0; i < 100001; i++) {
     if (!v[i].empty()) {
       long long k = v[i].size();
       long long j;
       if (k % (n - i) != 0) {
         ok = 0;
         break;
       }
       long long t = k / (n - i);
       long long temp = 1;
       j = 0;
       while (temp <= t) {
         while (j < temp * (n - i)) {
           b[v[i][j]] = clr;
           j++;
         }
         clr++;
         temp++;
       }
     }
   }
   if (ok) {
     cout <<  Possible
 ;
     for (i = 1; i < n + 1; i++) cout << b[i] <<    ;
   } else
     cout <<  Impossible ;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class T>
 bool uin(T &a, T b) {
   return a > b ? (a = b, true) : false;
 }
 template <class T>
 bool uax(T &a, T b) {
   return a < b ? (a = b, true) : false;
 }
 const long long maxn = 1000001, mod = 1e9 + 7;
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n;
   cin >> n;
   int ar[n];
   map<int, int> mapp;
   for (long long i = 0; i < (long long)(n); ++i) {
     cin >> ar[i];
     mapp[ar[i]] = i;
   }
   set<int> s;
   s.insert(-1);
   s.insert(n);
   int ans = 0;
   for (int i = n; i >= 1; i--) {
     int idx = mapp[i];
     auto it = s.lower_bound(idx);
     auto iit = s.upper_bound(idx);
     if (it != s.begin()) it--;
     int a = *it + 1;
     int b = *iit - 1;
     if (idx - a < b - idx) {
       for (long long j = (long long)(a); j <= (long long)(idx - 1); ++j) {
         int acha = mapp[i - ar[j]];
         if (acha > idx && acha <= b) {
           ans++;
         }
       }
     } else {
       for (long long j = (long long)(idx + 1); j <= (long long)(b); ++j) {
         int acha = mapp[i - ar[j]];
         if (acha < idx && acha >= a) {
           ans++;
         }
       }
     }
     s.insert(mapp[i]);
   }
   cout << ans;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 struct Trie {
   Trie *nx[2];
   int cnt;
   Trie() {
     nx[0] = nx[1] = nullptr;
     cnt = 0;
   }
 };
 Trie *root;
 void ins(long long x) {
   Trie *now = root;
   for (int bit = 45; bit >= 0; --bit) {
     int p = (x >> bit) & 1LL;
     if (now->nx[p] == nullptr) now->nx[p] = new Trie();
     now = now->nx[p];
     now->cnt++;
   }
 }
 long long query(long long x) {
   Trie *now = root;
   long long ret = 0LL;
   for (int bit = 45; bit >= 0; --bit) {
     int p = (x >> bit) & 1LL;
     p ^= 1;
     if (now->nx[p] != nullptr && now->nx[p]->cnt > 0) {
       ret += 1LL << bit;
       now = now->nx[p];
     } else {
       now = now->nx[p ^ 1];
     }
     if (now == nullptr || now->cnt == 0) break;
   }
   return ret;
 }
 const int MXSZ = 1e5;
 int n;
 long long a[MXSZ + 5];
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   root = new Trie();
   cin >> n;
   long long curr = 0LL;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
     curr ^= a[i];
     ins(curr);
   }
   long long mx = 0LL;
   mx = max(mx, query(0));
   curr = 0LL;
   for (int i = n; i >= 1; --i) {
     curr ^= a[i];
     mx = max(mx, query(curr));
   }
   cout << mx << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n;
 int b[5000];
 int f[5000];
 int main() {
   scanf(  %d , &n);
   for (int i = 0; i < (int)(n); i++) scanf(  %d , b + i);
   for (int i = 0; i < (int)(n); i++) b[i]--;
   for (int i = 0; i < n; i++) {
     int c[5000] = {};
     pair<int, int> best = make_pair(0, 0);
     for (int j = i; j < n; j++) {
       c[b[j]]++;
       best = max(best, make_pair(c[b[j]], -b[j]));
       f[-best.second]++;
     }
   }
   for (int i = 0; i < (int)(n); i++) printf( %d  , f[i]);
   puts(  );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 using LL = long long;
 const int maxn = 3000010;
 int n, b;
 int pre[maxn], vis[maxn];
 vector<int> prime;
 struct init {
   init() {
     memset(pre, 0, sizeof pre);
     prime.clear();
     for (int i = 2; i < maxn; i++) {
       if (pre[i] == 0) {
         pre[i] = i;
         prime.emplace_back(i);
       }
       for (int j = 0; j < prime.size() && i * prime[j] < maxn; j++) {
         if (prime[j] > pre[i]) break;
         pre[i * prime[j]] = prime[j];
       }
     }
   }
 } init_;
 bool ok(int x) {
   if (x == 1) return 0;
   return pre[x] == 0;
 }
 signed main() {
   while (cin >> n) {
     memset(vis, 0, sizeof vis);
     for (int i = 1; i <= 2 * n; i++) {
       scanf( %d , &b);
       vis[b]++;
     }
     for (int i = maxn - 1; i > 1; i--) {
       if (pre[i] == i) continue;
       while (vis[i] > 0) {
         printf( %d  , i);
         vis[i]--;
         vis[i / pre[i]]--;
       }
     }
     for (int i = 2; i < maxn; i++) {
       while (vis[i] > 0) {
         printf( %d  , i);
         vis[i]--;
         vis[prime[i - 1]]--;
       }
     }
     printf(
 );
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios::sync_with_stdio(0), cin.tie(0);
   string s;
   cin >> s;
   sort(s.begin(), s.end());
   reverse(s.begin(), s.end());
   cout << s[0];
   for (long long int(i) = (1); (i) < (s.length()); (i)++) {
     if (s[i] == s[i - 1])
       cout << s[i];
     else
       break;
   }
   cout <<
 ;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   for (int i = 1; i <= n; i++) {
     if ((i * (i + 1)) / 2 == n) {
       cout <<  YES  << endl;
       return 0;
     }
     if ((i * (i + 1)) / 2 > n) {
       cout <<  NO  << endl;
       return 0;
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 bool KT(long long k, long long n) {
   long long take = 0, cur = n;
   while (cur > 0) {
     long long temp = min(k, cur);
     take += temp;
     cur -= temp;
     cur -= cur / 10;
   }
   if (take * 2 >= n) return true;
   return false;
 }
 int main() {
   long long n;
   cin >> n;
   long long left = 1, right = n, res = 0;
   while (left <= right) {
     long long mid = (left + right) / 2;
     if (KT(mid, n)) {
       res = mid;
       right = mid - 1;
     } else {
       left = mid + 1;
     }
   }
   cout << res;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 struct in {
   int x, y;
 } a[300000];
 int get(int prex, int prey, int x, int y, int k) {
   int num, ans = 100000000;
   if (prex <= k) {
     num = (prex + x + k - 1) / k - 1;
     if (y == num)
       ans = prex + x - num * k;
     else if (y > num && y <= (long long)x * k)
       ans = 1;
   }
   if (prey <= k) {
     num = (x + k - 1) / k - 1;
     if (y == num)
       ans = min(ans, x - num * k);
     else if (y > num && y - k + prey <= (long long)(x - 1) * k)
       ans = 1;
   }
   return ans;
 }
 int main() {
   int N, K, pre0 = 0, pre1 = 0, next0, next1;
   scanf( %d%d , &N, &K);
   for (int i = 1; i <= N; i++) scanf( %d , &a[i].x);
   for (int i = 1; i <= N; i++) scanf( %d , &a[i].y);
   for (int i = 1; i <= N; i++) {
     next0 = get(pre0, pre1, a[i].x, a[i].y, K);
     next1 = get(pre1, pre0, a[i].y, a[i].x, K);
     pre0 = next0;
     pre1 = next1;
   }
   if (pre0 <= K || pre1 <= K)
     puts( YES );
   else
     puts( NO );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 vector<int> vi;
 void primefact(int n) {
   while (n % 2 == 0) {
     vi.push_back(2);
     n /= 2;
   }
   int i = 3;
   while (i <= n) {
     while (n % i == 0) {
       vi.push_back(i);
       n /= i;
     }
     i += 2;
   }
   if (n > 2) vi.push_back(n);
 }
 int main() {
   int n, k, last = 1, i;
   cin >> n >> k;
   primefact(n);
   if (k > vi.size())
     cout <<  -1  << endl;
   else {
     for (i = 0; i < k - 1; i++) cout << vi[i] <<    ;
     for (i = k - 1; i < vi.size(); i++) last *= vi[i];
     cout << last;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 200005;
 const long long INF = 1e9;
 const long long MOD = 1000000007;
 int prevs[20];
 int main() {
   ios ::sync_with_stdio(0);
   cin.tie(0);
   int n, q;
   cin >> n >> q;
   int arr[n];
   for (int i = 0; i < n; i++) cin >> arr[i];
   int ar[n][20];
   for (int i = 0; i < n; i++)
     for (int j = 0; j < 20; j++) ar[i][j] = n + 3;
   for (int i = n - 1; i >= 0; i--) {
     int x = 1;
     for (int j = 0; j < 20; j++) {
       if ((x << j) & arr[i]) {
         ar[i][j] = i;
         if (prevs[j] != 0)
           for (int k = 0; k < 20; k++)
             ar[i][k] = min(ar[i][k], ar[prevs[j]][k]);
         prevs[j] = i;
       }
     }
   }
   while (q--) {
     int x, y;
     cin >> x >> y;
     x--, y--;
     if (!arr[x] || !arr[y]) {
       cout <<  Fou  << endl;
       continue;
     }
     int p = 1;
     int l = 0;
     for (int j = 0; j < 20; j++)
       if (p << j & arr[y])
         if (ar[x][j] <= y) {
           l = 1;
           continue;
         }
     if (l == 1)
       cout <<  Shi  << endl;
     else
       cout <<  Fou  << endl;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int Maxn = 1000 + 10;
 const int INF = 0x7f7f7f7f;
 const double eps = 1e-10;
 const double pi = acos(-1.0);
 inline int realcmp(double a, double b) {
   return (a > b + eps) ? 1 : ((a + eps < b) ? -1 : 0);
 }
 int main() {
   double hh, mm;
   ios::sync_with_stdio(0);
   scanf( %lf:%lf , &hh, &mm);
   hh += mm / 60;
   while (realcmp(hh, 12) >= 0) hh -= 12;
   printf( %.9lf  , 30.0 * hh);
   printf( %.9lf
 , 6.0 * mm);
   return 0;
 }


#include <bits/stdc++.h>
 struct point {
   long x;
   long y;
   long z;
 };
 const long maxn = 5001;
 const double inf = 2000000000;
 const double eps = 1.0e-8;
 point a[maxn];
 double nnew, min;
 long n, q, choice1, choice2;
 double d[maxn];
 double sqr(double x) { return (x * x); }
 double dist(point a, point b) {
   return (pow(sqr(a.x - b.x) + sqr(a.y - b.y) + sqr(a.z - b.z), 0.5));
 }
 int main() {
   scanf( %ld , &n);
   for (q = 1; q <= n; q++) scanf( %ld%ld%ld , &a[q].x, &a[q].y, &a[q].z);
   min = inf;
   for (long h = 2; h <= n; h++) d[h] = dist(a[1], a[h]);
   for (choice1 = 2; choice1 <= n; choice1++)
     for (choice2 = choice1 + 1; choice2 <= n; choice2++) {
       nnew = (d[choice1] + d[choice2] + dist(a[choice1], a[choice2])) / 2;
       if (min - nnew > eps) min = nnew;
     }
   printf( %0.8lf , min);
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, x, i, y, ans = 0, q;
   scanf( %d%d , &n, &x);
   y = int(sqrt(x));
   if (n < y) y = n;
   for (i = 1; i <= y; i++) {
     if (x % i == 0) {
       q = x / i;
       if (q <= n) {
         if (i == q)
           ans++;
         else
           ans += 2;
       }
     }
   }
   if (x == 1)
     printf( %d
 , 1);
   else
     printf( %d
 , ans);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int mx = 1e9;
 struct Data {
   int p1, p2, p3, p4;
   Data(int a = mx, int b = mx, int c = mx, int d = mx) {
     p1 = a, p2 = b, p3 = c, p4 = d;
   }
 };
 inline Data UN(Data a, Data b) {
   Data c;
   c.p1 = min(a.p1 + b.p1, a.p2 + b.p3), c.p2 = min(a.p1 + b.p2, a.p2 + b.p4);
   c.p3 = min(a.p3 + b.p1, a.p4 + b.p3), c.p4 = min(a.p3 + b.p2, a.p4 + b.p4);
   c.p1 = min(c.p1, mx), c.p2 = min(c.p2, mx), c.p3 = min(c.p3, mx),
   c.p4 = min(c.p4, mx);
   return c;
 }
 struct node {
   int l, r;
   Data s;
 } T[200010 << 2];
 char G[3][200010];
 void build(int rt, int l, int r) {
   T[rt].l = l, T[rt].r = r;
   int mid = (l + r) >> 1;
   if (l == r) {
     if (G[1][l] == '.') T[rt].s.p1 = 1;
     if (G[2][l] == '.') T[rt].s.p4 = 1;
     if (G[1][l] == '.' && G[2][l] == '.') T[rt].s.p2 = T[rt].s.p3 = 2;
     return;
   }
   build(rt << 1, l, mid), build(rt << 1 | 1, mid + 1, r);
   T[rt].s = UN(T[rt << 1].s, T[rt << 1 | 1].s);
 }
 Data query(int rt, int start, int end) {
   int l = T[rt].l, r = T[rt].r, mid = (l + r) >> 1;
   if (start <= l && r <= end) return T[rt].s;
   if (end <= mid) return query(rt << 1, start, end);
   if (start > mid) return query(rt << 1 | 1, start, end);
   return UN(query(rt << 1, start, end), query(rt << 1 | 1, start, end));
 }
 int main() {
   int n, q;
   scanf( %d%d , &n, &q);
   scanf( %s%s , G[1] + 1, G[2] + 1);
   build(1, 1, n);
   while (q--) {
     int a, b;
     scanf( %d%d , &a, &b);
     int l = a > n ? a - n : a, r = b > n ? b - n : b, res;
     if (l > r) swap(l, r), swap(a, b);
     Data tmp = query(1, l, r);
     if (a <= n && b <= n) res = tmp.p1;
     if (a <= n && b > n) res = tmp.p2;
     if (a > n && b <= n) res = tmp.p3;
     if (a > n && b > n) res = tmp.p4;
     if (res < 1e8)
       printf( %d
 , res - 1);
     else
       printf( -1
 );
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long t, x, y, a, b;
   scanf( %lld , &t);
   while (t--) {
     scanf( %lld %lld %lld %lld , &x, &y, &a, &b);
     bool yes = false;
     int i = 0;
     int tens = 1000000;
     while (x <= y) {
       if (x == y) {
         yes = true;
         break;
       }
       while (x + a * tens > y - b * tens && tens > 1) tens /= 10;
       x += tens * a;
       y -= tens * b;
       i += tens;
     }
     printf( %d
 , yes ? i : -1);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 mt19937 rnd(228);
 const int N = 404;
 int mod;
 int fact[N], d0[N], d[N], d2[N][N];
 int main() {
   int qq;
   cin >> qq >> mod;
   fact[0] = 1;
   for (int i = 1; i < N; ++i) fact[i] = (1LL * fact[i - 1] * i) % mod;
   d[1] = 1;
   d0[1] = 1;
   for (int n = 2; n < N; ++n) {
     d0[n] = fact[n];
     for (int k = 1; k < n; ++k)
       d0[n] = (d0[n] - 1LL * d0[k] * fact[n - k]) % mod;
     if (d0[n] < 0) d0[n] += mod;
   }
   d2[0][0] = 1;
   for (int n = 1; n < N; ++n) {
     d2[n][1] = fact[n];
     for (int k = 2; k <= n; ++k)
       for (int x = 1; x < n; ++x)
         d2[n][k] = (d2[n][k] + 1LL * fact[x] * d2[n - x][k - 1]) % mod;
   }
   for (int n = 2; n < N; ++n) {
     int dz = 0;
     for (int x = 1; x < n - 1; ++x)
       for (int y = x; y < n - 1; ++y) {
         int c = fact[y - x + 1];
         c = (1LL * c * d0[x]) % mod;
         c = (1LL * c * d0[n - y - 1]) % mod;
         dz += c;
         if (dz >= mod) dz -= mod;
       }
     dz = (dz * 2) % mod;
     int cd = fact[n];
     cd = (cd - dz + mod) % mod;
     for (int k = 3; k < n; ++k) {
       cd = (cd - 1LL * d2[n][k] * d[k]) % mod;
     }
     if (n != 2) {
       for (int x = 1; x < n; ++x) cd = (cd - 1LL * d0[x] * d0[n - x]) % mod;
       for (int x = 1; x < n; ++x) cd = (cd - 1LL * d0[x] * d0[n - x]) % mod;
     }
     cd = (cd + mod) % mod;
     d[n] = cd;
   }
   while (qq--) {
     int x;
     cin >> x;
     cout << d[x] <<
 ;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 2020;
 vector<tuple<int, int, int> > edges;
 vector<int> g[N];
 vector<int> back_edge[N];
 bool global;
 int num[N], low[N], low2[N], cnt, pai[N], pw[N], aux[N], prev_pai[N],
     prev_pw[N], sobe[N], prev_sobe[N];
 int edg_used, edg_u, edg_v, edg_w;
 void dfs(int u) {
   num[u] = low[u] = ++cnt;
   bool flag = false;
   for (auto w : g[u]) {
     int x, v, p;
     tie(x, v, p) = edges[w];
     if (v == u) swap(v, x);
     if (edg_used == w) continue;
     if (!num[v]) {
       pai[v] = u;
       pw[v] = p;
       sobe[v] = w;
       dfs(v);
       low[u] = min(low[u], low[v]);
     } else if (flag or pai[u] != v) {
       low[u] = min(low[u], num[v]);
       if (!global and num[u] > num[v]) back_edge[u].push_back(w);
     } else if (pai[u] == v)
       flag = true;
   }
 }
 int main(void) {
   int n, m;
   scanf( %d %d , &n, &m);
   int s, t;
   scanf( %d %d , &s, &t);
   for (int i = 0; i < m; i++) {
     int u, v, w;
     scanf( %d %d %d , &u, &v, &w);
     g[u].push_back(i);
     g[v].push_back(i);
     edges.emplace_back(u, v, w);
   }
   edg_used = -1;
   dfs(s);
   global = true;
   int S = s;
   if (!low[t]) {
     printf( 0
0
 );
     return 0;
   }
   int ans = 0x3f3f3f3f;
   int edg;
   int v = t;
   while (v != s) {
     int u = pai[v];
     if (low[v] > num[u]) {
       if (pw[v] < ans) edg = sobe[v];
       ans = min(ans, pw[v]);
     }
     v = u;
   }
   int dupla = INT_MAX;
   int x, y;
   for (int i = 1; i <= n; i++) {
     if (back_edge[i].empty()) continue;
     int k = 0, ans = 0x3f3f3f3f;
     for (int j = 0; j < back_edge[i].size(); j++) {
       int e = back_edge[i][j];
       int x, v, p;
       tie(x, v, p) = edges[e];
       if (v == i) swap(v, x);
       if (num[v] < ans) k = j;
     }
     vector<int> c[5];
     cnt = 0;
     for (int j = 1; j <= n; j++) {
       c[0].push_back(num[j]);
       c[1].push_back(low[j]);
       c[2].push_back(pai[j]);
       c[3].push_back(pw[j]);
       c[4].push_back(sobe[j]);
       num[j] = low[j] = 0;
     }
     tie(edg_u, edg_v, edg_w) = edges[back_edge[i][k]];
     edg_used = back_edge[i][k];
     dfs(s);
     ans = 0x3f3f3f3f;
     int v = t, edg;
     while (v != s) {
       int u = pai[v];
       if (low[v] > num[u]) {
         if (pw[v] < ans) edg = sobe[v];
         ans = min(ans, pw[v]);
       }
       v = u;
     }
     if (ans != 0x3f3f3f3f and ans + edg_w < dupla) {
       dupla = ans + edg_w;
       x = back_edge[i][k];
       y = edg;
     }
     for (int j = 1; j <= n; j++) {
       num[j] = c[0][j - 1];
       low[j] = c[1][j - 1];
       pai[j] = c[2][j - 1];
       pw[j] = c[3][j - 1];
       sobe[j] = c[4][j - 1];
     }
   }
   for (int i = 1; i <= n; i++) {
     prev_pai[i] = pai[i];
     prev_pw[i] = pw[i];
     prev_sobe[i] = sobe[i];
   }
   for (int i = 1; i <= n; i++) {
     if (i == s) continue;
     cnt = 0;
     for (int j = 1; j <= n; j++) num[j] = low[j] = 0;
     tie(edg_u, edg_v, edg_w) = edges[prev_sobe[i]];
     edg_used = prev_sobe[i];
     dfs(s);
     if (!low[t]) continue;
     int ans = 0x3f3f3f3f, v = t, edg;
     while (v != s) {
       int u = pai[v];
       if (low[v] > num[u]) {
         if (pw[v] < ans) edg = sobe[v];
         ans = min(ans, pw[v]);
       }
       v = u;
     }
     if (ans != 0x3f3f3f3f and ans + edg_w < dupla) {
       dupla = ans + edg_w;
       x = prev_sobe[i];
       y = edg;
     }
   }
   if (ans == 0x3f3f3f3f and dupla == INT_MAX) {
     printf( -1
 );
   } else if (ans < dupla and ans != 0x3f3f3f3f)
     printf( %d
1
%d
 , ans, edg + 1);
   else
     printf( %d
2
%d %d
 , dupla, x + 1, y + 1);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   int i, j, k;
   j = (n * 2) - 1;
   cout << j <<
        <<  2 ;
   cout << endl <<  1  2 ;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1e5 + 5;
 vector<pair<int, int> > adj[N];
 int ans[N];
 int off[N];
 int lvl[N], anc[N][25];
 int n, a, b, k;
 void dfs(int u = 0, int par = 0, int l = 0) {
   lvl[u] = l;
   anc[u][0] = par;
   for (auto nxt : adj[u])
     if (nxt.first != par) dfs(nxt.first, u, l + 1);
 }
 void buildLCA() {
   int lg = ceil(log2(n));
   for (int j = 1; j < lg; j++)
     for (int i = 0; i < n; i++) anc[i][j] = anc[anc[i][j - 1]][j - 1];
 }
 int LCA(int i, int j) {
   int lg = ceil(log2(n));
   int st = lg;
   if (lvl[i] > lvl[j]) swap(i, j);
   int cur = lvl[j];
   for (; st >= 0; st--)
     if (cur - (1 << st) >= lvl[i]) cur -= (1 << st), j = anc[j][st];
   if (i == j) return 2 * i - j;
   cur = lvl[i];
   for (st = lg; st >= 0; st--)
     if (anc[i][st] != anc[j][st])
       cur -= (1 << st), i = anc[i][st], j = anc[j][st];
   return anc[i][0];
 }
 int solve(int u = 0, int par = 0) {
   int cnt = off[u];
   for (auto nxt : adj[u]) {
     if (par == nxt.first) continue;
     int x = solve(nxt.first, u);
     ans[nxt.second] = x;
     cnt += x;
   }
   return cnt;
 }
 int main() {
   scanf( %d , &n);
   for (int i = 0; i < n - 1; i++) {
     scanf( %d%d , &a, &b);
     a--, b--;
     adj[a].push_back({b, i});
     adj[b].push_back({a, i});
   }
   dfs();
   buildLCA();
   scanf( %d , &k);
   for (int i = 0; i < k; i++) {
     scanf( %d%d , &a, &b);
     a--, b--;
     off[a]++, off[b]++;
     off[LCA(a, b)] -= 2;
   }
   solve();
   for (int i = 0; i < n - 1; i++) printf( %d%c , ans[i],
 [i == n - 2]);
   return 0;
 }


#include <bits/stdc++.h>
 #pragma GCC optimize( Ofast )
 using namespace std;
 struct Point {
   int x, y, type, index;
 } num[20005];
 int ans[10005];
 Point c;
 bool cmp(Point a, Point b) {
   return (a.x - c.x) * (b.y - c.y) - (a.y - c.y) * (b.x - c.x) > 0;
 }
 bool cmp2(Point a, Point b) { return (a.x < b.x) || (a.x == b.x && a.y < b.y); }
 void f(int l, int r) {
   if (l >= r) return;
   int i;
   swap(num[l], num[min_element(num + l, num + r + 1, cmp2) - num]);
   for (i = l + 1; i <= r; i++) {
     num[i].x -= num[l].x;
     num[i].y -= num[l].y;
   }
   num[l].x = num[l].y = 0;
   c = num[l];
   sort(num + l + 1, num + r + 1, cmp);
   int pre = num[l].type, minv = 1000000000, id = -1;
   for (i = l + 1; i <= r; i++) {
     pre += num[i].type;
     if (!pre && num[i].type != num[l].type && max(i - l - 1, r - i) < minv) {
       minv = max(i - l - 1, r - i);
       id = i;
     }
   }
   if (num[l].type == 1)
     ans[num[id].index] = num[l].index;
   else
     ans[num[l].index] = num[id].index;
   f(l + 1, id - 1);
   f(id + 1, r);
 }
 int main() {
   int i, n;
   scanf( %d , &n);
   for (i = 0; i < n; i++) {
     scanf( %d%d , &num[i].x, &num[i].y);
     num[i].type = -1;
     num[i].index = i + 1;
   }
   for (i = 0; i < n; i++) {
     scanf( %d%d , &num[n + i].x, &num[n + i].y);
     num[n + i].type = 1;
     num[n + i].index = i + 1;
   }
   f(0, 2 * n - 1);
   for (i = 1; i <= n; i++) printf( %d
 , ans[i]);
 }