#include <bits/stdc++.h>
 using namespace std;
 struct Rectangle {
   int x1;
   int x2;
   int y1;
   int y2;
   Rectangle() {}
   Rectangle(int a, int b, int c, int d) {
     x1 = a;
     y1 = b;
     x2 = c;
     y2 = d;
     if (x1 > x2) {
       swap(x1, x2);
     }
     if (y1 > y2) {
       swap(y1, y2);
     }
   }
   bool operator<(Rectangle r) const {
     if (x1 != r.x1) {
       return x1 < r.x1;
     } else if (x2 != r.x2) {
       return x2 < r.x2;
     } else if (y1 != r.y1) {
       return y1 < r.y1;
     } else {
       return y2 < r.y2;
     }
   }
 };
 int Area(Rectangle r) { return (r.x2 - r.x1) * (r.y2 - r.y1); }
 set<Rectangle> rec;
 set<Rectangle> lines;
 int main() {
   int W, H, N;
   scanf( %d , &W);
   ;
   scanf( %d , &H);
   ;
   scanf( %d , &N);
   ;
   rec.insert(Rectangle(0, 0, W, H));
   for (int(n) = 0; n < (int)N; n++) {
     int a, b, c, d;
     scanf( %d , &a);
     ;
     scanf( %d , &b);
     ;
     scanf( %d , &c);
     ;
     scanf( %d , &d);
     ;
     lines.insert(Rectangle(a, b, c, d));
   }
   for (int(n) = 0; n < (int)N; n++) {
     for (__typeof(rec).begin() t = rec.begin(); t != rec.end(); t++) {
       Rectangle r = *t;
       for (__typeof(lines).begin() it = lines.begin(); it != lines.end();
            it++) {
         if (it->x1 == it->x2) {
           if (r.x1 < it->x1 && it->x2 < r.x2 && r.y1 == it->y1 &&
               r.y2 == it->y2) {
             lines.erase(lines.find(*it));
             rec.erase(*t);
             rec.insert(Rectangle(r.x1, r.y1, it->x2, r.y2));
             rec.insert(Rectangle(it->x2, r.y1, r.x2, r.y2));
             goto end;
           }
         } else if (it->y1 == it->y2) {
           if (r.y1 < it->y1 && it->y2 < r.y2 && r.x1 == it->x1 &&
               r.x2 == it->x2) {
             lines.erase(lines.find(*it));
             rec.erase(*t);
             rec.insert(Rectangle(r.x1, r.y1, r.x2, it->y1));
             rec.insert(Rectangle(r.x1, it->y1, r.x2, r.y2));
             goto end;
           }
         }
       }
     }
   end:
     int sol = 42;
   }
   vector<int> res;
   for (__typeof(rec).begin() it = rec.begin(); it != rec.end(); it++) {
     res.push_back(Area(*it));
   }
   sort(res.begin(), res.end());
   for (__typeof(res).begin() it = res.begin(); it != res.end(); it++) {
     printf(  %d , *it);
   }
   printf(
 );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long N = 1e3 + 10;
 long long q, x, v, u, w, ans;
 map<long long, long long> len;
 int main() {
   cin >> q;
   for (int i = 1; i <= q; i++) {
     cin >> x >> v >> u;
     if (x == 1) {
       cin >> w;
       while (v != u) {
         if (v > u) {
           len[v] += w;
           v = v / 2;
         } else {
           len[u] += w;
           u = u / 2;
         }
       }
     } else {
       ans = 0;
       while (v != u) {
         if (v > u) {
           ans += len[v];
           v = v / 2;
         } else {
           ans += len[u];
           u = u / 2;
         }
       }
       cout << ans << '
';
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long INF = 1000000000000000000ll;
 long long x[6], y[6];
 int main() {
   ios_base::sync_with_stdio(0);
   int n;
   cin >> n;
   for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
   if (n == 1) {
     cout << -1 << endl;
     return 0;
   }
   if (n == 2) {
     if (x[0] == x[1] || y[0] == y[1]) {
       cout << -1 << endl;
       return 0;
     }
     long long s = (abs(x[0] - x[1]) * abs(y[0] - y[1]));
     cout << s << endl;
     return 0;
   }
   long long X = 0, Y = 0;
   for (int i = 1; i < n; i++) {
     X = max(X, abs(x[0] - x[i]));
     Y = max(Y, abs(y[0] - y[i]));
   }
   cout << X * Y << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int INF = 0x3f3f3f3f;
 const long long LINF = 0x3f3f3f3f3f3f3f3f;
 const int MOD = (int)1e9 + 7;
 const int N = (int)3e5 + 7;
 char read_char() {
   char c;
   for (;;) {
     c = getchar();
     if (c >= 'A' && c <= 'Z') return c;
   }
 }
 long long powmod(long long a, long long b) {
   long long res = 1;
   a %= MOD;
   for (; b; b >>= 1) {
     if (b & 1) res = res * a % MOD;
     a = a * a % MOD;
   }
   return res;
 }
 long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
 long long add(long long a, long long b) {
   a = ((a + b) % MOD + MOD) % MOD;
   return a;
 }
 long long mul(long long a, long long b) { return a * b % MOD; }
 int n, p, cnt[N], tmp[N];
 pair<int, int> a[N];
 void Init() {
   memset(cnt, 0, sizeof(cnt));
   for (int i = (0); i < (n); ++i) {
     int u, v;
     scanf( %d%d , &u, &v);
     if (u > v) swap(u, v);
     a[i].first = u, a[i].second = v;
     cnt[u]++;
     cnt[v]++;
   }
   for (int i = (1); i < (n + 1); ++i) tmp[i] = cnt[i];
   sort(tmp + 1, tmp + n + 1);
   sort(a, a + n);
 }
 int Solve() {
   long long ans = 0;
   for (int i = n, j = 1; j < i; i--) {
     while (tmp[j] + tmp[i] < p && j < i) j++;
     ans += i - j;
   }
   for (int i = 0, j; i < n; i = j) {
     j = i + 1;
     while (j < n && a[i] == a[j]) j++;
     int u = a[i].first, v = a[i].second;
     if (cnt[u] + cnt[v] >= p && cnt[u] + cnt[v] - (j - i) < p) {
       ans--;
     }
   }
   return !printf( %lld
 , ans);
 }
 int main() {
   while (~scanf( %d%d , &n, &p)) {
     Init();
     Solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 map<long long, long long> s;
 long long n, b[500005], c[500005];
 int main() {
   cin >> n;
   for (int i = 0; i < n; i++) {
     long long x;
     cin >> x;
     s[x]++;
   }
   long long m, mx1 = 0, mx2 = 0, index = 1;
   cin >> m;
   for (int i = 0; i < m; i++) {
     cin >> b[i];
   }
   for (int i = 0; i < m; i++) {
     cin >> c[i];
   }
   for (int i = 0; i < m; i++) {
     if (s[b[i]] > mx1) {
       mx1 = s[b[i]];
       index = i + 1;
     }
   }
   for (int i = 0; i < m; i++) {
     if (s[b[i]] == mx1) {
       if (s[c[i]] > mx2) {
         index = i + 1;
         mx2 = s[c[i]];
       }
     }
   }
   cout << index << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAX_N = 1010;
 const double EPS = 0.0000001;
 struct Point {
   int x, y;
   Point() {}
   Point(int a, int b) : x(a), y(b) {}
 };
 int n;
 long long k;
 Point centers[MAX_N];
 int radii[MAX_N];
 double GetDist(int x1, int y1, int x2, int y2) {
   return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
 }
 void AddEvents(vector<pair<double, int> > &events, double ang1, double ang2) {
   for (int i = 0; i < 3; ++i) {
     events.push_back(make_pair(ang1 + i * 2 * M_PI + EPS, 1));
     events.push_back(make_pair(ang2 + i * 2 * M_PI - EPS, -1));
   }
 }
 int main() {
   cin >> n >> k;
   for (int i = 1; i <= n; ++i) {
     int x, y;
     cin >> x >> y >> radii[i];
     centers[i] = Point(x, y);
   }
   int best = 0;
   for (int i = 1; i <= n; ++i) {
     vector<pair<double, int> > events;
     int cnt = 0;
     for (int j = 1; j <= n; ++j) {
       if (i != j) {
         double ang =
             atan2(centers[j].y - centers[i].y, centers[j].x - centers[i].x);
         double d =
             GetDist(centers[i].x, centers[i].y, centers[j].x, centers[j].y);
         double u1 = asin((radii[i] - radii[j]) / d);
         double u2 = asin((radii[i] + radii[j]) / d);
         AddEvents(events, ang + u1 - M_PI / 2, ang + u2 - M_PI / 2);
         AddEvents(events, ang - u2 + M_PI / 2, ang - u1 + M_PI / 2);
       }
     }
     sort(events.begin(), events.end());
     for (size_t j = 0; j < events.size(); ++j) {
       cnt += events[j].second;
       if (cnt < 0) {
         cnt = 0;
       }
       best = max(best, cnt);
     }
   }
   long long sol = k * (k + 1) / 2 + (k + 1) * best + (n - best);
   cout << sol << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long calc(const long long &x, const long long &pow, const long long &pp) {
   long long res = 1, tmp = (x % pp);
   long long cur = pow;
   while (cur > 0) {
     if (cur % 2 == 0) {
       tmp = (tmp * tmp) % pp;
       cur = cur / 2;
     } else {
       res = (res * tmp) % pp;
       cur = cur - 1;
     }
   }
   return res;
 }
 int obr() {
   long long k, l, r, p;
   cin >> k >> l >> r >> p;
   long long ans;
   if (p == 2) {
     cout << (1 - (k % 2)) << endl;
     return 0;
   }
   if (k == 1)
     ans = 2 % p;
   else {
     long long st_l = calc(2, l, p - 1), st_r = calc(2, r + 1, p - 1);
     long long rev_2 = (p + 1) / 2;
     long long ch = (calc(k, st_r, p) + p - 1) % p;
     long long zn = (calc(k, st_l, p) + p - 1) % p;
     if (k % p == 0) zn = ch = p - 1;
     if (zn == 0) {
       ch = calc(2, r - l + 1, p);
     } else {
       zn = calc(zn, p - 2, p);
       ch = (ch * zn) % p;
     }
     if (k % 2) {
       long long to_div = calc(rev_2, r - l, p);
       ch = (ch * to_div) % p;
     }
     ans = ch;
   }
   cout << ans << endl;
   return 0;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   int t;
   cin >> t;
   for (int i = 1; i <= t; ++i) obr();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m;
 int x[500010], y[500010];
 bitset<2010 * 2> A[2010];
 void Work() {
   for (int i = 1; i <= n; i++) {
     int t = i;
     for (int j = i + 1; j <= n; j++)
       if (A[j][i]) t = j;
     swap(A[i], A[t]);
     for (int j = 1; j <= n; j++)
       if (A[j][i] && j != i) A[j] ^= A[i];
   }
   for (int i = 1; i <= m; i++)
     if (A[y[i]][x[i] + n])
       puts( NO );
     else
       puts( YES );
 }
 void Init() {
   scanf( %d%d , &n, &m);
   for (int i = 1; i <= m; i++) {
     scanf( %d%d , &x[i], &y[i]);
     A[x[i]][y[i]] = 1;
   }
   for (int i = 1; i <= n; i++) A[i][i + n] = 1;
 }
 int main() {
   Init();
   Work();
   return 0;
 }


#include <bits/stdc++.h>
 const int MAXN = 60;
 int n, P, A[MAXN];
 const int mod = 1000000007;
 void reduce(int& x) { x += x >> 31 & mod; }
 int mul(int a, int b) { return (long long)a * b % mod; }
 int pow(int a, int b, int res = 1) {
   for (; b; b >>= 1, a = mul(a, a))
     if (b & 1) res = mul(res, a);
   return res;
 }
 int dp[MAXN][MAXN][MAXN];
 int main() {
   std::ios_base::sync_with_stdio(false), std::cin.tie(0);
   std::cin >> n >> P;
   for (int i = 1; i <= n; ++i) std::cin >> A[i];
   dp[0][0][0] = 1;
   for (int i = 1; i <= n; ++i)
     for (int j = 0; j <= i; ++j)
       for (int k = 0; k <= i; ++k)
         if (dp[i - 1][j][k]) {
           if (A[i] == 0 || A[i] == -1) {
             int t = pow(2, i - 1 - (!!k), dp[i - 1][j][k]);
             reduce(dp[i][j + 1][k] += t - mod);
             if (k) reduce(dp[i][j][k] += t - mod);
           }
           if (A[i] == 1 || A[i] == -1) {
             int t = pow(2, i - 1 - (!!j), dp[i - 1][j][k]);
             reduce(dp[i][j][k + 1] += t - mod);
             if (j) reduce(dp[i][j][k] += t - mod);
           }
         }
   int ans = 0;
   for (int i = 0; i <= n; ++i)
     for (int j = 0; j <= n; ++j)
       if ((i + j & 1) == P) reduce(ans += dp[n][i][j] - mod);
   std::cout << ans << std::endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int k, r;
   cin >> k >> r;
   int n = 1;
   while (true) {
     if ((k * n - r) % 10 == 0 || (k * n) % 10 == 0) {
       cout << n <<
 ;
       return 0;
     }
     n++;
   }
 }


#include <bits/stdc++.h>
 #pragma GCC optimize( O3 )
 using namespace std;
 template <class c>
 struct rge {
   c b, e;
 };
 template <class c>
 rge<c> range(c h, c n) {
   return {h, n};
 }
 template <class c>
 auto dud(c* r) -> decltype(cerr << *r);
 template <class c>
 char dud(...);
 struct muu {
   template <class c>
   muu& operator<<(const c&) {
     return *this;
   }
   muu& operator()() { return *this; }
 };
 const int N = 1e5 + 7;
 long long tab[N];
 int n;
 long long inf = 1e18;
 void fail() {
   printf( No
 );
   exit(0);
 }
 int main() {
   scanf( %d , &n);
   for (int i = 2; i <= n; i += 2) scanf( %lld , tab + i);
   long long sum = 0;
   for (int i = 2; i <= n; i += 2) {
     long long nsum = inf;
     for (int d = 1; d * d <= tab[i]; ++d) {
       if (tab[i] % d == 0) {
         long long a = (tab[i] / d) - d;
         long long b = (tab[i] / d) + d;
         if (a % 2 == 0 && b % 2 == 0) {
           if (a * a > 4 * sum) {
             nsum = min(nsum, (b * b) / 4);
           }
         }
       }
     }
     (muu() << __FUNCTION__ <<  #  << 67 <<  :  ) << i << ' ' << nsum;
     if (nsum == inf) fail();
     tab[i - 1] = nsum - sum - tab[i];
     sum = nsum;
   }
   printf( Yes
 );
   for (int i = 1; i <= n; ++i) printf( %lld  , tab[i]);
   printf(
 );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 3e5 + 50;
 vector<int> e[N];
 int dp[N], res, deg[N];
 void dfs(int u, int pre) {
   dp[u] = deg[u];
   for (int v : e[u]) {
     if (v == pre) continue;
     dfs(v, u);
     res = max(res, dp[u] + dp[v]);
     dp[u] = max(dp[u], dp[v] + deg[u] - 2 + 1);
   }
 }
 int main() {
   int t;
   scanf( %d , &t);
   while (t--) {
     int n;
     scanf( %d , &n);
     for (int i = 1; i <= n; i++) e[i].clear(), deg[i] = 0;
     for (int i = 0; i < n - 1; i++) {
       int u, v;
       scanf( %d%d , &u, &v);
       e[u].push_back(v);
       e[v].push_back(u);
       deg[u]++;
       deg[v]++;
     }
     res = 0;
     dfs(1, 0);
     printf( %d
 , res);
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m;
 const int maxN = (int)1e6 + 10;
 vector<int> g[maxN];
 int p[maxN];
 int a[maxN];
 long long s = 0;
 long long tr[maxN];
 set<long long> all;
 void dfs(int v) {
   tr[v] = a[v];
   for (int to : g[v]) {
     dfs(to);
     tr[v] += tr[to];
   }
   if (s % tr[v] == 0) {
     all.insert(tr[v]);
   }
 }
 int val[maxN];
 const int mod = (int)1e9 + 7;
 int sum(int a, int b) {
   int s = a + b;
   if (s >= mod) s -= mod;
   return s;
 }
 set<long long> ok;
 long long id[maxN];
 long long sm[maxN];
 map<long long, int> f;
 int dp[maxN];
 int main() {
   ios_base::sync_with_stdio(false);
   cin >> n;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
     s += a[i];
   }
   for (int i = 1; i < n; i++) {
     cin >> p[i];
     g[p[i]].push_back(i + 1);
   }
   dfs(1);
   int sz = 1;
   int oth = 1;
   for (long long t : all) {
     memset(sm, 0, sizeof sm);
     bool can = true;
     for (int i = n; i >= 1; i--) {
       if (sm[i] + a[i] > t) {
         can = false;
         break;
       }
       if (sm[i] + a[i] == t) {
         continue;
       }
       if (i == 1) {
         can = false;
         break;
       }
       sm[p[i - 1]] += (sm[i] + a[i]);
     }
     if (can) {
       f[t] = oth;
       oth++;
       ok.insert(t);
     }
   }
   for (long long x : ok) {
     int id = f[x];
     dp[id] = 1;
     for (long long y : ok) {
       if (y >= x) continue;
       if (x % y == 0) dp[id] = sum(dp[id], dp[f[y]]);
     }
   }
   cout << dp[f[s]];
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int INF = 0x3f3f3f3f;
 const long long LINF = 0x3f3f3f3f3f3f3f3f;
 const int MOD = (int)1e9 + 7;
 const int N = (int)2e5 + 7;
 int tree[N << 1];
 void update(int x, int n) {
   x += n;
   if (tree[x]) return;
   while (x) {
     tree[x]++;
     x >>= 1;
   }
 }
 int query(int l, int r, int n) {
   int re = 0;
   l += n, r += n;
   while (l <= r) {
     if (l & 1) re += tree[l++];
     if (~r & 1) re += tree[r--];
     l >>= 1, r >>= 1;
   }
   return re;
 }
 pair<int, int> p[N];
 vector<int> x;
 int l[N];
 int main() {
   int n;
   scanf( %d , &n);
   for (int i = (0); i < (n); ++i) {
     scanf( %d%d , &p[i].first, &p[i].second);
     x.push_back(p[i].first);
   }
   sort((x).begin(), (x).end());
   sort(p, p + n);
   for (int i = (0); i < (n); ++i) {
     p[i].first = lower_bound((x).begin(), (x).end(), p[i].first) - x.begin();
     swap(p[i].first, p[i].second);
   }
   sort(p, p + n);
   long long ans = 0;
   for (int i = n - 1, j; i >= 0; i = j) {
     for (j = i; j >= 0 && p[i].first == p[j].first; j--)
       ;
     int z = 0;
     for (int k = (j + 1); k < (i + 1); ++k) {
       l[k] = query(z, p[k].second - 1, n);
       update(p[k].second, n);
       z = p[k].second + 1;
     }
     for (int k = (j + 1); k < (i + 1); ++k) {
       ans += (long long)(l[k] + 1) * (query(p[k].second + 1, n, n) + 1);
     }
   }
   printf( %lld
 , ans);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   double l, p, q;
   cin >> l >> p >> q;
   double qq = l / (p + q) * p;
   cout << setiosflags(ios::fixed);
   cout << setprecision(4) << qq;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long exp(long long x, long long y) {
   x %= 1000000007;
   long long res = 1;
   while (y) {
     if (y & 1) res = res * x % 1000000007;
     x = x * x % 1000000007;
     y >>= 1;
   }
   return res;
 }
 long long fact(long long n) {
   long long res = 1;
   for (long long i = 2; i <= n; ++i) (res *= i) %= 1000000007;
   return res;
 }
 bool isprime(long long n) {
   for (long long i = 2; i * i <= n; ++i)
     if (n % i == 0) return 0;
   return 1;
 }
 int main() {
   int n, m;
   cin >> n >> m;
   const long long inf = 1e17;
   vector<long long> sum(n), pre(n), s(n);
   vector<long long> t(n);
   for (int i = 0; i < n; ++i) {
     int x;
     cin >> x;
     long long val = -inf;
     long long mx = -inf;
     vector<long long> v1, v2;
     for (int j = 0; j < x; ++j) {
       long long k;
       cin >> k;
       val = max(k, val + k);
       mx = max(mx, val);
       v1.push_back(k);
       v2.push_back(k);
     }
     t[i] = mx;
     for (int j = 1; j < x; ++j) v1[j] += v1[j - 1];
     for (int j = x - 2; j >= 0; --j) v2[j] += v2[j + 1];
     sum[i] = v1[x - 1];
     pre[i] = *max_element(v1.begin(), v1.end());
     s[i] = *max_element(v2.begin(), v2.end());
   }
   long long to = -inf;
   vector<int> v(m + 1);
   for (int i = 1; i <= m; ++i) {
     cin >> v[i];
     to = max(to, t[v[i] - 1]);
   }
   long long dp[m + 1][3];
   memset(dp, 0, sizeof(dp));
   for (int i = 1; i <= m; ++i) {
     dp[i][0] = s[v[i] - 1];
     dp[i][1] = max(dp[i - 1][0] + sum[v[i] - 1], dp[i - 1][1] + sum[v[i] - 1]);
     dp[i][2] = max(dp[i - 1][0] + pre[v[i] - 1], dp[i - 1][1] + pre[v[i] - 1]);
   }
   long long ans = -inf;
   for (int i = 1; i <= m; ++i) ans = max(ans, dp[i][2]);
   cout << max(ans, to);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAXN = -1;
 struct disk {
   long long L;
   double p;
   disk(long long L = 0, double p = 0.) : L(L), p(p) {}
 };
 bool operator<(disk a, disk b) {
   return (a.L * a.p * (1 - b.p)) > (b.L * b.p * (1 - a.p));
 }
 int n;
 vector<disk> P;
 int main() {
   while (cin >> n) {
     P.resize(n);
     for (int i = (0); i < (int)(n); i++)
       scanf( %lld %lf , &P[i].L, &P[i].p), P[i].p /= 100;
     sort(P.begin(), P.end());
     double ans = 0., E = 0.;
     for (int i = ((int)n) - 1; i >= 0; i--) {
       disk D = P[i];
       ans += D.L * (1 + E * D.p);
       E = D.p * E + (1 - D.p) * (E + 1);
     }
     printf( %.6f
 , ans);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long i, n, now, ans, hh, m, p = 1000000009;
 int main() {
   scanf( %lld , &n);
   if (n == 2) {
     puts( 10 );
     return 0;
   }
   m = n / 2;
   now = 4;
   hh = 1;
   for (i = 3; i <= m; i++) {
     now = now * 2 % p;
     hh = hh * (now - 3) % p;
     ans = (ans + hh) % p;
   }
   ans = ans * 4 + 6;
   ans %= p;
   ans = ans * ans % p;
   ans++;
   ans = ans * 2 % p;
   printf( %lld , ans);
 }


#include <bits/stdc++.h>
 using namespace std;
 int m(int x, int md) { return (((x) % md) + md) % md; }
 void solve() {
   int n;
   cin >> n;
   vector<int> a(n);
   for (int i = 0; i < n; i++) cin >> a[i];
   set<int> st;
   for (int r = 0; r < n; r++) {
     st.insert(m(r + a[r], n));
   }
   if (st.size() == n)
     cout <<  YES
 ;
   else
     cout <<  NO
 ;
 }
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   int T;
   cin >> T;
   for (int testcase = 1; testcase <= T; testcase++) {
     solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 struct event {
   int pos, type, p;
   event(int pos = 0, int type = -1, int p = 0) : pos(pos), type(type), p(p) {}
   bool operator<(const event &e) const {
     if (pos == e.pos) return type < e.type;
     return pos < e.pos;
   }
 };
 const int maxE = 5e5 + 10;
 event E[maxE];
 int cnt[111];
 double fpow(double a, int n) {
   double r = 1;
   for (; n; n = n >> 1) {
     if (n & 1) r *= a;
     a = a * a;
   }
   return r;
 }
 int main() {
   memset((cnt), (0), sizeof(cnt));
   int n, m, x, h, l, r, sz = 0, b, z;
   scanf( %d%d , &n, &m);
   for (int _n(n), i(0); i < _n; i++) {
     scanf( %d%d%d%d , &x, &h, &l, &r);
     l = 100 - l;
     r = 100 - r;
     E[sz++] = event(x - h, 0, l);
     E[sz++] = event(x, 0, -1 - l);
     E[sz++] = event(x + 1, 0, r);
     E[sz++] = event(x + h + 1, 0, -1 - r);
   }
   for (int _n(m), i(0); i < _n; i++) {
     scanf( %d%d , &b, &z);
     E[sz++] = event(b, z);
   }
   sort(E, E + sz);
   double expectation = 0, pro = 0;
   for (int _n(sz), i(0); i < _n; i++) {
     if (E[i].type == 0) {
       if (E[i].p >= 0) {
         cnt[E[i].p]++;
       } else
         cnt[-E[i].p - 1]--;
     } else {
       pro = 1;
       for (int _n(101), i(0); i < _n; i++) pro *= fpow(0.01 * i, cnt[i]);
       expectation += pro * E[i].type;
     }
   }
   printf( %.7f
 , expectation);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAX_N = 100011;
 const long long INF = (1 << 29) + 123;
 const long long MOD = 1000000007;
 const long double PI = 4 * atan((long double)1);
 int fenw[2 * MAX_N];
 int n;
 void mod(int i, int v) {
   while (i <= n) {
     fenw[i] += v;
     i += i & -i;
   }
 }
 int query(int i) {
   int sum = 0;
   while (i > 0) {
     sum += fenw[i];
     i -= i & -i;
   }
   return sum;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin >> n;
   vector<pair<int, int> > p;
   int x[n], v[n];
   for (int i = 0; i < n; i++) cin >> x[i];
   for (int i = 0; i < n; i++) {
     cin >> v[i];
     p.push_back(make_pair(v[i], x[i]));
   }
   unordered_map<int, int> m;
   int rev_map[n];
   sort(x, x + n);
   for (int i = 0; i < n; i++) {
     m[x[i]] = i + 1;
     rev_map[i] = x[i];
   }
   for (int i = 0; i < n; i++) {
     p[i].second = m[p[i].second];
   }
   sort(p.begin(), p.end());
   long long ans = 0;
   for (int i = 0; i < n; i++) {
     int q = query(p[i].second);
     ans += 1LL * q * rev_map[p[i].second - 1];
     ans -=
         1LL * ((n - i - 1) - (p[i].second - 1 - q)) * rev_map[p[i].second - 1];
     mod(p[i].second, 1);
   }
   cout << ans << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, p1 = 0, p2 = 0;
   cin >> n;
   int mid[1000], index = 0;
   for (int i = 0; i < n; i++) {
     int a;
     cin >> a;
     if (a % 2 == 0) {
       for (int j = 1; j <= (a / 2); j++) {
         int t;
         cin >> t;
         p1 += t;
       }
       for (int j = 1; j <= (a / 2); j++) {
         int t;
         cin >> t;
         p2 += t;
       }
     } else {
       for (int j = 1; j <= (a / 2); j++) {
         int t;
         cin >> t;
         p1 += t;
       }
       cin >> mid[index++];
       for (int j = 1; j <= (a / 2); j++) {
         int t;
         cin >> t;
         p2 += t;
       }
     }
   }
   sort(mid, mid + index);
   for (int i = index - 1; i >= 0; i--) {
     if (((index - 1) % 2 == 0 && i % 2 == 0) ||
         ((index - 1) % 2 == 1 && i % 2 == 1))
       p1 += mid[i];
     else
       p2 += mid[i];
   }
   cout << p1 <<     << p2 << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 6010;
 vector<int> a[N];
 int L[N], cnt, r[N], n, res = 0;
 void Refresh() {
   L[0] = cnt = 0;
   for (int i = 1; i <= n + 1; i++) L[i] = 10000000;
 }
 void DFS(int u, int p) {
   int Oldval, Oldid, Oldcnt = cnt;
   if (cnt == 0 || r[u] > L[cnt])
     L[++cnt] = r[u];
   else {
     Oldid = lower_bound(L, L + n + 1, r[u]) - L;
     Oldval = L[Oldid];
     L[Oldid] = r[u];
   }
   res = max(res, cnt);
   for (int i = 0; i < a[u].size(); i++) {
     int v = a[u][i];
     if (v != p) DFS(v, u);
   }
   if (Oldcnt != cnt)
     L[cnt--] = 10000000;
   else
     L[Oldid] = Oldval;
 }
 int main() {
   ios_base::sync_with_stdio(0);
   int u, v;
   cin >> n;
   for (int i = 1; i <= n; i++) cin >> r[i];
   for (int i = 1; i < n; i++) {
     cin >> u >> v;
     a[u].push_back(v);
     a[v].push_back(u);
   }
   for (int i = 1; i <= n; i++) {
     Refresh();
     DFS(i, 0);
   }
   cout << res;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long pow1(int a, int b) {
   long long res = 1;
   for (int i = 1; i <= b; i++) res *= a;
   return res;
 }
 int main() {
   int n;
   cin >> n;
   long long sum = 2 * (pow1(2, n) - 1);
   cout << sum << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long int gcd(long long int a, long long int b) {
   if (b == 0)
     return a;
   else
     return gcd(b, a % b);
 }
 bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
   return (a.second < b.second);
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   std::cout.precision(12);
   int t;
   cin >> t;
   while (t--) {
     bool f = 0;
     int n, m;
     cin >> n >> m;
     char a[n][m];
     char ans[n][m];
     vector<pair<int, int>> v[26];
     int ma = -1;
     int r, c;
     for (long long int i = 0; i < n; i++) {
       for (long long int j = 0; j < m; j++) {
         cin >> a[i][j];
         ans[i][j] = '.';
         if (a[i][j] >= 97 && a[i][j] <= 'z') {
           v[a[i][j] - 'a'].push_back({i + 1, j + 1});
           if (a[i][j] - 'a' > ma) {
             ma = a[i][j] - 'a';
             r = i + 1;
             c = j + 1;
           }
         }
       }
     }
     vector<pair<int, int>> start[ma + 1], end[ma + 1];
     for (long long int i = 0; i < ma + 1; i++) {
       if (v[i].size() == 0) {
         start[i].push_back({r, c});
         end[i].push_back({r, c});
       } else if (v[i].size() == 1) {
         ans[v[i][0].first - 1][v[i][0].second - 1] = 'a' + i;
         start[i].push_back({v[i][0].first, v[i][0].second});
         end[i].push_back({v[i][0].first, v[i][0].second});
       } else {
         if (v[i][1].first == v[i][0].first) {
           int mi = m + 6, m = 0;
           for (int j = 0; j < v[i].size(); j++) {
             if (v[i][j].first != v[i][0].first) {
               f = 1;
               break;
             }
             mi = min(mi, v[i][j].second);
             m = max(m, v[i][j].second);
           }
           if (f == 1) break;
           for (int j = mi - 1; j < m; j++) {
             ans[v[i][0].first - 1][j] = 'a' + i;
           }
           start[i].push_back({v[i][0].first, mi});
           end[i].push_back({v[i][0].first, m});
         } else if (v[i][1].second == v[i][0].second) {
           int mi = n + 6, m = 0;
           for (int j = 0; j < v[i].size(); j++) {
             if (v[i][j].second != v[i][0].second) {
               f = 1;
               break;
             }
             mi = min(mi, v[i][j].first);
             m = max(m, v[i][j].first);
           }
           if (f == 1) break;
           for (int j = mi - 1; j < m; j++) {
             ans[j][v[i][0].second - 1] = 'a' + i;
           }
           start[i].push_back({mi, v[i][0].second});
           end[i].push_back({m, v[i][0].second});
         } else {
           f = 1;
           break;
         }
       }
     }
     for (long long int i = 0; i < n; i++) {
       for (long long int j = 0; j < m; j++) {
         if (a[i][j] != ans[i][j]) {
           f = 1;
           break;
         }
       }
       if (f == 1) break;
     }
     if (f == 0) {
       cout <<  YES
 ;
       cout << ma + 1 << endl;
       for (long long int i = 0; i < ma + 1; i++)
         cout << start[i][0].first <<     << start[i][0].second <<
              << end[i][0].first <<     << end[i][0].second << endl;
     } else {
       cout <<  NO
 ;
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
 const long long linf = 4000000000000000000LL;
 const long long inf = 998244353;
 const long double pi = 3.1415926535;
 void pv(vector<int> a) {
   for (auto& x : a) cout << x <<    ;
   cout << '
';
 }
 void pv(vector<long long> a) {
   for (auto& x : a) cout << x <<    ;
   cout << '
';
 }
 void pv(vector<vector<int>> a) {
   for (int i = (0); i < (int(a.size())); ++i) {
     cout << i << '
';
     pv(a[i]);
     cout << '
';
   }
 }
 void pv(vector<vector<long long>> a) {
   for (int i = (0); i < (int(a.size())); ++i) {
     cout << i << '
';
     pv(a[i]);
   }
   cout << '
';
 }
 void pv(vector<string> a) {
   for (auto& x : a) cout << x << '
';
   cout << '
';
 }
 void build_primes(vector<int>& primes, int size) {
   vector<int> visited;
   visited.resize(size, 0);
   for (int i = (2); i < (size); ++i) {
     if (visited[i] == 0) {
       primes.push_back(i);
       int a = i;
       while (a < size) {
         visited[a] = 1;
         a += i;
       }
     }
   }
 }
 vector<vector<long long>> matrix_mult(vector<vector<long long>>& a,
                                       vector<vector<long long>>& b) {
   int n = a.size();
   vector<vector<long long>> answer;
   answer.resize(n);
   for (int i = 0; i < n; i++) answer[i].resize(n, 0);
   for (int i = 0; i < n; i++) {
     for (int j = 0; j < n; j++) {
       for (int k = 0; k < n; k++)
         answer[i][j] = (answer[i][j] + a[i][k] * b[k][j]) % inf;
     }
   }
   return answer;
 }
 int modInverse(int a, int m) {
   int m0 = m;
   int y = 0, x = 1;
   if (m == 1) return 0;
   while (a > 1) {
     int q = a / m;
     int t = m;
     m = a % m, a = t;
     t = y;
     y = x - q * y;
     x = t;
   }
   if (x < 0) x += m0;
   return x;
 }
 long long power(long long x, long long y) {
   long long k = 1LL << 60;
   long long z = 1;
   while (k != 0) {
     z *= z;
     z %= inf;
     if (y >= k) {
       z *= x;
       z %= inf;
       y -= k;
     }
     k >>= 1;
   }
   return z;
 }
 struct point {
   long double x, y;
   bool operator<(const point& rhs) const {
     if (x == rhs.x) return y < rhs.y;
     return x < rhs.x;
   }
 };
 struct pt {
   long long x, y;
   bool operator<(const point& rhs) const {
     if (x == rhs.x) return y < rhs.y;
     return x < rhs.x;
   }
 };
 long double area(point x, point y, point z) {
   return (x.y * y.x + y.y * z.x + z.y * x.x - x.x * y.y - y.x * z.y -
           z.x * x.y) /
          2.0;
 }
 bool clockwise(point x, point y, point z) { return area(x, y, z) > 0; }
 long double area(pt x, pt y, pt z) {
   return (x.y * y.x + y.y * z.x + z.y * x.x - x.x * y.y - y.x * z.y -
           z.x * x.y) /
          2.0;
 }
 bool clockwise(pt x, pt y, pt z) { return area(x, y, z) > 0; }
 long long gcd(long long a, long long b) {
   if (a > b) swap(a, b);
   if (a == 0) return b;
   return gcd(a, b % a);
 }
 int popcount(long long a) {
   int count = 0;
   while (a) {
     count += (a & 1);
     a >>= 1;
   }
   return count;
 }
 long long choose(long long n, long long r) {
   long long p = 1, k = 1;
   if (n - r < r) r = n - r;
   if (r != 0) {
     while (r) {
       p *= n;
       k *= r;
       long long m = gcd(p, k);
       p /= m;
       k /= m;
       n--;
       r--;
     }
   } else
     p = 1;
   return p;
 }
 vector<long long> prefix_hash(string& a, vector<long long>& powers) {
   int n = int(a.size());
   vector<long long> prefix(n + 1);
   for (int i = (0); i < (n); ++i)
     prefix[i + 1] = (prefix[i] + powers[i] * (a[i] - 'a' + 1)) % inf;
   return prefix;
 }
 struct custom_hash {
   static uint64_t splitmix64(uint64_t x) {
     x += 0x9e3779b97f4a7c15;
     x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
     x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
     return x ^ (x >> 31);
   }
   uint64_t operator()(uint64_t x) const {
     static const uint64_t FIXED_RANDOM =
         chrono::steady_clock::now().time_since_epoch().count();
     return splitmix64(x + FIXED_RANDOM);
   }
 };
 struct custom_hash_fast {
   uint64_t operator()(uint64_t x) const {
     static const uint64_t FIXED_RANDOM =
         chrono::steady_clock::now().time_since_epoch().count();
     x ^= FIXED_RANDOM;
     return x ^ (x >> 16);
   }
 };
 void setIO(string second) {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
 }
 int main() {
   setIO(  );
   int testc;
   cin >> testc;
   while (testc--) {
     int n;
     cin >> n;
     string a;
     cin >> a;
     int i = n - 1;
     for (; i >= 0; i--)
       if ((a[i] - '0') & 1) break;
     if (i == -1) {
       cout << -1 << '
';
       continue;
     }
     int j = 0;
     for (; j < i; j++) {
       if ((a[j] - '0') % 2 == 1) break;
     }
     if (j == i) {
       cout << -1 << '
';
       continue;
     }
     cout << a[j] << a[i] << '
';
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int t;
   cin >> t;
   while (t--) {
     int n, m, k;
     cin >> n >> m >> k;
     int cardsPlayer = n / k;
     double maxCard;
     int jokerMax = min(m, cardsPlayer);
     maxCard = ceil((m - jokerMax) / (k - 1.0));
     if (jokerMax - maxCard > 0)
       cout << jokerMax - maxCard << endl;
     else
       cout << 0 << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 typedef struct {
   long long j, x1, x2;
 } inter;
 struct comp1 {
   bool operator()(const inter& a, const inter& b) const { return a.x1 < b.x1; };
 };
 struct comp2 {
   bool operator()(const inter& a, const inter& b) const {
     return (a.x2 == b.x2) ? (a.x1 < b.x1) : (a.x2 < b.x2);
   };
 };
 void solve() {
   long long n;
   cin >> n;
   vector<long long> a(n), b(n), m(n);
   unordered_map<long long, vector<long long>> dsize;
   for (long long i = 0; i < (n); i++) {
     cin >> a[i] >> b[i] >> m[i];
     dsize[a[i] + b[i] - m[i]].push_back(i);
   }
   long long c = 0;
   vector<long long> ea(n);
   for (auto& x : dsize) {
     multiset<inter, comp1> inter1;
     multiset<inter, comp2> inter2;
     for (auto& i : x.second) {
       long long eamax = min(m[i], a[i]);
       long long eamin = max(m[i] - b[i], 0LL);
       inter1.insert(inter{i, a[i] - eamax, a[i] - eamin});
       inter2.insert(inter{i, a[i] - eamax, a[i] - eamin});
     }
     auto p1 = inter1.begin();
     while (!inter2.empty()) {
       long long targ = inter2.begin()->x2;
       while ((p1 == inter1.end()) ? false : (p1->x1 <= targ)) {
         inter2.erase(*p1);
         ea[p1->j] = a[p1->j] - targ;
         p1++;
       }
       c++;
     }
   }
   cout << c << endl;
   for (long long i = 0; i < (n); i++)
     cout << ea[i] <<     << m[i] - ea[i] << endl;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   ifstream ifs;
   if (  [0]) cin.rdbuf((ifs = ifstream(  )).rdbuf());
   ;
   ofstream ofs;
   if (  [0]) cout.rdbuf((ofs = ofstream(  )).rdbuf());
   ;
   ofstream lfs;
   if (  [0]) clog.rdbuf((lfs = ofstream(  )).rdbuf());
   ;
   int t;
   cin >> t;
   for (int i = 1; i <= t; i++) {
     solve();
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long mod = 1e9 + 7;
 long long a[2000], dp[2000];
 long long qmod(long long y) {
   long long res = 1, two = (long long)2;
   for (; y; y >>= 1) {
     if (y & 1) res = res * two % mod;
     two = two * two % mod;
   }
   return res;
 }
 int main() {
   long long x, y;
   int cnt = 0;
   scanf( %lld%lld , &x, &y);
   if (y % x) return 0 * puts( 0 );
   for (long long i = 1; i <= sqrt(y); ++i) {
     if (y % i == 0) {
       if (i % x == 0) a[++cnt] = i;
       if (i * i != y && y / i % x == 0) a[++cnt] = y / i;
     }
   }
   sort(a + 1, a + 1 + cnt);
   for (int i = cnt; i > 0; --i) {
     dp[i] = qmod(y / a[i] - 1);
     for (int j = i + 1; j <= cnt; ++j)
       if (a[j] % a[i] == 0) dp[i] = ((dp[i] - dp[j]) % mod + mod) % mod;
   }
   printf( %lld
 , dp[1]);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline void Input_Output() {}
 const double eps = 0.000001;
 const long double pi = acos(-1);
 const int maxn = 1e7 + 9;
 const int mod = 1e9 + 7;
 const long long MOD = 1e18 + 9;
 const long long INF = 1e18 + 123;
 const int inf = 2e9 + 11;
 const int mxn = 1e6 + 9;
 const int N = 6e5 + 123;
 const int K = 80;
 const int pri = 997;
 const int Magic = 2101;
 const int dx[] = {-1, 0, 1, 0};
 const int dy[] = {0, -1, 0, 1};
 int n, m, k, x;
 vector<int> state;
 int ids[(1 << 8)];
 struct Mat {
   long long d[K][K];
   Mat(long long val = INF) {
     for (int i = 0; i < K; ++i)
       for (int j = 0; j < K; ++j) d[i][j] = INF;
     for (int i = 0; i < K; ++i) d[i][i] = val;
   }
   Mat operator+(Mat &b) {
     Mat res;
     for (int i = 0; i < K; ++i)
       for (int j = 0; j < K; ++j)
         for (int k = 0; k < K; ++k)
           res.d[i][j] = min(res.d[i][j], d[i][k] + b.d[k][j]);
     return res;
   }
   void print() {
     for (int i = 0; i < K; ++i) {
       for (int j = 0; j < K; ++j) {
         if (d[i][j] == INF) {
           cout <<  bd  ;
           continue;
         }
         cout << d[i][j] << ' ';
       }
       cout << '
';
     }
   }
 };
 Mat make_matrix(vector<long long> &c) {
   assert((int)(c.size()) == k);
   Mat res;
   for (int id = 0; id < (int)(state.size()); ++id) {
     int msk = state[id];
     if (msk % 2 == 0) {
       int nmsk = msk / 2;
       res.d[id][ids[nmsk]] = 0;
       continue;
     }
     for (int i = 0; i < k; ++i) {
       int nmsk = (msk >> 1);
       if (nmsk & (1 << i)) {
         continue;
       }
       nmsk |= (1 << i);
       res.d[id][ids[nmsk]] = min(res.d[id][ids[nmsk]], c[i]);
     }
   }
   return res;
 }
 int main() {
   ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> x >> k >> n >> m;
   for (int msk = 0; msk < (1 << k); ++msk) {
     ids[msk] = -1;
     if (__builtin_popcount(msk) != x) {
       continue;
     }
     ids[msk] = (int)(state.size());
     state.push_back(msk);
   }
   vector<long long> c(k);
   for (auto &e : c) cin >> e;
   vector<int> pos = {0, n - x};
   vector<pair<int, int> > spec(m);
   for (auto &it : spec) {
     cin >> it.first >> it.second;
     it.first--;
     for (int i = 0; i <= k; ++i) {
       int s = it.first - i;
       s = max(s, 0);
       s = min(s, n - x);
       pos.push_back(s);
     }
   }
   sort(pos.begin(), pos.end());
   pos.resize(unique(pos.begin(), pos.end()) - pos.begin());
   vector<Mat> Pw;
   Pw.push_back(make_matrix(c));
   int bit = 0;
   while ((1 << bit) <= n) {
     ++bit;
     Pw.push_back(Pw.back() + Pw.back());
   }
   Mat cur = 0;
   for (int it = 0; it + 1 < (int)(pos.size()); ++it) {
     int l = pos[it], r = pos[it + 1];
     vector<long long> nc = c;
     for (auto s : spec) {
       if (s.first > l && s.first <= l + k) {
         nc[s.first - l - 1] += s.second;
       }
     }
     if (nc != c) {
       Mat cn = make_matrix(nc);
       cur = cur + cn;
     } else {
       int dif = r - l;
       for (int i = 0; i < (int)(Pw.size()); ++i) {
         if (dif & (1 << i)) {
           cur = cur + Pw[i];
         }
       }
     }
   }
   int fin = (1 << x) - 1;
   fin = ids[fin];
   assert(fin != -1);
   cout << cur.d[fin][fin] << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 bool vis[2][100005];
 char c[2][100005];
 int main() {
   queue<pair<int, pair<int, int> > > q;
   bool flag = 0;
   int n, k;
   cin >> n >> k;
   scanf( %s%s , c[0], c[1]);
   q.push(make_pair(0, make_pair(0, 0)));
   while (!q.empty()) {
     int x = q.front().first, y = q.front().second.first,
         de = q.front().second.second;
     q.pop();
     if (y >= n) {
       flag = 1;
       break;
     }
     if (vis[x][y] || de > y) continue;
     vis[x][y] = 1;
     if (y - 1 >= 0 && c[x][y - 1] != 'X' && y - 1 >= de + 1 && !vis[x][y - 1]) {
       q.push(make_pair(x, make_pair(y - 1, de + 1)));
     }
     if (y + 1 >= n || (c[x][y + 1] != 'X' && !vis[x][y + 1])) {
       q.push(make_pair(x, make_pair(y + 1, de + 1)));
     }
     if (y + k >= n || (c[x ^ 1][y + k] != 'X' && !vis[x ^ 1][y + k])) {
       q.push(make_pair(x ^ 1, make_pair(y + k, de + 1)));
     }
   }
   if (flag)
     cout <<  YES ;
   else
     cout <<  NO ;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   ;
   long long int n, k, sum = 0;
   cin >> n >> k;
   long long int a[n];
   for (long long int i = 0; i < n; i++) cin >> a[i];
   string s;
   cin >> s;
   vector<long long int> v;
   v.push_back(a[0]);
   for (long long int i = 1; s[i]; i++) {
     if (s[i] == s[i - 1])
       v.push_back(a[i]);
     else {
       sort(v.rbegin(), v.rend());
       for (long long int i = 0; i < k && i < v.size(); i++) {
         sum += v[i];
       }
       v.clear();
       v.push_back(a[i]);
     }
   }
   sort(v.rbegin(), v.rend());
   for (long long int i = 0; i < k && i < v.size(); i++) sum += v[i];
   cout << sum;
 }


#include<bits/stdc++.h>
 using namespace std;
 int a[10];
 int main() {
     int T;scanf( %d ,&T);
     while(T--) {
         int sum = 0;
         for(int i = 1;i <= 3;i++) {
             scanf( %d ,&a[i]);
             sum += a[i];
         }
         if(sum % 9 == 0) {
             if(a[1] >= sum / 9 && a[2] >= sum / 9 && a[3] >= sum / 9) {
                 printf( YES
 );
             } else {
                 printf( NO
 );
             }
         } else {
             printf( NO
 );
         }
     }
     return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 using ll = long long int;
 using ld = long double;
 using vi = vector<int>;
 using vll = vector<ll>;
 using vd = vector<double>;
 using vvi = vector<vi>;
 int ctoi(char c) { return c - '0'; }
 int slen(string s) { return s.length(); }
 int vsize(vi a) { return (int)a.size(); }
 int in() {
   int x;
   cin >> x;
   return x;
 }
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
   int N;
   cin >> N;
   vi d(N);
   for (auto& x : d) cin >> x;
   int mn = abs(d[N - 1] - d[0]);
   int a = N - 1, b = 0;
   for (int i = 1; i < N; i++) {
     if (abs(d[i] - d[i - 1]) < mn) {
       mn = abs(d[i] - d[i - 1]);
       a = i;
       b = i - 1;
     }
   }
   cout << a + 1 <<     << b + 1 << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   int result = 0;
   for (int i = 0; i < n; i++) {
     int k, a;
     cin >> k >> a;
     long x = k * a;
     int c = 0;
     if (a % 4 == 0) a--;
     while (a) {
       a /= 4;
       c++;
     }
     result = (((result) < (k + c)) ? (k + c) : (result));
   }
   cout << result;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long n, m;
   cin >> n >> m;
   long long x;
   for (int i = 0; i < m; i++) {
     cin >> x;
     if (x > n)
       cout << 0 << endl;
     else {
       if (x % 2 == 1)
         cout << x / 2 + 1 << endl;
       else {
         long long a = x, b, c = n;
         while (1) {
           if (a % 2 == 1) break;
           b = a + (c - a / 2);
           a = b;
         }
         cout << a / 2 + 1 << endl;
       }
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int inf = 0x3f3f3f3f;
 const int maxn = 100010;
 int x0[maxn], x1[maxn], d[maxn], c[maxn];
 int main() {
   int n, m, y0, y1;
   scanf( %d %d %d %d , &n, &m, &y0, &y1);
   for (int i = 0; i < n; ++i) {
     scanf( %d , &x0[i]);
   }
   memset(d, -1, sizeof(d));
   for (int i = 0; i < m; ++i) {
     scanf( %d , &x1[i]);
   }
   int p = 0, k = 0, last = -1;
   for (int i = 0; i < n; ++i) {
     while (p < m && abs(x0[i] - x1[p]) > abs(x0[i] - x1[p + 1])) ++p;
     if (last < p || abs(x0[i - 1] - x1[p]) == abs(x0[i] - x1[p]))
       ++k, last = p;
     else if (p < m && abs(x0[i] - x1[p]) == abs(x0[i] - x1[p + 1]))
       ++k, last = ++p;
     else
       last = p;
   }
   printf( %d
 , n - k);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   string a;
   cin >> a;
   long long int x = a.length();
   std::vector<long long int> v;
   long long int c = 0;
   long long int d = 0;
   for (long long int i = 0; i < x; i++) {
     if (a[i] == 'b') {
       d++;
     }
     if (a[i] == 'a') {
       if (d > 0 && c > 0) {
         v.push_back(c);
         d = 0;
         c = 0;
       }
       c++;
       d = 0;
     }
   }
   if (c > 0) v.push_back(c);
   long long int res = 1;
   for (long long int i = 0; i < v.size(); i++) {
     res = (res * (v[i] + 1)) % 1000000007;
   }
   cout << res - 1;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, a[16], b[16];
 int main() {
   double cnt = 0;
   ios::sync_with_stdio(false);
   cin >> n;
   for (register int i = 0; i < n; i++) cin >> a[i];
   for (register int i = 0; i < n; i++) cin >> b[i];
   for (register int i = 0; i < 1e6; ++i) {
     register bool f = false;
     for (register int j = 0; !f && j < n; ++j) f |= i % a[j] == b[j];
     cnt += f;
   }
   cout.setf(ios::fixed, ios::floatfield);
   return (cout << setprecision(7) << cnt / 1e6 << endl) && 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long n, k1, k2;
 long long a[1005];
 long long b[1005];
 void ReadData() {
   cin >> n >> k1 >> k2;
   for (long long i = 1; i <= n; i++) cin >> a[i];
   for (long long i = 1; i <= n; i++) cin >> b[i];
 }
 long long c[1005];
 void process() {
   long long k = k1 + k2;
   priority_queue<long long> heap;
   for (long long i = 1; i <= n; i++) {
     c[i] = abs(a[i] - b[i]);
     heap.push(c[i]);
   }
   while (k--) {
     long long tmp = heap.top();
     heap.pop();
     tmp--;
     heap.push(abs(tmp));
   }
   long long res = 0;
   while (!heap.empty()) {
     long long tmp = heap.top();
     heap.pop();
     res += tmp * tmp;
   }
   cout << res;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ReadData();
   process();
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1002, M = 10002;
 pair<int, long long> dp[N][M];
 map<long long, int> di;
 bool vis[N][M];
 int nxt[N][M];
 long long a[N], b[N], k;
 int T[M][N];
 int n;
 long long gcd(long long a, long long b) {
   if (b == 0) return a;
   return gcd(b, a % b);
 }
 int main() {
   scanf( %d %lld , &n, &k);
   for (int i = 0; i < n; ++i) {
     scanf( %lld , b + i);
     a[i] = gcd(b[i], k);
   }
   if (k == 1) return printf( %d
%ld
 , 1, min_element(b, b + n) - b + 1), 0;
   vector<long long> divisor;
   for (long long i = 1; i * i <= k; ++i)
     if (k % i == 0) {
       divisor.push_back(i);
       divisor.push_back(k / i);
     }
   sort(divisor.begin(), divisor.end());
   divisor.resize(unique(divisor.begin(), divisor.end()) - divisor.begin());
   int m = divisor.size();
   for (int i = 0; i < m; ++i) di[divisor[i]] = i;
   for (int i = 0; i < m; ++i)
     for (int j = 0; j < n; ++j)
       T[i][j] = di[divisor[i] / gcd(divisor[i], a[j])];
   nxt[n][0] = -1;
   dp[n][0] = {0, 0};
   for (int i = 1; i < m; ++i) dp[n][i] = {n + 1, 0};
   for (int i = 0; i < m; ++i)
     for (int j = n - 1; j >= 0; --j) {
       pair<int, long long> ans1 = dp[j + 1][i];
       pair<int, long long> ans2 = dp[j + 1][T[i][j]];
       ans2.first += 1;
       ans2.second += b[j];
       if (ans1 <= ans2) {
         nxt[j][i] = nxt[j + 1][i];
         dp[j][i] = ans1;
       } else {
         nxt[j][i] = j;
         dp[j][i] = ans2;
       }
     }
   pair<int, long long> ans = dp[0][m - 1];
   if (ans.first > n) return puts( -1 ), 0;
   printf( %d
 , ans.first);
   int pos = 0;
   int nx = m - 1;
   while (pos != -1) {
     if (nxt[pos][nx] != pos)
       pos = nxt[pos][nx];
     else {
       nx = T[nx][pos];
       printf( %d  , pos + 1);
       pos += 1;
     }
   }
   puts(  );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios_base::sync_with_stdio(0);
   int n;
   cin >> n;
   int a[100005];
   for (int i = 0; i < n; i++) cin >> a[i];
   sort(a, a + n);
   if (n == 1) {
     cout << -1 << endl;
     return 0;
   }
   bool flag = true;
   for (int i = 1; i < n; i++) flag = flag && (a[0] == a[i]);
   if (flag) {
     cout << 1 << endl;
     cout << a[0] << endl;
     return 0;
   }
   if (n == 2) {
     if ((a[0] + a[1]) % 2 == 0)
       cout << 3 << endl;
     else
       cout << 2 << endl;
     cout << 2 * a[0] - a[1] <<    ;
     if ((a[0] + a[1]) % 2 == 0) cout << (a[1] + a[0]) / 2 <<    ;
     cout << 2 * a[1] - a[0] <<    ;
     return 0;
   }
   flag = true;
   for (int i = 2; i < n; i++) flag = flag && (a[1] - a[0] == a[i] - a[i - 1]);
   if (flag) {
     cout << 2 << endl;
     cout << 2 * a[0] - a[1] <<    ;
     cout << 2 * a[n - 1] - a[n - 2] << endl;
     return 0;
   }
   vector<int> diff;
   set<int> di;
   for (int i = 1; i < n; i++) {
     diff.push_back(a[i] - a[i - 1]);
     di.insert(a[i] - a[i - 1]);
   }
   if (di.size() != 2) {
     cout << 0 << endl;
     return 0;
   }
   sort(diff.begin(), diff.end());
   int chan = diff[n - 2];
   if (chan != 2 * diff[0]) {
     cout << 0 << endl;
     return 0;
   }
   for (int i = n - 3; i >= 0; i--) {
     if (diff[i] == chan || diff[i] != diff[0]) {
       cout << 0 << endl;
       return 0;
     }
   }
   for (int i = 1; i < n; i++) {
     if (a[i] - a[i - 1] == chan) {
       if ((a[i] + a[i - 1]) % 2 == 0) {
         cout << 1 << endl;
         cout << (a[i] + a[i - 1]) / 2 << endl;
         return 0;
       } else {
         cout << 0 << endl;
         return 0;
       }
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 vector<long int> fib(46, -1);
 int adv_fib(int n) {
   if (n == 0 || n == 1) {
     return 1;
   } else if (fib[n] == -1) {
     return fib[n] = adv_fib(n - 1) + adv_fib(n - 2);
   } else {
     return fib[n];
   }
 }
 int main() {
   int n, curr = 1;
   cin >> n;
   for (int i = 1; i <= n; i++) {
     if (adv_fib(curr) == i) {
       cout << 'O';
       curr++;
     } else {
       cout << 'o';
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 long long i, j, k, l, m, n, t, a[211111], b[211111], c[111111], d, s;
 string p[111111], q[111111];
 int main() {
   cin >> n;
   for (i = 1; i <= n; i++) scanf( extra , &a[i]);
   for (i = 1; i <= n; i++) scanf( extra , &b[i]);
   i = 1;
   j = 1;
   while (i <= n) {
     while (a[i] != b[j] && j <= n) j++;
     if (j <= n)
       i++;
     else
       break;
   }
   if (i > n) {
     cout << 0;
     return 0;
   }
   cout << n - i + 1;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   vector<int> v(n);
   for (auto &x : v) cin >> x;
   int mine = *min_element(v.begin(), v.end());
   vector<int> temp;
   for (int i = 0; i < n; i++) {
     if (v[i] == mine) temp.push_back(i);
   }
   for (int i = 0; i < temp.size() - 1; i++) temp[i] = temp[i + 1] - temp[i];
   cout << *min_element(temp.begin(), temp.end() - 1) << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 1e5 + 50;
 int n, a[maxn], ans, maxx = 0;
 int main() {
   cin >> n;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
     maxx = max(maxx, a[i]);
   }
   cout << maxx;
   return 0;
 }