#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   int f = n * 1.0 / 3 + 0.5;
   cout << f / 12 << ' ' << f % 12 << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long MAX1 = 3e5 + 10;
 long long a, b, c, d, e, cnt, x, y, z, l, r, flag, num[MAX1], mod = 1e10 + 7;
 string s;
 char p[MAX1];
 long long sta(long long n) {
   for (int i = 1; i < 1000000; ++i) {
     if (i * (i - 1) / 2 == n) return i;
   }
   return 0;
 }
 int main() {
   cin >> a >> b >> c >> d;
   x = sta(a);
   y = sta(d);
   if (a == 0) {
     if (b == 0 && c == 0 && x && y) {
       for (int i = 0; i < y; ++i) cout << 1;
       return 0;
     } else
       x = 1;
   }
   if (d == 0) {
     if (b == 0 && c == 0 && x && y) {
       for (int i = 0; i < x; ++i) cout << 0;
       return 0;
     } else
       y = 1;
   }
   if (x == 0 || y == 0) {
     cout <<  Impossible ;
     return 0;
   }
   if (x * y != b + c) {
     cout <<  Impossible ;
     return 0;
   }
   cnt = b / y;
   b -= cnt * y;
   x -= cnt;
   for (long long i = 0; i < cnt; ++i) cout << 0;
   for (long long i = 0; i < y - b; ++i) cout << 1;
   y -= y - b;
   if (x && b) cout << 0, --x;
   for (long long i = 0; i < y; ++i) cout << 1;
   for (long long i = 0; i < x; ++i) cout << 0;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long bigpow(long long x, long long n) {
   if (n == 0) return 1;
   long long temp = bigpow(x, n / 2);
   return n % 2 == 0 ? (temp * temp) % 1000000009
                     : (x * ((temp * temp) % 1000000009)) % 1000000009;
 }
 int main() {
   long long n, m, k, x, t, p, q, gaps, groups;
   cin >> n >> m >> k;
   gaps = n - m;
   groups = m % (k - 1) == 0 ? m / (k - 1) : m / (k - 1) + 1;
   if (gaps >= groups - 1)
     cout << m << endl;
   else {
     x = n - gaps * k;
     t = 2 * (bigpow(2, x / k) - 1) * k + x % k;
     t += gaps * (k - 1);
     cout << t % 1000000009 << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int inf = 1e9;
 const int MOD = 1e9 + 7;
 const int N = 0;
 int a[5], m;
 long long sum(int len, int x) {
   return 1LL * len * x - 1LL * (x + 1) * x / 2 + x;
 }
 long long cal(int x, int y, int bar, int len) {
   if (len < 0) return 0;
   int R = min(bar - y, len), L = min(len - (bar - x), R);
   long long ans = 0;
   if (L >= 0)
     ans += 1LL * (L + 1) * (bar - x + 1);
   else
     L = -1;
   ans += sum(len, R) - sum(len, L);
   return ans;
 }
 long long solve(int x, int y, int z, int len) {
   int tmp = max(max(y, z) + 1, x);
   len -= tmp - x;
   x = tmp;
   long long ans = 0;
   for (auto i = 0; i <= len; i++) {
     int cur = x + i, rem = min(2 * (cur - 1) - y - z, len - i);
     if (rem > cur - y - z)
       ans += cal(y, z, cur - 1, rem) - cal(y, z, cur - 1, (cur - y - z));
   }
   return ans;
 }
 long long solve2(int x, int y, int z, int len) {
   int tmp = max(x, y);
   len -= 2 * tmp - x - y;
   x = tmp;
   if (x <= z) len -= 2 * (z + 1 - x), x = z + 1;
   long long ans = 0;
   if (len >= 0)
     for (auto i = 0; i <= len / 2; i++) {
       int rem = len - 2 * i;
       ans += min(x + i - 1 - z, rem) + 1;
     }
   return ans;
 }
 int main() {
   for (auto i = 0; i <= 2; i++) cin >> a[i];
   cin >> m;
   long long ans = 0;
   for (auto i = 0; i <= 2; i++)
     ans += solve(a[i], a[(i + 1) % 3], a[(i + 2) % 3], m);
   for (auto i = 0; i <= 2; i++)
     ans += solve2(a[i], a[(i + 1) % 3], a[(i + 2) % 3], m);
   int tmp = *max_element(a, a + 3), v = 0;
   for (auto i = 0; i <= 2; i++) v += tmp - a[i];
   if (v <= m) ans += (m - v) / 3 + 1;
   cout << ans;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, k;
   cin >> n >> k;
   int a[k];
   for (int i = 0; i < k; i++) cin >> a[i];
   list<int> leader;
   for (int i = 1; i <= n; i++) leader.insert(leader.end(), i);
   int l = 1;
   int i = 0;
   int begin = 0;
   while (k--) {
     l = (leader.size() + a[i] + begin) % leader.size();
     list<int>::iterator pnlist = leader.begin();
     advance(pnlist, l);
     if (k == 0)
       cout << *pnlist << endl;
     else
       cout << *pnlist <<    ;
     leader.erase(pnlist);
     begin = l;
     i++;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 long long gcd(long long a, long long b) {
   while (b) {
     a %= b;
     swap(a, b);
   }
   return a;
 }
 int main() {
   int n;
   cin >> n;
   vector<int> q(n);
   for (int i = 0; i < n; ++i) cin >> q[i];
   vector<int> cost(n, -1);
   int m;
   cin >> m;
   for (int i = 0; i < m; ++i) {
     int a, b, c;
     cin >> a >> b >> c;
     if (cost[b - 1] == -1 || cost[b - 1] > c) {
       cost[b - 1] = c;
     }
   }
   int ans = 0, head = 0;
   for (int i = 0; i < n; ++i) {
     if (cost[i] != -1)
       ans += cost[i];
     else
       head++;
   }
   if (head > 1)
     cout << -1 << endl;
   else {
     if (!head) {
       int maxx = cost[0];
       for (int i = 1; i < n; ++i) maxx = max(maxx, cost[i]);
       ans -= maxx;
     }
     cout << ans << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m;
 vector<int> g[200002];
 vector<pair<int, pair<int, int> > > first[200002];
 int lvl[200002];
 int p[20][200002];
 int h[20][200002];
 int d[200002][2];
 inline int lca(int v1, int v2) {
   if (lvl[v1] < lvl[v2]) swap(v1, v2);
   for (int i = 20 - 1; i >= 0; --i) {
     if (lvl[p[i][v1]] >= lvl[v2]) {
       v1 = p[i][v1];
     }
   }
   if (v1 == v2) return v1;
   for (int i = 20 - 1; i >= 0; --i) {
     if (p[i][v1] != p[i][v2]) {
       v1 = p[i][v1];
       v2 = p[i][v2];
     }
   }
   return p[0][v1];
 }
 void dfs(int v = 0, int level = 0, int pr = 0) {
   lvl[v] = level;
   p[0][v] = pr;
   for (int i = 1; i < 20; ++i) p[i][v] = p[i - 1][p[i - 1][v]];
   for (const int& v2 : g[v]) {
     dfs(v2, level + 1, v);
   }
 }
 inline int getit(int v, int k) {
   if (h[k][v] != -1) return h[k][v];
   return h[k][v] = getit(p[k - 1][v], k - 1) + getit(v, k - 1);
 }
 inline int get(int v, int k) {
   if (k < 0) return 0;
   int res = 0;
   for (int i = 20 - 1; i >= 0; --i) {
     if ((k & (1 << i)) > 0) {
       res += getit(v, i);
       k ^= (1 << i);
       v = p[i][v];
     }
   }
   return res;
 }
 void go(int v = 0) {
   for (const int& v2 : g[v]) {
     go(v2);
     d[v][0] += max(d[v2][0], d[v2][1]);
   }
   for (const int& v2 : g[v]) {
     h[0][v2] = d[v][0] - max(d[v2][0], d[v2][1]);
   }
   for (const auto& t : first[v]) {
     int cost = t.first;
     int v1 = t.second.first;
     int v2 = t.second.second;
     int w = -d[v][0] + get(v1, lvl[v1] - lvl[v]) + get(v2, lvl[v2] - lvl[v]) +
             d[v1][0] + d[v2][0] + cost;
     d[v][1] = max(d[v][1], w);
   }
 }
 int main() {
   memset(h, -1, sizeof(h));
   scanf( %d%d , &n, &m);
   for (int i = 0; i < n - 1; ++i) {
     int t;
     scanf( %d , &t);
     --t;
     g[t].push_back(i + 1);
   }
   dfs();
   for (int i = 0; i < m; ++i) {
     int v1, v2, cost;
     scanf( %d%d%d , &v1, &v2, &cost);
     --v1, --v2;
     int lcav = lca(v1, v2);
     first[lcav].push_back(make_pair(cost, make_pair(v1, v2)));
   }
   go();
   printf( %d
 , max(d[0][0], d[0][1]));
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int t[2000002];
 int longestPrefix(string &s) {
   t[0] = 0;
   for (int pos = 1; pos < s.length(); ++pos) {
     int prev = t[pos - 1];
     while (prev > 0 && s[pos] != s[prev]) {
       prev = t[prev - 1];
     }
     if (s[pos] == s[prev]) {
       t[pos] = prev + 1;
     } else {
       t[pos] = prev;
     }
   }
   return t[s.length() - 1];
 }
 int main() {
   int t;
   cin >> t;
   while (t-- > 0) {
     string s;
     cin >> s;
     int lindex = 0, rindex = s.length();
     while (lindex < rindex && s[lindex] == s[rindex - 1]) {
       ++lindex;
       --rindex;
     }
     if (lindex >= rindex) {
       cout << s << endl;
       continue;
     }
     string mid = s.substr(lindex, rindex - lindex);
     string rmid = mid;
     reverse(rmid.begin(), rmid.end());
     string pre = mid + '*' + rmid;
     string suf = rmid + '*' + mid;
     int pref = longestPrefix(pre);
     int suff = longestPrefix(suf);
     int len = max(pref, suff);
     for (int i = 0; i < lindex; ++i) {
       cout << s[i];
     }
     if (pref >= suff) {
       for (int i = lindex; i < lindex + pref; ++i) {
         cout << s[i];
       }
     } else {
       for (int i = rindex - suff; i < rindex; ++i) {
         cout << s[i];
       }
     }
     for (int i = rindex; i < s.length(); ++i) {
       cout << s[i];
     }
     cout << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int V[200010];
 char vowel[] =  aeiouAEIOU ;
 int v(int a, int k) {
   if (k == 0) return 0;
   int x = V[a + k - 1];
   if (a > 0) x -= V[a - 1];
   return x;
 }
 int f(int a, int k) { return 2 * k - 3 * v(a, k); }
 int g(int k) { return f(0, k); }
 bool Good(int a, int k) { return f(a, k) >= 0; }
 bool is_vowel(char c) {
   for (int i = 0; i < 10; i++) {
     if (vowel[i] == c) return true;
   }
   return false;
 }
 bool sf(const int& a, const int& b) {
   if (g(a) < g(b)) return true;
   if (g(a) > g(b)) return false;
   return a < b;
 }
 int Q[200010];
 vector<int> P;
 int R[200010];
 int my_bin_search(int s, string S) {
   int a = 0;
   int b = P.size() - 1;
   while (a <= b) {
     int k = (a + b) / 2;
     if (P[k] == s)
       return k;
     else if (sf(P[k], s))
       a = k + 1;
     else
       b = k - 1;
   }
   throw  element not found ;
 }
 void create_data(string S) {
   int N = S.length();
   for (int a = 0; a <= N; a++) {
     P.push_back(a);
   }
   sort(P.begin(), P.end(), sf);
   for (int x = 0; x < P.size(); x++) {
     R[P[x]] = x;
   }
   Q[0] = P[0];
   for (unsigned int x = 1; x < P.size(); x++) {
     Q[x] = min(Q[x - 1], P[x]);
   }
 }
 int main() {
   string S;
   cin >> S;
   int N = S.length();
   V[0] = 0;
   for (unsigned int i = 0; i < S.length(); i++) {
     if (i > 0) V[i] = V[i - 1];
     if (is_vowel(S[i])) V[i]++;
   }
   create_data(S);
   int bestk = 0;
   for (int a = 0; a <= N; a++) {
     int x = R[a];
     int b = Q[x];
     bestk = max(bestk, a - b);
   }
   if (bestk == 0) {
     cout <<  No solution  << endl;
     return 0;
   }
   int found = 0;
   for (int a = 0; (a + bestk) <= N; a++) {
     if (Good(a, bestk)) {
       found++;
     }
   }
   cout << bestk <<     << found << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const double PI = acos(-1);
 void read(int& x) {
   x = 0;
   int f = 1;
   char ch = getchar();
   while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
   if (ch == '-') f = -1, ch = getchar();
   while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
   x *= f;
 }
 int n, f[200005], g[200005], els[200005];
 vector<int> E[200005];
 int power(int a, int b, int p) {
   int s = 1, w = a;
   while (b) {
     if (b & 1) s = (long long)s * w % p;
     w = (long long)w * w % p;
     b >>= 1;
   }
   return s;
 }
 vector<int> F[200005], B[200005];
 void dfs(int now) {
   f[now] = 1;
   for (int i = (0); i < (E[now].size()); i++) {
     dfs(E[now][i]),
         f[now] = (long long)f[now] * (f[E[now][i]] + 1) % 1000000007;
     F[now].push_back(f[E[now][i]] + 1), B[now].push_back(f[E[now][i]] + 1);
   }
   for (int i = (1); i < (E[now].size()); i++)
     F[now][i] = (long long)F[now][i - 1] * F[now][i] % 1000000007;
   for (int i = (E[now].size() - 2); i >= (0); i--)
     B[now][i] = (long long)B[now][i + 1] * B[now][i] % 1000000007;
   if (E[now].size() == 1) {
     els[E[now][0]] = 1;
     return;
   }
   for (int i = (0); i < (E[now].size()); i++) {
     if (i == 0)
       els[E[now][i]] = B[now][i + 1];
     else if (i + 1 == E[now].size())
       els[E[now][i]] = F[now][i - 1];
     else
       els[E[now][i]] = (long long)B[now][i + 1] * F[now][i - 1] % 1000000007;
   }
 }
 void work(int now) {
   for (int i = (0); i < (E[now].size()); i++) {
     g[E[now][i]] = ((long long)g[now] * els[E[now][i]] + 1) % 1000000007;
     work(E[now][i]);
   }
 }
 int main() {
   read(n);
   for (int i = (2); i <= (n); i++) {
     int x;
     read(x);
     E[x].push_back(i);
   }
   dfs(1);
   g[1] = 1;
   work(1);
   for (int i = (1); i <= (n); i++)
     printf( %lld  , (long long)f[i] * g[i] % 1000000007);
   printf(
 );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 string n;
 int i, j, a[9][7], x, y;
 int main() {
   cin >> n;
   for (i = n.size() - 1; i >= 0; i--) {
     x = n[i] - 48;
     y = max(y, x);
     for (j = 0; j < x; j++) a[j][7 + i - n.size()] = 1;
   }
   cout << y << endl;
   for (i = 0; i < y; cout <<    , i++)
     for (j = 0, x = 0; j < 7; j++) {
       if (a[i][j] != 0) x = 1;
       if (x != 0) cout << a[i][j];
     }
   cout << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline long long read() {
   long long s = 0, w = 1;
   register char ch = getchar();
   while (ch < '0' || ch > '9') {
     if (ch == '-') w = -1;
     ch = getchar();
   }
   while (ch >= '0' && ch <= '9')
     s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
   return s * w;
 }
 long long n;
 string s;
 signed main() {
   n = read();
   cin >> s;
   for (register long long i = 2; i <= n; i++) {
     if (n % i) continue;
     for (register long long j = 0; j < i / 2; j++) swap(s[j], s[i - j - 1]);
   }
   cout << s << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int D = 505;
 const int N = 5005;
 pair<int, int> pre[D][N];
 int ans[D][N];
 void solve() {
   memset(pre, -1, sizeof(pre));
   memset(ans, -1, sizeof(ans));
   int d, s;
   cin >> d >> s;
   queue<pair<int, int> > que;
   que.push(pair<int, int>(0, 0));
   vector<int> vec;
   while (!que.empty()) {
     pair<int, int> u = que.front();
     que.pop();
     if (u.first == 0 && u.second == s) {
       pair<int, int> cur = u;
       while (!(cur.first == 0 && cur.second == 0)) {
         vec.push_back(ans[cur.first][cur.second]);
         cur = pre[cur.first][cur.second];
       }
       break;
     }
     for (int i = 0; i <= 9; i++) {
       pair<int, int> v = pair<int, int>((u.first * 10 + i) % d, u.second + i);
       if (v.second <= s && ans[v.first][v.second] == -1) {
         ans[v.first][v.second] = i;
         pre[v.first][v.second] = u;
         que.push(v);
       }
     }
   }
   if (!vec.size())
     printf( -1
 );
   else {
     reverse(vec.begin(), vec.end());
     for (auto i : vec) putchar(i + '0');
     printf(
 );
   }
 }
 int main() {
   solve();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long N = 1e6 + 5, MOD = 998244353;
 int m, n, k;
 long long res;
 int free_Row, free_Col, line_vert, line_hori;
 int Num_Row[N], Num_Row2[N][2], Num_Col[N], Num_Col2[N][2];
 int c[2][2];
 map<pair<int, int>, int> M;
 long long power(long long x, int k) {
   long long ans = 1;
   while (k) {
     if (k & 1) ans = ans * x % MOD;
     x = x * x % MOD;
     k >>= 1;
   }
   return ans;
 }
 void Calculate() {
   res = 0;
   if (line_vert && line_hori) return;
   if (!line_vert) (res += power(2, free_Row)) %= MOD;
   if (!line_hori) (res += power(2, free_Col)) %= MOD;
   if (!line_vert && !line_vert) {
     if (c[0][0] == 0 && c[1][1] == 0) (res += MOD - 1) %= MOD;
     if (c[0][1] == 0 && c[1][0] == 0) (res += MOD - 1) %= MOD;
   }
 }
 void Delete(int x, int y) {
   if (!M.count({x, y})) return;
   int z = M[{x, y}];
   M.erase({x, y});
   --c[z][(x + y) & 1];
   if (--Num_Row[x] == 0) ++free_Row;
   if (--Num_Row2[x][z ^ (y & 1)] == 0 && Num_Row[x]) --line_vert;
   if (--Num_Col[y] == 0) ++free_Col;
   if (--Num_Col2[y][z ^ (x & 1)] == 0 && Num_Col[y]) --line_hori;
 }
 void Add(int x, int y, int z) {
   M[{x, y}] = z;
   ++c[z][(x + y) & 1];
   if (Num_Row[x]++ == 0) --free_Row;
   if (Num_Row2[x][z ^ (y & 1)]++ == 0 && Num_Row[x] > 1) ++line_vert;
   if (Num_Col[y]++ == 0) --free_Col;
   if (Num_Col2[y][z ^ (x & 1)]++ == 0 && Num_Col[y] > 1) ++line_hori;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   cin >> m >> n >> k;
   free_Row = m;
   free_Col = n;
   line_hori = 0;
   line_vert = 0;
   int x, y, z;
   while (k--) {
     cin >> x >> y >> z;
     Delete(x, y);
     if (z >= 0) Add(x, y, z);
     Calculate();
     cout << res << '
';
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 10000;
 vector<int> vec(N);
 int main() {
   int n, m;
   cin >> n >> m;
   for (int i = 0; i < n; i++) {
     cin >> vec[i];
   }
   sort(vec.begin(), vec.begin() + n);
   int sum = 0;
   for (int i = 0; i < m; i++) {
     sum += vec[i];
   }
   cout << sum << endl;
 }


#include <bits/stdc++.h>
 namespace algo {
 using std::swap;
 const long double PI = 3.141592653589793238462643383279502884L;
 const long double E = 2.718281828459045235360287471352662498L;
 const long double EPS = 1e-12L;
 template <typename T1, typename T2>
 T1 bin_pow(T1 a, T2 n) {
   T1 r{1};
   while (n > 0) {
     if (n % 2 == 1) r *= a;
     a *= a;
     n /= 2;
   }
   return r;
 }
 template <typename T1, typename T2>
 T1 bin_pow(T1 a, T2 n, const T1& m) {
   if (m == 1) return 0;
   T1 r{1};
   while (n > 0) {
     if (n % 2 == 1) {
       r *= a;
       r %= m;
     }
     a *= a;
     a %= m;
     n /= 2;
   }
   return r;
 }
 template <typename T>
 T gcd(const T& a, const T& b) {
   if (b == 0) return a < 0 ? -a : a;
   return gcd(b, a % b);
 }
 template <typename T>
 T gcd(const T& a, const T& b, T& x, T& y) {
   if (b == 0) {
     x = a < 0 ? -1 : 1;
     y = 0;
     return x * a;
   }
   T d{gcd(b, a % b, y, x)};
   y -= (a / b) * x;
   return d;
 }
 template <typename T>
 T lcm(const T& a, const T& b) {
   T r{a / gcd(a, b) * b};
   return r < 0 ? -r : r;
 }
 template <typename T>
 T mod_add(const T& a, const T& b, const T& m) {
   if (a < m - b) return a + b;
   return a - (m - b);
 }
 template <typename T>
 T mod_sub(const T& a, const T& b, const T& m) {
   if (a < b) return a + (m - b);
   return a - b;
 }
 template <typename T>
 T mod_mul(T a, T b, const T& m) {
   if (b > a) swap(a, b);
   T r{0};
   while (b > 0) {
     if (b % 2 == 1) r = mod_add(r, a, m);
     a = mod_add(a, a, m);
     b /= 2;
   }
   return r;
 }
 template <typename T1, typename T2>
 T1 mod_pow(T1 a, T2 n, const T1& m) {
   if (m == 1) return 0;
   T1 r{1};
   while (n > 0) {
     if (n % 2 == 1) r = mod_mul(r, a, m);
     a = mod_mul(a, a, m);
     n /= 2;
   }
   return r;
 }
 template <typename T>
 T mod_inv(const T& a, const T& m) {
   T x, y;
   T d{gcd(a, m, x, y)};
   if (d != 1) return 0;
   if (x < 0) x += m;
   return x;
 }
 template <typename T>
 T phi(T n) {
   T t = std::sqrt(n) + EPS;
   T r = n;
   for (T i = 2; i <= t; ++i) {
     if (n % i == 0) {
       r -= r / i;
       do {
         n /= i;
       } while (n % i == 0);
       t = std::sqrt(n) + EPS;
     }
   }
   if (n > 1) r -= r / n;
   return r;
 }
 class LinearPhi {
  public:
   LinearPhi(uint32_t n = 1 << 20) : size_{n} {
     assert(size_ > 0 &&  Size should be nonzero );
     assert(size_ <= INT32_MAX &&  Size should fit into an 32-bit signed int );
     uint32_t sz = (size_ + 1) / 2;
     phi_ = new int32_t[sz];
     mark_.assign(sz, false);
     phi_[0] = 1;
     if (size_ > 1) primes_.push_back(2);
     for (uint32_t i = 1; i < sz; ++i) {
       uint32_t val = i << 1 | 1;
       if (!mark_[i]) {
         phi_[i] = val - 1;
         primes_.push_back(val);
       }
       if (val < sz) {
         for (uint32_t j = 1; j < primes_.size(); ++j) {
           uint32_t t = val * primes_[j];
           if (t > size_) break;
           mark_[t >> 1] = true;
           if (val % primes_[j] == 0) {
             phi_[t >> 1] = phi_[i] * primes_[j];
             break;
           }
           phi_[t >> 1] = phi_[i] * (primes_[j] - 1);
         }
       }
     }
   }
   LinearPhi(const LinearPhi&) = delete;
   LinearPhi& operator=(const LinearPhi&) = delete;
   ~LinearPhi() {
     delete[] phi_;
     phi_ = nullptr;
   }
   const uint32_t& size() const { return size_; }
   int32_t phi(int32_t i) const {
     int32_t r = 1;
     int k = __builtin_ctz(i);
     if (k > 0) {
       i >>= k;
       r <<= k - 1;
     }
     return r * phi_[i >> 1];
   }
   int32_t operator[](int32_t i) const { return phi(i); }
   const std::vector<int32_t>& primes() const { return primes_; }

  private:
   int32_t* phi_ = nullptr;
   std::vector<bool> mark_;
   uint32_t size_;
   std::vector<int32_t> primes_;
 };
 class Sieve {
  public:
   Sieve(uint32_t n = 1 << 20) : size_{n} {
     assert(size_ > 0 &&  Size should be nonzero );
     assert(size_ <= INT32_MAX &&  Size should fit into an 32-bit signed int );
     uint32_t sz = (size_ + 1) / 2;
     prime_.assign(sz, true);
     prime_[0] = false;
     for (uint32_t i = 1; i < sz; ++i) {
       uint32_t val = i << 1 | 1;
       if (prime_[i] && val * 1ULL * val <= size_)
         for (uint32_t j = val * val; j <= size_; j += 2 * val)
           prime_[j >> 1] = false;
     }
   }
   Sieve(const Sieve&) = delete;
   Sieve& operator=(const Sieve&) = delete;
   const uint32_t& size() const { return size_; }
   bool isPrime(const int32_t& i) const {
     if (i % 2 == 0) return i == 2;
     return prime_[i >> 1];
   }
   bool operator[](const int32_t& i) const { return isPrime(i); }

  private:
   uint32_t size_;
   std::vector<bool> prime_;
 };
 class LinearSieve {
  public:
   LinearSieve(uint32_t n = 1 << 20) : size_{n} {
     assert(size_ > 0 &&  Size should be nonzero );
     assert(size_ <= INT32_MAX &&  Size should fit into an 32-bit signed int );
     uint32_t sz = (size_ + 1) / 2;
     lpf_ = new uint16_t[sz];
     std::fill(lpf_, lpf_ + sz, 0);
     lpf_[0] = 1;
     if (size_ > 1) primes_.push_back(2);
     for (uint32_t i = 1; i < sz; ++i) {
       uint32_t val = i << 1 | 1;
       if (!lpf_[i]) primes_.push_back(val);
       if (val < sz) {
         for (uint32_t j = 1; j < primes_.size(); ++j) {
           uint32_t t = val * primes_[j];
           if (t > size_) break;
           lpf_[t >> 1] = static_cast<uint16_t>(primes_[j]);
           if (lpf_[t >> 1] == (lpf_[i] ? lpf_[i] : val)) break;
         }
       }
     }
   }
   LinearSieve(const LinearSieve&) = delete;
   LinearSieve& operator=(const LinearSieve&) = delete;
   ~LinearSieve() {
     delete[] lpf_;
     lpf_ = nullptr;
   }
   const uint32_t& size() const { return size_; }
   bool isPrime(const int32_t& i) const {
     if (i % 2 == 0) return i == 2;
     return !lpf_[i >> 1];
   }
   bool operator[](const int32_t& i) const { return isPrime(i); }
   int32_t lpf(const int32_t& i) const {
     if (i % 2 == 0) return 2;
     if (!lpf_[i >> 1]) return i;
     return lpf_[i >> 1];
   }
   int32_t phi(int32_t i) const {
     int32_t r = 1;
     int k = __builtin_ctz(i);
     if (k > 0) {
       i >>= k;
       r <<= k - 1;
     }
     int32_t n, t = lpf_[i >> 1] ? lpf_[i >> 1] : i;
     while (t != 1) {
       r *= (t - 1);
       i /= t;
       n = lpf_[i >> 1] ? lpf_[i >> 1] : i;
       while (n == t) {
         r *= n;
         i /= t;
         n = lpf_[i >> 1] ? lpf_[i >> 1] : i;
       }
       t = n;
     }
     return r;
   }
   const std::vector<int32_t>& primes() const { return primes_; }

  private:
   uint16_t* lpf_ = nullptr;
   uint32_t size_;
   std::vector<int32_t> primes_;
 };
 }  // namespace algo
 using namespace std;
 using namespace algo;
 namespace task {
 int x1, y1, x2, y2, x3, y3;
 int main() {
   cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
   cout << 3 << '
';
   cout << x3 - x1 + x2 << ' ' << y3 - y1 + y2 << '
';
   cout << x1 - x2 + x3 << ' ' << y1 - y2 + y3 << '
';
   cout << x2 - x3 + x1 << ' ' << y2 - y3 + y1 << '
';
   return 0;
 }
 }  // namespace task
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.precision(11);
   cout.setf(ios::fixed);
   return task::main();
 }


#include <bits/stdc++.h>
 using namespace std;
 bool BeauYear(int y) {
   int a = y % 10;
   int b = (y / 10) % 10;
   int c = (y / 100) % 10;
   int d = (y / 1000) % 10;
   if (a != b && a != c && a != d && b != c && b != d && c != d) return true;
   return false;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int year;
   cin >> year;
   for (int i = year + 1; i <= 9012; i++) {
     if (BeauYear(i) == true) {
       cout << i;
       i = 9013;
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 100005;
 int n, a, b, q, p[N], d[N];
 vector<pair<int, int> > g[N];
 int dp[N][17], v, ud[N], ans[N];
 bool vis[N];
 void dfs(int u) {
   vis[u] = 1;
   for (int i = 0; i < (int)g[u].size(); ++i) {
     v = g[u][i].first;
     if (!vis[v]) {
       p[v] = u;
       d[v] = d[u] + 1;
       dfs(v);
     }
   }
 }
 int lca(int a, int b) {
   if (d[a] < d[b]) swap(a, b);
   int log = 0;
   for (; (1 << log) <= d[a]; ++log)
     ;
   --log;
   for (int i = log; i >= 0; --i) {
     if (d[a] - (1 << i) >= d[b]) a = dp[a][i];
   }
   if (a == b) return a;
   for (int i = log; i >= 0; --i) {
     if (dp[a][i] != dp[b][i]) {
       a = dp[a][i];
       b = dp[b][i];
     }
   }
   return p[a];
 }
 int DFS(int u) {
   vis[u] = 1;
   for (int i = 0; i < (int)g[u].size(); ++i) {
     int v = g[u][i].first;
     if (!vis[v]) {
       ud[u] += DFS(v);
       ans[g[u][i].second] = ud[v];
     }
   }
   return ud[u];
 }
 int main(int argc, char **argv) {
   scanf( %d , &n);
   for (int i = 1; i < n; ++i) {
     scanf( %d%d , &a, &b);
     g[a].push_back(make_pair(b, i));
     g[b].push_back(make_pair(a, i));
   }
   memset(p, -1, sizeof p);
   memset(dp, -1, sizeof dp);
   dfs(1);
   for (int i = 0; i <= n; ++i) dp[i][0] = p[i];
   for (int j = 1; (1 << j) <= n; ++j) {
     for (int i = 0; i <= n; ++i) {
       if (dp[i][j - 1] != -1) dp[i][j] = dp[dp[i][j - 1]][j - 1];
     }
   }
   scanf( %d , &q);
   int LCA;
   while (q--) {
     scanf( %d%d , &a, &b);
     LCA = lca(a, b);
     ++ud[a], ++ud[b], ud[LCA] -= 2;
   }
   memset(vis, 0, sizeof vis);
   DFS(1);
   for (int i = 1; i < n; ++i) {
     if (i > 1) printf(   );
     printf( %d , ans[i]);
   }
   puts(  );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 string tobinary(long long x) {
   string ret;
   char ch;
   while (x) ch = '0' + (x % 2), ret = ch + ret, x /= 2;
   return ret;
 }
 long long todecimal(string s) {
   int sz = s.size();
   long long ret = 0;
   for (int i = 0; i < sz; i++) ret = 2 * ret + (s[i] - '0');
   return ret;
 }
 bool _greater(string s, string t) {
   int n = s.size(), m = t.size();
   if (n > m) return true;
   if (n < m) return false;
   for (int i = 0; i < n; i++) {
     if (s[i] > t[i])
       return true;
     else if (s[i] < t[i])
       return false;
   }
   return false;
 }
 long long eval(long long l, long long r) {
   string s = tobinary(l), t = tobinary(r), ret = s;
   while (1) {
     if (_greater(s, t)) break;
     ret = s;
     int sz = s.size();
     bool ok = false;
     for (int i = sz - 1; i >= 0; i--)
       if (s[i] == '0') {
         s[i] = '1';
         ok = true;
         break;
       }
     if (!ok) {
       s = '1' + s;
       int n = s.size(), m = t.size();
       if (n > m) break;
     }
   }
   return todecimal(ret);
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   while (n--) {
     long long l, r;
     cin >> l >> r;
     cout << eval(l, r) << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 vector<pair<int, int> > points;
 pair<int, int> dif(pair<int, int> pa, pair<int, int> pb) {
   pair<int, int> res;
   res.first = pb.first - pa.first;
   res.second = pb.second - pa.second;
   return res;
 }
 int dot(pair<int, int> a, pair<int, int> b) {
   return a.first * b.first + a.second * b.second;
 }
 double dist(pair<int, int> a, pair<int, int> b) {
   return ((double)((a.first - b.first) * (a.first - b.first) +
                    (a.second - b.second) * (a.second - b.second)));
 }
 double len(pair<int, int> a) { return dist(a, make_pair(0, 0)); }
 int main() {
   for (int i = 0; i < 8; i++) {
     int x, y;
     cin >> x >> y;
     points.push_back(make_pair(x, y));
   }
   vector<int> perm;
   for (int i = 0; i < 8; i++) perm.push_back(i);
   int cnt = 0;
   bool found = false;
   do {
     cnt++;
     bool fs = false, ss = false;
     bool fis = true, sif = true;
     pair<int, int> a = points[perm[0]];
     pair<int, int> b = points[perm[1]];
     pair<int, int> c = points[perm[2]];
     pair<int, int> d = points[perm[3]];
     pair<int, int> e = points[perm[4]];
     pair<int, int> f = points[perm[5]];
     pair<int, int> g = points[perm[6]];
     pair<int, int> h = points[perm[7]];
     pair<int, int> ab = dif(a, b);
     pair<int, int> bc = dif(b, c);
     pair<int, int> cd = dif(c, d);
     pair<int, int> da = dif(d, a);
     fs = (dot(ab, bc) == 0 && dot(bc, cd) == 0 && dot(cd, da) == 0 &&
           dot(da, ab) == 0 && fabs(len(ab) - len(bc)) < 0.01 &&
           fabs(len(bc) - len(cd)) < 0.01 && fabs(len(cd) - len(da)) < 0.01);
     pair<int, int> ef = dif(e, f);
     pair<int, int> fg = dif(f, g);
     pair<int, int> gh = dif(g, h);
     pair<int, int> he = dif(h, e);
     ss = (dot(ef, fg) == 0 && dot(fg, gh) == 0 && dot(gh, he) == 0 &&
           dot(he, ef) == 0 && fabs(len(ef) - len(gh)) < 0.01 &&
           fabs(len(fg) - len(he)) < 0.01);
     if (ss && fs) {
       found = true;
       break;
     }
   } while (next_permutation(perm.begin(), perm.end()));
   if (found) {
     cout <<  YES  << endl;
     for (int i = 0; i < 4; i++) {
       if (i != 0) cout <<    ;
       cout << perm[i] + 1;
     }
     cout << endl;
     for (int i = 4; i < 8; i++) {
       if (i != 4) cout <<    ;
       cout << perm[i] + 1;
     }
     cout << endl;
   } else
     cout <<  NO  << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int mod = 1e9 + 7;
 int n;
 char s[5001];
 int dp[5001][5001];
 int main() {
   scanf( %d , &n);
   for (int i = 1; i <= n; ++i) {
     scanf(
%c , &s[i]);
   }
   dp[1][0] = 1;
   for (int j = 1; j <= n; ++j) {
     dp[1][j] = 0;
   }
   for (int i = 2; i <= n; ++i) {
     if (s[i - 1] == 'f') {
       for (int j = 1; j <= n; ++j) {
         dp[i][j] = dp[i - 1][j - 1];
       }
     } else {
       int x = 0;
       for (int j = n; j >= 0; --j) {
         x += dp[i - 1][j];
         if (x >= mod) {
           x -= mod;
         }
         dp[i][j] = x;
       }
     }
   }
   int res = 0;
   for (int i = 0; i <= n; ++i) {
     res += dp[n][i];
     if (res >= mod) {
       res -= mod;
     }
   }
   cout << res <<
 ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 using lli = long long;
 using Double = long double;
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   string s[9][3];
   for (int i = 0; i < 9; ++i) {
     for (int j = 0; j < 3; ++j) {
       cin >> s[i][j];
     }
   }
   int x, y, cnt = 0;
   cin >> x >> y, --x, --y;
   for (auto c : s[x % 3 * 3][y % 3]) cnt += c == '.';
   for (auto c : s[x % 3 * 3 + 1][y % 3]) cnt += c == '.';
   for (auto c : s[x % 3 * 3 + 2][y % 3]) cnt += c == '.';
   if (cnt == 0) {
     for (int i = 0; i < 9; ++i) {
       for (int j = 0; j < 3; ++j) {
         for (auto c : s[i][j]) {
           cout << (c == '.' ? '!' : c);
         }
         cout <<
 [j == 2];
       }
       if (i % 3 == 2) cout <<
 ;
     }
   } else {
     for (int i = 0; i < 9; ++i) {
       for (int j = 0; j < 3; ++j) {
         for (auto c : s[i][j]) {
           cout << (c == '.' and i / 3 == x % 3 and j == y % 3 ? '!' : c);
         }
         cout <<
 [j == 2];
       }
       if (i % 3 == 2) cout <<
 ;
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxm = 2e5 + 10;
 set<int> g;
 queue<set<int> > q;
 int m, n, x, y;
 int dfs(int top) {
   if (abs(top) <= 1) return 0;
   int now = 0;
   if ((-top) % 2 == 0)
     now = top / 2;
   else
     now = (top + 1) / 2;
   if (g.find(now) == g.end()) {
     g.erase(top);
     g.insert(now);
     return 1;
   } else
     return dfs(now);
 }
 int main() {
   cin >> m;
   for (int i = 1; i <= m; i++) {
     cin >> x;
     g.insert(-x);
   }
   for (;;) {
     int top = *g.begin();
     if (!dfs(top)) break;
   }
   for (auto e : g) cout << -e <<    ;
   cout << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 vector<int> v;
 int qtd[100001];
 int main() {
   int n;
   scanf( %d , &n);
   for (int i = 0; i < n; i++) {
     int a;
     scanf( %d , &a);
     v.push_back(a);
   }
   sort(v.begin(), v.end());
   int cont = 0;
   for (int i = 1, tmp = 0; i < n; i++) {
     if (v[i] > v[i - 1]) {
       cont += i - tmp;
       tmp = i;
     }
     qtd[i] = cont;
   }
   int ans = 0;
   int used = 0;
   for (int i = 0; i < n; i++) {
     if (qtd[i] > used) {
       used++;
       ans++;
     }
   }
   printf( %d
 , ans);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 struct W {
   int t, l, r;
 } w[100010];
 int n, m, s, f;
 int main() {
   while (cin >> n >> m >> s >> f) {
     for (int i = (0); i < (m); i++) {
       cin >> w[i].t >> w[i].l >> w[i].r;
     }
     int t = 1, p = 0;
     int dir = f > s ? 1 : -1;
     while (s != f) {
       if (p < m && w[p].t == t &&
           ((w[p].l <= s && s <= w[p].r) ||
            (w[p].l <= s + dir && s + dir <= w[p].r))) {
         cout <<  X ;
       } else {
         s += dir;
         cout << (dir == 1 ? 'R' : 'L');
       }
       if (++t > w[p].t) p++;
     }
     cout << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1e6 + 100;
 int t, cnt[N];
 int mx;
 int check(int row, int col, int n, int m) {
   if (row < 0 || row >= n || col < 0 || col >= m) return 0;
   int i = 0, j = 0, ok = 1;
   for (; i < n; i++) {
     for (j = 0; j < m; j++) {
       if (!cnt[abs(row - i) + abs(col - j)]--) {
         ok = 0;
         break;
       }
     }
     if (!ok) break;
   }
   if (ok) {
     cout << n <<     << m << endl;
     cout << row + 1 <<     << col + 1 << endl;
     return 1;
   }
   for (int a = 0; a <= i; a++)
     for (int b = 0; b < m && (a != i || b <= j); b++)
       ++cnt[abs(row - a) + abs(col - b)];
   return 0;
 }
 bool solve(int row, int n, int m, int mxi, int mxj) {
   if (check(row, mxj - (mx - abs(row - mxi)), n, m)) return 1;
   return check(row, mxj + (mx - abs(row - mxi)), n, m);
 }
 int main() {
   scanf( %d , &t);
   for (int i = 0; i < t; ++i) {
     int v;
     scanf( %d , &v);
     ++cnt[v];
     mx = max(mx, v);
   }
   if (cnt[0] != 1) return puts( -1 );
   int a;
   if (cnt[1] != 4)
     a = 0;
   else {
     a = 1;
     while (cnt[a + 1] == (a + 1) * 4) a++;
   }
   for (int n = 1; n * n <= t; n++) {
     if (t % n) continue;
     int m = t / n;
     if (solve(a, n, m, 0, 0)) return 0;
     if (solve(a, n, m, 0, m - 1)) return 0;
     if (solve(a, n, m, n - 1, 0)) return 0;
     if (solve(a, n, m, n - 1, m - 1)) return 0;
     if (solve(a, m, n, 0, 0)) return 0;
     if (solve(a, m, n, 0, n - 1)) return 0;
     if (solve(a, m, n, m - 1, 0)) return 0;
     if (solve(a, m, n, m - 1, n - 1)) return 0;
   }
   return puts( -1 );
 }


#include <bits/stdc++.h>
 int main() {
   int i, j;
   int str[6];
   int num[6];
   char ch;
   for (i = 0; i < 6; i++) {
     str[i] = 0;
     num[i] = 0;
   }
   for (i = 0; i < 6; i++) {
     scanf( %c , &ch);
     switch (ch) {
       case 'R':
         str[0]++;
         break;
       case 'O':
         str[1]++;
         break;
       case 'Y':
         str[2]++;
         break;
       case 'G':
         str[3]++;
         break;
       case 'B':
         str[4]++;
         break;
       case 'V':
         str[5]++;
         break;
     }
   }
   for (j = 0; j < 6; j++) {
     num[str[j]]++;
   }
   switch (num[0]) {
     case 0:
       printf( 30
 );
       break;
     case 1:
       printf( 15
 );
       break;
     case 2:
       switch (num[1]) {
         case 2:
           printf( 8
 );
           break;
         case 3:
           printf( 5
 );
           break;
       }
       break;
     case 3:
       switch (num[1]) {
         case 2:
           printf( 2
 );
           break;
         case 1:
           printf( 3
 );
           break;
         case 0:
           printf( 6
 );
           break;
       }
       break;
     case 4:
       switch (num[1]) {
         case 1:
           printf( 1
 );
           break;
         case 0:
           printf( 2
 );
           break;
       }
       break;
     case 5:
       printf( 1
 );
       break;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int Head[1000010], Next[1000010], Go[1000010], Val[1000010], iscut[1000010],
     Len[1000010], Dep[1000010], Fa[400010][21], Cnt = 1, n, m, q;
 int Head2[1000010], Next2[1000010], Go2[1000010], Val2[1000010], Cnt2 = 1;
 int DFN[1000010], MIN[1000010], ins[1000010], Bel[1000010], vis[1000010],
     tim = 0, tt = 0;
 vector<int> S;
 void addedge(int x, int y) {
   Go[++Cnt] = y;
   Next[Cnt] = Head[x];
   Head[x] = Cnt;
 }
 void addedge2(int x, int y, int v) {
   Go2[++Cnt2] = y;
   Next2[Cnt2] = Head2[x];
   Head2[x] = Cnt2;
   Val2[Cnt2] = v;
 }
 void Tarjan(int x, int f = 0) {
   ins[x] = 1;
   S.push_back(x);
   DFN[x] = ++tim;
   MIN[x] = DFN[x];
   int las = x;
   for (int T = Head[x]; T; T = Next[T])
     if (Go[T] != f) {
       if (!DFN[Go[T]]) {
         Tarjan(Go[T], x);
         MIN[x] = min(MIN[x], MIN[Go[T]]);
         if (DFN[x] <= MIN[Go[T]]) {
           tt++;
           for (;;) {
             if (S.back() == las) break;
             addedge2(tt + n + 1, S.back(), 1);
             addedge2(S.back(), tt + n + 1, 1);
             S.pop_back();
           }
           addedge2(x, tt + n + 1, 1);
           addedge2(tt + n + 1, x, 1);
         } else
           las = S.back();
       } else if (ins[Go[T]])
         MIN[x] = min(MIN[x], DFN[Go[T]]);
     }
   ins[x] = 0;
 }
 void DFS2(int x, int dep = 1, int len = 0) {
   vis[x] = 1;
   Len[x] = len;
   Dep[x] = dep;
   for (int T = Head[x]; T; T = Next[T])
     if (!vis[Go[T]]) {
       Fa[Go[T]][0] = x;
       DFS2(Go[T], dep + 1, len + Val[T]);
     }
 }
 int lca(int x, int y) {
   if (Dep[x] < Dep[y]) swap(x, y);
   int det = Dep[x] - Dep[y];
   for (int i = 18; i >= 0; i--)
     if ((det >> i) & 1) x = Fa[x][i];
   if (x == y) return x;
   for (int i = 18; i >= 0; i--)
     if (Fa[x][i] != Fa[y][i]) x = Fa[x][i], y = Fa[y][i];
   return Fa[x][0];
 }
 int main() {
   scanf( %d%d%d , &n, &m, &q);
   for (int i = 1; i <= m; i++) {
     int a, b;
     scanf( %d%d , &a, &b);
     addedge(a, b);
     addedge(b, a);
   }
   for (int i = 1; i <= n; i++)
     if (!DFN[i]) Tarjan(i);
   memcpy(Head, Head2, sizeof Head);
   memcpy(Next, Next2, sizeof Next);
   memcpy(Go, Go2, sizeof Go);
   memcpy(Val, Val2, sizeof Val);
   for (int i = 1; i <= n + tt + 1; i++)
     if (!vis[i]) DFS2(i);
   for (int i = 1; i <= 20; i++)
     for (int j = 1; j <= n + tt + 1; j++) Fa[j][i] = Fa[Fa[j][i - 1]][i - 1];
   for (int i = 1; i <= q; i++) {
     int a, b;
     scanf( %d%d , &a, &b);
     printf( %d
 , (Len[a] + Len[b] - 2 * Len[lca(a, b)]) / 2);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline int read() {
   char ch = getchar();
   int x = 0, f = 1;
   while (ch < '0' || ch > '9') {
     if (ch == '-') f = -1;
     ch = getchar();
   }
   while (ch >= '0' && ch <= '9') {
     x = (x << 1) + (x << 3) - '0' + ch;
     ch = getchar();
   }
   return x * f;
 }
 int main() {
   priority_queue<int> q;
   int n = read(), T = read();
   int ans = 0;
   for (int i = 1; i <= n; i++) {
     int x = read();
     x = max(x, i);
     while (!q.empty() && q.top() >= T - i) {
       q.pop();
     }
     if (x < T) q.push(x - i);
     ans = max(ans, (int)q.size());
   }
   printf( %d
 , ans);
 }


#include <bits/stdc++.h>
 using namespace std;
 int a[1005];
 int b[1005];
 int h;
 bool cmp(int x, int y) { return x > y; }
 bool check(int x) {
   for (int i = 1; i <= x; i++) {
     b[i] = a[i];
   }
   sort(b + 1, b + x + 1, cmp);
   long long sum = 0;
   for (int i = 1; i <= x; i += 2) {
     sum += (long long)(b[i]);
   }
   if (sum <= h) {
     return 1;
   } else {
     return 0;
   }
 }
 int main() {
   int n;
   cin >> n >> h;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
   }
   int l = 1, r = n, mid;
   while (l < r) {
     mid = (l + r + 1) / 2;
     if (check(mid)) {
       l = mid;
     } else {
       r = mid - 1;
     }
   }
   cout << l;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline int in() {
   int x;
   scanf( %d , &x);
   return x;
 }
 template <typename T>
 inline istream& operator>>(istream& i, vector<T>& v) {
   for (int j = 0; j < ((int)(v).size()); ++j) i >> v[j];
   return i;
 }
 template <typename T>
 string join(const vector<T>& v) {
   stringstream s;
   for (int i = 0; i < ((int)(v).size()); ++i) s << ' ' << v[i];
   return s.str().substr(1);
 }
 template <typename T>
 inline ostream& operator<<(ostream& o, const vector<T>& v) {
   if ((int)(v).size()) o << join(v);
   return o;
 }
 template <typename T1, typename T2>
 inline istream& operator>>(istream& i, pair<T1, T2>& v) {
   return i >> v.first >> v.second;
 }
 template <typename T1, typename T2>
 inline ostream& operator<<(ostream& o, const pair<T1, T2>& v) {
   return o << v.first <<  ,  << v.second;
 }
 template <typename T>
 inline long long int suma(const vector<T>& a) {
   long long int res(0);
   for (auto&& x : a) res += x;
   return res;
 }
 const double eps = 1e-10;
 const long long int LINF = 1001002003004005006ll;
 const int INF = 1001001001;
 const int MX = 200005;
 int n, m;
 int dp[55][55][55];
 struct Q {
   int l, r, x, c;
   int cost(int i, int h) {
     if (l <= i && i < r && h > x) return c;
     return 0;
   }
 };
 vector<Q> q;
 int dfs(int l, int r, int h) {
   if (l == r) return 0;
   int& now = dp[l][r][h];
   if (now != -1) return now;
   now = 0;
   if (h) now = dfs(l, r, h - 1);
   for (int i = l; i < r; ++i) {
     int c = h * h;
     for (int k = 0; k < (m); ++k) {
       if (l <= q[k].l && q[k].r <= r) c -= q[k].cost(i, h);
     }
     c += dfs(l, i, h) + dfs(i + 1, r, h);
     (now = max(now, c));
   }
   return now;
 }
 int main() {
   int h;
   cin >> n >> h >> m;
   q = vector<Q>(m);
   for (int i = 0; i < (m); ++i) {
     int l, r, x, c;
     scanf( %d%d%d%d , &l, &r, &x, &c);
     --l;
     q[i] = (Q){l, r, x, c};
   }
   for (int i = 0; i < (n); ++i)
     for (int j = 0; j < (n + 1); ++j)
       for (int k = 0; k < (h + 1); ++k) dp[i][j][k] = -1;
   int ans = dfs(0, n, h);
   cout << ans << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 struct node {
   int x, y;
 } p[8];
 int cmp(node a, node b) {
   if (a.x == b.x) return (a.y < b.y);
   return a.x < b.x;
 }
 int main() {
   while (scanf( %d %d , &p[0].x, &p[0].y) != EOF) {
     int cnt1 = 0;
     int cnt2 = 0;
     int cnt3 = 0;
     int cnt4 = 0;
     for (int i = 1; i < 8; i++) {
       scanf( %d %d , &p[i].x, &p[i].y);
     }
     sort(p, p + 8, cmp);
     node zuoshang = p[0];
     node youxia = p[7];
     for (int i = 1; i < 7; i++) {
       if (p[i].x == zuoshang.x) cnt1++;
       if (p[i].y == zuoshang.y) cnt2++;
       if (p[i].x == youxia.x) cnt3++;
       if (p[i].y == youxia.y) cnt4++;
     }
     if (cnt1 == 2 && cnt2 == 2 && cnt3 == 2 && cnt4 == 2 && p[1].y == p[6].y &&
         p[4].x == p[3].x)
       puts( respectable );
     else
       puts( ugly );
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   for (int i = 0; i < n; i++) {
     double x, y, z, a, b, c, sq;
     cin >> x;
     a = 1.0, b = x, c = x;
     z = (b * b) - (4 * a * c);
     if (z < 0) {
       cout <<  N  << endl;
       continue;
     }
     y = ((-b + (sqrt((b * b) - (4 * a * c)))) / 2 * a);
     if (y != 0) y = -1 * y;
     cout << fixed << setprecision(9) <<  Y   << (x - y) <<     << y << endl;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 2e3 + 789;
 const int M = 2e5 + 5;
 const int NN = 1e5 + 55;
 const long long mod = 1e9 + 7;
 const long long inf = 0x3f3f3f3f;
 const long long INF = 1LL << 62;
 bitset<2000> P[N], S[N], T;
 char ms[N][N];
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   int n, m;
   cin >> n >> m;
   P[0].reset();
   for (int i = 0; i < n; i++) {
     cin >> ms[i];
     if (i) P[i] = P[i - 1];
     for (int j = 0; j < m; j++) {
       if (ms[i][j] == '1') P[i][j] = 1;
     }
   }
   for (int i = n - 1; i >= 0; i--) {
     if (i != n - 1) S[i] = S[i + 1];
     for (int j = 0; j < m; j++) {
       if (ms[i][j] == '1') S[i][j] = 1;
     }
   }
   bool f = 0;
   for (int i = 0; i < n; i++) {
     T.reset();
     if (i - 1 >= 0) T |= P[i - 1];
     if (i + 1 < n) T |= S[i + 1];
     if (T.count() == m) f = 1;
   }
   if (f)
     cout <<  YES  << endl;
   else
     cout <<  NO  << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline void Boost() {
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
 }
 const int NMax = 1e6 + 50;
 string convert(const string &s) {
   string ret =  @ ;
   for (int i = 0; i < (int)s.size(); ++i) {
     ret +=  #  + s.substr(i, 1);
   }
   ret +=  #$ ;
   return ret;
 }
 int P[NMax * 2];
 void Solve() {
   string s;
   cin >> s;
   int n = (int)s.size();
   int a = 0;
   int b = n - 1;
   while (a <= b) {
     if (a == b) {
       cout << s <<
 ;
       return;
     }
     if (s[a] == s[b]) {
       ++a;
       --b;
       if (a > b) {
         cout << s <<
 ;
         return;
       }
     } else {
       string nw = convert(s);
       int cen = 0, r = 0;
       for (int i = 0; i < (int)nw.size(); ++i) P[i] = 0;
       for (int i = 1; i < (int)nw.size() - 1; ++i) {
         int mir = cen - (i - cen);
         if (r > i) {
           P[i] = min(r - i, P[mir]);
         }
         while (nw[i + 1 + P[i]] == nw[i - 1 - P[i]]) {
           P[i]++;
         }
         if (i + P[i] > r) {
           cen = i;
           r = i + P[i];
         }
       }
       int best = 0;
       int pos = 0;
       for (int i = 1; i < (int)nw.size() - 1; i++) {
         int start = (i - 1 - P[i]) / 2;
         int fin = start + P[i] - 1;
         if (start < a) {
           int mv = a - start;
           start += mv;
           fin -= mv;
         }
         if (fin > b) {
           int mv = fin - b;
           start += mv;
           fin -= mv;
         }
         if (start != a && fin != b) continue;
         if (start <= fin && (fin - start + 1) > best) {
           best = fin - start + 1;
           pos = start;
         }
       }
       for (int i = 0; i < a; ++i) cout << s[i];
       for (int i = pos; i < pos + best; ++i) cout << s[i];
       for (int i = a - 1; i >= 0; --i) cout << s[i];
       cout <<
 ;
       return;
     }
   }
 }
 int main() {
   Boost();
   int t;
   cin >> t;
   while (t--) {
     Solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 bool is_prefix(string s, string comp) {
   bool res = false;
   int sz = s.size();
   int comp_sz = comp.size();
   if (sz > comp_sz)
     return res;
   else {
     res = true;
     for (int i = 0; i < sz; i++) {
       if (s[i] != comp[i]) {
         res = false;
         break;
       }
     }
   }
   return res;
 }
 int main(int argc, char* argv[]) {
   int n;
   string s;
   vector<string> res;
   cin >> s;
   cin >> n;
   for (int i = 0; i < n; i++) {
     string t;
     cin >> t;
     if (is_prefix(s, t)) res.push_back(t);
   }
   if (res.size() == 0) {
     cout << s;
   } else {
     sort(res.begin(), res.end());
     cout << res[0];
   }
   return 0;
 }


#include <bits/stdc++.h>
 const int maxn = 100001;
 int n, val[maxn], cL[maxn], cR[maxn], ord[maxn], tot, in[maxn], out[maxn],
     bit[maxn], ans;
 bool vis[maxn];
 void dfs(int u) {
   if (u == -1) return;
   in[u] = ++tot;
   dfs(cL[u]);
   dfs(cR[u]);
   out[u] = tot;
 }
 void bit_add(int x, int v) {
   for (; x <= n; x += x & -x) bit[x] += v;
 }
 int bit_sum(int x) {
   int ret = 0;
   for (; x > 0; x -= x & -x) ret += bit[x];
   return ret;
 }
 bool cmp(int const &x, int const &y) { return val[x] < val[y]; }
 int main() {
   scanf( %d , &n);
   for (int i = 1; i <= n; ++i) {
     scanf( %d%d%d , val + i, cL + i, cR + i);
     if (cL[i] != -1) vis[cL[i]] = 1;
     if (cR[i] != -1) vis[cR[i]] = 1;
     ord[i] = i;
   }
   std::sort(ord + 1, ord + n + 1, cmp);
   for (int i = 1; i <= n; ++i)
     if (!vis[i]) dfs(i);
   for (int i = 1; i <= n; ++i)
     if (cR[i] != -1) {
       bit_add(in[cR[i]], 1);
       bit_add(out[cR[i]] + 1, -1);
     }
   for (int i = 1, j = 1; i <= n;) {
     for (; j <= n && val[ord[j]] <= val[ord[i]]; ++j) {
       int u = ord[j];
       if (cL[u] != -1) {
         bit_add(in[cL[u]], 1);
         bit_add(out[cL[u]] + 1, -1);
       }
       if (cR[u] != -1) {
         bit_add(in[cR[u]], -1);
         bit_add(out[cR[u]] + 1, 1);
       }
     }
     int cnt = 0, flg = 0;
     for (int v = val[ord[i]]; i <= n && val[ord[i]] == v; ++i, ++cnt)
       flg |= !bit_sum(in[ord[i]]);
     if (!flg) ans += cnt;
   }
   printf( %d
 , ans);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 210;
 int n, m, x;
 long long dp[maxn][maxn], v[maxn], ans = -1;
 void read_and_parse() {
   scanf( %d%d%d , &n, &m, &x);
   for (int i = 1; i <= n; i++) scanf( %d , &v[i]);
 }
 void solve() {
   memset(dp, 0xcf, sizeof(dp));
   dp[0][0] = 0;
   for (int i = 1; i <= n; i++)
     for (int j = 1; j <= x; j++)
       for (int k = max(0, i - m); k < i; k++)
         dp[i][j] = max(dp[i][j], dp[k][j - 1] + v[i]);
   for (int i = n - m + 1; i <= n; i++) ans = max(ans, dp[i][x]);
   printf( %lld
 , ans);
 }
 int main() {
   read_and_parse();
   solve();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class L, class R>
 ostream &operator<<(ostream &os, map<L, R> P) {
   for (auto const &vv : P) os <<  (  << vv.first <<  ,  << vv.second <<  ) ;
   return os;
 }
 template <class T>
 ostream &operator<<(ostream &os, set<T> V) {
   os <<  [ ;
   for (auto const &vv : V) os << vv <<  , ;
   os <<  ] ;
   return os;
 }
 template <class T>
 ostream &operator<<(ostream &os, vector<T> V) {
   os <<  [ ;
   for (auto const &vv : V) os << vv <<  , ;
   os <<  ] ;
   return os;
 }
 template <class L, class R>
 ostream &operator<<(ostream &os, pair<L, R> P) {
   os <<  (  << P.first <<  ,  << P.second <<  ) ;
   return os;
 }
 inline int fstoi(const string &str) {
   auto it = str.begin();
   bool neg = 0;
   int num = 0;
   if (*it == '-')
     neg = 1;
   else
     num = *it - '0';
   ++it;
   while (it < str.end()) num = num * 10 + (*it++ - '0');
   if (neg) num *= -1;
   return num;
 }
 inline void getch(char &x) {
   while (x = getchar_unlocked(), x < 33) {
     ;
   }
 }
 inline void getstr(string &str) {
   str.clear();
   char cur;
   while (cur = getchar_unlocked(), cur < 33) {
     ;
   }
   while (cur > 32) {
     str += cur;
     cur = getchar_unlocked();
   }
 }
 template <typename T>
 inline bool sc(T &num) {
   bool neg = 0;
   int c;
   num = 0;
   while (c = getchar_unlocked(), c < 33) {
     if (c == EOF) return false;
   }
   if (c == '-') {
     neg = 1;
     c = getchar_unlocked();
   }
   for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48;
   if (neg) num *= -1;
   return true;
 }
 template <typename T, typename... Args>
 inline void sc(T &num, Args &...args) {
   bool neg = 0;
   int c;
   num = 0;
   while (c = getchar_unlocked(), c < 33) {
     ;
   }
   if (c == '-') {
     neg = 1;
     c = getchar_unlocked();
   }
   for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48;
   if (neg) num *= -1;
   sc(args...);
 }
 int getsum(int a, int b) {
   int oor, oand;
   cout <<  and   << a << ' ' << b << endl;
   cin >> oand;
   cout <<  or   << a << ' ' << b << endl;
   cin >> oor;
   return oor + oand;
 }
 int main() {
   int n, k;
   cin >> n >> k;
   int cr;
   int x, y, z;
   x = getsum(1, 2);
   y = getsum(1, 3);
   z = getsum(2, 3);
   int a[n + 1];
   a[3] = (y + z - x) / 2;
   a[2] = (-y + z + x) / 2;
   a[1] = (y - z + x) / 2;
   for (auto i = (4); i <= (n); ++i) {
     int wh = getsum(1, i);
     a[i] = wh - a[1];
   }
   sort(a + 1, a + n + 1);
   cout <<  finish   << a[k] << endl;
   cout << a[k] << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int INF = 0x3f3f3f3f;
 const long long LINF = 0x3f3f3f3f3f3f3f3fll;
 const long double pi = acos(-1);
 const int MOD = 1e9 + 7;
 const int N = 2e5 + 100;
 int tr_min[4 * N][1 << 5];
 int tr_max[4 * N][1 << 5];
 vector<int> cara[N];
 int n, k;
 void build(int node, int b, int e) {
   if (b == e) {
     for (int cord = 0; cord < (1 << k); cord++) {
       long long x = 0;
       for (int i = 0; i < k; i++) {
         if (cord & (1 << i))
           x += cara[b][i];
         else
           x -= cara[b][i];
       }
       tr_max[node][cord] = tr_min[node][cord] = x;
     }
   } else {
     int mid = (b + e) / 2;
     build(2 * node, b, mid);
     build(2 * node + 1, mid + 1, e);
     for (int i = 0; i < (1 << k); i++) {
       tr_max[node][i] = max(tr_max[2 * node][i], tr_max[2 * node + 1][i]);
       tr_min[node][i] = min(tr_min[2 * node][i], tr_min[2 * node + 1][i]);
     }
   }
 }
 void update(int node, int b, int e, int i, vector<int> &cara) {
   if (e < i or b > i) return;
   if (b == e and b == i) {
     for (int cord = 0; cord < (1 << k); cord++) {
       long long x = 0;
       for (int i = 0; i < k; i++) {
         if (cord & (1 << i))
           x += cara[i];
         else
           x -= cara[i];
       }
       tr_max[node][cord] = tr_min[node][cord] = x;
     }
     return;
   }
   int mid = (b + e) / 2;
   update(2 * node, b, mid, i, cara);
   update(2 * node + 1, mid + 1, e, i, cara);
   for (int i = 0; i < (1 << k); i++) {
     tr_max[node][i] = max(tr_max[2 * node][i], tr_max[2 * node + 1][i]);
     tr_min[node][i] = min(tr_min[2 * node][i], tr_min[2 * node + 1][i]);
   }
 }
 int query(int node, int b, int e, int i, int j, int cord) {
   if (e < i or b > j) return -INF;
   if (i <= b and j >= e) {
     return tr_max[node][cord];
   }
   int mid = (b + e) / 2;
   return max(query(2 * node, b, mid, i, j, cord),
              query(2 * node + 1, mid + 1, e, i, j, cord));
 }
 int query2(int node, int b, int e, int i, int j, int cord) {
   if (e < i or b > j) return INF;
   if (i <= b and j >= e) {
     return tr_min[node][cord];
   }
   int mid = (b + e) / 2;
   return min(query2(2 * node, b, mid, i, j, cord),
              query2(2 * node + 1, mid + 1, e, i, j, cord));
 }
 int proc(int cord, int l, int r) {
   int maxi = query(1, 1, n, l, r, cord);
   int mini = query2(1, 1, n, l, r, cord);
   return abs(mini - maxi);
 }
 int main() {
   scanf( %d %d , &n, &k);
   for (int i = 1; i <= n; i++) {
     for (int j = 0; j < k; j++) {
       int x;
       scanf( %d , &x);
       cara[i].push_back(x);
     }
   }
   int q;
   build(1, 1, n);
   scanf( %d , &q);
   while (q--) {
     int op;
     scanf( %d , &op);
     if (op == 1) {
       int idx;
       scanf( %d , &idx);
       vector<int> val;
       for (int j = 0; j < k; j++) {
         int x;
         scanf( %d , &x);
         val.push_back(x);
       }
       update(1, 1, n, idx, val);
     } else {
       int l, r;
       scanf( %d %d , &l, &r);
       int resp = 0;
       for (int i = 0; i < (1 << k); i++) resp = max(proc(i, l, r), resp);
       printf( %d
 , resp);
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAXN = 100010;
 bool operator<(pair<int, int> lhs, pair<int, int> rhs) {
   return (lhs.first != rhs.first) ? (lhs.first < rhs.first)
                                   : (lhs.second < rhs.second);
 }
 set<pair<int, int> > inqUp, inqDown, pendUp, pendDown;
 int N, M, prsis, rci;
 long long T, Ans[MAXN];
 struct User {
   int id, ar, f, t;
 };
 bool cmp_Useraraz(User lhs, User rhs) { return lhs.ar < rhs.ar; }
 User u[MAXN], ru[MAXN];
 int Where;
 void Unload() {
   while ((inqUp.size()) && (inqUp.begin()->first == Where)) {
     Ans[inqUp.begin()->second] = T;
     inqUp.erase(inqUp.begin());
     rci++;
   }
   while (((inqDown.size()) && (--inqDown.end())->first == Where)) {
     Ans[(--inqDown.end())->second] = T;
     inqDown.erase(--inqDown.end());
     rci++;
   }
 }
 void Request() {
   while ((prsis != N) && (u[prsis + 1].ar == T)) {
     prsis++;
     if (u[prsis].f >= Where)
       pendUp.insert(make_pair(u[prsis].f, u[prsis].id));
     else
       pendDown.insert(make_pair(u[prsis].f, u[prsis].id));
   }
 }
 void Load(int id) {
   if (ru[id].t >= Where)
     inqUp.insert(make_pair(ru[id].t, id));
   else
     inqDown.insert(make_pair(ru[id].t, id));
 }
 void Load() {
   while ((pendUp.size()) && (pendUp.begin()->first == Where)) {
     Load(pendUp.begin()->second);
     pendUp.erase(pendUp.begin());
   }
   while ((pendDown.size()) && ((--pendDown.end())->first == Where)) {
     Load((--pendDown.end())->second);
     pendDown.erase(--pendDown.end());
   }
 }
 int main() {
   scanf( %d%d , &N, &M);
   int i;
   for (i = 1; i <= N; i++) {
     scanf( %d%d%d , &u[i].ar, &u[i].f, &u[i].t);
     u[i].id = i;
     ru[i] = u[i];
   }
   sort(u + 1, u + N + 1, cmp_Useraraz);
   inqUp.clear();
   inqDown.clear();
   pendUp.clear();
   pendDown.clear();
   Where = 1;
   T = 0;
   prsis = rci = 0;
   while (rci < N) {
     Unload();
     Request();
     Load();
     int pUp = inqUp.size() + pendUp.size();
     int pDown = inqDown.size() + pendDown.size();
     int Action = (pUp + pDown) ? ((pUp >= pDown) ? 1 : -1) : 0;
     int timePass = (prsis == N) ? M : (u[prsis + 1].ar - T);
     if (Action == 1) {
       if (pendUp.size())
         timePass = min(timePass, pendUp.begin()->first - Where);
       if (inqUp.size()) timePass = min(timePass, inqUp.begin()->first - Where);
     }
     if (Action == -1) {
       if (pendDown.size())
         timePass = min(timePass, Where - (--pendDown.end())->first);
       if (inqDown.size())
         timePass = min(timePass, Where - (--inqDown.end())->first);
     }
     T += timePass;
     Where += timePass * Action;
   }
   for (i = 1; i <= N; i++) printf( extra
 , Ans[i]);
 }


#include <bits/stdc++.h>
 using namespace std;
 map<char, char> mp;
 string check(string s) {
   for (int i = 0; i <= s.size() / 2; i++)
     if (s[i] != mp[s[s.size() - 1 - i]]) return  NIE ;
   return  TAK ;
 }
 int main() {
   mp['A'] = 'A';
   mp['b'] = 'd';
   mp['d'] = 'b';
   mp['H'] = 'H';
   mp['I'] = 'I';
   mp['M'] = 'M';
   mp['O'] = 'O';
   mp['o'] = 'o';
   mp['p'] = 'q';
   mp['q'] = 'p';
   mp['T'] = 'T';
   mp['U'] = 'U';
   mp['V'] = 'V';
   mp['v'] = 'v';
   mp['W'] = 'W';
   mp['w'] = 'w';
   mp['X'] = 'X';
   mp['x'] = 'x';
   mp['Y'] = 'Y';
   string s;
   cin >> s;
   cout << check(s) << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 200000;
 const long long mod = 1e9 + 7;
 long long fac[maxn + 5], inv[maxn + 5];
 long long f[2005];
 struct node {
   long long x, y;
 } data[2005];
 long long qmod(long long a, long long b) {
   long long ans = 1;
   a = a % mod;
   while (b) {
     if (b & 1) {
       ans = (ans * a) % mod;
     }
     b = b / 2;
     a = (a * a) % mod;
   }
   return ans;
 }
 void init() {
   fac[0] = 1;
   for (long long i = 1; i <= maxn; i++) {
     fac[i] = (fac[i - 1] * i) % mod;
   }
 }
 long long com(long long n, long long m) {
   if (n < m)
     return 0;
   else if (n == m)
     return 1;
   else
     return (fac[n] * qmod(fac[m] * fac[n - m], mod - 2)) % mod;
 }
 long long Lucas(long long n, long long m) {
   if (m == 0)
     return 1;
   else
     return (com(n % mod, m % mod) * Lucas(n / mod, m / mod)) % mod;
 }
 bool cmp(node a, node b) {
   if (a.x < b.x)
     return true;
   else if (a.x == b.x) {
     if (a.y < b.y)
       return true;
     else
       return false;
   } else
     return false;
 }
 int main(int argc, char const *argv[]) {
   long long h, w, n;
   init();
   scanf( %lld %lld %lld , &h, &w, &n);
   for (int i = 1; i <= n; i++) {
     scanf( %lld %lld , &data[i].x, &data[i].y);
   }
   sort(data + 1, data + 1 + n, cmp);
   memset(f, 0, sizeof(f));
   n++;
   data[n].x = h;
   data[n].y = w;
   for (int i = 1; i <= n; i++) {
     long long dx, dy;
     dx = data[i].x - 1;
     dy = data[i].y - 1;
     f[i] = Lucas(dx + dy, dx);
     for (int j = 1; j < i; j++) {
       if (data[i].x >= data[j].x && data[i].y >= data[j].y) {
         dx = data[i].x - data[j].x;
         dy = data[i].y - data[j].y;
         f[i] = f[i] - (f[j] * Lucas(dx + dy, dx)) % mod;
         f[i] = (f[i] + mod) % mod;
       }
     }
   }
   cout << (f[n] + mod) % mod << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, x[100], s[100];
 struct par {
   int v, id;
   bool operator<(const par &r) const { return v < r.v; }
 };
 vector<par> v;
 int main() {
   scanf( %d , &n);
   for (int i = 0; i < n; i++) {
     scanf( %d , &x[i]);
     v.push_back({x[i], i});
   }
   sort(v.begin(), v.end());
   vector<par> v1 = v;
   rotate(v1.begin(), v1.begin() + 1, v1.end());
   for (int i = 0; i < (int)v.size(); i++) s[v[i].id] = v1[i].v;
   for (int i = 0; i < n; i++) {
     printf( %d , s[i]);
     i == n - 1 ? printf(
 ) : printf(   );
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int oo = 3e5 + 7;
 unordered_map<int, vector<int>> values[2];
 int t, n, q, a[oo], p[oo];
 vector<int> ans;
 int psum(int l, int r) { return p[r] - (l ? p[l - 1] : 0); }
 int first(vector<int>& list, int val) {
   int l = 0, r = list.size();
   while (l < r) {
     int s = (l + r) / 2;
     if (list[s] >= val)
       r = s;
     else
       l = s + 1;
   }
   if (l == list.size()) return n * 2;
   return list[l];
 }
 void problem(int l, int r) {
   int sum = psum(l, r);
   if (sum == 0) return;
   if (sum % 2 == 0) {
     ans.push_back(r);
     problem(l, r - 1);
     return;
   }
   int pl = p[l] - a[l];
   int vals[2] = {pl + (sum + 1) / 2 - 1, pl + (sum - 1) / 2 + 1};
   for (int i = 0; i < 2; i++) {
     int pans = first(values[i][vals[i]], l);
     if (pans <= r) {
       ans.push_back(pans);
       return;
     }
   }
   throw 69;
 }
 void solve() {
   cin >> n >> q;
   string ss;
   cin >> ss;
   for (int i = 0; i < n; i++)
     a[i] = (ss[i] == '+' ? 1 : -1) * (i % 2 == 0 ? -1 : 1);
   p[0] = a[0];
   for (int i = 1; i < n; i++) p[i] = p[i - 1] + a[i];
   for (int i = 0; i < n; i++) values[(a[i] + 1) / 2][p[i]].push_back(i);
   while (q--) {
     int l, r;
     cin >> l >> r;
     l--, r--;
     problem(l, r);
     cout << ans.size() << endl;
     for (int e : ans) cout << e + 1 <<    ;
     cout << endl;
     ans.clear();
   }
   values[0].clear();
   values[1].clear();
 }
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   cin >> t;
   while (t--) solve();
 }


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


#include <bits/stdc++.h>
 using namespace std;
 long long mx(long long a, long long b) { return a >= b ? a : b; }
 long long mn(long long a, long long b) { return a <= b ? a : b; }
 string a[3] = {( twone ), ( two ), ( one )};
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   long long t, x;
   cin >> t;
   while (t--) {
     string str, str2;
     long long ans = 0;
     vector<long long> v;
     cin >> str;
     if (str.size() <= 2) {
       cout << 0 <<

            <<
 ;
       continue;
     }
     for (long long i = 0; i < str.size() - 2; i++) {
       if (str[i] == 't' and str[i + 1] == 'w' and str[i + 2] == 'o' and
           str[i + 3] == 'n' and str[i + 4] == 'e')
         str[i + 2] = 'l', ans++, v.push_back(i + 3);
       if (str[i] == 't' and str[i + 1] == 'w' and str[i + 2] == 'o')
         ans++, str[i + 1] = 'l', v.push_back(i + 2);
       if (str[i] == 'o' and str[i + 1] == 'n' and str[i + 2] == 'e')
         ans++, str[i + 1] = 'l', v.push_back(i + 2);
     }
     cout << ans <<
 ;
     for (long long i = 0; i < v.size(); i++) cout << v[i] <<    ;
     cout <<
 ;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int a;
   cin >> a;
   int max = 0;
   vector<int> b;
   int x;
   for (int i = 0; i < a; i++) {
     cin >> x;
     b.push_back(x);
   }
   sort(b.begin() + 1, b.end());
   int count = 0;
   if (b[0] > b[b.size() - 1]) {
     cout <<  0 ;
   } else {
     while (1) {
       b[b.size() - 1]--;
       count++;
       b[0] = b[0] + 1;
       sort(b.begin() + 1, b.end());
       if (b[0] > b[b.size() - 1]) {
         cout << count;
         break;
       }
     }
   }
   printf(
 );
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int vet[1010], dp[2][1010];
 const int mod = 998244353;
 long long soma(long long x, long long y) {
   x += y;
   if (x >= mod) x -= mod;
   return x;
 }
 int main() {
   int n;
   cin >> n;
   for (int i = 0; i < n; i++) {
     cin >> vet[i];
   }
   for (int i = 0; i < n; i++) {
     for (int j = 0; j < n; j++) {
       dp[1][j] = dp[0][j];
     }
     if (vet[i] < n and vet[i] > 0) {
       dp[1][vet[i]] = soma(soma(dp[0][0], 1), dp[1][vet[i]]);
     }
     for (int k = 0; k < n; k++) {
       dp[1][k] = soma(dp[1][k], dp[0][k + 1]);
     }
     swap(dp[0], dp[1]);
   }
   cout << dp[0][0] << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class node>
 struct link_cut_tree {
   bool connected(node* u, node* v) { return lca(u, v) != NULL; }
   int depth(node* u) {
     access(u);
     return get_sz(u->ch[0]);
   }
   node* get_root(node* u) {
     access(u);
     while (u->ch[0]) u = u->ch[0], u->push();
     return access(u), u;
   }
   node* ancestor(node* u, int k) {
     k = depth(u) - k;
     for (;; u->push()) {
       int sz = get_sz(u->ch[0]);
       if (sz == k) return access(u), u;
       if (sz < k)
         k -= sz + 1, u = u->ch[1];
       else
         u = u->ch[0];
     }
   }
   node* lca(node* u, node* v) {
     if (u == v) return u;
     access(u);
     access(v);
     if (!u->p) return NULL;
     u->splay();
     return u->p ?: u;
   }
   void link(node* u, node* v) {
     make_root(v);
     access(u);
     set_link(v, u, 0);
     v->update();
   }
   void cut(node* u) {
     access(u);
     u->ch[0]->p = NULL;
     u->ch[0] = NULL;
     u->update();
   }
   void cut(node* u, node* v) { cut(depth(u) > depth(v) ? u : v); }
   void make_root(node* u) {
     access(u);
     u->rev ^= 1;
     access(u);
   }
   void access(node* u) {
     for (node *v = u, *pre = NULL; v; v = v->p) {
       v->splay();
       if (pre) v->update_vsub(pre, false);
       if (v->ch[1]) v->update_vsub(v->ch[1], true);
       v->ch[1] = pre;
       v->update();
       pre = v;
     }
     u->splay();
   }
   node* operator[](int i) { return &data[i]; }
   int operator[](node* i) { return i - &data[0]; }
   vector<node> data;
   link_cut_tree(int n) : data(n) {}
 };
 template <typename pnode>
 struct splay_tree {
   pnode ch[2], p;
   bool rev;
   int sz;
   splay_tree() {
     ch[0] = ch[1] = p = NULL;
     rev = 0;
     sz = 1;
   }
   friend int get_sz(pnode u) { return u ? u->sz : 0; }
   virtual void update() {
     if (ch[0]) ch[0]->push();
     if (ch[1]) ch[1]->push();
     sz = 1 + get_sz(ch[0]) + get_sz(ch[1]);
   }
   virtual void push() {
     if (rev) {
       if (ch[0]) ch[0]->rev ^= 1;
       if (ch[1]) ch[1]->rev ^= 1;
       swap(ch[0], ch[1]);
       rev = 0;
     }
   }
   int dir() {
     if (!p) return -2;
     if (p->ch[0] == this) return 0;
     if (p->ch[1] == this) return 1;
     return -1;
   }
   bool is_root() { return dir() < 0; }
   friend void set_link(pnode u, pnode v, int d) {
     if (v) v->p = u;
     if (d >= 0) u->ch[d] = v;
   }
   void rotate() {
     int x = dir();
     pnode g = p;
     set_link(g->p, static_cast<pnode>(this), g->dir());
     set_link(g, ch[x ^ 1], x);
     set_link(static_cast<pnode>(this), g, x ^ 1);
     g->update();
     update();
   }
   void splay() {
     while (!is_root() && !p->is_root()) {
       p->p->push(), p->push(), push();
       dir() == p->dir() ? p->rotate() : rotate();
       rotate();
     }
     if (!is_root()) p->push(), push(), rotate();
     push();
   }
 };
 struct node;
 node* root;
 bool capture;
 vector<pair<int, int>> vec;
 struct node : splay_tree<node*> {
   using splay_tree::ch;
   int val, lazy;
   node() : splay_tree() {
     val = -1e9;
     lazy = -1;
   }
   void update() override { splay_tree::update(); }
   void update_vsub(node* v, bool add) {
     if (!add && capture) vec.push_back({this - root, val});
   }
   void push() override {
     splay_tree::push();
     if (lazy != -1) {
       val = lazy;
       if (ch[0]) ch[0]->lazy = lazy;
       if (ch[1]) ch[1]->lazy = lazy;
       lazy = -1;
     }
   }
 };
 int main() {
   ios_base::sync_with_stdio(0), cin.tie(0);
   int n, m;
   cin >> n >> m;
   vector<vector<pair<int, int>>> adj(n);
   for (int i = 1, u, v, w; i < n; ++i) {
     cin >> u >> v >> w;
     --u, --v;
     adj[u].push_back({v, w});
   }
   vector<long long> dist(n);
   vec.reserve(n);
   link_cut_tree<node> lct(n);
   function<void(int)> dfs_access = [&](int u) {
     for (auto v : adj[u]) {
       dist[v.first] = dist[u] + v.second;
       lct.link(lct[u], lct[v.first]);
       dfs_access(v.first);
     }
   };
   dfs_access(0);
   root = lct[0];
   vector<pair<long long, long long>> s;
   for (int i = 0, d, t; i < m; ++i) {
     cin >> d >> t;
     --d;
     auto u = lct[d], v = u;
     while (!v->is_root()) v = v->p, v->push();
     while (v->ch[1]) v = v->ch[1], v->push();
     vec.clear();
     capture = true;
     lct.access(u);
     capture = false;
     for (auto x : vec)
       s.push_back({dist[x.first] + x.second, dist[x.first] + t});
     int val = u->val;
     u->lazy = t;
     u->push();
     u->val = val;
     lct.access(v);
   }
   long long explosion = -1, changes = s.size();
   sort(s.begin(), s.end());
   priority_queue<long long, vector<long long>, greater<long long>> pq;
   for (long long t = 1, i = 0; i < s.size() || !pq.empty();) {
     if (pq.empty() && t <= s[i].first) t = s[i].first + 1;
     while (i < s.size() && s[i].first < t) pq.push(s[i].second), ++i;
     if (t > pq.top()) {
       explosion = t - 1;
       break;
     }
     pq.pop();
     ++t;
   }
   if (explosion != -1)
     changes -= count_if(s.begin(), s.end(), [&](pair<long long, long long> x) {
       return x.second >= explosion;
     });
   cout << explosion <<     << changes <<
 ;
   return 0;
 }


#include <bits/stdc++.h>
 #pragma GCC optimize( O2 )
 using namespace std;
 const int N = 1e5 + 10;
 const long long mod = 1e9 + 7;
 const long long mod2 = 998244353;
 const int inf = 1e9;
 const int LOG = 22;
 long long pw(long long a, long long b, long long M) {
   return (!b ? 1
              : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M
                       : pw(a * a % M, b / 2, M)));
 }
 struct node {
   int mx1, mx2, cnt, lz;
   long long sum;
   node(int m1 = -inf, int m2 = -inf, int c = 0, int l = inf, long long s = 0) {
     mx1 = m1, mx2 = m2, cnt = c, lz = l, sum = s;
   }
   friend node operator|(node L, node R) {
     if (L.mx1 < R.mx1) swap(L, R);
     if (L.mx1 == R.mx1)
       L.cnt += R.cnt;
     else
       L.mx2 = max(L.mx2, R.mx1);
     L.mx2 = max(L.mx2, R.mx2);
     L.sum += R.sum;
     L.lz = inf;
     return L;
   }
 };
 struct segment_beats {
   node seg[N << 2];
   void shift(int v, int lz) {
     seg[v].lz = min(seg[v].lz, lz);
     seg[v].sum -= 1ll * seg[v].cnt * max(0, seg[v].mx1 - lz);
     seg[v].mx1 = min(seg[v].mx1, lz);
   }
   void second(int v, int tl, int tr) {
     if (tl == tr) return;
     shift(v << 1, seg[v].lz);
     shift(v << 1 | 1, seg[v].lz);
   }
   void change(int p, int x, int v = 1, int tl = 1, int tr = N - 1) {
     second(v, tl, tr);
     if (p > tr || p < tl) return;
     if (tl == tr) {
       seg[v] = node(x, -inf, 1, inf, x);
       return;
     }
     int mid = (tl + tr) >> 1;
     change(p, x, v << 1, tl, mid), change(p, x, v << 1 | 1, mid + 1, tr);
     seg[v] = seg[v << 1] | seg[v << 1 | 1];
   }
   void upd(int l, int r, int x, int v = 1, int tl = 1, int tr = N - 1) {
     second(v, tl, tr);
     if (l > tr || r < tl || l > r || seg[v].mx1 <= x) return;
     if (l <= tl && tr <= r && seg[v].mx2 < x) {
       shift(v, x);
       return;
     }
     int mid = (tl + tr) >> 1;
     upd(l, r, x, v << 1, tl, mid), upd(l, r, x, v << 1 | 1, mid + 1, tr);
     seg[v] = seg[v << 1] | seg[v << 1 | 1];
   }
   long long get(int l, int r, int v = 1, int tl = 1, int tr = N - 1) {
     second(v, tl, tr);
     if (l > tr || r < tl || l > r) return 0ll;
     if (l <= tl && tr <= r) {
       return seg[v].sum;
     }
     int mid = (tl + tr) >> 1;
     return get(l, r, v << 1, tl, mid) + get(l, r, v << 1 | 1, mid + 1, tr);
   }
 } seg1, seg2;
 struct segment {
   int lz[N << 2];
   segment() {
     for (int i = 0; i < N << 2; i++) lz[i] = inf;
   }
   void upd(int l, int r, int x, int v = 1, int tl = 1, int tr = N - 1) {
     if (l > tr || r < tl || l > r) return;
     if (l <= tl && tr <= r) {
       lz[v] = min(lz[v], x);
       return;
     }
     int mid = (tl + tr) >> 1;
     upd(l, r, x, v << 1, tl, mid), upd(l, r, x, v << 1 | 1, mid + 1, tr);
   }
   int ask(int p, int v = 1, int tl = 1, int tr = N - 1) {
     if (tl == tr) {
       return lz[v];
     }
     int mid = (tl + tr) >> 1;
     if (p <= mid) {
       return min(lz[v], ask(p, v << 1, tl, mid));
     }
     return min(lz[v], ask(p, v << 1 | 1, mid + 1, tr));
   }
 } Seg1, Seg2;
 set<int> st1, st2;
 int main() {
   for (int i = 1; i < N; i++) st1.insert(i), st2.insert(i);
   int n;
   scanf( %d , &n);
   for (int i = 1; i <= n; i++) {
     int tp, l, r;
     scanf( %d%d%d , &tp, &l, &r);
     r--;
     if (tp == 1) {
       int x;
       scanf( %d , &x);
       if (x < 0) {
         x = abs(x);
         seg1.upd(l, r, x);
         Seg1.upd(l, r, x);
         while (1) {
           auto it = st1.lower_bound(l);
           if (it == st1.end() || *it > r) break;
           int cu = *it;
           st1.erase(cu);
           if (st2.count(cu) == 0) {
             seg1.change(cu, x);
             seg2.change(cu, Seg2.ask(cu));
           }
         }
       } else {
         seg2.upd(l, r, x);
         Seg2.upd(l, r, x);
         while (1) {
           auto it = st2.lower_bound(l);
           if (it == st2.end() || *it > r) break;
           int cu = *it;
           st2.erase(cu);
           if (st1.count(cu) == 0) {
             seg2.change(cu, x);
             seg1.change(cu, Seg1.ask(cu));
           }
         }
       }
     } else {
       printf( %lld
 , seg1.get(l, r) + seg2.get(l, r));
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long INF = 1LL << 60;
 string operator*(const string& s, int k) {
   if (k == 0) return   ;
   string p = (s + s) * (k / 2);
   if (k % 2 == 1) p += s;
   return p;
 }
 template <class T>
 inline bool chmin(T& a, T b) {
   if (a > b) {
     a = b;
     return true;
   }
   return false;
 }
 template <class T>
 inline bool chmax(T& a, T b) {
   if (a < b) {
     a = b;
     return true;
   }
   return false;
 }
 struct Edge {
   long long to, cap, rev;
   Edge(long long _to, long long _cap, long long _rev) {
     to = _to;
     cap = _cap;
     rev = _rev;
   }
 };
 void add_edge(vector<vector<Edge>>& G, long long from, long long to,
               long long cap, bool revFlag, long long revCap) {
   G[from].push_back(Edge(to, cap, (long long)G[to].size()));
   if (revFlag)
     G[to].push_back(Edge(from, revCap, (long long)G[from].size() - 1));
 }
 long long max_flow_dfs(vector<vector<Edge>>& G, long long v, long long t,
                        long long f, vector<bool>& used) {
   if (v == t) return f;
   used[v] = true;
   for (int i = 0; i < G[v].size(); ++i) {
     Edge& e = G[v][i];
     if (!used[e.to] && e.cap > 0) {
       long long d = max_flow_dfs(G, e.to, t, min(f, e.cap), used);
       if (d > 0) {
         e.cap -= d;
         G[e.to][e.rev].cap += d;
         return d;
       }
     }
   }
   return 0;
 }
 long long max_flow(vector<vector<Edge>>& G, long long s, long long t) {
   long long flow = 0;
   for (;;) {
     vector<bool> used(G.size());
     for (int(i) = (int)(0); i < (int)(used.size()); i++) used[i] = false;
     long long f = max_flow_dfs(G, s, t, INF, used);
     if (f == 0) {
       return flow;
     }
     flow += f;
   }
 }
 void BellmanFord(vector<vector<Edge>>& G, long long s, vector<long long>& d,
                  vector<long long>& negative) {
   d.resize(G.size());
   negative.resize(G.size());
   for (int(i) = (int)(0); i < (int)(d.size()); i++) d[i] = INF;
   for (int(i) = (int)(0); i < (int)(d.size()); i++) negative[i] = false;
   d[s] = 0;
   for (int(k) = (int)(0); k < (int)(G.size() - 1); k++) {
     for (int(i) = (int)(0); i < (int)(G.size()); i++) {
       for (int(j) = (int)(0); j < (int)(G[i].size()); j++) {
         if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) {
           d[G[i][j].to] = d[i] + G[i][j].cap;
         }
       }
     }
   }
   for (int(k) = (int)(0); k < (int)(G.size() - 1); k++) {
     for (int(i) = (int)(0); i < (int)(G.size()); i++) {
       for (int(j) = (int)(0); j < (int)(G[i].size()); j++) {
         if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) {
           d[G[i][j].to] = d[i] + G[i][j].cap;
           negative[G[i][j].to] = true;
         }
         if (negative[i] == true) negative[G[i][j].to] = true;
       }
     }
   }
 }
 void Dijkstra(vector<vector<Edge>>& G, long long s, vector<long long>& d) {
   d.resize(G.size());
   for (int(i) = (int)(0); i < (int)(d.size()); i++) d[i] = INF;
   d[s] = 0;
   priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                  greater<pair<long long, long long>>>
       q;
   q.push(make_pair(0, s));
   while (!q.empty()) {
     pair<long long, long long> a = q.top();
     q.pop();
     if (d[a.second] < a.first) continue;
     for (int(i) = (int)(0); i < (int)(G[a.second].size()); i++) {
       Edge e = G[a.second][i];
       if (d[e.to] > d[a.second] + e.cap) {
         d[e.to] = d[a.second] + e.cap;
         q.push(make_pair(d[e.to], e.to));
       }
     }
   }
 }
 void WarshallFloyd(vector<vector<Edge>>& G, vector<vector<long long>>& d) {
   d.resize(G.size());
   for (int(i) = (int)(0); i < (int)(d.size()); i++) d[i].resize(G.size());
   for (int(i) = (int)(0); i < (int)(d.size()); i++) {
     for (int(j) = (int)(0); j < (int)(d[i].size()); j++) {
       d[i][j] = INF;
     }
   }
   for (int(i) = (int)(0); i < (int)(G.size()); i++) {
     for (int(j) = (int)(0); j < (int)(G[i].size()); j++) {
       d[i][G[i][j].to] = G[i][j].cap;
     }
   }
   for (int(i) = (int)(0); i < (int)(G.size()); i++) {
     for (int(j) = (int)(0); j < (int)(G.size()); j++) {
       for (int(k) = (int)(0); k < (int)(G.size()); k++) {
         chmin(d[j][k], d[j][i] + d[i][k]);
       }
     }
   }
 }
 bool tsort(vector<vector<Edge>>& graph, vector<int>& order) {
   int n = graph.size(), k = 0;
   vector<long long> in(n);
   for (auto& es : graph)
     for (auto& e : es) in[e.to]++;
   priority_queue<long long, vector<long long>, greater<long long>> que;
   for (int(i) = (int)(0); i < (int)(n); i++)
     if (in[i] == 0) que.push(i);
   while (que.size()) {
     int v = que.top();
     que.pop();
     order.push_back(v);
     for (auto& e : graph[v])
       if (--in[e.to] == 0) que.push(e.to);
   }
   if (order.size() != n)
     return false;
   else
     return true;
 }
 class lca {
  public:
   const int n = 0;
   const int log2_n = 0;
   std::vector<std::vector<int>> parent;
   std::vector<int> depth;
   lca() {}
   lca(const vector<vector<Edge>>& g, int root)
       : n(g.size()),
         log2_n(log2(n) + 1),
         parent(log2_n, std::vector<int>(n)),
         depth(n) {
     dfs(g, root, -1, 0);
     for (int k = 0; k + 1 < log2_n; k++) {
       for (int v = 0; v < (int)g.size(); v++) {
         if (parent[k][v] < 0)
           parent[k + 1][v] = -1;
         else
           parent[k + 1][v] = parent[k][parent[k][v]];
       }
     }
   }
   void dfs(const vector<vector<Edge>>& g, int v, int p, int d) {
     parent[0][v] = p;
     depth[v] = d;
     for (auto& e : g[v]) {
       if (e.to != p) dfs(g, e.to, v, d + 1);
     }
   }
   int get(int u, int v) {
     if (depth[u] > depth[v]) std::swap(u, v);
     for (int k = 0; k < log2_n; k++) {
       if ((depth[v] - depth[u]) >> k & 1) {
         v = parent[k][v];
       }
     }
     if (u == v) return u;
     for (int k = log2_n - 1; k >= 0; k--) {
       if (parent[k][u] != parent[k][v]) {
         u = parent[k][u];
         v = parent[k][v];
       }
     }
     return parent[0][u];
   }
 };
 class UnionFind {
   vector<int> data;
   long long num;

  public:
   UnionFind(int size) : data(size, -1), num(size) {}
   bool unite(int x, int y) {
     x = root(x);
     y = root(y);
     if (x != y) {
       if (data[y] < data[x]) swap(x, y);
       data[x] += data[y];
       data[y] = x;
     }
     num -= (x != y);
     return x != y;
   }
   bool findSet(int x, int y) { return root(x) == root(y); }
   int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
   int size(int x) { return -data[root(x)]; }
   int numSet() { return num; }
 };
 class SumSegTree {
  private:
   long long _sum(long long a, long long b, long long k, long long l,
                  long long r) {
     if (r <= a || b <= l) return 0;
     if (a <= l && r <= b)
       return dat[k];
     else {
       long long s1 = _sum(a, b, 2 * k + 1, l, (l + r) / 2);
       long long s2 = _sum(a, b, 2 * k + 2, (l + r) / 2, r);
       return s1 + s2;
     }
   }

  public:
   long long n, height;
   vector<long long> dat;
   SumSegTree(long long _n) {
     n = 1;
     height = 1;
     while (n < _n) {
       n *= 2;
       height++;
     }
     dat = vector<long long>(2 * n - 1, 0);
   }
   void add(long long i, long long x) {
     i += n - 1;
     dat[i] += x;
     while (i > 0) {
       i = (i - 1) / 2;
       dat[i] += x;
     }
   }
   long long sum(long long a, long long b) { return _sum(a, b, 0, 0, n); }
 };
 class RmqTree {
  private:
   long long _find(long long a, long long b, long long k, long long l,
                   long long r) {
     if (r <= a || b <= l) return INF;
     if (a <= l && r <= b)
       return dat[k];
     else {
       long long s1 = _find(a, b, 2 * k + 1, l, (l + r) / 2);
       long long s2 = _find(a, b, 2 * k + 2, (l + r) / 2, r);
       return min(s1, s2);
     }
   }

  public:
   long long n, height;
   vector<long long> dat;
   RmqTree(long long _n) {
     n = 1;
     height = 1;
     while (n < _n) {
       n *= 2;
       height++;
     }
     dat = vector<long long>(2 * n - 1, INF);
   }
   void update(long long i, long long x) {
     i += n - 1;
     dat[i] = x;
     while (i > 0) {
       i = (i - 1) / 2;
       dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
     }
   }
   long long find(long long a, long long b) { return _find(a, b, 0, 0, n); }
 };
 void divisor(long long n, vector<long long>& ret) {
   for (long long i = 1; i * i <= n; i++) {
     if (n % i == 0) {
       ret.push_back(i);
       if (i * i != n) ret.push_back(n / i);
     }
   }
   sort(ret.begin(), ret.end());
 }
 vector<long long> lis_fast(const vector<long long>& a) {
   const long long n = a.size();
   vector<long long> A(n, INT_MAX);
   vector<long long> id(n);
   for (int i = 0; i < n; ++i) {
     id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i]));
     A[id[i]] = a[i];
   }
   long long m = *max_element(id.begin(), id.end());
   vector<long long> b(m + 1);
   for (int i = n - 1; i >= 0; --i)
     if (id[i] == m) b[m--] = a[i];
   return b;
 }
 bool z_algorithm(string& str, vector<int>& z, long long s) {
   const int L = str.size();
   z.resize(str.size());
   for (int i = 1, left = 0, right = 0; i < L; i++) {
     if (i > right) {
       left = right = i;
       for (; right < L && str[right - left] == str[right]; right++)
         ;
       z[i] = right - left;
       right--;
     } else {
       int k = i - left;
       if (z[k] < right - i + 1) {
         z[i] = z[k];
       } else {
         left = i;
         for (; right < L && str[right - left] == str[right]; right++)
           ;
         z[i] = right - left;
         right--;
       }
     }
     if (z[i] == s) return true;
   }
   return false;
 }
 bool z_algorithm(string& str, vector<int>& z) {
   const int L = str.size();
   z.resize(str.size());
   for (int i = 1, left = 0, right = 0; i < L; i++) {
     if (i > right) {
       left = right = i;
       for (; right < L && str[right - left] == str[right]; right++)
         ;
       z[i] = right - left;
       right--;
     } else {
       int k = i - left;
       if (z[k] < right - i + 1) {
         z[i] = z[k];
       } else {
         left = i;
         for (; right < L && str[right - left] == str[right]; right++)
           ;
         z[i] = right - left;
         right--;
       }
     }
   }
   return true;
 }
 struct RollingHash {
   static const int base1 = 1007, base2 = 2009;
   static const int mod1 = 1000000007, mod2 = 1000000009;
   vector<long long> hash1, hash2, power1, power2;
   RollingHash(const string& S) {
     int n = (int)S.size();
     hash1.assign(n + 1, 0);
     hash2.assign(n + 1, 0);
     power1.assign(n + 1, 1);
     power2.assign(n + 1, 1);
     for (int i = 0; i < n; ++i) {
       hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
       hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
       power1[i + 1] = (power1[i] * base1) % mod1;
       power2[i + 1] = (power2[i] * base2) % mod2;
     }
   }
   inline pair<long long, long long> get(int l, int r) const {
     long long res1 = hash1[r] - hash1[l] * power1[r - l] % mod1;
     if (res1 < 0) res1 += mod1;
     long long res2 = hash2[r] - hash2[l] * power2[r - l] % mod2;
     if (res2 < 0) res2 += mod2;
     return {res1, res2};
   }
   inline int getLCP(int a, int b) const {
     int len = min((int)hash1.size() - a, (int)hash1.size() - b);
     int low = 0, high = len;
     while (high - low > 1) {
       int mid = (low + high) >> 1;
       if (get(a, a + mid) != get(b, b + mid))
         high = mid;
       else
         low = mid;
     }
     return low;
   }
 };
 long long mod_pow(long long x, long long n, long long mod) {
   long long res = 1LL;
   while (n > 0) {
     if (n & 1) res = res * x % mod;
     x = x * x % mod;
     n >>= 1;
   }
   return res;
 }
 long long mod_inv(long long x, long long mod) {
   return mod_pow(x, mod - 2, mod);
 }
 class Combination {
  public:
   vector<long long> fact;
   vector<long long> inv;
   long long mod;
   long long mod_inv(long long x) {
     long long n = mod - 2LL;
     long long res = 1LL;
     while (n > 0) {
       if (n & 1) res = res * x % mod;
       x = x * x % mod;
       n >>= 1;
     }
     return res;
   }
   long long nCr(long long n, long long r) {
     return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
   }
   long long nPr(long long n, long long r) {
     return (fact[n] * inv[n - r]) % mod;
   }
   long long nHr(long long n, long long r) { return nCr(r + n - 1, r); }
   Combination(long long n, long long _mod) {
     mod = _mod;
     fact.resize(n + 1);
     fact[0] = 1;
     for (int(i) = (int)(0); i < (int)(n); i++) {
       fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
     }
     inv.resize(n + 1);
     for (int(i) = (int)(0); i < (int)(n + 1); i++) {
       inv[i] = mod_inv(fact[i]);
     }
   }
 };
 long long gcd(long long m, long long n) {
   if (n == 0) return m;
   return gcd(n, m % n);
 }
 long long lcm(long long m, long long n) { return m / gcd(m, n) * n; }
 vector<vector<long long>> mIdentity(long long n) {
   vector<vector<long long>> A(n, vector<long long>(n));
   for (int i = 0; i < n; ++i) A[i][i] = 1;
   return A;
 }
 vector<vector<long long>> mMul(const vector<vector<long long>>& A,
                                const vector<vector<long long>>& B) {
   vector<vector<long long>> C(A.size(), vector<long long>(B[0].size()));
   for (int i = 0; i < C.size(); ++i)
     for (int j = 0; j < C[i].size(); ++j)
       for (int k = 0; k < A[i].size(); ++k)
         (C[i][j] += (A[i][k] % 1000000007) * (B[k][j] % 1000000007)) %=
             1000000007;
   return C;
 }
 vector<vector<long long>> mPow(const vector<vector<long long>>& A,
                                long long e) {
   return e == 0       ? mIdentity(A.size())
          : e % 2 == 0 ? mPow(mMul(A, A), e / 2)
                       : mMul(A, mPow(A, e - 1));
 }
 template <class T>
 class RectangleSum {
  public:
   vector<vector<T>> sum;
   T GetSum(int left, int right, int top, int bottom) {
     T res = sum[bottom][right];
     if (left > 0) res -= sum[bottom][left - 1];
     if (top > 0) res -= sum[top - 1][right];
     if (left > 0 && top > 0) res += sum[top - 1][left - 1];
     return res;
   }
   RectangleSum(const vector<vector<T>>& s, int h, int w) {
     sum.resize(h);
     for (int i = 0; i < h; i++) sum[i].resize(w, 0);
     for (int y = 0; y < h; y++) {
       for (int x = 0; x < w; x++) {
         sum[y][x] = s[y][x];
         if (y > 0) sum[y][x] += sum[y - 1][x];
         if (x > 0) sum[y][x] += sum[y][x - 1];
         if (y > 0 && x > 0) sum[y][x] -= sum[y - 1][x - 1];
       }
     }
   }
 };
 long long _garner(vector<long long>& xs, vector<long long>& mods) {
   int M = xs.size();
   vector<long long> coeffs(M, 1), constants(M, 0);
   for (int i = 0; i < M - 1; ++i) {
     long long mod_i = mods[i];
     long long v = (xs[i] - constants[i] + mod_i) % mod_i;
     v = (v * mod_pow(coeffs[i], mod_i - 2, mod_i)) % mod_i;
     for (int j = i + 1; j < M; j++) {
       long long mod_j = mods[j];
       constants[j] = (constants[j] + coeffs[j] * v) % mod_j;
       coeffs[j] = (coeffs[j] * mod_i) % mod_j;
     }
   }
   return constants.back();
 }
 template <typename T>
 inline void bit_reverse(vector<T>& a) {
   int n = a.size();
   int i = 0;
   for (int j = 1; j < n - 1; ++j) {
     for (int k = n >> 1; k > (i ^= k); k >>= 1)
       ;
     if (j < i) swap(a[i], a[j]);
   }
 }
 template <long long mod, long long primitive_root>
 class NTT {
  public:
   long long get_mod() { return mod; }
   void _ntt(vector<long long>& a, int sign) {
     const int n = a.size();
     assert((n ^ (n & -n)) == 0);
     const long long g = primitive_root;
     long long tmp = (mod - 1) * mod_pow(n, mod - 2, mod) % mod;
     long long h = mod_pow(g, tmp, mod);
     if (sign == -1) h = mod_pow(h, mod - 2, mod);
     bit_reverse(a);
     for (int m = 1; m < n; m <<= 1) {
       const int m2 = 2 * m;
       long long _base = mod_pow(h, n / m2, mod);
       long long _w = 1;
       for (int x = 0; x < m; ++x) {
         for (int s = x; s < n; s += m2) {
           long long u = a[s];
           long long d = (a[s + m] * _w) % mod;
           a[s] = (u + d) % mod;
           a[s + m] = (u - d + mod) % mod;
         }
         _w = (_w * _base) % mod;
       }
     }
   }
   void ntt(vector<long long>& input) { _ntt(input, 1); }
   void intt(vector<long long>& input) {
     _ntt(input, -1);
     const long long n_inv = mod_pow(input.size(), mod - 2, mod);
     for (auto& x : input) x = (x * n_inv) % mod;
   }
   vector<long long> convolution(const vector<long long>& a,
                                 const vector<long long>& b) {
     int result_size = a.size() + b.size() - 1;
     int n = 1;
     while (n < result_size) n <<= 1;
     vector<long long> _a = a, _b = b;
     _a.resize(n, 0);
     _b.resize(n, 0);
     ntt(_a);
     ntt(_b);
     for (int i = 0; i < n; ++i) _a[i] = (_a[i] * _b[i]) % mod;
     intt(_a);
     _a.resize(result_size);
     return _a;
   }
 };
 vector<long long> convolution_ntt(vector<long long>& a, vector<long long>& b,
                                   long long mod = 1224736769LL) {
   for (auto& x : a) x %= mod;
   for (auto& x : b) x %= mod;
   long long maxval = max(a.size(), b.size()) *
                      *max_element(a.begin(), a.end()) *
                      *max_element(b.begin(), b.end());
   if (maxval < 1224736769) {
     NTT<1224736769, 3> ntt3;
     return ntt3.convolution(a, b);
   }
   NTT<167772161, 3> ntt1;
   NTT<469762049, 3> ntt2;
   NTT<1224736769, 3> ntt3;
   vector<long long> x1 = ntt1.convolution(a, b);
   vector<long long> x2 = ntt2.convolution(a, b);
   vector<long long> x3 = ntt3.convolution(a, b);
   vector<long long> ret(x1.size());
   vector<long long> mods{167772161, 469762049, 1224736769, mod};
   for (int i = 0; i < x1.size(); ++i) {
     vector<long long> xs{x1[i], x2[i], x3[i], 0};
     ret[i] = _garner(xs, mods);
   }
   return ret;
 }
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   long long n, k;
   cin >> n >> k;
   long long mi = (n + 1) * n / 2;
   long long ma = mi * 2 - (n / 2 + 1) * (n / 2);
   if (n % 2 == 1) ma -= n / 2 + 1;
   if (k < mi) {
     cout << -1 << endl;
     return 0;
   }
   cout << min(k, ma) << endl;
   for (int(i) = (int)(0); i < (int)(n); i++) cout << i + 1 << ' ';
   cout << endl;
   if (k >= ma) {
     for (int(i) = (int)(0); i < (int)(n); i++) cout << n - i << ' ';
     cout << endl;
     return 0;
   }
   long long rest = k - mi;
   vector<long long> ans(n);
   for (int(i) = (int)(0); i < (int)(n); i++) ans[i] = i + 1;
   long long now = 0;
   for (int i = n - 1; i >= 0; i--) {
     if (rest >= i - now) {
       swap(ans[i], ans[now]);
       rest -= i - now;
     } else {
       swap(ans[i], ans[i - rest]);
       break;
     }
     now++;
   }
   for (int(i) = (int)(0); i < (int)(n); i++) cout << ans[i] << ' ';
   cout << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int vis[100005], mark[100005];
 vector<int> g[100005];
 int prob = 0;
 void dfs(int node, int k) {
   mark[node] = k;
   vis[node] = 1;
   for (auto i : g[node]) {
     if (!vis[i]) {
       dfs(i, 1 - k);
     } else {
       if (mark[i] == k) {
         prob = 1;
       }
     }
   }
 }
 int main() {
   int n, m;
   cin >> n >> m;
   for (int i = 0; i < m; i++) {
     int u, v;
     scanf( %d , &u);
     scanf( %d , &v);
     g[u].push_back(v);
     g[v].push_back(u);
   }
   for (int i = 1; i <= n; i++) {
     if (!vis[i]) dfs(i, 0);
   }
   if (prob) {
     cout <<  -1 ;
     return 0;
   }
   int k = 0;
   for (int i = 1; i <= n; i++) {
     if (mark[i] == 1) k++;
   }
   cout << k <<
 ;
   for (int i = 1; i <= n; i++) {
     if (mark[i] == 1) cout << i <<    ;
   }
   cout <<
 ;
   k = 0;
   for (int i = 1; i <= n; i++) {
     if (mark[i] == 0) k++;
   }
   cout << k <<
 ;
   for (int i = 1; i <= n; i++) {
     if (mark[i] == 0) cout << i <<    ;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <typename T>
 T sqr(T x) {
   return x * x;
 }
 template <typename T>
 T abs(T x) {
   return x < 0 ? -x : x;
 }
 template <typename T>
 T gcd(T a, T b) {
   return b ? gcd(b, a % b) : a;
 }
 set<vector<int> > s;
 vector<pair<char, pair<int, int> > > ans;
 bool rec(vector<int>& a) {
   if (a.size() == 1) {
     return a[0] == 24;
   }
   if (s.find(a) != s.end()) {
     return false;
   }
   s.insert(a);
   for (size_t i = 0; i < a.size(); ++i) {
     for (size_t j = i + 1; j < a.size(); ++j) {
       vector<int> b = a;
       int x = a[i], y = a[j];
       b.erase(b.begin() + j);
       b.erase(b.begin() + i);
       b.push_back(x + y);
       ans.push_back(make_pair('+', make_pair(x, y)));
       if (rec(b)) {
         return true;
       }
       b.pop_back();
       ans.pop_back();
       b.push_back(y - x);
       ans.push_back(make_pair('-', make_pair(y, x)));
       if (rec(b)) {
         return true;
       }
       b.pop_back();
       ans.pop_back();
       b.push_back(x - y);
       ans.push_back(make_pair('-', make_pair(x, y)));
       if (rec(b)) {
         return true;
       }
       b.pop_back();
       ans.pop_back();
       b.push_back(x * y);
       ans.push_back(make_pair('*', make_pair(x, y)));
       if (rec(b)) {
         return true;
       }
       b.pop_back();
       ans.pop_back();
     }
   }
   return false;
 }
 int main(int, char**) {
   ios_base::sync_with_stdio(false);
   int n;
   cin >> n;
   if (n < 4) {
     cout <<  NO  << endl;
     return 0;
   }
   cout <<  YES  << endl;
   vector<int> a;
   for (int i = 1; i <= n % 2 + 4; ++i) {
     a.push_back(i);
   }
   rec(a);
   for (int i = n % 2 + 4; i < n; i += 2) {
     ans.push_back(make_pair('-', make_pair(i + 2, i + 1)));
     ans.push_back(make_pair('*', make_pair(24, 1)));
   }
   for (size_t i = 0; i < ans.size(); ++i) {
     int x = ans[i].second.first;
     int y = ans[i].second.second;
     int r = -1;
     switch (ans[i].first) {
       case '-':
         r = x - y;
         break;
       case '+':
         r = x + y;
         break;
       case '*':
         r = x * y;
         break;
     }
     cout << x <<     << ans[i].first <<     << y <<   =   << r << endl;
   }
   fprintf(stderr,  Time execute: %.3lf sec
 ,
           clock() / (double)CLOCKS_PER_SEC);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 void fast();
 int main() {
   fast();
   int k, d;
   cin >> k >> d;
   string ans =   ;
   if ((d > (pow(10, k) - 1)) || (d == 0 && k != 1)) {
     cout <<  No solution ;
     return 0;
   }
   for (int i = 0; i < k; i++) {
     if (d > 9) {
       ans +=  9 ;
       d -= 9;
     } else {
       stringstream t;
       t << d;
       ans += t.str();
       d = 0;
     }
   }
   cout << ans;
   return 0;
 }
 void fast() {
   ios_base::sync_with_stdio(0);
   cin.tie(NULL), cout.tie(NULL);
 }


#include <bits/stdc++.h>
 using namespace std;
 const int INF = 1029384756;
 const double PI = acos(-1);
 const double EPS = 0.0000000304;
 long long A, B, C;
 int main() {
   scanf( extraextraextra , &A, &B, &C);
   if ((A % 2) == (B % 2) && (B % 2) == (C % 2)) {
     printf( extra , A + B + C - max(A, max(B, C)) - min(A, min(B, C)));
   } else if (A % 2 == B % 2) {
     printf( extra , max(A, B));
   } else if (A % 2 == C % 2) {
     printf( extra , max(A, C));
   } else {
     printf( extra , max(B, C));
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 vector<long long int> v;
 int main() {
   long long int n, m, a, b, sum = 0, i, j, k;
   cin >> n >> k;
   long long int s[n], x[n];
   for (i = 0; i < n; i++) {
     cin >> a >> b;
     sum += min(a, b);
     v.push_back(min(2 * a, b) - min(a, b));
   }
   sort(v.begin(), v.end());
   for (i = 0; i < n && i < k; i++) sum += v[n - i - 1];
   cout << sum << endl;
 }