#include <bits/stdc++.h>
 using namespace std;
 int n, m, q, num, tot, tp, cnt, ans, w[200100], head[200100], dfn[200100],
     c[200100], low[200100], sta[200100];
 int dfc, sz[200100], d[200100], f[200100], son[200100], top[200100],
     tree[200100], mn[200100 * 4];
 vector<int> v[200100];
 multiset<int> s[200100];
 struct point {
   int fr, to, nxt;
 } a[200100 * 2];
 void add(int x, int y) {
   a[++tot].fr = x;
   a[tot].to = y;
   a[tot].nxt = head[x];
   head[x] = tot;
 }
 void tarjan(int x) {
   dfn[x] = low[x] = ++num;
   sta[++tp] = x;
   for (int i = 0; i < v[x].size(); i++) {
     int y = v[x][i];
     if (!dfn[y]) {
       tarjan(y);
       low[x] = min(low[x], low[y]);
       if (low[y] == dfn[x]) {
         ++cnt;
         int now;
         do {
           now = sta[tp--];
           add(cnt, now);
           add(now, cnt);
         } while (now != y);
         add(cnt, x);
         add(x, cnt);
       }
     } else
       low[x] = min(low[x], dfn[y]);
   }
 }
 void dfs1(int x, int fa) {
   f[x] = fa;
   d[x] = d[fa] + 1;
   sz[x] = 1;
   for (int i = head[x]; i; i = a[i].nxt) {
     int y = a[i].to;
     if (y == fa) continue;
     dfs1(y, x);
     sz[x] += sz[y];
     if (sz[y] > sz[son[x]]) son[x] = y;
   }
 }
 void dfs2(int x, int lst) {
   top[x] = lst;
   dfn[x] = ++dfc;
   tree[dfc] = x;
   if (son[x]) dfs2(son[x], lst);
   for (int i = head[x]; i; i = a[i].nxt)
     if (!top[a[i].to]) dfs2(a[i].to, a[i].to);
 }
 void build(int x, int l, int r) {
   if (l == r) return mn[x] = w[tree[l]], void();
   int mid = (l + r) >> 1;
   build(x << 1, l, mid);
   build(x << 1 | 1, mid + 1, r);
   mn[x] = min(mn[x << 1], mn[x << 1 | 1]);
 }
 void modify(int x, int l, int r, int p, int y) {
   if (l == r) return mn[x] = y, void();
   int mid = (l + r) >> 1;
   if (p <= mid)
     modify(x << 1, l, mid, p, y);
   else
     modify(x << 1 | 1, mid + 1, r, p, y);
   mn[x] = min(mn[x << 1], mn[x << 1 | 1]);
 }
 int query(int x, int l, int r, int L, int R) {
   if (l >= L && r <= R) return mn[x];
   int mid = (l + r) >> 1, ret = 1e9;
   if (L <= mid) ret = min(ret, query(x << 1, l, mid, L, R));
   if (R > mid) ret = min(ret, query(x << 1 | 1, mid + 1, r, L, R));
   return ret;
 }
 int query(int x, int y, int ret = 1e9) {
   while (top[x] != top[y]) {
     if (d[top[x]] < d[top[y]]) swap(x, y);
     ret = min(ret, query(1, 1, cnt, dfn[top[x]], dfn[x]));
     x = f[top[x]];
   }
   if (d[x] < d[y]) swap(x, y);
   ret = min(ret, query(1, 1, cnt, dfn[y], dfn[x]));
   if (y > n) ret = min(ret, w[f[y]]);
   return ret;
 }
 int main() {
   scanf( ddd , &n, &m, &q);
   cnt = n;
   for (int i = 1; i <= n; i++) scanf( d , &w[i]);
   for (int i = 1, x, y; i <= m; i++)
     scanf( dd , &x, &y), v[x].push_back(y), v[y].push_back(x);
   tarjan(1);
   dfs1(1, 0);
   dfs2(1, 1);
   memset(mn, 0x3f, sizeof(mn));
   for (int i = 1; i <= n; i++) s[f[i]].insert(w[i]);
   for (int i = n + 1; i <= cnt; i++) w[i] = (*s[i].begin());
   build(1, 1, cnt);
   for (int i = 1; i <= q; i++) {
     char ch[4];
     int a, b;
     scanf( sdd , ch + 1, &a, &b);
     if (ch[1] == 'C') {
       if (f[a]) {
         multiset<int>::iterator pos = s[f[a]].find(w[a]);
         s[f[a]].erase(pos);
         s[f[a]].insert(b);
         w[f[a]] = (*s[f[a]].begin());
         modify(1, 1, cnt, dfn[f[a]], (*s[f[a]].begin()));
       }
       w[a] = b;
       modify(1, 1, cnt, dfn[a], w[a]);
     } else
       printf( d
 , query(a, b));
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 100001;
 vector<int> v, w;
 char s[1000001];
 int main() {
   scanf( s , &s);
   int len = strlen(s);
   for (int i = (0); i < (len); i++) {
     if (s[i] == '@') v.push_back(i);
     if (s[i] == '.') w.push_back(i);
   }
   int t = 0, tmp = 0;
   long long ans = 0;
   while (t < v.size() && tmp < w.size()) {
     long long first = 0, mid = 1, last = 0;
     if (t == v.size()) break;
     while (v[t] > w[tmp] && tmp < w.size()) tmp++;
     if (tmp == w.size()) break;
     if (v[t] + 1 == w[tmp]) mid = 0;
     for (int i = v[t] + 1; i < w[tmp]; i++) {
       if ((s[i] > '9' || s[i] < '0') && (s[i] > 'z' || s[i] < 'a')) {
         mid = 0;
         break;
       }
     }
     if (!mid) {
       t++;
       continue;
     }
     if (v[t] > 0)
       for (int i = v[t] - 1; i >= 0; i--) {
         if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= '0' && s[i] <= '9') ||
             s[i] == '_') {
           if (s[i] >= 'a' && s[i] <= 'z') first++;
         } else
           break;
       }
     if (w[tmp] + 1 < len)
       for (int i = w[tmp] + 1; i < len; i++) {
         if (s[i] >= 'a' && s[i] <= 'z')
           last++;
         else
           break;
       }
     ans += first * last;
     t++;
   }
   cout << ans << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m, c;
 int ans[1001];
 int zero;
 inline void send(int x, int p) {
   if (ans[x] == 0) --zero;
   ans[x] = p;
   printf( d
 , x);
   fflush(stdout);
 }
 int main() {
   scanf( d d d , &n, &m, &c);
   int mid = (c + 1) / 2;
   zero = n;
   for (int round = 1; zero && round <= m; ++round) {
     int p;
     scanf( d , &p);
     if (p <= mid) {
       int i;
       for (i = 1; i < n; ++i)
         if (ans[i] == 0 || ans[i] > p) {
           break;
         }
       send(i, p);
     } else {
       int i;
       for (i = n; i > 1; --i)
         if (ans[i] == 0 || ans[i] < p) {
           break;
         }
       send(i, p);
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const double PI = acos(-1.0);
 const int INF = 1000000000;
 const int MOD = 1073741824;
 const int M = INF;
 const double RRR = 180.0 / PI;
 vector<vector<int> > g;
 vector<bool> used;
 void dfs(int v) {
   used[v] = 1;
   for (vector<int>::iterator it = g[v].begin(); it != g[v].end(); ++it) {
     if (!used[*it]) {
       dfs(*it);
     }
   }
 }
 int main() {
   int x, y;
   cin >> x >> y;
   int d1 = 1, d2 = 0;
   int e = 1;
   int f = 0;
   int a = 0, b = 0;
   int r = 0;
   int ans = 0;
   if (a == x && b == y) {
     cout << 0;
     return 0;
   }
   while (1) {
     a += d1;
     b += d2;
     r++;
     if (a == x && b == y) {
       cout << ans;
       return 0;
     }
     if (r == e) {
       ans++;
       if (f == 0) {
         f = 1;
         d1 = 0;
         d2 = 1;
         r = 0;
       } else {
         if (f == 1) {
           f = 2;
           e++;
           r = 0;
           d1 = -1;
           d2 = 0;
         } else {
           if (f == 2) {
             f = 3;
             r = 0;
             d1 = 0;
             d2 = -1;
           } else {
             f = 0;
             e++;
             r = 0;
             d1 = 1;
             d2 = 0;
           }
         }
       }
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long mcd(long long a, long long b) {
   if (b > a) swap(a, b);
   if (b == 0)
     return a;
   else
     return mcd(b, a  b);
 }
 long long i, j, n, m, q, a, l, r, b;
 int main() {
   cin.tie(0);
   cout.tie(0);
   ios_base::sync_with_stdio(0);
   cin >> q;
   while (q--) {
     cin >> n;
     if (n == 1)
       cout << 3;
     else if (n == 2)
       cout << 2;
     else if (n & 1)
       cout << 1;
     else
       cout << 0;
     cout << '
';
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long modulo = 998244353;
 const long long p = modulo;
 vector<int> edges[300005];
 int father[300005];
 long long rCount[300005];
 long long oCount[300005];
 long long eCount[300005];
 pair<int, int> gcd(long long a, long long b) {
   if (b == 0ll) return {1ll, 0ll};
   pair<int, int> q = gcd(b, a  b);
   return {q.second, q.first - q.second * (a / b)};
 }
 long long inv(long long a) {
   long long aa = gcd(a, p).first;
   aa = p;
   if (aa < 0) aa += p;
   return aa;
 }
 void trace(int index) {
   for (int j = 0; j < edges[index].size(); ++j) {
     int v = edges[index][j];
     if (v == father[index]) {
       edges[index].erase(edges[index].begin() + j);
       --j;
       continue;
     }
     father[v] = index;
     trace(v);
   }
 }
 void dfs(int index) {
   if (edges[index].empty()) {
     rCount[index] = 1;
     oCount[index] = 1;
     eCount[index] = 0;
     return;
   }
   long long totalR = 1;
   long long total = 1;
   for (int j = 0; j < edges[index].size(); ++j) {
     int v = edges[index][j];
     dfs(v);
     totalR *= rCount[v];
     totalR = modulo;
     total *= rCount[v] + eCount[v];
     total = modulo;
   }
   rCount[index] = totalR;
   oCount[index] = 1;
   eCount[index] = 0;
   for (int j = 0; j < edges[index].size(); ++j) {
     int v = edges[index][j];
     long long temp = oCount[v] * total;
     temp = modulo;
     temp *= inv(rCount[v] + eCount[v]);
     temp = modulo;
     rCount[index] += temp;
     rCount[index] = modulo;
     oCount[index] *= (rCount[v] + eCount[v]);
     oCount[index] = modulo;
     eCount[index] += temp;
     eCount[index] = modulo;
   }
 }
 int main() {
   int n;
   cin >> n;
   if (n == 1) {
     cout << 1 << endl;
     return 0;
   }
   int u, v;
   for (int i = 0; i < n - 1; ++i) {
     scanf( ii , &u, &v);
     --u;
     --v;
     edges[u].push_back(v);
     edges[v].push_back(u);
   }
   for (int i = 0; i < n; ++i) {
     father[i] = -1;
     rCount[i] = 0;
     oCount[i] = 0;
     eCount[i] = 0;
   }
   father[0] = -1;
   trace(0);
   dfs(0);
   long long result = rCount[0];
   while (result < 0) {
     result += modulo;
   }
   result = modulo;
   cout << result << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxN = (int)1e2, maxM = (int)1e2, intMax = INT_MAX, maxValue = 44721;
 const long long llmax = LLONG_MAX, INF = (long long)1e9 + 1, mod = 998244353;
 long long nod(long long a, long long b) {
   while (a != 0 && b != 0) {
     if (a < b)
       b = a;
     else
       a = b;
   }
   return a + b;
 }
 int nod(int a, int b) {
   while (a != 0 && b != 0) {
     if (a < b)
       b = a;
     else
       a = b;
   }
   return a + b;
 }
 long long nok(long long a, long long b) { return a * b / nod(a, b); }
 int nok(int a, int b) { return a * b / nod(a, b); }
 long long modPlus(long long a, long long b) {
   a = mod;
   b = mod;
   return a + b;
 }
 long long modPlus(int a, int b) {
   a = mod;
   b = mod;
   return (a + b)  mod;
 }
 long long binPow(long long a, long long b) {
   long long res = 1;
   while (b) {
     if (b  2 == 1) {
       res *= a;
       res = mod;
     }
     a = a * a;
     a = mod;
     b >>= 1;
   }
   return res;
 }
 int n, s, a, b, emaxx = -1;
 int main() {
   scanf( dd , &n, &s);
   s *= 100;
   for (int i = 0; i < n; i++) {
     scanf( dd , &a, &b);
     b += a * 100;
     if (s >= b) emaxx = max((100 - (b  100))  100, emaxx);
   }
   printf( d
 , emaxx);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int t;
   cin >> t;
   while (t--) {
     int a, b, c;
     cin >> a >> b >> c;
     int diff = INT_MAX;
     int a1, b1, c1;
     for (int i = 1; i <= 10000; i++) {
       for (int j = i; j <= 20000; j += i) {
         for (int k = j; k <= 50000; k += j) {
           int dif = abs(a - i) + abs(b - j) + abs(c - k);
           if (dif < diff) {
             diff = dif;
             a1 = i;
             b1 = j;
             c1 = k;
           }
         }
       }
     }
     cout << diff << endl << a1 <<     << b1 <<     << c1 << endl;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, k, q;
 int it[35][800005];
 struct point {
   int a[10];
   point(){};
   int &operator[](int x) { return a[x]; }
 };
 point p[200005];
 int sign(point &p, int bit) {
   int ans = 0;
   for (int i = 0; i < k; i++) {
     if (bit & 1 == 1) {
       ans += p[i];
     } else {
       ans -= p[i];
     }
     bit >>= 1;
   }
   return ans;
 }
 void build(int id, int l, int r) {
   if (l == r - 1) {
     for (int i = 0; i < (1 << k); i++) {
       it[i][id] = sign(p[l], i);
     }
     return;
   }
   int mid = (l + r) / 2;
   build(id * 2, l, mid);
   build(id * 2 + 1, mid, r);
   for (int i = 0; i < (1 << k); i++) {
     it[i][id] = min(it[i][id * 2], it[i][id * 2 + 1]);
   }
 }
 void update(int id, int l, int r, int pos, point &val) {
   if (l == r - 1) {
     for (int i = 0; i < (1 << k); i++) {
       it[i][id] = sign(val, i);
     }
     return;
   }
   int mid = (l + r) / 2;
   if (pos < mid) {
     update(id * 2, l, mid, pos, val);
   } else {
     update(id * 2 + 1, mid, r, pos, val);
   }
   for (int i = 0; i < (1 << k); i++) {
     it[i][id] = min(it[i][id * 2], it[i][id * 2 + 1]);
   }
 }
 int chosen[35];
 void get(int id, int l, int r, int a, int b) {
   if (a >= b) return;
   if (l == a && r == b) {
     for (int i = 0; i < (1 << k); i++) {
       chosen[i] = min(chosen[i], it[i][id]);
     }
     return;
   }
   int mid = (l + r) / 2;
   get(id * 2, l, mid, a, min(mid, b));
   get(id * 2 + 1, mid, r, max(mid, a), b);
 }
 int main() {
   cin >> n >> k;
   for (int i = 0; i < n; i++) {
     for (int j = 0; j < k; j++) {
       cin >> p[i][j];
     }
   }
   build(1, 0, n);
   cin >> q;
   while (q--) {
     int t;
     cin >> t;
     if (t == 1) {
       int x;
       cin >> x;
       x--;
       point cnt;
       for (int i = 0; i < k; i++) {
         cin >> cnt[i];
       }
       update(1, 0, n, x, cnt);
     }
     if (t == 2) {
       int l, r;
       cin >> l >> r;
       l--;
       for (int i = 0; i < (1 << k); i++) {
         chosen[i] = 1e9;
       }
       get(1, 0, n, l, r);
       int res = 0;
       for (int i = 0; i < (1 << k); i++) {
         res = max(res, abs(chosen[(1 << k) - i - 1] + chosen[i]));
       }
       cout << res << endl;
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MOD = 1000000007;
 int N;
 int X[206], Y[206];
 int D[202][202];
 long long area(int i1, int i2, int i3) {
   return 1LL * X[i1] * Y[i2] + 1LL * X[i2] * Y[i3] + 1LL * X[i3] * Y[i1] -
          1LL * Y[i1] * X[i2] - 1LL * Y[i2] * X[i3] - 1LL * Y[i3] * X[i1];
 }
 int sign(int i1, int i2, int i3) {
   long long val = area(i1, i2, i3);
   if (val < 0) return -1;
   if (val > 0) return 1;
   return 0;
 }
 bool inpoly(int x, int y) {
   int pnx = 1e9 + 7, pny = 1e9 + 9;
   X[N + 2] = x;
   Y[N + 2] = y;
   X[N + 3] = pnx;
   Y[N + 3] = pny;
   for (int i = 1; i <= N + 1; ++i) {
     X[i] *= 2;
     Y[i] *= 2;
   }
   int nn = 0;
   for (int i = 1; i <= N; ++i)
     if (sign(N + 2, N + 3, i) * sign(N + 2, N + 3, i + 1) == -1 &&
         sign(i, i + 1, N + 2) * sign(i, i + 1, N + 3) == -1)
       ++nn;
   for (int i = 1; i <= N + 1; ++i) {
     X[i] /= 2;
     Y[i] /= 2;
   }
   return (nn  2);
 }
 bool isok(int i1, int i2) {
   if (i1 + 1 == i2 || (i2 == N && i1 == 1)) return true;
   for (int i = 1; i <= N; ++i)
     if (i != i1 && i != i2) {
       if (X[i] < min(X[i1], X[i2]) || X[i] > max(X[i1], X[i2])) continue;
       if (Y[i] < min(Y[i1], Y[i2]) || Y[i] > max(Y[i1], Y[i2])) continue;
       if (1LL * (Y[i] - Y[i1]) * (X[i2] - X[i]) ==
           1LL * (Y[i2] - Y[i]) * (X[i] - X[i1]))
         return false;
     }
   for (int i = 1; i <= N; ++i)
     if (i != i1 && i + 1 != i1 && (i + 1)  N != i1)
       if (i != i2 && i + 1 != i2 && (i + 1)  N != i2) {
         int p1 = i, p2 = i + 1;
         if (sign(i1, i2, p1) * sign(i1, i2, p2) == -1 &&
             sign(p1, p2, i1) * sign(p1, p2, i2) == -1)
           return false;
       }
   int xn = X[i1] + X[i2];
   int yn = Y[i1] + Y[i2];
   if (!inpoly(xn, yn)) return false;
   return true;
 }
 int ways(int i1, int i2) {
   if (D[i1][i2] != -1) return D[i1][i2];
   if (i1 + 1 == i2) return 1;
   int& now = D[i1][i2];
   now = 0;
   if (!isok(i1, i2)) return now;
   for (int k = i1 + 1; k <= i2 - 1; ++k)
     now = (now + 1LL * ways(i1, k) * ways(k, i2))  MOD;
   return now;
 }
 int main() {
   cin.sync_with_stdio(false);
   cin >> N;
   for (int i = 1; i <= N; ++i) cin >> X[i] >> Y[i];
   X[N + 1] = X[1];
   Y[N + 1] = Y[1];
   memset(D, -1, sizeof(D));
   cout << ways(1, N) << '
';
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAXN = 2e5 + 10;
 struct Node {
   int a, b, d;
 } p[MAXN];
 int n, k;
 bool cmp(Node aa, Node bb) { return aa.d < bb.d; }
 bool cmp2(Node aa, Node bb) { return aa.d > bb.d; }
 int main() {
   scanf( dd , &n, &k);
   for (int i = 1; i <= n; i++) scanf( d , &p[i].a);
   for (int i = 1; i <= n; i++) {
     scanf( d , &p[i].b);
     p[i].d = p[i].a - p[i].b;
   }
   long long ans = 0;
   sort(p + 1, p + 1 + n, cmp);
   if (p[1].d >= 0) {
     for (int i = 1; i <= k; i++) ans += (long long)p[i].a;
     for (int i = k + 1; i <= n; i++) ans += (long long)p[i].b;
   } else if (p[n].d <= 0) {
     sort(p + 1, p + 1 + n, cmp2);
     for (int i = 1; i <= n; i++) {
       ans += (long long)p[i].a;
     }
   } else {
     if (p[k].d <= 0) {
       for (int i = 1; i <= n; i++) {
         if (p[i].d <= 0)
           ans += (long long)p[i].a;
         else
           ans += (long long)p[i].b;
       }
     } else {
       int tmp = 0;
       for (int i = 1; i <= n; i++) {
         if (p[i].d <= 0) {
           ans += (long long)p[i].a;
         } else {
           tmp = i;
           break;
         }
       }
       sort(p + tmp, p + 1 + k, cmp2);
       for (int i = tmp; i <= k; i++) {
         ans += (long long)p[i].a;
       }
       for (int i = k + 1; i <= n; i++) {
         ans += (long long)p[i].b;
       }
     }
   }
   cout << ans << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long n;
   cin >> n;
   vector<long long> dp;
   dp.push_back(0);
   dp.push_back(1);
   while (dp.back() <= n - 1) {
     dp.push_back(dp[dp.size() - 1] + dp[dp.size() - 2] + 1);
   }
   cout << dp.size() - 2 << endl;
 }


#include <bits/stdc++.h>
 #pragma GCC optimize( Ofast ,  unroll-loops )
 using namespace std;
 const int inf = numeric_limits<int>::max() / 2;
 const long double eps = 1e-9;
 const long double pi = acos(-1);
 inline void solve(), read();
 int main() {
   ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   read();
   solve();
   return 0;
 }
 pair<int, int> operator+(pair<int, int> p1, pair<int, int> p2) {
   return {p1.first + p2.first, p1.second + p2.second};
 }
 int q;
 map<pair<int, int>, int> l, s;
 map<int, set<pair<int, int>>> qs;
 int n = 0;
 int gcd(int a, int b) {
   while (b != 0) {
     a = b;
     swap(a, b);
   }
   return a;
 }
 pair<int, int> getp(pair<int, int> p) {
   int g = gcd(p.first, p.second);
   return {p.first / g, p.second / g};
 }
 void add(pair<int, int> p) {
   ++n;
   pair<int, int> t = getp(p);
   ++l[t];
   int d = p.first * p.first + p.second * p.second;
   for (pair<int, int> q : qs[d]) {
     pair<int, int> u = getp(p + q);
     ++s[u];
   }
   qs[d].insert(p);
 }
 void del(pair<int, int> p) {
   --n;
   pair<int, int> t = getp(p);
   --l[t];
   int d = p.first * p.first + p.second * p.second;
   qs[d].erase(p);
   for (pair<int, int> q : qs[d]) {
     pair<int, int> u = getp(p + q);
     --s[u];
   }
 }
 int get(pair<int, int> p) {
   pair<int, int> t = getp(p);
   return n - l[t] - 2 * s[t];
 }
 inline void solve() {
   for (int i = 0; i < q; i++) {
     int t;
     pair<int, int> p;
     cin >> t >> p.first >> p.second;
     if (t == 1) {
       add(p);
     } else if (t == 2) {
       del(p);
     } else if (t == 3) {
       int ans = get(p);
       cout << ans <<
 ;
     }
   }
 }
 inline void read() { cin >> q; }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 100005;
 vector<pair<int, int>> adj[N], fish[N];
 int n, m, now, depth[N];
 struct node_t {
   int x, d, v;
   node_t(int x, int d, int v, int t = 0) : x(x - d * t), d(d), v(v) {}
   bool operator<(const node_t &b) const {
     int p = x + now * d, q = b.x + now * b.d;
     return p == q ? d < b.d : p < q;
   }
 };
 struct collision_t {
   node_t x, y;
   int when;
   collision_t(node_t x, node_t y) : x(x), y(y) { when = y.x - x.x >> 1; }
   bool operator<(const collision_t &b) const {
     if (when != b.when) {
       return when < b.when;
     } else {
       return make_tuple(x.x, x.v, y.x, y.v) <
              make_tuple(b.x.x, b.x.v, b.y.x, b.y.v);
     }
   }
 };
 struct info_t {
   set<collision_t> collisions;
   set<node_t> nodes;
   void insert_collision(node_t x, node_t y) {
     if (x.d > 0 && y.d < 0) {
       collisions.insert(collision_t(x, y));
     }
   }
   void erase_collision(node_t x, node_t y) {
     if (x.d > 0 && y.d < 0) {
       collisions.erase(collision_t(x, y));
     }
   }
   void insert(node_t x) {
     if (!x.v) {
       return;
     }
     if (nodes.find(x) != nodes.end()) {
       x.v += nodes.find(x)->v;
       erase(*nodes.find(x));
     }
     auto it = nodes.insert(x).first, next = it;
     ++next;
     if (it != nodes.begin()) {
       auto prev = it;
       --prev;
       if (next != nodes.end()) {
         erase_collision(*prev, *next);
       }
       insert_collision(*prev, x);
     }
     if (next != nodes.end()) {
       insert_collision(x, *next);
     }
   }
   void erase(node_t x) {
     auto it = nodes.find(x), next = it;
     ++next;
     if (next != nodes.end()) {
       erase_collision(x, *next);
     }
     if (it != nodes.begin()) {
       auto prev = it;
       --prev;
       erase_collision(*prev, x);
       if (next != nodes.end()) {
         insert_collision(*prev, *next);
       }
     }
     nodes.erase(it);
   }
   int reset(int x, int y) {
     node_t l(x + 1, -1, y, now), r(x - 1, 1, y, now);
     return max(0, y - max(nodes.find(l) == nodes.end() ? 0 : nodes.find(l)->v,
                           nodes.find(r) == nodes.end() ? 0 : nodes.find(r)->v));
   }
   node_t cancel(node_t x, node_t y) {
     if (x.v > y.v) {
       return node_t(x.x, x.d, x.v - y.v);
     } else {
       return node_t(y.x, y.d, y.v - x.v);
     }
   }
   void collide(collision_t x) {
     erase(x.x);
     erase(x.y);
     insert(cancel(x.x, x.y));
   }
   void maintain(int x) {
     while (!collisions.empty() && collisions.begin()->when <= x) {
       collide(*collisions.begin());
     }
   }
   void merge(info_t &b) {
     if (nodes.size() < b.nodes.size()) {
       swap(nodes, b.nodes);
       swap(collisions, b.collisions);
     }
     for (auto x : b.nodes) {
       insert(x);
     }
   }
   int query() {
     int answer = 0;
     for (auto x : nodes) {
       if (x.d > 0) {
         answer += x.v;
       }
     }
     return answer;
   }
 } info[N];
 void dfs(int x, int parent) {
   for (auto e : adj[x]) {
     int y = e.first, w = e.second;
     if (y != parent) {
       depth[y] = depth[x] + w;
       dfs(y, x);
     }
   }
 }
 void solve(int x, int parent) {
   for (auto e : adj[x]) {
     int y = e.first, w = e.second;
     if (y != parent) {
       solve(y, x);
       now = -depth[y];
       info[y].maintain(-(depth[x] + 1));
       now = -(depth[x] + 1);
       info[x].merge(info[y]);
     }
   }
   now = -(depth[x] + 1);
   for (auto &e : fish[x]) {
     e.second = info[x].reset(e.first, e.second);
   }
   info[x].maintain(-depth[x]);
   now = -depth[x];
   for (auto e : fish[x]) {
     info[x].insert(node_t(e.first, -1, e.second, now));
     info[x].insert(node_t(e.first, 1, e.second, now));
   }
 }
 int main() {
   scanf( d , &n);
   for (int i = 1; i < n; ++i) {
     int x, y, w;
     scanf( d d d , &x, &y, &w);
     --x;
     --y;
     w <<= 1;
     adj[x].emplace_back(y, w);
     adj[y].emplace_back(x, w);
   }
   scanf( d , &m);
   for (int i = 1; i <= m; ++i) {
     int day, value, where;
     scanf( d d d , &day, &value, &where);
     day <<= 1;
     --where;
     fish[where].emplace_back(day, value);
   }
   dfs(0, -1);
   solve(0, -1);
   info[0].maintain(INT_MAX);
   printf( d
 , info[0].query());
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, i, j, k;
   double maxm, sum, r;
   cin >> n;
   double A[n];
   for (i = 0; i < n; i++) cin >> A[i];
   sort(A, A + n);
   maxm = A[n - 1];
   for (i = n - 1; i >= 0; i--) {
     sum = 0;
     for (j = n - 1; j >= i; j--) {
       r = A[j];
       for (k = n - 1; k >= i; k--) {
         if (k != j) r = r * (double(1.0) - A[k]);
       }
       sum += r;
     }
     if (sum > maxm) maxm = sum;
   }
   cout << setprecision(10) << maxm << endl;
 }


#include <bits/stdc++.h>
 void fre() {
   freopen( c://test//input.in ,  r , stdin);
   freopen( c://test//output.out ,  w , stdout);
 }
 template <class T>
 inline void gmax(T &a, T b) {
   if (b > a) a = b;
 }
 template <class T>
 inline void gmin(T &a, T b) {
   if (b < a) a = b;
 }
 using namespace std;
 const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, maxint = 2147483647,
           ms31 = 522133279, ms63 = 1061109567, ms127 = 2139062143;
 const double eps = 1e-8, PI = acos(-1.0);
 int n, m;
 int x, y;
 int ind[N], s[N], num, top;
 vector<int> a[N], b[N];
 bool e[N];
 void dfs(int x) {
   e[x] = 1;
   num++;
   if (ind[x] == 0) s[++top] = x;
   for (int i = a[x].size() - 1; i >= 0; i--) {
     int y = a[x][i];
     if (!e[y]) dfs(y);
   }
 }
 int main() {
   while (~scanf( dd , &n, &m)) {
     memset(ind, 0, sizeof(ind));
     for (int i = 1; i <= n; i++) a[i].clear(), b[i].clear();
     for (int i = 1; i <= m; i++) {
       scanf( dd , &x, &y);
       ind[y]++;
       a[x].push_back(y);
       a[y].push_back(x);
       b[x].push_back(y);
     }
     int ans = 0;
     memset(e, 0, sizeof(e));
     for (int i = 1; i <= n; i++)
       if (!e[i]) {
         num = top = 0;
         dfs(i);
         int sum = top;
         while (top) {
           int x = s[top--];
           for (int j = b[x].size() - 1; j >= 0; j--) {
             int y = b[x][j];
             ind[y]--;
             if (ind[y] == 0) {
               s[++top] = y;
               sum++;
             }
           }
         }
         if (sum == num)
           ans += (num - 1);
         else
           ans += num;
       }
     printf( d
 , ans);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int t;
   cin >> t;
   while (t--) {
     int a, b, c;
     cin >> a >> b >> c;
     if (a > b) swap(a, b);
     int mx = (b - a) * 2;
     if (a > mx || b > mx || c > mx)
       cout <<  -1
 ;
     else {
       if (c > mx / 2)
         cout << c - mx / 2 <<
 ;
       else
         cout << c + mx / 2 <<
 ;
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, a[50100];
 long long m, ans;
 struct node {
   int s, cnt[30];
   node *ch[2];
   node();
 } * tp, *nul, *root[50100];
 int getint() {
   char ch;
   while (!isdigit(ch = getchar()))
     ;
   int x = ch - '0';
   for (; isdigit(ch = getchar()); x = x * 10 + ch - '0')
     ;
   return x;
 }
 node::node() { ch[0] = tp, tp = this; }
 node *newnode(node *x) {
   if (!tp) new node[50000];
   node *t = tp;
   tp = t->ch[0], *t = *x;
   return t;
 }
 void insert(node *&x, node *y, int w) {
   node *ret = newnode(y);
   ++(x = ret)->s;
   for (int i = 29; i >= 0; --i) {
     for (int j = 0; j <= i; ++j) x->cnt[j] += (w >> j) & 1;
     int t = (w >> i) & 1;
     x->ch[t] = newnode(y = y->ch[t]), ++(x = x->ch[t])->s;
   }
   x = ret;
 }
 int main() {
   scanf( dextra , &n, &m);
   nul = new node, tp = 0;
   memset(nul, 0, sizeof(node));
   root[1] = nul->ch[0] = nul->ch[1] = nul;
   for (int i = 1; i <= n; ++i) insert(root[i + 1], root[i], a[i] = getint());
   for (int i = 29; i >= 0; --i) {
     long long sum = 0;
     for (int j = 2; j <= n; ++j) sum += root[j]->ch[1 ^ ((a[j] >> i) & 1)]->s;
     if (sum < m) {
       m -= sum, ans += (1LL << i) * sum;
       for (int j = 2; j <= n; ++j) {
         node *x = root[j]->ch[1 ^ ((a[j] >> i) & 1)];
         for (int k = 0; k <= i - 1; ++k)
           ans +=
               (1LL << k) * (((a[j] >> k) & 1) ? x->s - x->cnt[k] : x->cnt[k]);
         root[j] = root[j]->ch[(a[j] >> i) & 1];
       }
     } else {
       ans += (1LL << i) * m;
       for (int j = 2; j <= n; ++j) root[j] = root[j]->ch[1 ^ ((a[j] >> i) & 1)];
     }
   }
   printf( d
 , ans  1000000007);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int a[200001];
 void op(int i) {
   int res = a[i] ^ a[i + 1] ^ a[i + 2];
   a[i] = a[i + 1] = a[i + 2] = res;
 }
 vector<int> push_left(int i) {
   vector<int> v;
   while (i - 2 >= 1 && a[i] == 0 && a[i - 1] == 1 && a[i - 2] == 1) {
     op(i - 2);
     v.push_back(i - 2);
     i -= 2;
   }
   return v;
 }
 vector<int> push_right(int i, int n) {
   vector<int> v;
   while (i + 2 <= n && a[i] == 0 && a[i + 1] == 1 && a[i + 2] == 1) {
     op(i);
     v.push_back(i);
     i += 2;
   }
   return v;
 }
 int main() {
   int i, t;
   for (scanf( d , &t); t--;) {
     int n;
     vector<int> v, ans;
     int cum = 0;
     for (scanf( d , &n), i = 1; i <= n; ++i) {
       scanf( d , a + i);
       cum += a[i];
     }
     if (cum == 0) {
       printf( YES
0
 );
       continue;
     } else if ((cum & 1) || cum == n) {
       printf( NO
 );
       continue;
     }
     int cur = 1;
     if (a[1]) {
       cum = a[1];
       cur = 2;
       while (cur <= n && a[cur]) cum += a[cur], ++cur;
       if (cum & 1) {
         --cur;
         bool y = 1;
         while (cur <= n && a[cur]) {
           if (cur + 2 <= n) {
             if (a[cur] + a[cur + 1] + a[cur + 2] == 3) {
               cur += 2;
             } else if (a[cur + 1] + a[cur + 2] == 0) {
               ans.push_back(cur);
               op(cur);
               cur += 2;
             } else if (a[cur + 1] == 0 && a[cur + 2] == 1) {
               ans.push_back(cur);
               op(cur);
               auto push_vec = push_left(cur);
               ans.insert(ans.end(), push_vec.begin(), push_vec.end());
               cur += 3;
               break;
             } else {
               auto push_vec = push_left(cur + 2);
               ans.insert(ans.end(), push_vec.begin(), push_vec.end());
               cur += 3;
               break;
             }
           } else {
             y = 0;
             break;
           }
         }
         if (y == 0) {
           printf( NO
 );
           continue;
         }
       } else {
         ans = push_left(cur);
       }
     }
     cur = 1;
     while (cur + 2 <= n) {
       if (a[cur] == 0 && a[cur + 1] + a[cur + 2] == 2) {
         op(cur);
         ans.push_back(cur);
         cur += 2;
       } else if (a[cur]) {
         int st = cur - 1;
         while (1) {
           if (cur + 2 <= n && a[cur + 1] + a[cur + 2] == 2)
             cur += 2;
           else if (cur + 2 <= n && a[cur + 1] + a[cur + 2] == 0) {
             op(cur);
             ans.push_back(cur);
             cur += 2;
           } else if (cur + 2 <= n && a[cur + 1] == 0 && a[cur + 2] == 1) {
             op(cur);
             ans.push_back(cur);
             break;
           } else {
             break;
           }
         }
         auto push_vec = push_right(st, n);
         ans.insert(ans.end(), push_vec.begin(), push_vec.end());
       } else
         ++cur;
     }
     cum = 0;
     for (i = 1; i <= n; ++i) cum += a[i];
     if (cum == 0) {
       printf( YES
d
 , ans.size());
       for (auto x : ans) printf( d  , x);
       puts(  );
     } else
       printf( NO
 );
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <typename T>
 inline void read(T& x) {
   x = 0;
   char s = (char)getchar();
   bool f = false;
   while (!(s >= '0' && s <= '9')) {
     if (s == '-') f = true;
     s = (char)getchar();
   }
   while (s >= '0' && s <= '9') {
     x = (x << 1) + (x << 3) + s - '0';
     s = (char)getchar();
   }
   if (f) x = (~x) + 1;
 }
 const long long N = 2e6 + 5, mod = 998244353, MAX = 2e6;
 long long power[N], fac[N], inv[N];
 inline long long quickpow(long long a, long long b, long long p = mod) {
   long long res = 1;
   while (b) {
     if (b & 1) res = res * a  p;
     a = a * a  p;
     b >>= 1;
   }
   return res;
 }
 inline long long C(long long n, long long m) {
   if (n < m) return 0;
   return fac[n] * inv[m]  mod * inv[n - m]  mod;
 }
 long long n;
 long long ans[N];
 void init() {
   long long limit = 2e5;
   long long x = 810;
   ans[1] = 10;
   ans[2] = 180;
   for (register long long i = 3; i <= limit; ++i) {
     ans[i] = ans[i - 1] * 10 + x;
     x *= 10;
     ans[i] = mod, x = mod;
   }
 }
 signed main() {
   init();
   long long n;
   cin >> n;
   for (register long long i = n; i >= 1; --i) cout << ans[i] <<    ;
   cout << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int kN = 100 + 1;
 const int kA = 256;
 bool dp[kN][kN][kA];
 bool used[kN][kN][kA];
 vector<pair<int, int> > g[kN];
 bool Dp(int u, int v, int mark) {
   if (!used[u][v][mark]) {
     used[u][v][mark] = true;
     dp[u][v][mark] = false;
     for (const auto& edge : g[u]) {
       if (edge.second < mark) {
         continue;
       }
       dp[u][v][mark] = dp[u][v][mark] || !Dp(v, edge.first, edge.second);
     }
   }
   return dp[u][v][mark];
 }
 void Solve() {
   int n, m;
   cin >> n >> m;
   for (int i = 0; i < m; ++i) {
     int u, v;
     char ch;
     cin >> u >> v >> ch;
     g[u - 1].emplace_back(v - 1, int(ch));
   }
   for (int u = 0; u < n; ++u) {
     for (int v = 0; v < n; ++v) {
       cout << (Dp(u, v, 0) ? 'A' : 'B');
     }
     cout << '
';
   }
 }
 int main() {
   std::ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int tests_count = 1;
   for (int test_index = 0; test_index < tests_count; ++test_index) {
     Solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MOD = 1e9 + 7;
 int n, S, L;
 int a[300005];
 int dp[300005];
 void solve() {
   deque<pair<int, int> > dqmin, dqmax, dqdp;
   int pos = 0;
   for (int i = 1; i <= n; i++) {
     if (i >= L) {
       while (dqdp.size() && dqdp.back().first >= dp[i - L]) dqdp.pop_back();
       dqdp.push_back(make_pair(dp[i - L], i - L));
     }
     while (dqmax.size() && dqmax.back().first <= a[i]) dqmax.pop_back();
     dqmax.push_back(make_pair(a[i], i));
     while (dqmin.size() && dqmin.back().first >= a[i]) dqmin.pop_back();
     dqmin.push_back(make_pair(a[i], i));
     while (dqmax.size() && dqmax.front().first - dqmin.front().first > S) {
       pos++;
       if (dqmax.front().second < pos) dqmax.pop_front();
       if (dqmin.front().second < pos) dqmin.pop_front();
     }
     while (dqdp.size() && dqdp.front().second < pos - 1) dqdp.pop_front();
     if (dqdp.size()) dp[i] = dqdp.front().first + 1;
   }
 }
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   cin >> n;
   cin >> S >> L;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
     dp[i] = n + 1;
   }
   solve();
   if (dp[n] <= n)
     cout << dp[n];
   else
     cout << -1;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long MaxN = 600005;
 template <class t>
 inline void rd(t &s) {
   s = 0;
   register char c = getchar();
   while (!isdigit(c)) c = getchar();
   while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
   return;
 }
 long long a[MaxN], b[MaxN], vis[MaxN * 3];
 struct Quetion {
   long long idx, pos, val;
 } que[MaxN];
 struct SegTree {
   struct Node {
     long long val, lazy;
   };
   Node tr[MaxN << 2];
   inline void clear() {
     memset(tr, 0, sizeof tr);
     return;
   }
   inline void pushup(long long u) {
     tr[u].val = max(tr[(u << 1)].val, tr[(u << 1 | 1)].val);
     return;
   }
   inline void pushdown(long long u, long long l, long long r) {
     if (tr[u].lazy) {
       tr[(u << 1)].lazy += tr[u].lazy;
       tr[(u << 1 | 1)].lazy += tr[u].lazy;
       tr[(u << 1)].val += tr[u].lazy;
       tr[(u << 1 | 1)].val += tr[u].lazy;
       tr[u].lazy = 0;
     }
     return;
   }
   inline void buildtr(long long u, long long l, long long r) {
     if (l == r) {
       tr[u].val = 0;
       return;
     }
     register long long mid = (l + r) >> 1;
     buildtr((u << 1), l, mid);
     buildtr((u << 1 | 1), mid + 1, r);
     pushup((u >> 1));
     return;
   }
   inline void change(long long u, long long l, long long r, long long ql,
                      long long qr, long long x) {
     if (ql == l && r == qr) {
       tr[u].val += x;
       tr[u].lazy += x;
       return;
     }
     if (l == r) return;
     register long long mid = (l + r) >> 1;
     pushdown(u, l, r);
     if (qr <= mid)
       change((u << 1), l, mid, ql, qr, x);
     else if (mid < ql)
       change((u << 1 | 1), mid + 1, r, ql, qr, x);
     else {
       change((u << 1), l, mid, ql, mid, x);
       change((u << 1 | 1), mid + 1, r, mid + 1, qr, x);
     }
     pushup(u);
     return;
   }
   inline long long query(long long u, long long l, long long r, long long ql,
                          long long qr) {
     if (l == r) return l;
     register long long mid = (l + r) >> 1;
     pushdown(u, l, r);
     if (tr[(u << 1 | 1)].val > 0)
       return query((u << 1 | 1), mid + 1, r, ql, qr);
     else
       return query((u << 1), l, mid, ql, qr);
   }
 } segtree;
 signed main(void) {
   long long n, m, q;
   register long long cnt = 0;
   rd(n);
   rd(m);
   for (long long i = 1; i <= n; ++i) rd(a[i]), vis[++cnt] = a[i];
   for (long long i = 1; i <= m; ++i) rd(b[i]), vis[++cnt] = b[i];
   rd(q);
   for (long long i = 1; i <= q; ++i) {
     rd(que[i].idx);
     rd(que[i].pos);
     rd(que[i].val);
     vis[++cnt] = que[i].val;
   }
   sort(vis + 1, vis + cnt + 1);
   cnt = unique(vis + 1, vis + cnt + 1) - vis - 1;
   for (long long i = 1; i <= n; ++i)
     a[i] = lower_bound(vis + 1, vis + cnt + 1, a[i]) - vis;
   for (long long i = 1; i <= m; ++i)
     b[i] = lower_bound(vis + 1, vis + cnt + 1, b[i]) - vis;
   for (long long i = 1; i <= q; ++i)
     que[i].val = lower_bound(vis + 1, vis + cnt + 1, que[i].val) - vis;
   segtree.buildtr(1, 1, cnt);
   for (long long i = 1; i <= n; ++i) segtree.change(1, 1, cnt, 1, a[i], 1);
   for (long long i = 1; i <= m; ++i) segtree.change(1, 1, cnt, 1, b[i], -1);
   for (long long i = 1; i <= q; ++i) {
     if (que[i].idx == 1) {
       segtree.change(1, 1, cnt, 1, a[que[i].pos], -1);
       a[que[i].pos] = que[i].val;
       segtree.change(1, 1, cnt, 1, a[que[i].pos], 1);
     } else {
       segtree.change(1, 1, cnt, 1, b[que[i].pos], 1);
       b[que[i].pos] = que[i].val;
       segtree.change(1, 1, cnt, 1, b[que[i].pos], -1);
     }
     if (segtree.tr[1].val <= 0)
       puts( -1 );
     else
       printf( lld
 , vis[segtree.query(1, 1, cnt, 1, cnt)]);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <typename T>
 void printvec(vector<T>& vec) {
   for (long long int i = 0; i < vec.size(); i++) {
     cout << vec[i] <<    ;
   }
   cout << endl;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   long long int n;
   cin >> n;
   vector<pair<long long int, long long int> > inp;
   for (long long int i = 0; i < n; i++) {
     long long int a, b, c, d;
     cin >> a >> b >> c >> d;
     a = a + b + c + d;
     inp.push_back(make_pair(-a, i));
   }
   sort(inp.begin(), inp.end());
   for (long long int i = 0; i < n; i++) {
     if (inp[i].second == 0) {
       cout << i + 1 <<
 ;
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int s = 1000000;
 int a[1000001];
 bool belongs[1000001];
 bool used[1000001];
 vector<int> ans;
 int main() {
   int n;
   cin >> n;
   for (int i = 0; i <= s; i++) belongs[i] = used[i] = false;
   for (int i = 0; i < n; i++) {
     scanf( i , &a[i]);
     belongs[a[i]] = true;
   }
   int u = 1;
   for (int i = 0; i < n; i++)
     if (!used[a[i]]) {
       if (belongs[a[i]] && !belongs[s - a[i] + 1] && !used[s - a[i] + 1]) {
         ans.push_back(s - a[i] + 1);
         used[s - a[i] + 1] = true;
         used[a[i]] = true;
       } else if (belongs[a[i]] && belongs[s - a[i] + 1]) {
         while (u <= s &&
                (belongs[u] || belongs[s - u + 1] || used[u] || used[s - u + 1]))
           u++;
         used[u] = true;
         used[s - u + 1] = true;
         used[s - a[i] + 1] = true;
         used[a[i]] = true;
         ans.push_back(u);
         ans.push_back(s - u + 1);
         u++;
       } else
         assert(false);
     }
   cout << int(ans.size()) << endl;
   for (int i = 0; i < int(ans.size()); i++) printf( i  , ans[i]);
   cout << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 string n;
 int sz;
 long long mul;
 long long ans;
 long long powe(long long a, long long b) {
   if (!b) return 1;
   long long tmp = powe(a, b / 2);
   tmp = (tmp * tmp)  1000000007;
   if (b  2 == 1)
     return (tmp * a)  1000000007;
   else
     return tmp;
 }
 int main() {
   cin >> n;
   sz = ((int)n.size());
   mul = powe(2, sz - 1);
   long long tp = 1;
   for (int i = sz - 1; i >= 0; i--) {
     if (n[i] == '1') {
       ans = (ans + ((tp * mul)  1000000007))  1000000007;
     }
     tp = (tp * 2)  1000000007;
   }
   cout << ans << endl;
   return 0;
 }


#include <bits/stdc++.h>
 #pragma GCC optimize( Ofast )
 #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma )
 #pragma GCC optimize( unroll-loops )
 using namespace std;
 long long MOD = 998244353;
 double eps = 1e-12;
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n;
   cin >> n;
   string s;
   cin >> s;
   int coins = 0;
   int x, y;
   if (s[0] == 'U') {
     x = 0;
     y = 1;
   } else {
     x = 1;
     y = 0;
   }
   for (int i = 1; i < n; i++) {
     if (s[i] == 'U') {
       if (x == y) {
         if (s[i - 1] == 'U') coins++;
       }
       y++;
     } else {
       if (x == y) {
         if (s[i - 1] == 'R') coins++;
       }
       x++;
     }
   }
   cout << coins;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 10000;
 const int maxm = 20000;
 const int maxk = 10;
 const int inf = 25;
 int tot_edge, sz;
 int head[maxn];
 int nxt[maxm];
 int to[maxm];
 int cap[maxm];
 int flow[maxk + 1][maxm];
 int qu[maxn];
 int prv[maxn];
 int when[maxn];
 int pass_flow[maxn];
 int last_time;
 int level[maxn], edge_pos[maxn];
 int read() {
   int xx = 0, ff = 1;
   char ch = getchar();
   while (ch > '9' || ch < '0') {
     if (ch == '-') ff = -1;
     ch = getchar();
   }
   while (ch >= '0' && ch <= '9') {
     xx = (xx << 3) + (xx << 1) + ch - '0';
     ch = getchar();
   }
   return xx * ff;
 }
 void add_edge(int u, int v, int w) {
   nxt[tot_edge] = head[u];
   head[u] = tot_edge;
   to[tot_edge] = v;
   cap[tot_edge] = w;
   tot_edge++;
 }
 bool bfs(int s, int t, int *flow) {
   sz = 0;
   qu[sz++] = t;
   int pnt = 0;
   memset(level, -1, sizeof(level));
   level[t] = 0;
   while (pnt < sz && level[s] == -1) {
     int u = qu[pnt++];
     for (int e = head[u]; e >= 0; e = nxt[e]) {
       int v = to[e];
       if (level[v] == -1 && flow[e ^ 1] < cap[e ^ 1]) {
         level[v] = level[u] + 1;
         qu[sz++] = v;
       }
     }
   }
   return level[s] != -1;
 }
 int dinic(int s, int t, int *flow) {
   int ret = 0;
   while (bfs(s, t, flow)) {
     copy(head, head + maxn, edge_pos);
     function<int(int, int)> find_path = [&](int u, int res) {
       if (u == t) return res;
       for (int &e = edge_pos[u]; e >= 0; e = nxt[e]) {
         int v = to[e];
         if (flow[e] == cap[e] || level[u] - 1 != level[v]) continue;
         int push = find_path(v, min(res, cap[e] - flow[e]));
         if (push > 0) {
           flow[e] += push;
           flow[e ^ 1] -= push;
           if (flow[e] == cap[e]) e = nxt[e];
           return push;
         }
       }
       return 0;
     };
     for (int f; (f = find_path(s, 1e9)) > 0;) ret += f;
   }
   return ret;
 }
 int augment(int s, int t, int *flow) {
   last_time++;
   sz = 0;
   qu[sz++] = s;
   when[s] = last_time;
   int pnt = 0;
   pass_flow[s] = inf;
   pass_flow[t] = 0;
   while (pnt < sz && when[t] != last_time) {
     int u = qu[pnt++];
     assert(pass_flow[u] > 0);
     for (int e = head[u]; e >= 0; e = nxt[e]) {
       int v = to[e];
       if (when[v] != last_time && flow[e] < cap[e]) {
         pass_flow[v] = min(pass_flow[u], cap[e] - flow[e]);
         prv[v] = e;
         when[v] = last_time;
         qu[sz++] = v;
         if (v == t) break;
       }
     }
   }
   int f = pass_flow[t];
   if (f == 0) return f;
   do {
     int e = prv[t];
     flow[e] += f;
     flow[e ^ 1] -= f;
     assert(to[e] == t);
     t = to[e ^ 1];
   } while (t != s);
   return f;
 }
 int max_flow(int s, int t, int *flow) {
   int res = 0, cur = 0;
   do {
     cur = augment(s, t, flow);
     res += cur;
   } while (cur);
   return res;
 }
 int n, m, k, q;
 int masked[1 << maxk];
 void go(int n, int m, int mask, int pointer) {
   for (int i = 0; (mask >> i & 1) == 0 && i < k; ++i) {
     int n_mask = mask | (1 << i);
     copy(flow[pointer], flow[pointer] + m, flow[pointer + 1]);
     cap[2 * i] = inf;
     masked[n_mask] = masked[mask] + max_flow(0, n - 1, flow[pointer + 1]);
     go(n, m, n_mask, pointer + 1);
     cap[2 * i] = 0;
   }
 }
 int wei[maxk];
 int suma[1 << maxk];
 int eptr;
 struct info {
   int u, v, w;
 } edges[maxm];
 vector<int> adj[maxn];
 void relabel(int n, int m) {
   sz = 0;
   qu[sz++] = 0;
   int pnt = 0;
   memset(level, -1, sizeof(level));
   level[0] = 0;
   level[n - 1] = n - 1;
   while (pnt < sz) {
     int u = qu[pnt++];
     for (auto v : adj[u]) {
       if (level[v] == -1) {
         level[v] = sz;
         qu[sz++] = v;
       }
     }
   }
   for (int i = 0; i < n; ++i)
     if (level[i] == -1) level[i] = sz++;
   for (int i = 0; i < m; ++i) {
     edges[i].u = level[edges[i].u];
     edges[i].v = level[edges[i].v];
   }
 }
 int main() {
   memset(head, -1, sizeof head);
   n = read();
   m = read();
   k = read();
   q = read();
   for (int i = 0; i < m; ++i) {
     int u, v, w;
     u = read();
     v = read();
     w = read();
     u--;
     v--;
     edges[i] = {u, v, w};
     adj[u].push_back(v);
   }
   relabel(n, m);
   for (int i = 0; i < m; ++i) {
     add_edge(edges[i].u, edges[i].v, edges[i].w);
     add_edge(edges[i].v, edges[i].u, 0);
   }
   masked[0] = dinic(0, n - 1, flow[0]);
   go(n, 2 * m, 0, 0);
   int top = (1 << k) - 1;
   for (int i = 0; i < q; ++i) {
     for (int j = 0; j < k; ++j) wei[j] = read();
     int answer = masked[top];
     for (int j = 1; j < (1 << k); j++) {
       int x = __builtin_ctz(j);
       suma[j] = suma[j ^ (1 << x)] + wei[x];
       answer = min(answer, masked[top ^ j] + suma[j]);
     }
     printf( d
 , answer);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   string n;
   cin >> n;
   cout <<  25  << endl;
   return 0;
 }


#include <bits/stdc++.h>
 #pragma GCC optimize( Ofast )
 using namespace std;
 const int maxn = 1000100;
 int cnt_neg = 0, cnt_pos = 0;
 int arr[maxn << 1];
 int main() {
   int n;
   scanf( d , &n);
   for (int e = 1; e <= n; e++) scanf( d , arr + e), arr[e + n] = arr[e];
   int hi = 2 * n, lo = n + 1, nowlo = n;
   long long sum = 0;
   set<pair<int, int> > go;
   unordered_set<int> removido;
   for (int cur = hi; cur >= lo; cur--) {
     if (arr[cur] <= nowlo)
       cnt_pos++;
     else
       cnt_neg++, go.insert(make_pair(arr[cur] - nowlo, cur));
     sum += abs(arr[cur] - nowlo);
     nowlo--;
   }
   long long ans = sum, shift = 0, state = 0;
   for (; lo > 1;) {
     if (arr[hi] <= n)
       cnt_pos--;
     else
       cnt_neg--;
     sum -= abs(arr[hi] - n);
     removido.insert(hi);
     shift++;
     sum += -cnt_neg + cnt_pos;
     sum += abs(arr[lo - 1] - 1);
     if (sum < ans) ans = sum, state = shift;
     if (arr[lo - 1] > 1)
       cnt_neg++, go.insert(make_pair(shift + arr[lo - 1] - 1, lo - 1));
     else
       cnt_pos++;
     while (!go.empty()) {
       int shi, val;
       tie(shi, val) = *go.begin();
       int removal = removido.count(val);
       if (!(removal || shi == shift)) break;
       if (!removal)
         cnt_neg--, cnt_pos++;
       else
         removido.erase(go.begin()->second);
       go.erase(go.begin());
     }
     lo--;
     hi--;
   }
   printf( lld lld
 , ans, state);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long mod(long long v, long long k, long long p) {
   long long res = 1;
   for (long long i = 0; i < 4; i++) res *= v, res = p;
   res -= ((k * v)  p);
   if (res < 0) res += p;
   return res;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   long long n, p, k;
   cin >> n >> p >> k;
   long long Array[n];
   for (long long i = 0; i < n; i++) cin >> Array[i];
   long long B[n];
   for (long long i = 0; i < n; i++) B[i] = mod(Array[i], k, p);
   vector<long long> out;
   sort(B, B + n);
   long long cnt = 1;
   for (long long i = 0; i < n - 1; i++) {
     if (B[i + 1] != B[i] and cnt != 1)
       out.push_back(cnt), cnt = 1;
     else if (B[i + 1] == B[i])
       cnt++;
   }
   if (cnt != 1) out.push_back(cnt);
   long long sum = 0;
   for (long long i = 0; i < out.size(); i++)
     sum += ((out[i] * (out[i] - 1)) / 2);
   cout << sum << '
';
   return 0;
 }


//頑張って
 #include <bits/stdc++.h>
 #define ff first
 #define ss second
 #define ll long long
 #define rep(i, n) for (int i = 0; i < n; i++)
 using namespace std;
 #define all(x) x.begin(), x.end()
 void solve() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a)
       cin >> i;
    int mxn = accumulate(all(a), 0);
    vector <bool> dp(mxn + 1);
    dp[0] = true;
    for (int i = 0; i < n; i++) {
       for (int j = mxn - a[i]; j >= 0; j--) {
          if (dp[j] == true)
             dp[a[i] + j] = true;
       }
    }
    if ((mxn  2 == 0 && !dp[mxn / 2]) || mxn  2) {
       cout <<  0
 ;
       return;
    }
    while (true) {
       for (int i = 0; i < n; i++) {
          if (a[i]  2 != 0) {
             cout <<  1
  << i + 1 << '
';
             return;
          }
          a[i] /= 2;
       }
    }
 }
 int main() {
 #ifndef ONLINE_JUDGE
    freopen( inp.in ,  r , stdin);      freopen( outp.in ,  w , stdout);
 #endif
    ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
    solve();
    return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long inf = (long long)1e18;
 const int N = 1234567;
 long long a[N], b[N];
 int main() {
   int n, k;
   scanf( d d , &n, &k);
   n++;
   for (int i = 0; i < n; i++) {
     int foo;
     scanf( d , &foo);
     a[i] = foo;
   }
   long long z = 0;
   int up = 0;
   for (int i = 0; i < n; i++) {
     z += a[i];
     b[i] = z;
     if (z  2 != 0) {
       break;
     }
     up++;
     z /= 2;
   }
   long long value = 0;
   int ans = 0;
   for (int i = n - 1; i >= 0; i--) {
     if (i <= up) {
       long long tmp = value * 2 + b[i];
       long long z = a[i] - tmp;
       if (-k <= z && z <= k && (i != n - 1 || z != 0)) {
         ans++;
       }
     }
     value = value * 2 + a[i];
     if (value < -inf || value > inf) {
       break;
     }
   }
   printf( d
 , ans);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int di[] = {-1, 0, 1, 0};
 const int dj[] = {0, 1, 0, -1};
 const long long MOD = 1e9 + 7;
 const long long INF = 1e9;
 const double EPS = 1e-11;
 class UnionFind {
  private:
   vector<long long> p, rank, setSize;
   int numSets;

  public:
   UnionFind(int N) {
     setSize.assign(N, 1);
     numSets = N;
     rank.assign(N, 0);
     p.assign(N, 0);
     for (int i = 0; i < N; i++) p[i] = i;
   }
   int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
   bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
   void unionSet(int i, int j) {
     if (!isSameSet(i, j)) {
       numSets--;
       int x = findSet(i), y = findSet(j);
       if (rank[x] > rank[y]) {
         p[y] = x;
         setSize[x] += setSize[y];
       } else {
         p[x] = y;
         setSize[y] += setSize[x];
         if (rank[x] == rank[y]) rank[y]++;
       }
     }
   }
   int numDisjointSets() { return numSets; }
   int sizeOfSet(int i) { return setSize[findSet(i)]; }
 };
 int main() {
   ios::sync_with_stdio(false), cin.tie(0);
   int n;
   cin >> n;
   vector<long long> num(n);
   map<int, int> idx, vis;
   for (int i = 0; i < n; ++i) cin >> num[i], idx[num[i]] = i;
   vector<long long> num2 = num;
   sort(num2.begin(), num2.end());
   UnionFind dsu(n);
   for (int i = 0; i < n; ++i) {
     swap(num[i], num[idx[num2[i]]]);
     dsu.unionSet(i, idx[num2[i]]);
   }
   for (int i = 0; i < n; ++i) num[i] = dsu.findSet(i);
   map<int, vector<long long> > r;
   for (int i = 0; i < n; ++i) r[num[i]].push_back(i + 1);
   cout << r.size() << endl;
   for (map<int, vector<long long> >::iterator i = r.begin(); i != r.end();
        ++i) {
     cout << i->second.size() <<    ;
     for (int j = 0; j < i->second.size(); ++j)
       cout << i->second[j] <<
 [j == i->second.size() - 1];
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 template <typename T>
 using minheap = priority_queue<T, vector<T>, greater<T>>;
 int main() {
   ios_base::sync_with_stdio(false);
   int t;
   cin >> t;
   while (t--) {
     long long w, h;
     cin >> w >> h;
     vector<vector<long long>> a(4);
     for (int i = 0; i < 4; i++) {
       int k, temp;
       cin >> k;
       for (int j = 0; j < k; j++) {
         cin >> temp;
         a[i].push_back(temp);
       }
     }
     long long ans = 0;
     ans = max(ans, (a[0].back() - a[0][0]) * h);
     ans = max(ans, (a[1].back() - a[1][0]) * h);
     ans = max(ans, (a[2].back() - a[2][0]) * w);
     ans = max(ans, (a[3].back() - a[3][0]) * w);
     cout << ans <<
 ;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 char a[5][6] = { aabb ,  abab ,  abba ,  aaaa };
 char s[5][10005];
 bool f[5];
 int find(char s[], int k) {
   int p1 = -1;
   int len = strlen(s);
   int cnt = 0;
   for (int i = len - 1; i >= 0; i--) {
     if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')
       cnt++;
     if (cnt == k) return i;
   }
   return -1;
 }
 bool check(char s[], char t[], int k) {
   int p = find(s, k), q = find(t, k);
   if (p == -1) return false;
   if (q == -1) return false;
   int l1 = strlen(s), l2 = strlen(t);
   if (l1 - p != l2 - q) return false;
   int j = q;
   for (int i = p; i < l1; i++) {
     if (s[i] == t[j])
       j++;
     else
       return false;
   }
   return true;
 }
 int main() {
   int n, k;
   while (scanf( dd , &n, &k) > 0) {
     memset(f, false, sizeof(f));
     for (int i = 1; i <= n; i++) {
       for (int j = 0; j < 4; j++) scanf( s , s[j]);
       if (!check(s[0], s[1], k)) {
         f[0] = true;
         f[3] = true;
       }
       if (!check(s[2], s[3], k)) {
         f[0] = true;
         f[3] = true;
       }
       if (!check(s[0], s[2], k)) {
         f[1] = true;
         f[3] = true;
       }
       if (!check(s[1], s[3], k)) {
         f[1] = true;
         f[3] = true;
       }
       if (!check(s[0], s[3], k)) {
         f[2] = true;
         f[3] = true;
       }
       if (!check(s[2], s[1], k)) {
         f[2] = true;
         f[3] = true;
       }
     }
     bool sol = false;
     if (!f[0] && !f[1] && !f[2]) {
       puts( aaaa );
       continue;
     }
     for (int i = 2; i >= 0; i--) {
       if (!f[i]) {
         puts(a[i]);
         sol = true;
         break;
       }
     }
     if (!sol) puts( NO );
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 100005;
 struct edge {
   int to, index;
   edge(int t = 0, int i = 0) {
     to = t;
     index = i;
   }
 };
 vector<edge> g[N];
 int num[N], ans[N], dep[N], fa[18][N], n, m;
 void add(int from, int to, int index) { g[from].push_back(edge(to, index)); }
 void dfs(int x, int ffa, int d) {
   fa[0][x] = ffa;
   dep[x] = d;
   for (int i = 0; i < g[x].size(); i++) {
     int y = g[x][i].to;
     if (y == ffa) continue;
     dfs(y, x, d + 1);
   }
 }
 void init() {
   m = 0;
   while (n >= (1 << m)) m++;
   for (int i = 1; i <= m; i++) {
     for (int j = 1; j <= n; j++) {
       if (fa[i - 1][j] < 0)
         fa[i][j] = -1;
       else {
         fa[i][j] = fa[i - 1][fa[i - 1][j]];
       }
     }
   }
 }
 int LCA(int x, int y) {
   if (dep[x] < dep[y]) swap(x, y);
   for (int i = m; i >= 0; i--) {
     if ((dep[x] - dep[y]) & (1 << i)) x = fa[i][x];
   }
   if (x == y) return x;
   for (int i = m; i >= 0; i--) {
     if (fa[i][x] != fa[i][y]) {
       x = fa[i][x];
       y = fa[i][y];
     }
   }
   return fa[0][x];
 }
 void dfs2(int x, int fa, int z) {
   for (int i = 0; i < g[x].size(); i++) {
     int y = g[x][i].to;
     if (y == fa) continue;
     dfs2(y, x, g[x][i].index);
     num[x] += num[y];
   }
   ans[z] = num[x];
 }
 int main() {
   int x, y, rt;
   scanf( d , &n);
   for (int i = 1; i < n; i++) {
     scanf( dd , &x, &y);
     add(x, y, i);
     add(y, x, i);
   }
   dfs(1, -1, 0);
   init();
   int TA;
   scanf( d , &TA);
   while (TA--) {
     scanf( dd , &x, &y);
     rt = LCA(x, y);
     num[x]++;
     num[y]++;
     num[rt] -= 2;
   }
   dfs2(1, -1, 0);
   for (int i = 1; i < n; i++) printf( d  , ans[i]);
   printf(
 );
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, a[2 * 100004], b[2 * 100004], c[2 * 100004], poz, x;
 int main() {
   ios::sync_with_stdio(false);
   cin >> n;
   for (int i = 1; i <= n; ++i) {
     cin >> a[i];
     c[a[i]] = 1;
   }
   poz = 1;
   for (int i = 1; i <= n; ++i) {
     cin >> b[i];
     if (c[b[i]] == 0) {
       cout <<  0  ;
       continue;
     }
     for (int j = poz; j <= n; ++j) {
       c[a[j]] = 0;
       if (a[j] == b[i]) {
         cout << j - poz + 1 <<    ;
         poz = j + 1;
         break;
       }
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, cou = 0;
   cin >> n;
   string s;
   cin >> s;
   int res = n + 1;
   for (int i = 0; i < n; i++) {
     if (s[i] == 'H') cou++;
   }
   for (int i = 0; i < n; i++) {
     int cnt = 0;
     for (int j = 0; j < cou; j++) {
       if (s[(i + j)  n] == 'T') cnt++;
     }
     res = min(res, cnt);
   }
   cout << res << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 int x[55], y[55];
 int main(int argc, char** argv) {
   int n;
   scanf( d , &n);
   for (int i = 1; i <= n; i++) scanf( d , &x[i]);
   for (int i = 1; i <= n; i++) scanf( d , &y[i]);
   int sum = 0;
   for (int i = 1; i <= n; i++) {
     sum += x[i] - y[i];
   }
   if (sum >= 0)
     cout <<  Yes ;
   else
     cout <<  No ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class T>
 void read(T &x) {
   T res = 0, f = 1;
   char c = getchar();
   while (!isdigit(c)) {
     if (c == '-') f = -1;
     c = getchar();
   }
   while (isdigit(c)) {
     res = (res << 3) + (res << 1) + c - '0';
     c = getchar();
   }
   x = res * f;
 }
 const long long N = 200000 + 10;
 long long w, a[N], n, mn = 1e13, mx = -1e13, sum;
 int main() {
   read(n), read(w);
   for (int i = 1; i <= n; i++) {
     read(a[i]);
     sum += a[i];
     mn = min(mn, sum);
     mx = max(mx, sum);
   }
   if (abs(mx) > w || abs(mn) > w) {
     printf( 0 );
     return 0;
   }
   long long l = 0, r = w;
   if (mn < 0) {
     l = 0 - mn;
   }
   if (mx > 0) {
     r = w - mx;
   }
   long long ans = r - l + 1;
   if (ans > 0)
     printf( lld , r - l + 1);
   else
     printf( 0 );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline long long getint() {
   long long _x = 0, _tmp = 1;
   char _tc = getchar();
   while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
   if (_tc == '-') _tc = getchar(), _tmp = -1;
   while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
   return _x * _tmp;
 }
 inline long long add(long long _x, long long _y,
                      long long _mod = 1000000007ll) {
   long long _ = _x + _y;
   if (_ >= _mod) _ -= _mod;
   return _;
 }
 inline long long sub(long long _x, long long _y,
                      long long _mod = 1000000007ll) {
   long long _ = _x - _y;
   if (_ < 0) _ += _mod;
   return _;
 }
 inline long long mul(long long _x, long long _y,
                      long long _mod = 1000000007ll) {
   long long _ = _x * _y;
   if (_ >= _mod) _ = _mod;
   return _;
 }
 long long mypow(long long _a, long long _x, long long _mod) {
   if (_x == 0) return 1ll;
   long long _tmp = mypow(_a, _x / 2, _mod);
   _tmp = mul(_tmp, _tmp, _mod);
   if (_x & 1) _tmp = mul(_tmp, _a, _mod);
   return _tmp;
 }
 long long mymul(long long _a, long long _x, long long _mod) {
   if (_x == 0) return 0ll;
   long long _tmp = mymul(_a, _x / 2, _mod);
   _tmp = add(_tmp, _tmp, _mod);
   if (_x & 1) _tmp = add(_tmp, _a, _mod);
   return _tmp;
 }
 inline bool equal(double _x, double _y) {
   return _x > _y - 1e-9 && _x < _y + 1e-9;
 }
 int __ = 1, _cs;
 void build() {}
 long long n, m, a, b;
 void init() {
   n = getint();
   m = getint();
   a = getint() - 1;
   b = getint() - 1;
 }
 void solve() {
   long long ai = a / m, aj = a  m;
   long long bi = b / m, bj = b  m;
   if (ai == bi || (a == 0 && b == n - 1) || m == 1) {
     puts( 1 );
     exit(0);
   }
   if (aj == 0 && (bj == m - 1 || b == n - 1)) {
     puts( 1 );
     exit(0);
   }
   if (aj == 0 || bj == m - 1 || bi == ai + 1 || bj + 1 == aj || b == n - 1) {
     puts( 2 );
     exit(0);
   }
   puts( 3 );
 }
 int main() {
   build();
   while (__--) {
     init();
     solve();
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class L, class R>
 ostream &operator<<(ostream &os, pair<L, R> P) {
   return os <<  (  << P.first <<  ,  << P.second <<  ) ;
 }
 template <class T>
 ostream &operator<<(ostream &os, vector<T> V) {
   os <<  [ ;
   for (auto vv : V) os << vv <<  , ;
   return os <<  ] ;
 }
 template <class TH>
 void _dbg(const char *sdbg, TH h) {
   cerr << sdbg << '=' << h << '
';
 }
 template <class TH, class... TA>
 void _dbg(const char *sdbg, TH h, TA... a) {
   while (*sdbg != ',') cerr << *sdbg++;
   cerr << '=' << h << ',';
   _dbg(sdbg + 1, a...);
 }
 const long long N = 4e5 + 7;
 long long n, a[N], pre[N], ansLen, ansIdx;
 double ans = -1.0;
 double sum(long long l, long long r) {
   return pre[r] - (l > 0 ? pre[l - 1] : 0);
 }
 double f(long long len, long long idx) {
   double ret = pre[idx] - pre[idx - len - 1];
   ret += pre[n] - pre[n - len];
   ret /= len + len + 1;
   ret -= a[idx];
   if (ret > ans) {
     ans = ret;
     ansIdx = idx;
     ansLen = len;
   }
   return ret;
 }
 signed main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   ;
   cin >> n;
   for (long long i = 1; i <= n; i++) cin >> a[i];
   sort(a + 1, a + n + 1);
   for (long long i = 1; i <= n; i++) pre[i] = a[i] + pre[i - 1];
   for (long long i = 1; i <= n; i++) {
     long long cnt = min(i - 1, n - i);
     long long lo = 0, hi = cnt;
     while (hi - lo > 3) {
       long long m1 = lo + (hi - lo) / 3, m2 = hi - (hi - lo) / 3;
       if (f(m1, i) < f(m2, i))
         lo = m1;
       else
         hi = m2;
     }
     for (long long k = lo; k <= hi; k++) f(k, i);
   }
   cout << 2 * ansLen + 1 << '
';
   for (long long i = ansIdx; i >= ansIdx - ansLen; i--) cout << a[i] <<    ;
   for (long long i = n - ansLen + 1; i <= n; i++) cout << a[i] <<    ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int i, n, a, j, b, m, s = 0, t = 0;
   int x[105] = {0};
   cin >> n >> m;
   for (i = 1; i <= m; ++i) {
     cin >> a;
     for (j = a; j <= n; ++j) {
       if (x[j] != 0) break;
       x[j] = a;
     }
   }
   for (i = 1; i <= n; ++i) cout << x[i] <<    ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAXN = 2e5 + 100;
 const int MAXM = 15;
 int N, Q, M;
 int log2(int v) {
   int r = 1;
   while (v >>= 1) r++;
   return r;
 }
 int a[MAXN];
 int t[2][MAXN];
 struct ST {
   int v[3 * MAXN][2][MAXM];
   int l[3 * MAXN], r[3 * MAXN];
   bool lz[3 * MAXN];
   int NXT;
   int sz;
   void updv(const int& n) {
     assert(n != -1 and l[n] != -1 and r[n] != -1);
     for (int i = 0; i <= M; i++)
       for (int j = 0; j < 2; j++) v[n][j][i] = v[l[n]][j][v[r[n]][j][i]];
   }
   void init(int n, int nl, int nr) {
     assert(n != -1 and nl < nr);
     lz[n] = false;
     l[n] = r[n] = -1;
     if (nr - nl == 1) {
       for (int i = 0; i < M; i++)
         for (int j = 0; j < 2; j++) v[n][j][i] = i + 1;
       v[n][a[nl]][M] = M, v[n][!a[nl]][M] = 0;
     }
     if (nr - nl > 1) {
       int m = nl + ((nr - nl) >> 1);
       init(l[n] = NXT++, nl, m);
       init(r[n] = NXT++, m, nr);
       updv(n);
     }
   }
   ST() {}
   ST(const int& s, bool ini) {
     sz = s;
     NXT = 0;
     if (ini) init(NXT++, 0, sz);
   }
   void prop(int n, int nl, int nr) {
     if (!lz[n]) return;
     for (int i = 0; i <= M; i++) swap(v[n][0][i], v[n][1][i]);
     if (nr - nl > 1) {
       lz[l[n]] = !lz[l[n]];
       lz[r[n]] = !lz[r[n]];
     }
     lz[n] = false;
   }
   void upd(int n, int nl, int nr, int gl, int gr) {
     if (gl <= nl and gr >= nr) {
       lz[n] = !lz[n];
       prop(n, nl, nr);
       return;
     }
     if (nr - nl > 1) {
       prop(n, nl, nr);
       int m = nl + ((nr - nl) >> 1);
       if (gl < m)
         upd(l[n], nl, m, gl, gr);
       else
         prop(l[n], nl, m);
       if (gr > m)
         upd(r[n], m, nr, gl, gr);
       else
         prop(r[n], m, nr);
       updv(n);
       return;
     }
     assert(false);
   }
   void upd(int gl, int gr) { upd(0, 0, sz, gl, gr); }
   int qry(int n, int nl, int nr, int gl, int gr, int c = M) {
     prop(n, nl, nr);
     if (gl <= nl and gr >= nr) {
       return v[n][0][c];
     }
     if (nr - nl > 1) {
       int m = nl + ((nr - nl) >> 1);
       if (gr > m) c = qry(r[n], m, nr, gl, gr, c);
       if (gl < m) c = qry(l[n], nl, m, gl, gr, c);
       return c;
     }
     assert(false);
     return -1;
   }
   int qry(int gl, int gr) { return qry(0, 0, sz, gl, gr); }
 } st;
 void q1() {
   int l, r, v;
   scanf( ddd , &l, &r, &v);
   if (v & 1) st.upd(--l, r);
 }
 void q2() {
   int l, r;
   scanf( dd , &l, &r);
   printf( d
 , (st.qry(--l, r) == 0 ? 2 : 1));
 }
 int main() {
   scanf( ddd , &N, &M, &Q);
   for (int i = 0, v; i < N; i++) {
     scanf( d , &v);
     a[i] = v & 1;
   }
   st = *(new ST(N, true));
   for (int i = 0, type; i < Q; i++) {
     scanf( d , &type);
     if (type == 1)
       q1();
     else if (type == 2)
       q2();
   }
   return 0;
 }


#include <bits/stdc++.h>
 const int N = (int)2e5 + 5;
 const int MOD = (int)1e9 + 7;
 const bool MULTI_TEST = true;
 const double PI = acos(-1.0);
 using namespace std;
 void solve() {
   int n;
   cin >> n;
   int a[n];
   int max = 0, index = -1;
   for (int i = 0; i < n; i++) {
     cin >> a[i];
     if (a[i] > max) {
       max = a[i];
     }
   }
   if (*min_element(a, a + n) == max)
     cout <<  -1
 ;
   else {
     for (int i = 0; i < n - 1; i++) {
       if (a[i] == max && a[i] > a[i + 1]) index = i + 1;
     }
     if (index != -1) {
       cout << index << '
';
       return;
     } else {
       for (int i = 1; i < n; i++) {
         if (a[i] == max && a[i] > a[i - 1]) index = i + 1;
       }
     }
     cout << index << endl;
   }
 }
 int main() {
   ios_base::sync_with_stdio(false);
   int t = 1;
   if (MULTI_TEST) cin >> t;
   while (t--) {
     solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long a[100500], c[300], dp[100500][305], z, cnt, tmp, e, s, l, r, n, m, x,
     y, k, j, p, k1, k2, i, cur, rez;
 vector<long long> f[100500];
 long long Abs(long long x) {
   if (x < 0) return -x;
   return x;
 }
 int main() {
   cin >> n >> m >> s >> e;
   for (i = 0; i < n; i++) cin >> a[i];
   for (j = 0; j < m; j++) {
     cin >> x;
     f[x].push_back(j);
   }
   for (i = 0; i <= n; i++)
     for (j = 0; j <= s / e; j++) dp[i][j] = m + 1;
   dp[0][0] = -1;
   for (i = 0; i < n; i++) {
     for (j = 0; j <= s / e; j++)
       if (dp[i][j] != m + 1) {
         long long tmp = upper_bound(f[a[i]].begin(), f[a[i]].end(), dp[i][j]) -
                         f[a[i]].begin();
         if (tmp != f[a[i]].size())
           dp[i + 1][j + 1] = min(dp[i + 1][j + 1], f[a[i]][tmp]);
         dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
       }
   }
   rez = 0;
   for (i = 0; i <= n; i++) {
     for (j = 0; j <= s / e; j++) {
       if (i + dp[i][j] + 1 + j * e <= s && dp[i][j] != m + 1) rez = max(rez, j);
     }
   }
   cout << rez << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 struct data {
   float x, a;
 } h[1005];
 bool cmp(data a, data b) { return a.x < b.x; };
 int main() {
   int n, ans = 2;
   float t, d;
   cin >> n >> t;
   for (int i = 1; i <= n; i++) cin >> h[i].x >> h[i].a;
   sort(h + 1, h + n + 1, cmp);
   for (int i = 1; i < n; i++) {
     d = h[i + 1].x - h[i].x - h[i].a / 2 - h[i + 1].a / 2;
     if (d > t) ans += 2;
     if (abs(d - t) < 1e-6) ans++;
   }
   cout << ans << endl;
   return 0;
 }


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


#include <bits/stdc++.h>
 using namespace std;
 template <typename T>
 using minpq = priority_queue<T, vector<T>, greater<T>>;
 const int N = 5e5 + 5;
 int n;
 long long a[N], x;
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cin >> n;
   for (int i = (0); i < ((n + 1) / 2); i++) cin >> a[i];
   cin >> x;
   long long sum = 0, mn = n / 2 + 1, mx = n;
   vector<pair<long long, long long>> ve;
   for (int i = (n + 1) / 2 - 1; i >= 0; i--) {
     sum += a[i];
     if (x > 0) {
       if (sum <= 0) {
         mn = max(mn,
                  min((long long)n - i + 1, (-sum + x) / x + (n + 1) / 2 - i));
       }
     } else if (x < 0) {
       if (sum > 0) {
         long long val = (sum - x - 1) / -x - 1 + (n + 1) / 2 - i;
         if (n - i + 1 > val) {
           ve.emplace_back(val + 1, n - i);
         }
       } else {
         mn = max(mn, (long long)n - i + 1);
       }
     } else if (sum <= 0) {
       mn = max(mn, (long long)n - i + 1);
     }
   }
   reverse((ve).begin(), (ve).end());
   for (auto &p : ve) {
     if (p.first <= mx && mx <= p.second) {
       mx = p.first - 1;
     }
   }
   if (mn <= mx) {
     cout << mx << '
';
   } else {
     cout <<  -1
 ;
   }
 }


#include <bits/stdc++.h>
 const long long Inf = 1e18;
 const long double eps = 1e-7;
 long long LINF = (long long)2e18;
 using namespace std;
 long long mod = 1e9 + 7;
 long long mod5 = 1e9 + 9;
 long long mod3 = 998244353;
 long long mod4 = 1000003;
 long long mod2 = 1e9 + 123;
 const int MAXN = 10100000;
 const int INF = 1000000000;
 vector<vector<int> > a;
 int n, m;
 vector<pair<int, int> > mx;
 int rec(int pos, vector<int> mxs) {
   if (pos == m) {
     int ss = 0;
     for (long long(i) = 0; (i) < n; (i)++) {
       ss += mxs[i];
     }
     return ss;
   }
   int cur = 0;
   int ss = 0;
   for (long long(i) = 0; (i) < n; (i)++) {
     cur += mxs[i];
     ss += mxs[i];
   }
   int ans = cur;
   for (long long(i) = 0; (i) < n; (i)++) {
     cur = ss;
     vector<int> lol = mxs;
     for (long long(j) = 0; (j) < n; (j)++) {
       if (a[(i + j)  n][mx[pos].second] > mxs[j]) {
         cur += a[(i + j)  n][mx[pos].second] - mxs[j];
         lol[j] = a[(i + j)  n][mx[pos].second];
       }
     }
     ans = max(ans, rec(pos + 1, lol));
   }
   return ans;
 }
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cout.setf(ios::fixed);
   cout.precision(20);
   int tt;
   cin >> tt;
   while (tt--) {
     cin >> n >> m;
     a.clear();
     a.resize(n, vector<int>(m));
     for (long long(i) = 0; (i) < n; (i)++) {
       for (long long(j) = 0; (j) < m; (j)++) {
         cin >> a[i][j];
       }
     }
     mx.clear();
     for (long long(i) = 0; (i) < m; (i)++) {
       int cur = -1;
       for (long long(j) = 0; (j) < n; (j)++) {
         cur = max(cur, a[j][i]);
       }
       mx.push_back({cur, i});
     }
     sort((mx).rbegin(), (mx).rend());
     mx.resize(min(4, m));
     m = min(m, 4);
     vector<int> kek(n, 0);
     cout << rec(0, kek) << '
';
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long M = 1000000007;
 int main() {
   int n, x, y;
   cin >> n >> x >> y;
   string s;
   cin >> s;
   int ans = 0;
   for (int i = 0; i < x; i++) {
     int pos = n - i - 1;
     char current = '0';
     if (i == y) {
       current = '1';
     }
     if (current != s[pos]) {
       ans++;
     }
   }
   cout << ans << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1e6 + 10, OO = 0x3f3f3f3f;
 int dx[] = {1, 0, -1, 0};
 int dy[] = {0, 1, 0, -1};
 int tc, n, m;
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   string s;
   cin >> tc;
   while (tc--) {
     cin >> n >> m;
     cin >> s;
     vector<long long> freq(n + 1, 0);
     vector<int> indx(m);
     for (int i = 0; i < int(m); i++) {
       cin >> indx[i];
       freq[0]++;
       freq[indx[i]]--;
     }
     freq[0]++;
     for (int i = int(1); i <= int(n - 1); i++) freq[i] += freq[i - 1];
     vector<long long> karakter(26, 0);
     for (int i = 0; i < int(n); i++) karakter[s[i] - 'a'] += freq[i];
     for (int i = 0; i < int(26); i++) cout << karakter[i] <<    ;
     cout <<
 ;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1e5 + 10;
 int a[N];
 int sum[11];
 int main() {
   int n;
   cin >> n;
   for (int i = 1; i <= n; ++i) {
     scanf( d , &a[i]);
     sum[a[i]]++;
   }
   while (1) {
     int i, aa[11];
     memset(aa, 0, sizeof(aa));
     for (i = 1; i < 11; ++i) aa[i] = sum[i];
     sort(aa, aa + 11);
     for (i = 0; i < 11; ++i)
       if (aa[i]) break;
     if (aa[10] - aa[i] > 1) {
       if (aa[i] == 1) {
         if (aa[i + 1] == aa[10]) {
           cout << n;
           break;
         }
       }
     } else if (aa[i] == aa[10]) {
       if (aa[i] == 1 || i == 10) {
         cout << n;
         break;
       }
     } else {
       if (aa[i] == 1) {
         if (aa[i + 1] == aa[10]) {
           cout << n;
           break;
         }
       }
       if (aa[i] == aa[9]) {
         cout << n;
         break;
       }
     }
     sum[a[n]]--;
     n--;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class T>
 bool umin(T& a, T b) {
   if (a > b) {
     a = b;
     return 1;
   }
   return 0;
 }
 template <class T>
 bool umax(T& a, T b) {
   if (a < b) {
     a = b;
     return 1;
   }
   return 0;
 }
 long long a, b, c, type, ric[300007], par[300007], cost[300007], d[300007], n,
     m, lvl[300007], P[300007][20 * 2];
 vector<pair<long long, long long> > E[300007];
 pair<pair<long long, long long>, long long> way[300007];
 long long atabul(long long x) {
   if (ric[x] == x) return x;
   return ric[x] = atabul(ric[x]);
 }
 void dfs(long long x, long long y, long long z) {
   lvl[x] = lvl[y] + 1;
   P[x][0] = y;
   cost[x] = z;
   if (z == 1) {
     ric[x] = y;
     atabul(x);
   }
   for (int i = 0; i < int(E[x].size()); i++)
     if (E[x][i].first != y) dfs(E[x][i].first, x, E[x][i].second);
 }
 void build_table() {
   for (int j = 1; j <= 20; j++)
     for (int i = 1; i <= n; i++)
       if (P[i][j - 1] > 0) P[i][j] = P[P[i][j - 1]][j - 1];
 }
 void form_LCA() {
   for (int i = 0; i <= n; i++)
     for (int j = 0; j <= 20; j++) P[i][j] = -1;
   dfs(1, 0, 0);
   build_table();
 }
 long long LCA(long long x, long long y) {
   if (lvl[x] < lvl[y]) swap(x, y);
   for (int i = 20; i >= 0; i--)
     if (lvl[x] - (1 << i) >= lvl[y]) x = P[x][i];
   if (x == y) return x;
   for (int i = 20; i >= 0; i--)
     if (P[x][i] > 0 && P[x][i] != P[y][i]) x = P[x][i], y = P[y][i];
   return P[x][0];
 }
 int main() {
   scanf( lldlld , &n, &m);
   ric[n] = n;
   for (int i = 1; i < n; i++) {
     scanf( lldlldlld , &a, &b, &c);
     E[a].push_back(make_pair(b, c));
     E[b].push_back(make_pair(a, c));
     ric[i] = i;
     way[i] = {{a, b}, c};
   }
   form_LCA();
   while (m--) {
     scanf( lld , &type);
     if (type == 1) {
       scanf( lldlldlld , &a, &b, &c);
       long long tr = LCA(a, b);
       while (atabul(a) != atabul(tr) && c > 0) {
         if (cost[a] == 1) {
           a = atabul(a);
           continue;
         }
         c /= cost[a];
         a = P[a][0];
       }
       while (atabul(b) != atabul(tr) && c > 0) {
         if (cost[b] == 1) {
           b = atabul(b);
           continue;
         }
         c /= cost[b];
         b = P[b][0];
       }
       printf( lld
 , c);
     } else {
       scanf( lldlld , &a, &b);
       long long qm = way[a].first.first, gr = way[a].first.second;
       if (lvl[qm] < lvl[gr]) swap(qm, gr);
       cost[qm] = b;
       if (b == 1) {
         ric[qm] = gr;
         atabul(qm);
       }
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline int in() {
   int32_t x;
   scanf( d , &x);
   return x;
 }
 inline string get() {
   char ch[1000010];
   scanf( s , ch);
   return ch;
 }
 const int MAX_LG = 60;
 const long long maxn = 1e6 + 100;
 const long long base = 29;
 const long long mod = 1e9 + 7;
 const long long INF = 1e18 + 100;
 struct state {
   long long a = 0, b = 0, tp = 0;
   state() {}
   state(long long a, long long b, long long tp) : a(a), b(b), tp(tp) {}
 };
 long long cnt[maxn];
 long long di[51][51][2];
 long long C[51][51];
 long long ways[51][51][2];
 queue<state> q;
 int32_t main() {
   long long n = in(), k = in();
   for (long long i = 0; i < n; i++) cnt[in() / 51]++;
   q.push({cnt[0], cnt[1], 0});
   for (long long i = 0; i <= 50; i++)
     for (long long j = 0; j <= 50; j++) di[i][j][0] = di[i][j][1] = INF;
   for (long long i = 0; i <= 50; i++) {
     for (long long j = 0; j <= i; j++) {
       if (j == 0)
         C[i][j] = 1;
       else
         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1])  mod;
     }
   }
   di[cnt[0]][cnt[1]][0] = 0;
   ways[cnt[0]][cnt[1]][0] = 1;
   while (q.empty() == false) {
     state now = q.front();
     q.pop();
     long long a2 = cnt[0] - now.a;
     long long b2 = cnt[1] - now.b;
     for (long long i = 0; i <= now.a; i++) {
       for (long long j = 0; j <= now.b; j++) {
         if (i + j == 0) continue;
         if (i * 50 + j * 100 > k) continue;
         long long d2 = di[now.a][now.b][now.tp] + 1;
         long long *d3 = &di[a2 + i][b2 + j][now.tp ^ 1];
         if (*d3 == INF) {
           *d3 = d2;
           q.push({a2 + i, b2 + j, now.tp ^ 1});
         }
         if (*d3 == d2) {
           ways[a2 + i][b2 + j][now.tp ^ 1] += ways[now.a][now.b][now.tp] *
                                               C[now.a][i]  mod * C[now.b][j]
                                               mod;
           if (ways[a2 + i][b2 + j][now.tp ^ 1] > mod)
             ways[a2 + i][b2 + j][now.tp ^ 1] -= mod;
         }
       }
     }
   }
   if (ways[cnt[0]][cnt[1]][1] == 0)
     return cout << -1 <<
  << 0 <<
 , 0;
   else {
     cout << di[cnt[0]][cnt[1]][1] <<
 ;
     cout << ways[cnt[0]][cnt[1]][1] <<
 ;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 long long modulo(long long base, long long exponent, long long modulus);
 long long choose(long long n, long long k);
 long long inverse(long long a, long long m);
 void build();
 void fileio();
 long long ncr(long long n, long long r);
 const int nax = 1e6 + 10;
 const int LG = log2(nax) + 1;
 vector<long long> fact(nax);
 long long dp[1LL << 20];
 int32_t main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   long long n, m;
   cin >> n >> m;
   string s;
   cin >> s;
   long long freq[m][m];
   memset(freq, 0, sizeof(freq));
   for (int i = 1; i < n; i++) {
     freq[s[i] - 'a'][s[i - 1] - 'a']++;
     freq[s[i - 1] - 'a'][s[i] - 'a']++;
   }
   for (int i = 0; i < (1LL << m); i++) dp[i] = 1000000000000000;
   for (int mask = 0; mask < (1LL << m); mask++) {
     long long cost = 0;
     for (int i = 0; i < m; i++) {
       for (int j = i + 1; j < m; j++) {
         if ((mask >> i & 1) ^ (mask >> j & 1)) {
           cost += freq[i][j];
         }
       }
     }
     for (int i = 0; i < m; i++) {
       if ((mask & (1LL << i)) == 0) continue;
       dp[mask] = min(dp[mask], dp[mask ^ (1LL << i)] + cost);
       if ((mask ^ (1LL << i)) == 0) dp[mask] = cost;
     }
   }
   long long ans = dp[(1LL << m) - 1];
   cout << ans << '
';
   return 0;
 }
 long long ncr(long long n, long long r) {
   if (r > n || r < 0 || n < 0) return 0;
   long long ans = fact[n];
   long long temp = (fact[n - r] * fact[r])  1000000007;
   ans = (ans * inverse(temp, 1000000007))  1000000007;
   return ans;
 }
 void fileio() {
   freopen( input.txt ,  r , stdin);
   freopen( output.txt ,  w , stdout);
 }
 void build() {
   fact[0] = 1;
   for (long long i = 1; i < nax; i++) fact[i] = (fact[i - 1] * i)  1000000007;
 }
 long long modulo(long long base, long long exponent, long long modulus) {
   if (modulus == 1) return 0;
   long long result = 1;
   base = base  modulus;
   while (exponent > 0) {
     if (exponent  2 == 1) {
       result = (result * base)  modulus;
     }
     exponent = exponent >> 1;
     base = (base * base)  modulus;
   }
   return result;
 }
 long long choose(long long n, long long k) {
   if (k == 0) return 1;
   return (n * choose(n - 1, k - 1)) / k;
 }
 void EE(long long a, long long b, long long &co1, long long &co2) {
   if (a  b == 0) {
     co1 = 0;
     co2 = 1;
     return;
   }
   EE(b, a  b, co1, co2);
   long long temp = co1;
   co1 = co2;
   co2 = temp - co2 * (a / b);
 }
 long long inverse(long long a, long long m) {
   long long x, y;
   EE(a, m, x, y);
   if (x < 0) x += m;
   return x;
 }


#include <bits/stdc++.h>
 using namespace std;
 vector<int> g[100500];
 int c[100500];
 int n;
 bool vis[100500];
 bool dfs(int u, int cu) {
   if (vis[u]) return 0;
   vis[u] = 1;
   bool r = 0;
   if (c[u] != cu) return 1;
   for (int v : g[u]) r |= dfs(v, cu);
   return r;
 }
 int main() {
   scanf( d , &n);
   for (int i = 0, qwe = n - 1; i < qwe; ++i) {
     int u, v;
     scanf( dd , &u, &v);
     u--;
     v--;
     g[u].push_back(v);
     g[v].push_back(u);
   }
   for (int i = 0, qwe = n; i < qwe; ++i) scanf( d , c + i);
   int u = -1, sz = 0;
   for (int i = 0, qwe = n; i < qwe; ++i) {
     set<int> s;
     for (int v : g[i])
       if (c[i] != c[v]) s.insert(v);
     if (s.size() > sz) u = i, sz = s.size();
   }
   if (u == -1) {
     puts( YES
1 );
     return 0;
   }
   vis[u] = 1;
   for (int i = 0, qwe = g[u].size(); i < qwe; ++i)
     if (dfs(g[u][i], c[g[u][i]])) {
       puts( NO );
       return 0;
     }
   printf( YES
d
 , u + 1);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m;
 int a[105][105];
 int main() {
   scanf( d d , &n, &m);
   if (n + m == 3 or n + m == 4)
     printf( -1
 );
   else {
     int num = 2;
     if (n >= m) {
       for (int i = 1; i <= n; i++)
         for (int j = 1; j <= m; j++) {
           if (num > m * n) num = 1;
           a[i][j] = num;
           num += 2;
         }
     } else
       for (int j = 1; j <= m; j++)
         for (int i = 1; i <= n; i++) {
           if (num > m * n) num = 1;
           a[i][j] = num;
           num += 2;
         }
     for (int i = 1; i <= n; i++)
       for (int j = 1; j <= m; j++) {
         printf( d , a[i][j]);
         if (j == m)
           printf(
 );
         else
           printf(   );
       }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const inline int __GET_INT() {
   int ret;
   scanf( d , &ret);
   return ret;
 }
 const int maxn = 2002;
 int n, m;
 char grid[maxn][maxn];
 int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
 int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
 int cntStar(int r, int c) {
   return (grid[r][c] == '*') + (grid[r + 1][c] == '*') +
          (grid[r][c + 1] == '*') + (grid[r + 1][c + 1] == '*');
 }
 void dfs(int r, int c) {
   if (r < 0 || c < 0 || (r + 1) >= n || (c + 1) >= m) {
     return;
   }
   if (cntStar(r, c) != 1) {
     return;
   }
   grid[r][c] = grid[r + 1][c] = grid[r][c + 1] = grid[r + 1][c + 1] = '.';
   for (int i = 0; i < 2; ++i)
     for (int j = 0; j < 2; ++j) {
       for (int k = 0; k < 8; ++k) {
         dfs(r + i + dx[k], c + j + dy[k]);
       }
     }
 }
 int main() {
   n = __GET_INT();
   m = __GET_INT();
   for (int i = 0; i < n; ++i) {
     scanf( s , grid[i]);
   }
   for (int i = 0; (i + 1) < n; ++i)
     for (int j = 0; (j + 1) < m; ++j) {
       dfs(i, j);
     }
   for (int i = 0; i < n; ++i) {
     for (int j = 0; j < m; ++j) printf( c , grid[i][j]);
     puts(  );
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long a[200005];
 int b[200005];
 int n, k, Q;
 long long ans;
 int l, r;
 int main() {
   scanf( d , &Q);
   while (Q--) {
     scanf( dd , &n, &k);
     for (int i = 1; i <= n; i++) scanf( lld , &a[i]);
     for (int i = 1; i <= k; i++) scanf( d , &b[i]);
     sort(a + 1, a + 1 + n);
     sort(b + 1, b + 1 + k);
     int l, r;
     ans = 0;
     l = 1;
     r = n;
     for (int i = 1; i <= k; i++) {
       if (b[i] == 1)
         ans += a[r] + a[r];
       else
         break;
       r--;
     }
     for (int i = k; i >= 1; i--) {
       if (b[i] == 1) break;
       ans += a[l] + a[r];
       r--;
       l += b[i] - 1;
     }
     printf( lld
 , ans);
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 long long max(long long a, long long b) {
   if (a > b) return a;
   return b;
 }
 long long min(long long a, long long b) {
   if (a < b) return a;
   return b;
 }
 const int MOD = 1e9 + 7, N = 102, L = 3005, INF = INT_MAX;
 pair<long long, long long> a[N];
 long long dp[L][N][2];
 int main() {
   int n, l;
   cin >> n >> l;
   for (int i = 0; i < n; i++) {
     cin >> a[i].first >> a[i].second;
   }
   for (int i = 1; i <= l; i++) {
     for (int j = 0; j < n; j++) {
       if (a[j].first == i)
         dp[i][j][0] = 1;
       else if (a[j].first < i) {
         for (int c = 0; c < n; c++) {
           if (c == j) continue;
           if (a[c].second == a[j].first)
             dp[i][j][0] += dp[i - a[j].first][c][0];
           if (a[c].first == a[j].first && a[c].first != a[c].second)
             dp[i][j][0] += dp[i - a[j].first][c][1];
           dp[i][j][0] = MOD;
         }
       }
       if (a[j].second == i)
         dp[i][j][1] = 1;
       else if (a[j].second < i) {
         for (int c = 0; c < n; c++) {
           if (c == j) continue;
           if (a[c].second == a[j].second)
             dp[i][j][1] += dp[i - a[j].second][c][0];
           if (a[c].first == a[j].second && a[c].first != a[c].second)
             dp[i][j][1] += dp[i - a[j].second][c][1];
           dp[i][j][1] = MOD;
         }
       }
     }
   }
   long long ans = 0;
   for (int i = 0; i < n; i++) {
     ans += dp[l][i][0];
     if (a[i].first != a[i].second) ans += dp[l][i][1];
     ans = MOD;
   }
   cout << ans <<
 ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int M = 11, N = 2e5 + 5;
 int n, k;
 int a[N];
 map<int, int> rem[M];
 long long solve() {
   long long ans = 0;
   for (int i = 0; i < n; ++i) {
     unsigned long long f = 10;
     int ln = ((int)(to_string(a[i])).size());
     for (int l = 1; l < M; ++l) {
       int r = (k - (int)((f * a[i])  k))  k;
       ans += rem[l][r];
       if (l == ln && r == a[i]  k) ans--;
       f *= 10;
     }
   }
   return ans;
 }
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cin >> n >> k;
   for (int i = 0; i < n; ++i) {
     cin >> a[i];
     int l = ((int)(to_string(a[i])).size());
     rem[l][a[i]  k]++;
   }
   cout << solve() << '
';
   return 0;
 }


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


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 5e5 + 5;
 int main() {
   long long v, w1, w2, v1, v2;
   cin >> v >> w1 >> w2 >> v1 >> v2;
   long long x = max(v1, v2);
   if (x * x >= v) {
     if (v1 < v2) swap(v1, v2), swap(w1, w2);
     long long ans = 0;
     for (int i = 0; i <= v / v1; i++) {
       ans = max(ans, i * w1 + (v - i * v1) / v2 * w2);
     }
     cout << ans << endl;
   } else {
     if (1.0 * w1 / v1 > 1.0 * w2 / v2) {
       swap(v1, v2), swap(w1, w2);
     }
     long long ans = 0;
     for (int i = 0; i < v2; i++) {
       ans = max(ans, i * w1 + (v - i * v1) / v2 * w2);
     }
     cout << ans << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 const int mod = 1000000007;
 const int inf = 1000000009;
 const long long INF = 1000000000000000009;
 const long long big = 1000000000000000;
 const long double eps = 0.000000000000000000001;
 using namespace std;
 const int M = 100000;
 int W[M + 5], U[M + 5], cnt[M + 5];
 vector<int> D[M + 5], S;
 long long int funkcja(int x) {
   long long int wynik = 0;
   for (auto v : D[x]) wynik += cnt[v] * U[v];
   return wynik;
 }
 void aktualizuj(int x, int c) {
   for (auto v : D[x]) cnt[v] += c;
 }
 int main() {
   ios::sync_with_stdio(false);
   cin.tie();
   cout.tie();
   int n;
   cin >> n;
   for (int i = 1; i <= M; i++) {
     for (int j = i; j <= M; j += i) D[j].push_back(i);
     if (i == 1)
       U[i] = 1;
     else if ((i / D[i][1])  D[i][1] == 0)
       U[i] = 0;
     else
       U[i] = -U[i / D[i][1]];
   }
   long long int wynik = 0;
   for (int i = 1; i <= n; i++) {
     int a;
     cin >> a;
     wynik = max(wynik, (long long int)a);
     for (auto v : D[a]) W[v] = 1;
   }
   for (int j = M; j >= 1; j--) {
     if (!W[j]) continue;
     while (funkcja(j)) {
       wynik = max(wynik, (long long int)j * S.back());
       aktualizuj(S.back(), -1);
       S.pop_back();
     }
     aktualizuj(j, 1);
     S.push_back(j);
   }
   cout << wynik;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int a, b, sum, x;
 int main() {
   cin >> a >> b;
   while (a) {
     sum += a;
     x += a  b;
     a /= b;
     a += x / b;
     x = b;
   }
   cout << sum;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long n, arr[500010], temp, j, i, ans;
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin >> n;
   for (long long i = 0; i < n; i++) {
     cin >> arr[i];
   };
   sort(arr, arr + n);
   i = 0, j = n / 2;
   ans = n;
   while (i < n / 2) {
     while (j < n) {
       if (arr[i] * 2 <= arr[j]) {
         ans--;
         j++;
         break;
       } else
         j++;
     }
     i++;
   }
   cout << ans <<
 ;
 }


#include <bits/stdc++.h>
 using namespace std;
 int l[210000], r[210000];
 vector<pair<int, int> > v;
 int n, m, k;
 int mp[1000];
 int lbit[1000];
 int dp[210000][300];
 int msk[210000];
 int main() {
   for (int i = 0; i < 210000; i++)
     for (int j = 0; j < 300; j++) dp[i][j] = -0x3f3f3f3f;
   dp[0][0] = 0;
   for (int i = 0; i < (1 << 9); i++) {
     int cnt = 0;
     for (int j = 0; j < 8; j++)
       if (i & (1 << j)) {
         mp[i]++;
       } else if (lbit[i] == 0) {
         lbit[i] = (1 << j);
       }
   }
   cin >> n >> m >> k;
   for (int i = 1; i <= n; i++) {
     scanf( dd , &l[i], &r[i]);
     v.push_back({l[i] - 1, i});
     v.push_back({r[i], -i});
   }
   sort(v.begin(), v.end());
   int tim = 0;
   int posmsk = 0;
   int ans = 0;
   int lst = 0;
   for (auto p : v) {
     tim++;
     if (p.second < 0) {
       for (int j = 0; j < (1 << 8); j++)
         if (j & msk[-p.second])
           dp[tim][j ^ msk[-p.second]] =
               max(dp[tim][j ^ msk[-p.second]],
                   dp[tim - 1][j] + max(0, p.first - lst) * (mp[j] & 1));
         else {
           dp[tim][j] =
               max(dp[tim][j], dp[tim - 1][j] + (p.first - lst) * (mp[j] & 1));
         }
       posmsk ^= msk[-p.second];
     } else {
       msk[p.second] = lbit[posmsk];
       posmsk ^= msk[p.second];
       for (int j = 0; j < (1 << 8); j++)
         if ((j & msk[p.second]) == 0) {
           dp[tim][j ^ msk[p.second]] =
               max(dp[tim][j ^ msk[p.second]],
                   dp[tim - 1][j] + (max(0, p.first - lst)) * (mp[j] & 1));
           dp[tim][j] =
               max(dp[tim][j], dp[tim - 1][j] + (p.first - lst) * (mp[j] & 1));
         }
     }
     lst = p.first;
   }
   cout << dp[2 * n][0];
   return ~~(0 ^ 0 ^ 0);
 }


#include <bits/stdc++.h>
 using namespace std;
 const int mod = 998244353;
 const int N = 3005;
 int n, c, a[N], dp[N][N], g[N][N], freq[N], mul[N], imul[N], pw[N], cnt[N];
 int dp2[2][N][1 << 12];
 int inverse(int n) {
   if (n == 1) return 1;
   return inverse(mod  n) * 1LL * (mod - mod / n)  mod;
 }
 inline void add(int &x, int y) {
   x += y;
   if (x >= mod) x -= mod;
 }
 void solve1() {
   for (int i = 1; i <= n; i++) {
     a[i]--;
   }
   memset(dp2, 0, sizeof(dp2));
   int flg = 0;
   dp2[0][0][0] = 1;
   for (int i = 1; i <= n; i++) {
     for (int p = 0; p * c <= i; p++) {
       for (int mask = 0; mask < (1 << c); mask++) {
         dp2[flg ^ 1][p][mask] = 0;
       }
     }
     for (int p = 0; p * c <= i; p++) {
       for (int mask = 0; mask + 1 < (1 << c); mask++) {
         int nmask = mask | (1 << a[i]);
         if (nmask + 1 == (1 << c)) {
           add(dp2[flg ^ 1][p + 1][0], dp2[flg][p][mask]);
         } else {
           add(dp2[flg ^ 1][p][nmask], dp2[flg][p][mask]);
         }
         add(dp2[flg ^ 1][p][mask], dp2[flg][p][mask]);
       }
     }
     flg ^= 1;
   }
   memset(cnt, 0, sizeof(cnt));
   for (int p = 0; p <= n; p++) {
     for (int mask = 0; mask + 1 < (1 << c); mask++) {
       add(cnt[p], dp2[flg][p][mask]);
     }
   }
   add(cnt[0], mod - 1);
   for (int i = 0; i <= n; i++) {
     cout << cnt[i] <<    ;
   }
   cout << '
';
 }
 void solve2() {
   mul[0] = 0;
   pw[0] = 1;
   for (int i = 1; i <= n; i++) {
     mul[i] = mul[i - 1] + mul[i - 1] + 1;
     if (mul[i] >= mod) mul[i] -= mod;
     imul[i] = inverse(mul[i]);
     pw[i] = mul[i] + 1;
   }
   memset(g, 0, sizeof(g));
   for (int i = 1; i <= n; i++) {
     int cnt = 0;
     long long prd = 1;
     memset(freq, 0, sizeof(freq));
     for (int j = i; j <= n; j++) {
       if (freq[a[j]] == 0) {
         cnt++;
       } else {
         (prd *= imul[freq[a[j]]]) = mod;
       }
       freq[a[j]]++;
       (prd *= mul[freq[a[j]]]) = mod;
       if (cnt == c) {
         g[i][j] = prd * imul[freq[a[j]]]  mod;
       }
     }
   }
   memset(dp, 0, sizeof(dp));
   for (int i = 1; i <= n; i++) {
     dp[i][1] = g[1][i];
     for (int j = 1; j <= i; j++) {
       for (int p = 2; p * c <= i; p++) {
         dp[i][p] += dp[j - 1][p - 1] * 1LL * g[j][i]  mod;
         if (dp[i][p] >= mod) dp[i][p] -= mod;
       }
     }
   }
   memset(cnt, 0, sizeof(cnt));
   for (int i = 1; i <= n; i++) {
     for (int p = 1; p * c <= i; p++) {
       cnt[p] += dp[i][p] * 1LL * pw[n - i]  mod;
       if (cnt[p] >= mod) cnt[p] -= mod;
     }
   }
   cnt[0] = mul[n] + mod - cnt[1];
   if (cnt[0] >= mod) cnt[0] -= mod;
   for (int p = 1; p <= n; p++) {
     cnt[p] += mod - cnt[p + 1];
     if (cnt[p] >= mod) cnt[p] -= mod;
   }
   for (int i = 0; i <= n; i++) {
     cout << cnt[i] <<    ;
   }
   cout << '
';
 }
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cin >> n >> c;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
   }
   if (c <= 10) {
     solve1();
   } else {
     solve2();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int ans[101000], mark[101000];
 char s[101000];
 int n, top, now, n_;
 int main() {
   do s[++n_] = getchar();
   while (s[n_] != '=');
   scanf( d , &n);
   mark[1] = 0;
   top = 1;
   for (int i = 3; i < n_; i += 4) mark[++top] = (s[i] == '-');
   now = 0;
   for (int i = 1; i <= top; i++) ans[i] = 1;
   for (int i = 1; i <= top; i++)
     if (mark[i])
       now--;
     else
       now++;
   while (now != n) {
     if (now < n) {
       int q = 0;
       for (int i = 1; i <= top; i++)
         if (!mark[i] && ans[i] < n) {
           q = i;
           break;
         }
       if (!q) {
         printf( Impossible );
         return 0;
       }
       int inc = min(n - ans[q], n - now);
       ans[q] += inc;
       now += inc;
     } else {
       int q = 0;
       for (int i = 1; i <= top; i++)
         if (mark[i] && ans[i] < n) {
           q = i;
           break;
         }
       if (!q) {
         printf( Impossible );
         return 0;
       }
       int inc = min(n - ans[q], now - n);
       ans[q] += inc;
       now -= inc;
     }
   }
   printf( Possible
 );
   printf( d , ans[1]);
   for (int i = 2; i <= top; i++) {
     putchar(' ');
     if (mark[i])
       putchar('-');
     else
       putchar('+');
     putchar(' ');
     printf( d , ans[i]);
   }
   printf(  = d , n);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int mod = 1e9 + 7;
 const int maxn = 4e5 + 5;
 long long a[maxn], f[maxn], d[maxn];
 int q[maxn];
 int main() {
   int n, i, j, l, r;
   long long c;
   scanf( dlld , &n, &c);
   for (i = 1; i < (n << 1); i++) {
     scanf( lld , &a[i]);
     a[i] += a[i - 1];
   }
   l = r = 1;
   j = q[1] = 0;
   for (i = 1; i <= n; i++) {
     while (j < i && a[(i << 1) - 1] - a[j << 1] > c) j++;
     while (l <= r && q[l] < j) l++;
     if (j) f[i] = f[j - 1] + c;
     if (l <= r) f[i] = max(f[i], d[q[l]] + a[(i << 1) - 1]);
     d[i] = f[i] - a[i << 1];
     while (l <= r && d[i] > d[q[r]]) r--;
     q[++r] = i;
   }
   printf( lld
 , f[n]);
   return 0;
 }


#include <bits/stdc++.h>
 template <typename T>
 std::istream& operator>>(std::istream& input, std::vector<T>& v) {
   for (T& a : v) input >> a;
   return input;
 }
 void answer(bool v) {
   constexpr const char* s[2] = { NO ,  YES };
   std::cout << s[v] << '
';
 }
 void solve(const std::vector<unsigned>& a) {
   const size_t n = a.size();
   for (size_t i = 1; i < n; ++i) {
     if (a[i] >= a[i - 1]) return answer(true);
   }
   answer(false);
 }
 void test_case() {
   size_t n;
   std::cin >> n;
   std::vector<unsigned> a(n);
   std::cin >> a;
   solve(a);
 }
 int main() {
   size_t t;
   std::cin >> t;
   while (t-- > 0) test_case();
   return 0;
 }


/**
  *    author:  Ujjwal Tripathi
  *    created: 15.04.2021 18:04:04
 **/

 #include<bits/stdc++.h>
 using namespace std;

 #define ar array<ll, 2>
 #define ll long long
 #define in insert
 #define pb push_back
 #define pii pair<ll,ll>
 #define vt vector
 #define P_Q(x) priority_queue<x>
 #define p_q(x) priority_queue<x, vector<x>, greater<x>>
 #define For(i, n) for(ll i = 0; i < n; i++)
 #define Rev(i, n) for(ll i = n-1; i >= 0; i--)
 #define FOR(i, n) for(ll i = 1; i <= n; i++)
 #define REV(i, n) for(ll i = n; i >= 1; i--)
 #define Rep(i,a,b) for(ll i = a; i <= b; i++)
 #define all(x) (x).begin(),(x).end()
 #define rall(x) (x).rbegin(), (x).rend()
 #define sz(x) (int) (x).size()

 // Maximum priority queue
 template <typename T>
 using mxpq = priority_queue<T>;

 // Minimum priority queue
 template <typename T>
 using mnpq = priority_queue<T, vt<T>, greater<T>>;

 // x | (x + 1) sets lowest unset bit of x
 // x & (x - 1) unsets lowest set bit of x

 const ll mod = 1e9L + 7;
 const ll INF = 1e18L + 5;
 const ll mxN = 2e5 + 1;

 ll n;
 ll dp[1000004];
 // remember to read no of test_cases
 void solve()
 {
    cin>>n;
    vt<ll> v(n);
    For(i,n)
    {
     cin>>v[i];
     if(v[i]2==0)
     {
         cout<<v[i]<<   ;
     }
    }

     For(i,n)
     {
       if(v[i]2==1)
       {
         cout<<v[i]<<   ;
       }
     }
     cout<<endl;
 }

 int main()
 {
   ios::sync_with_stdio(0);  cin.tie(0);
   ll t = 1;
   cin >> t;
   FOR(tt, t) solve();
   return 0;
 }