#include <bits/stdc++.h>
 double const EPS = 3e-8;
 using namespace std;
 template <class T>
 T gcd(T a, T b) {
   return (b != 0 ? gcd<T>(b, a  b) : a);
 }
 template <class T>
 T lcm(T a, T b) {
   return (a / gcd<T>(a, b) * b);
 }
 struct debugger {
   template <typename T>
   debugger& operator,(const T& v) {
     cerr << v <<  	 ;
     return *this;
   }
 } dbg;
 template <class A, class B>
 ostream& operator<<(ostream& o, const pair<A, B>& p) {
   return o <<  (  << p.first <<  ,   << p.second <<  ) ;
 }
 template <class T>
 ostream& operator<<(ostream& o, const vector<T>& v) {
   o <<  [ ;
   for (__typeof((v).end()) it = (v).begin(); it != (v).end(); ++it)
     o << *it <<  ,  ;
   return o <<  ] ;
 }
 template <class T>
 ostream& operator<<(ostream& o, const set<T>& v) {
   o <<  [ ;
   for (__typeof((v).end()) it = (v).begin(); it != (v).end(); ++it)
     o << *it <<  ,  ;
   return o <<  ] ;
 }
 template <class T>
 inline bool read(T& x) {
   int c = getchar();
   int sgn = 1;
   while (~c && c < '0' || c > '9') {
     if (c == '-') sgn = -1;
     c = getchar();
   }
   for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
   x *= sgn;
   return ~c;
 }
 int dx[] = {1, 0, -1, 0};
 int dy[] = {0, 1, 0, -1};
 const int NX = 1e6 + 10;
 int fromFront[NX], fromBack[NX];
 string a, b;
 void solve(int cs) {
   cin >> a >> b;
   int asz = a.size();
   int bsz = b.size();
   int backIdx = bsz - 1;
   int cur = 0;
   for (int i = asz - 1; i >= 0; i--) {
     if (backIdx >= 0 && a[i] == b[backIdx]) {
       backIdx--;
       cur++;
     }
     fromBack[i] = cur;
   }
   int frontIdx = 0;
   cur = 0;
   for (int i = 0; i < asz; i++) {
     if (frontIdx < bsz && a[i] == b[frontIdx]) {
       frontIdx++;
       cur++;
     }
     fromFront[i] = cur;
   }
   int low = 0, high = 0;
   int ans = 0;
   while (high < asz) {
     int f = 0, b = 0;
     if (low > 0) f = fromFront[low - 1];
     if (high + 1 < asz) b = fromBack[high + 1];
     if (f + b >= bsz) {
       ans = max(ans, high - low + 1);
     } else {
       while (f + b < bsz && low <= high) {
         low++;
         f = fromFront[low - 1];
         if (high + 1 < asz) b = fromBack[high + 1];
       }
     }
     high++;
   }
   printf( d
 , ans);
 }
 int main() {
   int t = 1;
   for (int cs = 1; cs <= t; cs++) solve(cs);
   return 0;
 }


#include <bits/stdc++.h>
 int main() {
   int n, k;
   while (~scanf( dd , &n, &k)) {
     int ant[55] = {0};
     int temp = 0;
     int count = k;
     for (int i = 1; i <= n; i++) {
       scanf( d , &ant[i - 1]);
       if (i == k) temp = ant[i - 1];
     }
     if (temp)
       for (int i = k + 1; i <= n; i++) {
         if (ant[i - 1] >= temp)
           count++;
         else
           break;
       }
     else
       for (int i = k; i >= 1; i--) {
         if (!ant[i - 1]) count--;
       }
     printf( d
 , count);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 void err(istream_iterator<string> it) {}
 template <typename T, typename... Args>
 void err(istream_iterator<string> it, T a, Args... args) {
   cerr << ' ' << *it <<   =   << a;
   err(++it, args...);
 }
 template <typename T, typename U>
 inline void min_self(T& x, U y) {
   if (y < x) x = y;
 }
 template <typename T, typename U>
 inline void max_self(T& x, U y) {
   if (x < y) x = y;
 }
 template <class T1, class T2>
 ostream& operator<<(ostream& out, pair<T1, T2> pair) {
   return out <<  (  << pair.first <<  ,   << pair.second <<  ) ;
 }
 template <class T>
 ostream& operator<<(ostream& out, vector<T> vec) {
   out <<  ( ;
   for (auto& v : vec) out << v <<  ,  ;
   return out <<  ) ;
 }
 template <class T>
 ostream& operator<<(ostream& out, set<T> vec) {
   out <<  ( ;
   for (auto& v : vec) out << v <<  ,  ;
   return out <<  ) ;
 }
 template <class L, class R>
 ostream& operator<<(ostream& out, map<L, R> vec) {
   out <<  ( ;
   for (auto& v : vec) out <<  [  << v.first <<  ,   << v.second <<  ] ;
   return out <<  ) ;
 }
 template <class A, class B>
 istream& operator>>(istream& in, pair<A, B>& a) {
   return in >> a.first >> a.second;
 }
 template <class A>
 istream& operator>>(istream& in, vector<A>& a) {
   for (A& i : a) in >> i;
   return in;
 }
 long long XX[4] = {-1, 0, 1, 0};
 long long YY[4] = {0, -1, 0, 1};
 void solve() {
   long long n, res = 0;
   cin >> n;
   vector<pair<long long, long long>> a(n);
   for (long long i = 0; i <= n - 1; i++) cin >> a[i];
   sort(a.begin(), a.end());
   long long maxi = a[0].second;
   for (long long i = 1; i <= n - 1; i++) {
     if (a[i].second < maxi && a[i].first > a[i - 1].first) {
       res++;
     }
     max_self(maxi, a[i].second);
   }
   cout << res << '
';
   return;
 }
 int32_t main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   long long t = 1;
   while (t--) {
     solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int N, K;
   cin >> N >> K;
   double res = 0;
   long double t1x, t1y, t2x, t2y;
   cin >> t1x >> t1y;
   for (int i = 1; i < N; ++i) {
     t2x = t1x;
     t2y = t1y;
     cin >> t1x >> t1y;
     res += sqrt((t1x - t2x) * (t1x - t2x) + (t1y - t2y) * (t1y - t2y));
   }
   printf( .15lf
 , res * K / 50);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 100005;
 int down[N], sz[N], up[N], n;
 vector<pair<int, bool> > adj[N];
 void dfs(int s, int p) {
   sz[s] = 1;
   for (auto it : adj[s]) {
     if (it.first != p) {
       dfs(it.first, s);
       sz[s] += sz[it.first];
       if (it.second)
         down[s] += sz[it.first];
       else
         down[s] += down[it.first];
     }
   }
 }
 void dfs2(int s, int p) {
   for (auto it : adj[s]) {
     if (it.first != p) {
       if (it.second)
         up[it.first] = n - sz[it.first];
       else
         up[it.first] = down[s] - down[it.first] + up[s];
       dfs2(it.first, s);
     }
   }
 }
 int main() {
   int i;
   scanf( d , &n);
   for (i = 0; i < n - 1; i++) {
     int a, b, c, te;
     bool flag = true;
     scanf( ddd , &a, &b, &c);
     while (c > 0) {
       if (c  10 == 4 || c  10 == 7)
         ;
       else
         flag = false;
       c /= 10;
     }
     adj[a - 1].push_back(make_pair(b - 1, flag));
     adj[b - 1].push_back(make_pair(a - 1, flag));
   }
   long long ans = 0;
   dfs(0, -1);
   dfs2(0, -1);
   for (i = 0; i < n; i++) {
     long long temp = up[i] + down[i];
     ans += temp * (temp - 1);
   }
   cout << ans;
 }


#include <bits/stdc++.h>
 using namespace std;
 int one, two, three, four;
 bool check(deque<int> x) {
   int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
   for (int i = 0; i < x.size(); i++) {
     if (x[i] == 0) cnt1++;
     if (x[i] == 1) cnt2++;
     if (x[i] == 2) cnt3++;
     if (x[i] == 3) cnt4++;
   }
   if (cnt1 == one && cnt2 == two && cnt3 == three & cnt4 == four) {
     for (int i = 0; i + 1 < x.size(); i++) {
       if (abs(x[i] - x[i + 1]) != 1) return 0;
     }
     cout <<  YES  << '
';
     for (int i : x) cout << i << ' ';
     exit(0);
   }
   return 0;
 }
 deque<int> merge(deque<int> x, deque<int> y) {
   for (int i : y) x.push_back(i);
   return x;
 }
 void go2(pair<int, int> a, pair<int, int> b, deque<int> ans) {
   deque<int> ans2 = ans;
   if (a.first < b.first) {
     for (int i = 0; i < a.first; i++) {
       ans.push_back(b.second);
       ans.push_back(a.second);
     }
     ans.push_back(b.second);
   } else {
     for (int i = 0; i < b.first; i++) {
       ans.push_back(a.second);
       ans.push_back(b.second);
     }
     if (a.first != b.first) ans.push_back(a.second);
   }
   check(ans);
   ans = ans2;
   if (a.first <= b.first) {
     for (int i = 0; i < a.first; i++) {
       ans.push_back(b.second);
       ans.push_back(a.second);
     }
     if (a.first != b.first) ans.push_back(b.second);
   } else {
     for (int i = 0; i < b.first; i++) {
       ans.push_back(a.second);
       ans.push_back(b.second);
     }
     if (a.first != b.first) ans.push_back(a.second);
   }
   ans = ans2;
   deque<int> zl;
   if (a.first < b.first) {
     for (int i = 0; i < a.first; i++) {
       zl.push_back(b.second);
       zl.push_back(a.second);
     }
     zl.push_back(b.second);
   } else {
     for (int i = 0; i < b.first; i++) {
       zl.push_back(a.second);
       zl.push_back(b.second);
     }
     if (a.first != b.first) zl.push_back(a.second);
   }
   check(merge(zl, ans));
   zl.clear();
   if (a.first <= b.first) {
     for (int i = 0; i < a.first; i++) {
       zl.push_back(b.second);
       zl.push_back(a.second);
     }
     if (a.first != b.first) zl.push_back(b.second);
   } else {
     for (int i = 0; i < b.first; i++) {
       zl.push_back(a.second);
       zl.push_back(b.second);
     }
     if (a.first != b.first) zl.push_back(a.second);
   }
   check(merge(zl, ans));
 }
 void go3(pair<int, int> a, pair<int, int> b, pair<int, int> c, deque<int> cur) {
   deque<int> ans;
   if (a.first <= b.first) {
     for (int i = 0; i < a.first; i++) {
       ans.push_back(a.second);
       ans.push_back(b.second);
     }
     go2(pair<int, int>(b.first - a.first, b.second), c, merge(cur, ans));
     go2(pair<int, int>(b.first - a.first, b.second), c, merge(ans, cur));
     ans.clear();
     for (int i = 0; i < a.first; i++) {
       ans.push_back(b.second);
       ans.push_back(a.second);
     }
     go2(pair<int, int>(b.first - a.first, b.second), c, merge(cur, ans));
     go2(pair<int, int>(b.first - a.first, b.second), c, merge(ans, cur));
   }
   ans.clear();
   if (c.first <= b.first) {
     for (int i = 0; i < c.first; i++) {
       ans.push_back(c.second);
       ans.push_back(b.second);
     }
     go2(a, pair<int, int>(b.first - c.first, b.second), merge(cur, ans));
     go2(a, pair<int, int>(b.first - c.first, b.second), merge(ans, cur));
     ans.clear();
     for (int i = 0; i < c.first; i++) {
       ans.push_back(b.second);
       ans.push_back(c.second);
     }
     go2(a, pair<int, int>(b.first - c.first, b.second), merge(cur, ans));
     go2(a, pair<int, int>(b.first - c.first, b.second), merge(ans, cur));
   }
 }
 void go4(int a, int b, int c, int d) {
   if (a <= b) {
     deque<int> lul;
     for (int i = 0; i < a; i++) {
       lul.push_back(0);
       lul.push_back(1);
     }
     go3(pair<int, int>(b - a, 1), pair<int, int>(c, 2), pair<int, int>(d, 3),
         lul);
     lul.clear();
     for (int i = 0; i < a; i++) {
       lul.push_back(1);
       lul.push_back(0);
     }
     go3(pair<int, int>(b - a, 1), pair<int, int>(c, 2), pair<int, int>(d, 3),
         lul);
   }
   if (d <= c) {
     deque<int> lul;
     for (int i = 0; i < d; i++) {
       lul.push_back(3);
       lul.push_back(2);
     }
     go3(pair<int, int>(a, 0), pair<int, int>(b, 1), pair<int, int>(c - d, 2),
         lul);
     lul.clear();
     for (int i = 0; i < d; i++) {
       lul.push_back(2);
       lul.push_back(3);
     }
     go3(pair<int, int>(a, 0), pair<int, int>(b, 1), pair<int, int>(c - d, 2),
         lul);
   }
 }
 int main() {
   cin >> one >> two >> three >> four;
   go4(one, two, three, four);
   cout <<  NO ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long range(long long L) {
   switch (L & 3) {
     case 0:
       return L;
     case 1:
       return 1;
     case 2:
       return L + 1;
     case 3:
       return 0;
   }
 }
 int main() {
   for (int N; cin >> N;) {
     long long sum = 0;
     for (int i = 0; i < (int)(N); ++i) {
       long long m, x;
       cin >> x >> m;
       long long b = range(x - 1);
       long long a = range(x + m - 1);
       sum ^= b;
       sum ^= a;
     }
     if (sum == 0)
       cout <<  bolik  << endl;
     else
       cout <<  tolik  << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 #include <cmath>
 #include <regex>
 #define ff first
 #define ss second
 #define pb push_back
 #define mp make_pair
 #define ba back
 #define ppb pop_back
 #define eb emplace_back
 #define eps 1e-6
 #define vec vector<long long int>
 #define sz(x) (int((x.size())))
 #define all(x) (x).begin(),(x).end()
 #define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)
 #define ll long long
 #define loop(i,s,n) for(int i=s;i<n;i++)
 using namespace std;
 //-----------------------------------------------------------------------------------------------------------------
 const ll M = 1e9 + 7;
 const ll N = 2e5 + 5;
 const ll inf = 2e18;
 ll mod(ll x){   return (xM);}
 ll mod_minus(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}

 ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}

 ll mod_add(ll a,ll b){ return mod(a+b);}

 ll power(ll a,ll n){
     if(n==0) return 1;
      else if(n==1) return a;
       ll R=power(a,n/2)M;
        if(n2==0) {    return mod(mod_mul(R,R));  }

       else {   return mod(mod_mul(mod_mul(R,a),mod(R)));  }
     }

 ll mod_inv(ll n){  return power(n,M-2);}

 // only if M is prime
 ll mod_div(ll a,ll b){
      ll ans=mod(a);   ll b1=power(b,M-2);
        ans= mod(mod_mul(ans,b1));
         return ans;
         }

 ll fact_mod(ll n){
     vec fact(n+1);
      fact[0]=1;
      loop(i,1,n+1){
           fact[i]=mod_mul(fact[i-1],i);
            }
             return fact[n];
     }

 unsigned long long nCr_mod(unsigned long long n,  ll r)
 {
     if (r == 0)
         return 1;
     unsigned long long fac[n + 1];
     fac[0] = 1;
     for (int i = 1; i <= n; i++)
         fac[i] = (fac[i - 1] * i)  M;

     return (fac[n] * mod_inv(fac[r])  M * mod_inv(fac[n - r])  M)  M;
 }
 //--------------------------------------------------------------------------------------------------------------
 void solve(){
     ll n;
     cin>>n;
     ll a[n];
     ll sum=0;
     loop(i,0,n){
         cin>>a[i];
         sum+=a[i];
     }
     sort(a,a+n);
     ll mx=a[n-1],mn=a[0];
     ll z=(n-1)-sum(n-1);
     if(z==(n-1)){
         z=0;
     }
     sum+=z;
     if(mx<=sum/(n-1)){
         cout<<z<<endl;
         return;
     }
     cout<<mx*(n-1)-sum+z<<endl;
 }

 int main(){
     FAST;
     int t;
     cin>>t;
     while(t--){
         solve();
     }
 }


#include <bits/stdc++.h>
 using namespace std;
 int read() {
   int x;
   scanf( d , &x);
   return x;
 }
 const int N = 1123456;
 int a[N];
 vector<int> v[N];
 int c[N];
 priority_queue<int> q[N];
 void dfs(int x, int t) {
   c[x] = t;
   q[t].push(a[x]);
   for (int i = 0; i < v[x].size(); i++) {
     int to = v[x][i];
     if (!c[to]) {
       dfs(to, t);
     }
   }
 }
 int main() {
   int n, m, i, j, x, y;
   n = read();
   m = read();
   for (i = 1; i <= n; i++) {
     a[i] = read();
   }
   for (i = 1; i <= m; i++) {
     x = read();
     y = read();
     v[x].push_back(y);
     v[y].push_back(x);
   }
   int cnt = 1;
   for (i = 1; i <= n; i++) {
     if (!c[i]) {
       dfs(i, cnt++);
     }
   }
   for (i = 1; i <= n; i++) {
     printf( d  , q[c[i]].top());
     q[c[i]].pop();
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 stack<pair<int, int> > a;
 int main() {
   int n, m = 0, i = 1;
   cin >> n;
   while (n--) {
     int b, c;
     char d, e, f[40];
     scanf(    );
     scanf( c , &d);
     scanf( dcd , &b, &e, &c);
     gets(f);
     b = 12;
     if (f[1] == 'p') b += 12;
     if (m) {
       if ((b < a.top().first) || (b == a.top().first && c < a.top().second))
         ;
       else
         m--;
       if (b == a.top().first && c == a.top().second)
         i++;
       else
         i = 1;
     }
     if (i > 10) {
       m++;
       i -= 10;
     }
     a.push({b, c});
     m++;
   }
   cout << m << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long maxn = 100010;
 const long long inf = 1e9 + 7;
 long long n, a[maxn];
 long long minv = inf;
 long long sum[3];
 int main() {
   scanf( extra , &n);
   for (long long i = 1; i <= n; i++) {
     scanf( extra , &a[i]);
     minv = min(minv, a[i]);
   }
   for (long long i = 1; i <= n; i++) a[i] -= minv;
   for (long long i = 1; i <= n; i++) sum[a[i]]++;
   sort(a + 1, a + n + 1);
   if (a[n] < 2) {
     printf( extra
 , n);
     for (long long i = 1; i <= n; i++) printf( extra  , a[i] + minv);
     return 0;
   } else {
     long long temp = min(sum[0], sum[2]);
     long long temp2 = sum[1] >> 1;
     if (temp > temp2) {
       sum[1] += (temp << 1);
       sum[0] -= temp;
       sum[2] -= temp;
     } else {
       temp = temp2;
       sum[1] -= (temp << 1);
       sum[0] += temp;
       sum[2] += temp;
     }
     printf( extra
 , n - (temp << 1));
     for (long long i = 0; i < 3; i++)
       for (long long j = 1; j <= sum[i]; j++) printf( extra  , i + minv);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline long long gcd(long long a, long long b) {
   return b == 0 ? a : gcd(b, a  b);
 }
 inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
 long long n, k, x, type(1), amt, box;
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   cin >> n >> k;
   for (int i = 1; i <= k; i++) {
     cin >> x;
     if (x * (n / x) > amt) {
       amt = x * (n / x);
       box = n / x;
       type = i;
     }
   }
   cout << type <<     << box << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 void debug_out() { cerr << endl; }
 void clock_out() {
   cerr <<
Time Elapsed :   << 1.0 * clock() / CLOCKS_PER_SEC <<   s
 ;
 }
 void fileio() {
   freopen( /home/dwai/Desktop/cp/input.txt ,  r , stdin);
   freopen( /home/dwai/Desktop/cp/output.txt ,  w , stdout);
   freopen( /home/dwai/Desktop/cp/debug.txt ,  w , stderr);
 }
 void ofileio() {
   freopen( input.txt ,  r , stdin);
   freopen( output.txt ,  w , stdout);
 }
 template <typename Head, typename... Tail>
 void debug_out(Head H, Tail... T) {
   cerr <<     << H;
   debug_out(T...);
 }
 int IT_MAX = 1 << 20;
 const long long MOD = 1000000007;
 const int INF = 0x3f3f3f3f;
 const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
 const double PI = acos(-1);
 const double ERR = 1e-10;
 int main() {
   42;
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   srand(time(NULL));
   long long n, m;
   cin >> n >> m;
   long long a[n], b[m];
   long long i;
   long long mn = 0, mx = 0;
   for (i = 0; i < n; i++) {
     cin >> a[i];
     if (i == 0) {
       mx = a[i];
       mn = a[i];
     } else
       mx = max(mx, a[i]);
     mn = min(mn, a[i]);
   }
   long long ans = mn * 2;
   for (i = 0; i < n; i++) {
     if (a[i] > ans) ans = a[i];
   }
   for (i = 0; i < m; i++) {
     cin >> b[i];
     if (b[i] <= ans) return cout << -1, 0;
   }
   cout << ans;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int N, K;
 int T[200005];
 vector<int> danger;
 vector<pair<int, int> > v;
 bool cf(pair<int, int> x, pair<int, int> y) {
   return x.second * y.first > y.second * x.first;
 }
 int main() {
   scanf( d d , &N, &K);
   for (int i = 0; i < N; i++) {
     scanf( d , &T[i]);
     if (T[i] < 0) {
       danger.push_back(i);
     }
   }
   if (danger.size() > K)
     puts( -1 );
   else {
     int change = danger.size() * 2;
     K -= danger.size();
     for (int i = 0; i < (int)danger.size(); i++) {
       if (i == danger.size() - 1)
         v.push_back(make_pair(N - danger[i] - 1, 1));
       else
         v.push_back(make_pair(danger[i + 1] - danger[i] - 1, 2));
     }
     sort(v.begin(), v.end(), cf);
     int idx = 0;
     while (idx < v.size()) {
       if (K - v[idx].first >= 0) {
         K -= v[idx].first;
         change -= v[idx].second;
       }
       idx++;
     }
     printf( d
 , change);
   }
   return 0;
 }


#include <bits/stdc++.h>
 #define ff first
 #define ss second
 #define ll long long
 #define ld long double
 #define pb push_back
 #define eb emplace_back
 #define mp make_pair
 #define mt make_tuple
 #define pii pair<int, int>
 #define pll pair<ll,ll>
 #define vi vector<int>
 #define vl vector<ll>
 #define vii vector<pii>
 #define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define endl '
'
 #define teto(a, b) ((a+b-1)/(b))
 using namespace std;

 // Extra
 #define forn(i, n) for(int i = 0; i < (int)n; i++)
 #define forne(i, a, b) for(int i = a; i <= b; i++)
 #define all(x) x.begin(), x.end()
 #define dbg(msg, var) cout << msg <<     << var << endl;
 //

 const int MAX = 200010;
 const ll MOD = (int)1e9 +7;
 const int INF = 1e9;
 const ll LLINF = 0x3f3f3f3f3f3f3f3f;
 const ld EPS = 1e-8;

 int n, l, r, s;
 vector<vector<bool>> tab;
 vector<vector<bool>> btab;

 int dp(int idx, int soma) {
     if(soma > s) return 0;
     if(idx >= n) {
         return (soma == s);
     }
     if(btab[idx][soma]) return tab[idx][soma];

     // cout << idx <<     << soma << endl;
     int res = 0;
     int pega = dp(idx+1, soma + idx+1);
     int npega = dp(idx+1, soma);

     if(npega >= pega) {
         res = npega;
     }
     else {
         res = pega;
     }

     btab[idx][soma] = true;
     return tab[idx][soma] = res;
 }

 vi solve(vi vals, int sz, bool& ruim) {
     int t = vals.size();
     vi foi(n+1, 0);
     forn(i, t)
         foi[vals[i]] = 1;

     ruim = false;
     while(t < sz and !ruim) {
         bool brk = false;
         forne(i, 1, n) {
             if(!foi[i]) continue;
             forne(j, 1, i-1) {
                 if(j == i-j) continue;
                 if(!foi[j] and !foi[i-j]) {
                     foi[i] = 0;
                     foi[j] = 1; foi[i-j] = 1;
                     t++;
                     brk = true;
                     break;
                 }
             }
             if(brk) break;
         }
         if(!brk) ruim = true;
     }

     return foi;
 }

 int32_t main() {
     // sws;
     int t;
     cin >> t;

     while(t--) {
         cin >> n >> l >> r >> s;

         tab.assign(n, vector<bool>(s+1, -1));
         btab.assign(n, vector<bool>(s+1, 0));

         bool win = dp(0, 0);
         if(win) {
             vi vals, p(n+1, -1);
             set<int> pos;
             forne(i, 1, n) pos.insert(i);

             int idx = 0, soma = 0;
             while(idx < n) {
                 if(dp(idx+1, soma)) {
                     idx++;
                 }
                 else {
                     soma += idx+1;
                     vals.pb(idx+1);
                     idx++;
                 }
             }

             if(vals.size() > (r-l+1)) {
                 cout << -1 << endl;
                 continue;
             }

             bool ruim;
             // for(auto val : vals) cout << val <<    ;
             // cout << endl;

             vi foi = solve(vals, (r-l+1), ruim);
             // cout <<  ruim =   << ruim << endl;

             // forne(i, 1, n) cout << foi[i] <<    ;
             // cout << endl;

             if(ruim) cout << -1 << endl;
             else {
                 int id1 = 1, id2 = 1;
                 forne(i, 1, n) {
                     if(l <= i and i <= r) {
                         while(id1 <= n and !foi[id1]) id1++;
                         cout << id1 <<    ;
                         id1++;
                     }
                     else {
                         while(id2 <= n and foi[id2]) id2++;
                         cout << id2 <<    ;
                         id2++;
                     }
                 }
                 cout << endl;
             }

         }
         else {
             cout << -1 << endl;
         }
     }

     // verificar limites, long long
     return 0;
 }


#include <bits/stdc++.h>
 #pragma GCC optimize( Ofast )
 #pragma GCC optimization( unroll-loops )
 std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},
                             {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
 using namespace std;
 const long long mod = 998244353;
 long long nop = 70;
 vector<int> primes(nop + 1, 1);
 void sieve() {
   primes[1] = primes[0] = 0;
   for (long long i = 2; i * i <= nop; i++) {
     if (primes[i]) {
       for (long long j = i * i; j <= nop; j += i) {
         primes[j] = 0;
       }
     }
   }
 }
 long long gcd(long long a, long long b) {
   if (b > a) swap(b, a);
   if (b == 0) return a;
   return gcd(b, a  b);
 }
 void extgcd(long long a, long long b, long long& x, long long& y) {
   if (a == 0) {
     x = a;
     y = b;
     return;
   }
   extgcd(b  a, a, x, y);
   long long y1 = y, x1 = x;
   x = y1 - (b / a) * x1;
   y = x1;
 }
 long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
 long long bexp(long long num, long long e) {
   long long ans = 1;
   while (e > 0) {
     if (e & 1) {
       ans *= num;
     }
     num *= num;
     e >>= 1;
   }
   return ans;
 }
 long long mexp(long long num, long long e) {
   long long ans = 1;
   while (e > 0) {
     if (e & 1) {
       ans = (ans * num)  mod;
     }
     num *= num;
     num = mod;
     e >>= 1;
   }
   return ans  mod;
 }
 long long modinv(long long a) {
   a = mod;
   return mexp(a, mod - 2);
 }
 void solve() {
   long long n, k;
   cin >> n >> k;
   string s;
   cin >> s;
   sort(s.begin(), s.end());
   vector<long long> cnt(26, 0);
   for (long long i = 0; i < (n); i++) {
     cnt[s[i] - 'a']++;
   }
   int first = -1, last = -1, nod = 0;
   for (long long i = 0; i < (26); i++) {
     if (cnt[i]) {
       nod++;
       if (first == -1) first = i;
       last = i;
     }
   }
   if (cnt[first] < k) {
     cout << s[k - 1] <<
 ;
     return;
   }
   string worst =   ;
   worst += char('a' + first);
   if (nod >= 3 || (nod == 2 && cnt[first] > k)) {
     for (long long i = k; i < n; i++) {
       worst += s[i];
     }
   } else {
     for (long long i = k; i < n; i++) {
       worst += s[i];
       i += (k - 1);
     }
   }
   cout << worst <<
 ;
 }
 int main() {
   cin.tie(0);
   cout.tie(0);
   ios::sync_with_stdio(0);
   int t = 1;
   cin >> t;
   for (long long T = 1; T <= (t); T++) {
     solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 1e5 + 5;
 int n, a[maxn];
 struct node {
   int pre;
   bool flag;
   int other;
 } num[2 * maxn];
 int main(int argc, char const *argv[]) {
   while (cin >> n) {
     bool flag = true;
     for (int i = 0; i <= n; i++) {
       cin >> a[i];
       if (a[i] != 1) flag = false;
     }
     if (flag == true) {
       cout <<  perfect  << endl;
       continue;
     }
     bool temp = false;
     bool ans = false;
     int cnt = 1;
     for (int i = 0; i <= n; i++) {
       if (i > 0 && a[i] > 1 && a[i - 1] > 1 && ans == false) {
         ans = true;
         int par = cnt - 1;
         int k = a[i];
         k--;
         while (k--) {
           num[cnt].pre = par;
           num[cnt].other = par - 1;
           num[cnt].flag = true;
           cnt++;
         }
         num[cnt].pre = num[cnt].other = par;
         num[cnt].flag = true;
         cnt++;
       } else {
         int par = cnt - 1;
         int k = a[i];
         while (k--) {
           num[cnt].pre = par;
           num[cnt].flag = false;
           cnt++;
         }
       }
     }
     if (ans == false) {
       cout <<  perfect  << endl;
       continue;
     }
     cout <<  ambiguous  << endl;
     for (int i = 1; i < cnt; i++) cout << num[i].pre <<    ;
     cout << endl;
     for (int i = 1; i < cnt; i++) {
       if (num[i].flag == false)
         cout << num[i].pre;
       else
         cout << num[i].other;
       cout <<    ;
     }
     cout << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int mymax(int x) {
   int max = 0;
   while (x) {
     int s = x  10;
     if (s > max) max = s;
     x /= 10;
   }
   return max;
 }
 int zh(int x, int n) {
   int s = 0, p = 1;
   while (x) {
     s += x  10 * p;
     x /= 10;
     p *= n;
   }
   return s;
 }
 int main() {
   int a, b;
   cin >> a >> b;
   int n = max(mymax(a), mymax(b)) + 1;
   int num = zh(a, n) + zh(b, n);
   int j = 0;
   while (num) {
     int s = num  n;
     num /= n;
     j++;
   }
   cout << j << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 class Constellation {
   static const long long N = 100010;
   inline long long sign(long long x) { return x > 0 ? 1 : x == 0 ? 0 : -1; }
   struct point {
     long long x, y, num;
   } b[N];
   long long n;
   long long cross(const point &a, const point &b, const point &c) {
     return sign((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x));
   }
   bool contain(const point &a, const point &b, const point &c, const point &p) {
     long long v1 = cross(a, b, p), v2 = cross(b, c, p), v3 = cross(c, a, p);
     return v1 * v2 >= 0 && v2 * v3 >= 0 && v3 * v1 >= 0;
   }

  public:
   void solve() {
     cin >> n;
     for (long long i = 1; i <= n; ++i) cin >> b[i].x >> b[i].y;
     long long p1 = 1, p2 = 2, p3 = 0;
     for (long long i = 3; i <= n; ++i)
       if (cross(b[p1], b[p2], b[i])) {
         p3 = i;
         break;
       }
     for (long long i = 1; i <= n; ++i)
       if (i != p1 && i != p2 && i != p3 && contain(b[p1], b[p2], b[p3], b[i])) {
         if (cross(b[p1], b[p2], b[i]))
           p3 = i;
         else
           p2 = i;
       }
     cout << p1 << ' ' << p2 << ' ' << p3 << endl;
   }
 } T;
 int main() { T.solve(); }


#include <bits/stdc++.h>
 double eps = 1e-9;
 using namespace std;
 int main() {
   std::ios::sync_with_stdio(false);
   int x, y, z, w, b, a;
   cin >> x >> y >> z >> w >> b >> a;
   cout << (2 * (2 * x + a + y) * (z + y) - (a * a + b * b + y * y + z * z)) / 2;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int dirx[] = {1, 0, -1, 0};
 int diry[] = {0, 1, 0, -1};
 int a;
 vector<int> graph[100005];
 int dist[100005];
 bool visit[100005];
 int cnt = 0;
 bool flag = false;
 int dfs(int u, int par) {
   visit[u] = true;
   for (int i = 0; i < graph[u].size(); i++) {
     if (!visit[graph[u][i]]) dist[u] += dfs(graph[u][i], u);
   }
   if (dist[u] != 0 && (dist[u] + 1)  2 == 0) {
     cnt++;
     dist[u] = 0;
     return 0;
   } else
     return 1;
 }
 int main() {
   scanf( d , &a);
   int x, y;
   int start = 0;
   for (int i = 0; i < a - 1; i++) {
     scanf( d d , &x, &y);
     start = x;
     graph[x].push_back(y);
     graph[y].push_back(x);
   }
   if (a  2 == 1) {
     cout << -1 << endl;
     return 0;
   }
   dfs(start, 0);
   cout << cnt - 1 << endl;
 }


#include <bits/stdc++.h>
 #pragma comment(linker,  /STACK:167772160000 )
 using namespace std;
 long long dp[5100][5100];
 long long x[5100];
 int a[5100], b[5100], c[5100], d[5100];
 int main() {
   int leftminright = 0;
   int n, s, e;
   cin >> n >> s >> e;
   s--;
   e--;
   for (int i = 0; i < n; i++) cin >> x[i];
   for (int i = 0; i < n; i++) cin >> a[i];
   for (int i = 0; i < n; i++) cin >> b[i];
   for (int i = 0; i < n; i++) cin >> c[i];
   for (int i = 0; i < n; i++) cin >> d[i];
   x[n] = 0;
   for (int i = 0; i < n + 2; i++)
     for (int j = 0; j < n + 2; j++) dp[i][j] = 1E18;
   dp[0][0] = 0;
   for (int i = 0; i < n; i++) {
     for (int j = 0; j < n; j++) {
       if (i != 0) {
         if (j == 0 && leftminright != 1) continue;
       }
       if (i == s) {
         leftminright--;
         long long now = dp[i][j];
         now += d[i];
         dp[i + 1][j + 1] =
             min(dp[i + 1][j + 1],
                 now + (x[i + 1] - x[i]) * ((j + 1) * 2 + leftminright));
         now -= d[i];
         now += c[i];
         if (j + leftminright + 1 > 0)
           dp[i + 1][j] = min(dp[i + 1][j],
                              now + (x[i + 1] - x[i]) * (j * 2 + leftminright));
         leftminright++;
         continue;
       }
       if (i == e) {
         leftminright++;
         long long now = dp[i][j];
         now += b[i];
         dp[i + 1][j] =
             min(dp[i + 1][j], now + (x[i + 1] - x[i]) * (j * 2 + leftminright));
         now -= b[i];
         now += a[i];
         if (j == 0) {
           leftminright--;
           continue;
         }
         dp[i + 1][j - 1] =
             min(dp[i + 1][j - 1],
                 now + (x[i + 1] - x[i]) * (2 * (j - 1) + leftminright));
         leftminright--;
         continue;
       }
       long long now = dp[i][j];
       now += b[i];
       now += d[i];
       dp[i + 1][j + 1] =
           min(dp[i + 1][j + 1],
               now + (x[i + 1] - x[i]) * ((j + 1) * 2 + leftminright));
       now -= d[i];
       now += c[i];
       if (j + leftminright > 0)
         dp[i + 1][j] =
             min(dp[i + 1][j], now + (x[i + 1] - x[i]) * (j * 2 + leftminright));
       now -= b[i];
       now += a[i];
       now -= c[i];
       now += d[i];
       if (j > 0)
         dp[i + 1][j] =
             min(dp[i + 1][j], now + (x[i + 1] - x[i]) * (j * 2 + leftminright));
       now -= d[i];
       now += c[i];
       if (j > 0 && j + leftminright > 0)
         dp[i + 1][j - 1] =
             min(dp[i + 1][j - 1],
                 now + (x[i + 1] - x[i]) * ((j - 1) * 2 + leftminright));
     }
     if (i == s) leftminright--;
     if (i == e) leftminright++;
   }
   cout << dp[n][0];
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const double PI = acos(-1.0);
 const double EPS = 1e-8;
 const long long INF = 0x3f3f3f3f3f3f3f3f;
 inline long long readll() {
   long long x(0), op(1);
   char ch = getchar();
   while (ch < '0' || ch > '9') {
     if (ch == '-') op = -1;
     ch = getchar();
   }
   while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
   return x * op;
 }
 const int sz = 2e5 + 9;
 long long a[sz], n;
 long long solve(long long a, long long b) {
   if (a == 0 || a == b) return 0;
   int l = 1, r = n;
   if (b) {
     if (b < a)
       l = b + 1;
     else
       r = b - 1;
   }
   return (a - l + 1) * (r - a + 1);
 }
 int main() {
   n = readll();
   for (int i = 1; i < n + 1; ++i) a[i] = readll();
   a[0] = a[n + 1] = 0;
   long long ans = 0;
   for (int i = 0; i < n + 1; ++i) {
     ans += solve(a[i], a[i + 1]);
     ans += solve(a[i + 1], a[i]);
   }
   cout << ans / 2 << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int max_n = 200222, inf = 1000111222;
 int n, m, a[max_n];
 bool check(int cnt) {
   long long sum = 0;
   int last = 1;
   for (int i = 0; i < n; ++i) {
     if (i  cnt == 0) --last;
     if (a[i] + last < 0) break;
     sum += (a[i] + last);
   }
   return sum >= m;
 }
 int main() {
   scanf( dd , &n, &m);
   for (int i = 0; i < n; ++i) scanf( d , &a[i]);
   sort(a, a + n);
   reverse(a, a + n);
   int l = 0, r = n + 1;
   while (r - l > 1) {
     int mid = (l + r) / 2;
     if (check(mid))
       r = mid;
     else
       l = mid;
   }
   if (r > n)
     puts( -1 );
   else
     printf( d
 , r);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long t[4 * 100100], dp[100100], a[100100], b[100100];
 long long K = 1, n, m;
 void build() {
   while (K < m + 2) K <<= 1;
 }
 long long query(long long l, long long r) {
   long long ans = 0;
   for (l += K - 1, r += K + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
     if (~l ^ 1) ans = ((ans) >= (t[l + 1]) ? (ans) : (t[l + 1]));
     if (r ^ 1) ans = ((ans) >= (t[r - 1]) ? (ans) : (t[r - 1]));
   }
   return ans;
 }
 void update(long long id, long long v) {
   for (t[id += K] = v, id >>= 1; id >= 1; id >>= 1)
     t[id] = max(t[id << 1 | 1], t[id << 1]);
 }
 long long get_id(long long x) {
   long long l = 1, r = m, mid;
   while (l < r) {
     mid = (l + r + 1) >> 1;
     if (b[mid] > x)
       r = mid - 1;
     else
       l = mid;
   }
   return l;
 }
 void unique() {
   m = 1;
   for (long long i = 2; i <= n; i++)
     if (b[i] != b[m]) b[++m] = b[i];
 }
 void input() {
   scanf( extra , &n);
   for (long long i = 1, r, h; i <= n; i++) {
     scanf( extraextra , &r, &h);
     a[i] = b[i] = r * r * h;
   }
   return;
 }
 void init() {
   sort(b + 1, b + n + 1);
   unique();
   build();
   return;
 }
 void work() {
   for (long long i = 1; i <= n; i++) {
     long long id = get_id(a[i]);
     dp[i] = query(1, id - 1) + a[i];
     update(id, dp[i]);
   }
   return;
 }
 void output() {
   printf( .15lf , query(1, m) * M_PI);
   return;
 }
 int main() {
   input();
   init();
   work();
   output();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, k, c[100005], visit[100005], tp = 0;
 vector<int> a[100005], ans;
 bool ok[100005];
 void dfs(int u) {
   visit[u] = tp;
   for (int i = 0; i < a[u].size(); i++) {
     int v = a[u][i];
     if (ok[v]) continue;
     if (visit[v] == tp) {
       cout << -1;
       exit(0);
     } else
       dfs(v);
   }
   ans.push_back(u);
   ok[u] = 1;
 }
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cin >> n >> k;
   for (int i = 1; i <= k; i++) cin >> c[i];
   for (int i = 1; i <= n; i++) {
     int t;
     cin >> t;
     while (t--) {
       int u;
       cin >> u;
       a[i].push_back(u);
     }
   }
   for (int i = 1; i <= k; i++) {
     if (!visit[c[i]]) {
       tp++;
       dfs(c[i]);
     }
   }
   cout << ans.size() << '
';
   for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long int n;
   cin >> n;
   long long int sum = n * (n - 1) / 2;
   if (n == 0) {
     cout << 0;
     return 0;
   }
   if ((n  2 == 0 && n  4 != 0) || (n  2 == 1 && n  4 != 3))
     cout << 1;
   else
     cout << 0;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <typename F, typename S>
 ostream &operator<<(ostream &os, const pair<F, S> &p) {
   return os <<  (  << p.first <<  ,   << p.second <<  ) ;
 }
 template <typename T>
 ostream &operator<<(ostream &os, const vector<T> &v) {
   os <<  { ;
   typename vector<T>::const_iterator it;
   for (it = v.begin(); it != v.end(); it++) {
     if (it != v.begin()) os <<  ,  ;
     os << *it;
   }
   return os <<  } ;
 }
 template <typename T>
 ostream &operator<<(ostream &os, const set<T> &v) {
   os <<  [ ;
   typename set<T>::const_iterator it;
   for (it = v.begin(); it != v.end(); it++) {
     if (it != v.begin()) os <<  ,  ;
     os << *it;
   }
   return os <<  ] ;
 }
 template <typename F, typename S>
 ostream &operator<<(ostream &os, const map<F, S> &v) {
   os <<  [ ;
   typename map<F, S>::const_iterator it;
   for (it = v.begin(); it != v.end(); it++) {
     if (it != v.begin()) os <<  ,  ;
     os << it->first <<   =   << it->second;
   }
   return os <<  ] ;
 }
 int n, m;
 string hor, ver;
 int give_dir(char ch) {
   if (ch == '>' || ch == 'v')
     return 1;
   else
     return -1;
 }
 bool valid(int x, int y) {
   if (x < 0 || y < 0 || x >= n || y >= m) return false;
   return true;
 }
 void dfs(int x, int y, vector<vector<bool> > &visited) {
   visited[x][y] = true;
   int nx, ny;
   nx = x + give_dir(ver[y]);
   ny = y + give_dir(hor[x]);
   if (valid(nx, y) && !visited[nx][y]) dfs(nx, y, visited);
   if (valid(x, ny) && !visited[x][ny]) dfs(x, ny, visited);
 }
 int main() {
   cin >> n >> m;
   cin >> hor >> ver;
   for (int k = 0; k < (n); k++) {
     for (int l = 0; l < (m); l++) {
       vector<vector<bool> > visited(n, vector<bool>(m, false));
       dfs(k, l, visited);
       for (int i = 0; i < (n); i++) {
         for (int j = 0; j < (m); j++) {
           if (!visited[i][j]) {
             cout <<  NO  << endl;
             return 0;
           }
         }
       }
     }
   }
   cout <<  YES  << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 #define me(a, b) memset(a, b, sizeof(a))
 #define IOS() ios::sync_with_stdio(false), cin.tie(0)
 #define endl '
'

 typedef long long ll;
 typedef pair<ll, ll> pll;
 typedef pair<int, int> pii;
 const int INF = 0x3f3f3f3f;
 const int maxn = 2e5 + 5;
 const ll mod = 1e9 + 7;

 int cnt[26];
 int n, k;
 vector<pii> ans;
 int check()
 {
 	ans.clear();
 	int sum = 0;
 	for(int i = 0; i < 26; ++i) {
 		int r = cnt[i]  k;
 		if(r){
 			ans.push_back(pii(i, k - r));
 			sum += k - r;
 		}
 	}
 	return sum;
 }

 void solve()
 {
 	me(cnt, 0);
 	string s;
 	cin >> n >> k >> s;
 	for(char &c : s)
 		++cnt[c - 'a'];
 	if(check() == 0) {
 		cout << s << endl;
 		return ;
 	}
 	for(int i = s.size()-1; i >= 0; --i) {
 		char &c = s[i];
 		--cnt[c - 'a'];
 		for(int j = s[i] - 'a' + 1; j < 26; ++j) {
 			c = j + 'a';
 			++cnt[j];
 			int sum = s.size()-i-1 - check();
 			--cnt[j];
 			if(sum >= 0 && sum  k == 0) {
 				string t;
 				for(int p = 0; p <= i; ++p)
 					t.push_back(s[p]);
 				t.append(sum, 'a');
 				for(pii p : ans) {
 					t.append(p.second, p.first+'a');
 				}
 				cout << t << endl;
 				return ;
 			}

 		}
 	}
 	cout <<  -1
 ;
 }

 int main()
 {
 	IOS();
 	int T;
 	cin >> T;
 	while(T--)
 		solve();
 	return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int f[100001], g[100001], h[100001];
 int n, cnt;
 bool work() {
   cnt = -1;
   for (int i = 0; i < n; ++i) {
     if (g[i] != -1) {
       if (f[i] != i) return false;
     } else {
       if (g[f[i]] == -1) {
         g[i] = ++cnt;
         h[cnt] = f[i];
         g[f[i]] = cnt;
       } else {
         if (h[g[f[i]]] != f[i]) return false;
         h[g[f[i]]] = f[i];
         g[i] = g[f[i]];
       }
     }
   }
   return true;
 }
 int main() {
   cin >> n;
   for (int i = 0; i < n; ++i) cin >> f[i];
   for (int i = 0; i < n; ++i) --f[i];
   for (int i = 0; i < n; ++i) g[i] = h[i] = -1;
   if (work()) {
     cout << ++cnt << endl;
     for (int i = 0; i < n; ++i) cout << ++g[i] << ' ';
     cout << endl;
     for (int i = 0; i < cnt; ++i) cout << ++h[i] << ' ';
   } else
     cout << -1 << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long int n;
   cin >> n;
   cout << n / 2 + 1;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxl = 200005;
 int T, n, mk, seq[maxl];
 char s[maxl];
 inline char read() {
   char ch = getchar();
   while (ch != '<' && ch != '>') ch = getchar();
   return ch;
 }
 int main() {
   scanf( d , &T);
   while (T--) {
     scanf( d , &n);
     mk = 0;
     memset(seq, 0, sizeof(seq));
     for (register int i = 1; i < n; i++) s[i] = read();
     s[0] = '>';
     s[n] = '<';
     for (register int i = n; i; i--)
       if (s[i - 1] == '>' && s[i] == '<') seq[i] = ++mk;
     mk = n;
     for (register int i = 1, j, tmp; i <= n; i++) {
       if (seq[i]) continue;
       if (s[i - 1] == '>')
         seq[i] = mk--;
       else {
         for (j = i; s[j] != '>' && j < n; j++)
           ;
         tmp = j;
         for (; j >= i; j--) seq[j] = mk--;
         i = tmp;
       }
     }
     for (register int i = 1; i <= n; i++) printf( d  , seq[i]);
     printf(
 );
     memset(seq, 0, sizeof(seq));
     mk = 0;
     for (register int i = 1; i <= n; i++)
       if (s[i - 1] == '>' && s[i] == '<') seq[i] = ++mk;
     mk = n;
     for (register int i = n, j, tmp; i; i--) {
       if (seq[i]) continue;
       if (s[i] == '<')
         seq[i] = mk--;
       else {
         for (j = i; s[j - 1] != '<' && j > 1; j--)
           ;
         tmp = j;
         for (; j <= i; j++) seq[j] = mk--;
         i = tmp;
       }
     }
     for (register int i = 1; i <= n; i++) printf( d  , seq[i]);
     printf(
 );
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ifstream in( date.in );
   ofstream out( date.out );
   long long nr2, k, rez[4001], con = 0, nr, n, pli[4001], plp[4001], inc[4001],
                                i, j;
   cin >> n;
   for (i = 1; i <= n; i++) cin >> pli[i] >> plp[i] >> inc[i];
   for (i = 1; i <= n; i++) {
     nr = nr2 = 0;
     if (inc[i] >= 0) {
       rez[++con] = i;
       nr = pli[i];
       for (j = i + 1; nr > 0 && j <= n; j++) {
         if (inc[j] >= 0) {
           inc[j] -= nr--;
         } else {
           if (pli[j]) {
             inc[j] -= nr;
             pli[j] = 0;
             nr2 = plp[j];
             for (k = j + 1; k <= n; k++) inc[k] -= nr2;
           }
         }
       }
     } else {
       if (pli[i]) {
         pli[i] = 0;
         nr2 = plp[i];
         for (k = i + 1; k <= n; k++) inc[k] -= nr2;
       }
     }
   }
   cout << con << '
';
   for (j = 1; j <= con; j++) cout << rez[j] <<    ;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int mod = 1000000007;
 const int N = 128;
 int num[N];
 int main() {
   int n;
   cin >> n;
   for (int i = 1; i <= n; ++i) {
     cin >> num[i];
   }
   int m;
   cin >> m;
   for (int i = 0; i < m; ++i) {
     int x, y;
     cin >> x >> y;
     num[x - 1] += y - 1;
     num[x + 1] += num[x] - y;
     num[x] = 0;
   }
   for (int i = 1; i <= n; ++i) {
     cout << num[i] << endl;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int p[3010000], n;
 int main() {
   scanf( d , &n);
   for (int i = 1; i < n + 1; i++) p[i] = i;
   for (int i = 2; i < n + 1; i++) {
     int s = p[i - 1], ns;
     for (int j = i - 1; j <= n + i - 2; j += i) {
       ns = p[j + i];
       if (j + i <= n + i - 2)
         p[j + i] = s;
       else
         p[n + i - 1] = s;
       s = ns;
     }
   }
   for (int i = 1; i < n + 1; i++) printf( d  , p[n - 1 + i]);
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int arr[101];
   int n;
   cin >> n;
   for (int i = 0; i < n; i++) {
     cin >> arr[i];
   }
   sort(arr, arr + n);
   for (int i = 0; i < n; i++) {
     cout << arr[i] <<    ;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1e6 + 100;
 long long arr[N], d[N], tree[N << 2], mx[N << 2];
 void build(int rt, int l, int r) {
   if (l == r) {
     tree[rt] = mx[rt] = arr[l];
     return;
   }
   int m = (l + r) / 2;
   build(rt << 1, l, m);
   build(rt << 1 | 1, m + 1, r);
   tree[rt] = tree[rt << 1] + tree[rt << 1 | 1];
   mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]);
 }
 void update(int L, int R, int rt, int l, int r) {
   if (mx[rt] <= 2) return;
   if (l == r) {
     tree[rt] = mx[rt] = d[tree[rt]];
     return;
   }
   int m = (l + r) >> 1;
   if (L <= m) update(L, R, rt << 1, l, m);
   if (R > m) update(L, R, rt << 1 | 1, m + 1, r);
   tree[rt] = tree[rt << 1] + tree[rt << 1 | 1];
   mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]);
 }
 long long query(int L, int R, int rt, int l, int r) {
   if (L <= l && r <= R) {
     return tree[rt];
   }
   int m = (l + r) >> 1;
   long long ans = 0;
   if (L <= m) ans += query(L, R, rt << 1, l, m);
   if (R > m) ans += query(L, R, rt << 1 | 1, m + 1, r);
   return ans;
 }
 int main() {
   ios::sync_with_stdio(false);
   int n, m, t, l, r;
   for (int i = 1; i < N; i++) {
     for (int j = i; j < N; j += i) d[j]++;
   }
   cin >> n >> m;
   for (int i = 1; i <= n; i++) cin >> arr[i];
   build(1, 1, n);
   while (m--) {
     cin >> t >> l >> r;
     if (t == 1)
       update(l, r, 1, 1, n);
     else
       cout << query(l, r, 1, 1, n) << endl;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class T>
 inline bool fs(T &x) {
   int c = getchar();
   int sgn = 1;
   while (~c && c < '0' || c > '9') {
     if (c == '-') sgn = -1;
     c = getchar();
   }
   for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
   x *= sgn;
   return ~c;
 }
 int main() {
   long long int n, m, cnt = 0;
   fs(n);
   fs(m);
   for (long long int i = 1; i * i <= m; i++) {
     if (m  i == 0 && m / i <= n) {
       if (m / i != i) cnt++;
       cnt++;
     }
   }
   cout << cnt << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int solve(vector<pair<int, int> > v, int price) {
   if (v.size() < 2) return 0;
   vector<int> p, b;
   for (int i = 0; i < v.size(); i++)
     p.push_back(v[i].first), b.push_back(v[i].second);
   int amx[v.size()];
   amx[0] = b[0];
   for (int i = 1; i < b.size(); i++) amx[i] = max(amx[i - 1], b[i]);
   int ans = 0;
   for (int i = 0; i < v.size(); i++) {
     int id = upper_bound(p.begin(), p.begin() + i, price - p[i]) - p.begin();
     id--;
     if (id < 0 || id >= v.size()) continue;
     if (id != i) ans = max(ans, b[i] + amx[id]);
   }
   return ans;
 }
 int main() {
   int i, j, k;
   int n, m;
   int c, d;
   int x, y;
   char ch;
   cin >> n >> c >> d;
   int mc = 0, md = 0;
   vector<pair<int, int> > coins, diamonds;
   for (i = 0; i < n; i++) {
     cin >> x >> y >> ch;
     if (ch == 'C') {
       if (c >= y) mc = max(mc, x), coins.push_back({y, x});
     } else {
       if (d >= y) md = max(md, x), diamonds.push_back({y, x});
     }
   }
   int ans = 0;
   if (mc > 0 && md > 0) ans = mc + md;
   sort(coins.begin(), coins.end());
   sort(diamonds.begin(), diamonds.end());
   ans = max(ans, solve(coins, c));
   ans = max(ans, solve(diamonds, d));
   printf( d  , ans);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int _, n;
 char s[100005];
 int main() {
   scanf( d , &_);
   while (_--) {
     scanf( d , &n);
     s[0] = 'a';
     scanf( s , s + 1);
     int p = -1;
     for (int i = n; i >= 1; i--) {
       if (s[i] == '0') {
         p = i;
         break;
       }
     }
     bool f = 0;
     for (int i = 1; i <= n; i++) {
       if (s[i] == '1') {
         if (s[i + 1] == '0')
           f = 1;
         else
           f = 0;
         if (i < p) {
           continue;
         }
         printf( 1 );
       } else {
         if (f) {
           printf( 0 );
           i = p;
           continue;
         }
         printf( 0 );
       }
     }
     puts(  );
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, ans, notOK;
 map<int, int> M;
 int main() {
   cin >> n;
   for (int i = 0, x; i < n; i++) cin >> x, M[x]++;
   for (map<int, int>::iterator it = M.begin(); it != M.end(); it++) {
     if (it->first) {
       if (it->second == 2)
         ans++;
       else if (it->second > 2)
         notOK = 1;
     }
   }
   cout << (notOK ? -1 : ans);
 }


#include <bits/stdc++.h>
 using namespace std;
 void actionFun() {
   long long n;
   cin >> n;
   long long c = 2;
   for (int i = 0; i < n; i++) {
     cout << c << ' ';
     ++c;
   }
   cout << endl;
   return;
 }
 int main() {
   int t;
   cin >> t;
   while (t--) {
     actionFun();
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   while (~scanf( d , &n)) {
     int cnt = 0;
     for (int i = 1; i < n; i++) {
       for (int j = i + 1; j < n; j++) {
         int sum = i * i + j * j;
         if (sum <= n * n) {
           if ((int)sqrt(sum) * (int)sqrt(sum) == sum) cnt++;
         }
       }
     }
     printf( d
 , cnt);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios_base::sync_with_stdio(false), cin.tie(NULL);
   long long n;
   cin >> n;
   vector<long long> a(n);
   for (int i = 0; i < n; i++) {
     cin >> a[i];
   }
   if (n == 1) {
     cout <<  YES ;
     return 0;
   }
   vector<long long> v;
   long long cnt0 = 1;
   for (int i = 1; i < n; i++) {
     if (a[i] != a[i - 1]) {
       v.push_back(cnt0);
       cnt0 = 1;
     } else
       cnt0++;
     if (i == n - 1) {
       v.push_back(cnt0);
     }
   }
   long long cnt = 1;
   for (int i = 0; i < v.size(); i++) {
     if (v[i] == v[i + 1]) cnt++;
   }
   if (cnt == v.size())
     cout <<  YES ;
   else
     cout <<  NO ;
 }


#include <bits/stdc++.h>
 using namespace std;
 #pragma GCC push_options
 #pragma GCC optimize( unroll-loops )
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   long long int INF = 10e18;
   long long t;
   cin >> t;
   while (t--) {
     long long n;
     cin >> n;
     long long a[n], b[n], c[n];
     for (long long i = 0; i < n; i++) {
       cin >> a[i] >> b[i];
     }
     for (long long i = 1; i <= n; i++) {
       c[i  n] = max(0ll, a[i  n] - b[i - 1]);
     }
     long long sum = accumulate(c, c + n, 0ll);
     long long res = INF;
     for (long long i = 0; i < n; i++) {
       res = min(res, sum + a[i] - c[i]);
     }
     cout << res << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int contrib[312345] = {0};
 bool in_set[312345] = {0};
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n, k;
   cin >> n >> k;
   vector<int> ans;
   int cnt = 0;
   for (int i = 1; i <= n / 2; i++) {
     if (cnt + contrib[i] <= k) {
       ans.push_back(i);
       in_set[i] = true;
       cnt += contrib[i];
       for (int j = i + i; j <= n; j += i) contrib[j]++;
     } else {
       while (cnt + contrib[i] > k) {
         cnt -= contrib[ans.back()];
         for (int j = ans.back() + ans.back(); j <= n; j += ans.back())
           contrib[j]--;
         in_set[ans.back()] = false;
         ans.pop_back();
       }
       ans.push_back(i);
       in_set[i] = true;
       cnt += contrib[i];
       for (int j = i + i; j <= n; j += i) contrib[j]++;
     }
     if (cnt == k) break;
   }
   priority_queue<pair<int, int> > pq;
   for (int i = n / 2 + 1; i <= n; i++) {
     if (in_set[i]) continue;
     pq.push(make_pair(contrib[i], i));
   }
   while (!pq.empty()) {
     while (!pq.empty() && cnt + pq.top().first > k) pq.pop();
     if (pq.empty()) break;
     cnt += pq.top().first;
     ans.push_back(pq.top().second);
     pq.pop();
   }
   if (cnt != k) {
     cout <<  No  << endl;
     return 0;
   }
   cout <<  Yes  << endl;
   cout << ans.size() << endl;
   for (int i = 0; i < ans.size(); i++) {
     if (i) cout <<    ;
     cout << ans[i];
   }
   cout << endl;
 }


#include <bits/stdc++.h>
 #pragma GCC optimize(2)
 using namespace std;
 void qread(int &x) {
   int neg = 1;
   x = 0;
   char c = getchar();
   while (c < '0' || c > '9') {
     if (c == '-') neg = -1;
     c = getchar();
   }
   while (c >= '0' && c <= '9') x = 10 * x + c - '0', c = getchar();
   x *= neg;
 }
 const int maxn = 200005;
 char c[maxn];
 int n, m;
 string s, t;
 int main() {
   scanf( dd , &n, &m);
   scanf( s , c);
   s = c;
   scanf( s , c);
   t = c;
   bool ok = false;
   for (int(i) = 0; (i) < n; i++)
     if (s[i] == '*') ok = true;
   if (!ok) {
     puts(s == t ?  YES  :  NO );
     return 0;
   }
   int pre = 0, suf = 0;
   while (s[pre] != '*' && s[pre] == t[pre]) pre++;
   while (s[n - suf - 1] != '*' && s[n - suf - 1] == t[m - suf - 1]) suf++;
   if (s[pre] == '*' && s[n - suf - 1] == '*' && pre - 1 < m - suf)
     puts( YES );
   else
     puts( NO );
   return 0;
 }


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


#include <bits/stdc++.h>
 using namespace std;
 using int64 = long long;
 using pii = pair<int, int>;
 using vchar = vector<char>;
 using vvchar = vector<vchar>;
 using vint = vector<int>;
 using vint64 = vector<int64>;
 using vvint = vector<vint>;
 using vbool = vector<bool>;
 using vpii = vector<pii>;
 template <typename T>
 T sqr(T x) {
   return x * x;
 }
 template <typename T>
 T gcd(T a, T b) {
   return b == 0 ? a : gcd(b, a  b);
 }
 pair<int, vint> solveD(vvint g, int k) {
   enum { NOT_VISITED, STARTED, FINISHED };
   const int n = g.size();
   vint depth(n, -1);
   depth[0] = 0;
   vint parent(n, -1);
   vint loopState(n, NOT_VISITED);
   pair<int, vint> result;
   result.first = 0;
   std::function<void(int)> DFS = [&](int v) {
     loopState[v] = STARTED;
     const int previous = parent[v];
     if (result.first != 0) return;
     int backVertex = -1;
     int backDepth = -1;
     for (auto to : g[v]) {
       if (to == previous) continue;
       if (loopState[to] == STARTED && depth[to] > backDepth) {
         backVertex = to;
         backDepth = depth[to];
       }
     }
     if (backVertex != -1) {
       vint loop;
       for (int u = v; u != backVertex; u = parent[u]) {
         loop.push_back(u);
       }
       loop.push_back(backVertex);
       reverse(std::begin(loop), std::end(loop));
       assert(depth[v] - depth[backVertex] + 1 == loop.size());
       const int loopLength = loop.size();
       if (loopLength > k) {
         result.first = 1;
         for (int i = 0; i < loop.size(); i += 2) {
           result.second.push_back(loop[i]);
         }
         result.second.resize((k + 1) / 2);
       } else {
         result.first = 2;
         result.second = loop;
       }
       return;
     }
     for (auto to : g[v]) {
       if (loopState[to] == NOT_VISITED) {
         parent[to] = v;
         depth[to] = depth[v] + 1;
         DFS(to);
         if (result.first != 0) return;
       }
     }
     loopState[v] = FINISHED;
   };
   DFS(0);
   if (result.first != 0) {
     return result;
   }
   vint colors(n, -1);
   std::function<void(int, int)> biColor = [&](int v, int color) {
     colors[v] = color;
     for (auto to : g[v]) {
       if (colors[to] == -1) {
         biColor(to, 1 - color);
       }
     }
   };
   biColor(0, 0);
   int colorCount[2] = {0};
   for (int i = 0; i < n; ++i) {
     colorCount[colors[i]]++;
   }
   const int bestColor = colorCount[0] > colorCount[1] ? 0 : 1;
   result.first = 1;
   for (int i = 0; i < n; ++i) {
     if (colors[i] == bestColor) {
       result.second.push_back(i);
     }
   }
   result.second.resize((k + 1) / 2);
   return result;
 }
 int main() {
   int T = 1;
   std::ios::sync_with_stdio(false);
   while (T--) {
     int n;
     cin >> n;
     ;
     int m;
     cin >> m;
     ;
     int k;
     cin >> k;
     ;
     vvint g(n);
     while (m--) {
       int u;
       cin >> u;
       ;
       int v;
       cin >> v;
       ;
       u--, v--;
       g[u].push_back(v);
       g[v].push_back(u);
     }
     auto result = solveD(g, k);
     assert(result.first == 1 || result.first == 2);
     cout << result.first << endl;
     for (int& v : result.second) {
       v++;
     }
     if (result.first == 2) {
       cout << result.second.size() << endl;
     }
     std::copy(std::begin(result.second), std::end(result.second),
               ostream_iterator<int>(cout,    ));
     cout << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int a[500000];
 int mina, maxa;
 int n, k;
 long long sum = 0;
 bool check(int c) {
   sum = 0;
   for (int i = 0; i < n; i++) {
     if (a[i] + c < mina) {
       sum += mina - c - a[i];
     } else {
       break;
     }
   }
   if (sum > k) return false;
   return true;
 }
 bool checkp(int c) {
   sum = 0;
   for (int i = 0; i < n; i++) {
     if (a[i] - c > maxa) {
       sum += a[i] - c - maxa;
     }
   }
   if (sum > k) return false;
   return true;
 }
 int main() {
   scanf( d d , &n, &k);
   long long sum = 0;
   for (int i = 0; i < n; i++) {
     scanf( d , &a[i]);
     sum += a[i];
   }
   if (sum  n == 0) {
     mina = maxa = sum / n;
   } else {
     mina = sum / n;
     maxa = sum / n + 1;
   }
   sort(a, a + n);
   int ll = 0, rr = 1000000000;
   while (ll != rr) {
     int mid = (ll + rr) / 2;
     if (check(mid)) {
       rr = mid;
     } else {
       ll = mid + 1;
     }
   }
   int lll = 0, rrr = 1000000000;
   while (lll != rrr) {
     int mid = (lll + rrr) / 2;
     if (checkp(mid)) {
       rrr = mid;
     } else {
       lll = mid + 1;
     }
   }
   printf( lld , (long long)lll + ll + maxa - mina);
   scanf( d , &n);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, m, s, f, i;
   cin >> n >> m >> s >> f;
   long long t;
   map<long long, pair<int, int>> h;
   pair<int, int> R;
   for (i = 0; i < m; i++) {
     cin >> t >> R.first >> R.second;
     h[t] = R;
   }
   i = 1;
   if (s < f)
     while (s != f) {
       if (h.find(i) == h.end()) {
         cout << 'R';
         s++;
       } else {
         if ((h[i].first <= s && s <= h[i].second) ||
             (h[i].first <= s + 1 && s + 1 <= h[i].second)) {
           cout << 'X';
         } else {
           cout << 'R';
           s++;
         }
       }
       i++;
     }
   else {
     while (s != f) {
       if (h.find(i) == h.end()) {
         cout << 'L';
         s--;
       } else {
         if ((h[i].first <= s && s <= h[i].second) ||
             (h[i].first <= s - 1 && s - 1 <= h[i].second)) {
           cout << 'X';
         } else {
           cout << 'L';
           s--;
         }
       }
       i++;
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   int d[n];
   int total = 0;
   for (int i = 0; i < n; i++) {
     cin >> d[i];
     total += d[i];
   }
   int s, t;
   cin >> s >> t;
   if (s == t) {
     cout << 0;
     return 0;
   }
   if (s > t) swap(s, t);
   int ans = 0;
   for (int i = s; i < t; i++) {
     ans += d[i - 1];
   }
   cout << min(ans, total - ans);
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, m, Q;
 double sy, l[200100], r[200100], sum[200100], zl, zr, x, y, ans;
 struct Node {
   double x, y;
 } bj[2][200100], tmp, L, R;
 inline bool lef(Node u, Node v, Node w) {
   if (u.x == v.x) return w.x < u.x;
   double t;
   t = v.x - (v.x - u.x) * (v.y - w.y) / (v.y - u.y);
   return w.x < t;
 }
 inline double ask(int u) {
   double p, q;
   if (bj[0][u].x == x)
     p = x;
   else {
     p = x - (x - bj[0][u].x) * (y - sy) / y;
   }
   if (bj[1][u].x == x)
     q = x;
   else {
     q = x - (x - bj[1][u].x) * (y - sy) / y;
   }
   return max((double)0, min(q, zr) - max(p, zl));
 }
 int main() {
   int i, j, p, q, mid, a, b;
   cin >> sy >> zl >> zr >> n;
   L.y = R.y = sy, L.x = zl, R.x = zr;
   for (i = 1; i <= n; i++) {
     scanf( lflf , &l[i], &r[i]);
     sum[i] = sum[i - 1] + r[i] - l[i];
     bj[0][i].y = 0, bj[0][i].x = l[i];
     bj[1][i].y = 0, bj[1][i].x = r[i];
   }
   cin >> m;
   for (i = 1; i <= m; i++) {
     scanf( lflf , &x, &y);
     ans = 0;
     tmp.x = x, tmp.y = y;
     for (p = 1, q = n; p < q;) {
       mid = ((p + q) >> 1);
       if (lef(tmp, bj[0][mid], L))
         q = mid;
       else
         p = mid + 1;
     }
     a = p - 1;
     for (p = 1, q = n; p < q;) {
       mid = ((p + q) >> 1);
       if (!lef(tmp, bj[1][mid], R))
         p = mid + 1;
       else
         q = mid;
     }
     b = p;
     printf( .10f
 , ask(a) + ask(b) * (a != b) +
                           max((double)0, sum[b - 1] - sum[a]) * (y - sy) / y);
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 #pragma warning(disable : 4996)
 const int MAX_N = 1000009;
 const long long mod = 998244353;
 long long modpow(long long a, long long b, long long m) {
   long long p = 1, q = a;
   for (int i = 0; i < 32; i++) {
     if ((b / (1LL << i))  2 == 1) {
       p *= q;
       p = m;
     }
     q *= q;
     q = m;
   }
   return p;
 }
 long long N, fact[MAX_N], factinv[MAX_N];
 void init() {
   fact[0] = 1;
   for (int i = 1; i <= 1000000; i++) fact[i] = (1LL * fact[i - 1] * i)  mod;
   for (int i = 0; i <= 1000000; i++) factinv[i] = modpow(fact[i], mod - 2, mod);
 }
 long long ncr(long long n, long long r) {
   if (r < 0 || n < r) return 0;
   return (fact[n] * factinv[r]  mod) * factinv[n - r]  mod;
 }
 int main() {
   cin >> N;
   init();
   long long V1 = modpow(modpow(3, N, mod), N, mod) -
                  modpow((modpow(3, N, mod) - 3LL + mod), N, mod);
   V1 += mod;
   V1 *= 2LL;
   V1 = mod;
   long long V2 = 0;
   for (int i = 1; i <= N; i++) {
     long long E1 = ncr(N, i);
     long long E2 = modpow(3, N - i, mod);
     long long E3 = (E2 + mod - 1)  mod;
     E2 = modpow(E2, N, mod);
     E3 = modpow(E3, N, mod);
     if (i  2 == 1) V2 += E1 * (E2 - E3 + mod);
     if (i  2 == 0) V2 -= E1 * (E2 - E3 + mod);
     while (V2 < 0) V2 += mod * mod;
     V2 = mod;
   }
   V2 *= 3LL;
   V2 = mod;
   cout << (V1 - V2 + mod)  mod << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const long double pi = 4 * atan((long double)1);
 const long long mod = 1e9 + 7;
 const long long inf = 922337203685477;
 const long long nax = 1e5 + 5;
 long long n, p, m;
 long long d[nax], t[nax];
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   cin >> n >> p >> m;
   for (long long i = 1; i <= n; i++) {
     cin >> d[i] >> t[i];
   }
   d[0] = 1;
   d[n + 1] = m + 1;
   long long cur = 0, ans = 0;
   for (long long i = 1; i <= n + 1; i++) {
     long long dif = 0;
     if (cur > 0) {
       dif = cur / p;
     }
     long long minus = d[i] - d[i - 1] - dif;
     if (minus < 0) {
       minus = 0;
     }
     ans += minus;
     cur -= (d[i] - d[i - 1]) * p;
     cur += t[i];
   }
   cout << ans << '
';
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1e5 + 10;
 const int SIZ_TREE = 3e5 + 10;
 int n, m;
 struct Node {
   int u, v;
   Node(int U = 0, int V = 0) {
     u = U, v = V;
     if (u < v) swap(u, v);
   }
   bool operator<(const Node A) const {
     if (u < A.u || (u == A.u && v < A.v)) return true;
     return false;
   }
 };
 vector<int> f[N], ans[2];
 vector<Node> edg;
 map<Node, bool> col;
 bool v[N], opr[N], flag1, flag2, add[N];
 int cnt_p, cnt_opr;
 void init() {
   char s;
   int x, y;
   scanf( d d , &n, &m);
   for (int i = 1; i <= m; i++) {
     scanf( d d , &x, &y);
     while ((s = getchar()) == ' ')
       ;
     f[y].push_back(x);
     f[x].push_back(y);
     edg.push_back(Node(x, y));
     col[Node(x, y)] = (s == 'R' ? false : true);
   }
 }
 bool dfs(int x) {
   v[x] = true;
   cnt_p++;
   cnt_opr += opr[x];
   for (int i = 0; i < f[x].size(); i++) {
     int y = f[x][i];
     if (v[y]) {
       if ((col[Node(x, y)] ^ opr[x] ^ opr[y]) == true) return false;
     } else {
       opr[y] = col[Node(x, y)] ^ opr[x];
       if (!dfs(y)) return false;
     }
   }
   return true;
 }
 void add_ans(int x, bool s1, int s2) {
   if (add[x]) return;
   opr[x] ^= s1;
   add[x] = true;
   if (opr[x]) ans[s2].push_back(x);
   for (int i = 0; i < f[x].size(); i++) add_ans(f[x][i], s1, s2);
 }
 bool solve(int sign) {
   memset(opr, 0, sizeof(opr));
   memset(v, 0, sizeof(v));
   memset(add, 0, sizeof(add));
   for (int i = 1; i <= n; i++)
     if (!v[i]) {
       cnt_opr = cnt_p = 0;
       if (!dfs(i)) return false;
       add_ans(i, (cnt_opr * 2 > cnt_p), sign);
     }
   return true;
 }
 void print(int s) {
   printf( d
 , ans[s].size());
   for (int i = 0; i < ans[s].size(); i++) printf( d  , ans[s][i]);
   printf(
 );
 }
 void work() {
   flag1 = solve(0);
   for (int i = 0; i < edg.size(); i++) col[edg[i]] = (!col[edg[i]]);
   flag2 = solve(1);
   if (!flag1 && !flag2)
     printf( -1
 );
   else if (flag1 && !flag2)
     print(0);
   else if (!flag1 && flag2)
     print(1);
   else if (ans[0].size() < ans[1].size())
     print(0);
   else
     print(1);
 }
 int main() {
   init();
   work();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MOD = 1e6 + 3;
 long long power(long long base, long long exp) {
   long long ans = 1;
   while (exp) {
     if (exp & 1) ans = (ans * base)  MOD;
     base = (base * base)  MOD;
     exp >>= 1;
   }
   return ans;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   long long n, k;
   cin >> n >> k;
   if (n <= 63 && k > (1LL << n)) {
     cout << 1 <<     << 1;
     return 0;
   }
   long long v2 = 0;
   int digits = __builtin_popcountll(k - 1);
   v2 = k - 1 - digits;
   long long ntmp = n  (MOD - 1);
   if (ntmp < 0) ntmp += (MOD - 1);
   long long ktmp = k  (MOD - 1);
   if (ktmp < 0) ktmp += (MOD - 1);
   long long v2tmp = v2  (MOD - 1);
   if (v2tmp < 0) v2tmp += (MOD - 1);
   long long exponent = ntmp * (ktmp - 1) - v2tmp;
   exponent = (MOD - 1);
   if (exponent < 0) exponent += MOD - 1;
   long long denom = power(2, exponent);
   long long numpart = 0;
   if (k - 1 >= MOD) {
     numpart = 0;
   } else {
     long long prod = 1;
     long long ntmp2 = power(2, ntmp);
     prod = power(2, v2tmp);
     prod = power(prod, MOD - 2);
     if (prod < 0) prod += MOD;
     for (long long y = 1; y <= k - 1; y++) {
       prod = (prod * (ntmp2 - y))  MOD;
     }
     numpart = prod;
   }
   long long num = (denom - numpart)  MOD;
   num = MOD;
   denom = MOD;
   if (num < 0) num += MOD;
   if (denom < 0) denom += MOD;
   cout << num <<     << denom;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ;
   long long n, k, i;
   cin >> n >> k;
   vector<pair<long long, long long> > v;
   long long a[n], b[n];
   long long x, y;
   for (i = 0; i < n; i++) cin >> a[i];
   for (i = 0; i < n; i++) cin >> b[i];
   for (i = 0; i < n; i++) {
     x = a[i] - b[i];
     v.push_back(make_pair(x, i));
   }
   sort(v.begin(), v.end());
   i = 0;
   y = 0;
   while (i < n) {
     if (i < k || v[i].first <= 0)
       y = y + a[v[i].second];
     else if (i >= k && v[i].first > 0)
       break;
     ++i;
   }
   while (i < n) {
     y = y + b[v[i].second];
     ++i;
   }
   cout << y;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long s, x;
   cin >> s >> x;
   long long ans = __builtin_popcountll(x);
   ans = 1LL << ans;
   if (s == x) ans -= 2;
   for (int i = 0; i < 60; i++) {
     if (x & (1LL << i)) s -= 1LL << i;
   }
   for (int i = 0; i < 60; i++) {
     int j = i + 1;
     if ((s & (1LL << j)) && !(x & (1LL << i))) s -= 1LL << j;
   }
   if (s != 0)
     puts( 0 );
   else
     cout << ans << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, tmp;
   bool ok = 1;
   int ar[5];
   memset(ar, 0, sizeof(ar));
   scanf( d , &n);
   for (int i = 0; i < n; ++i) {
     scanf( d , &tmp);
     tmp /= 25;
     if (!ok) continue;
     if (tmp == 1) {
       ar[1]++;
     } else if (tmp == 2) {
       if (ar[1] > 0) {
         ar[1]--;
         ar[2]++;
       } else
         ok = 0;
     } else if (tmp == 4) {
       if (ar[1] > 0 && ar[2] > 0) {
         ar[1]--;
         ar[2]--;
         ar[4]++;
       } else if (ar[1] > 2) {
         ar[1] -= 3;
         ar[4]++;
       } else
         ok = 0;
     }
   }
   if (ok)
     cout <<  YES  << endl;
   else
     cout <<  NO  << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 struct Que {
   int a, b, w;
 } Q[300010];
 bool operator<(Que a, Que b) { return a.b < b.b; }
 int n, i, m, Lim, j;
 long long ans[301000], w[301000], s[301000];
 int main() {
   scanf( d , &n);
   for (i = 0; i < n; i++) scanf( extra , &w[i]);
   scanf( d , &m);
   for (i = 0; i < m; i++) scanf( dd , &Q[i].a, &Q[i].b), Q[i].a--, Q[i].w = i;
   sort(Q, Q + m);
   Lim = (int)sqrt(n);
   for (i = 0; i < m; i++) {
     if (Q[i].b > Lim) {
       long long tmp = 0;
       for (j = Q[i].a; j < n; j += Q[i].b) tmp += w[j];
       ans[Q[i].w] = tmp;
     } else {
       memset(s, 0, sizeof(s));
       for (j = n - 1; j >= 0; j--) s[j] = w[j] + s[j + Q[i].b];
       j = i;
       do {
         ans[Q[j].w] = s[Q[j].a];
         j++;
       } while (Q[j].b == Q[j - 1].b);
       i = j - 1;
     }
   }
   for (i = 0; i < m; i++) printf( extra
 , ans[i]);
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long maxn = 1000000 + 5;
 const long long DIFF = 2000;
 const long long mod = 1000000000 + 7;
 long long dp[DIFF + 5][DIFF + 5];
 char s[maxn];
 int main() {
   dp[0][0] = 1;
   for (int i = 1; i <= DIFF; dp[i][0] = dp[i - 1][1], i++)
     for (int j = 1; j <= i; j++)
       dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1])  mod;
   long long n, m;
   scanf( extraextras , &n, &m, s);
   long long len = strlen(s), diff = 0, Min = 0, ans = 0;
   for (long long i = 0; i < len; i++) {
     diff += (s[i] == '(' ? 1 : -1);
     Min = min(Min, diff);
   }
   for (long long i = 0; i <= n - m; i++)
     for (long long j = 0; j <= i; j++)
       if (j + Min >= 0 && j + diff >= 0 && j + diff <= n - m)
         ans = (ans + (dp[i][j] * dp[n - m - i][j + diff])  mod)  mod;
   printf( extra
 , ans);
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int x, y, a, b, i, c = 0, j = 0;
   cin >> x >> y;
   a = 240 - y;
   for (i = 1; c <= a; i++) {
     c = c + (5 * i);
     j++;
   }
   if (j - 1 <= x) {
     cout << j - 1 << endl;
   } else {
     cout << x << endl;
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long mx = (1 << 22);
 long long f[mx], ans[mx];
 int32_t main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   ;
   long long n;
   cin >> n;
   long long a[n];
   for (long long i = 0; i < n; i++) cin >> a[i];
   memset(ans, -1, sizeof(ans));
   for (long long i = 0; i < n; i++) {
     f[a[i]]++;
     ans[a[i]] = a[i];
   }
   for (long long j = 0; j < 22; j++)
     for (long long i = 0; i < mx; i++)
       if (i & (1 << j)) {
         f[i] += f[i ^ (1 << j)];
         if (f[i ^ (1 << j)]) ans[i] = ans[i ^ (1 << j)];
       }
   for (long long i = 0; i < n; i++) {
     long long p = (mx - 1) & (~a[i]);
     cout << ans[p] <<    ;
   }
   cout << '
';
 }


#include <bits/stdc++.h>
 using namespace std;
 const int mod = 1e9 + 7;
 struct node {
   int x, y, c;
 } s[2005], tmp[2005];
 int n, k, l, cx, cy;
 int lx[2005], ly[2005], bk[2005];
 multiset<int> t[2005];
 namespace Tree {
 int mn[8005], mx[8005], sum[8005], lzy[8005];
 inline void pushtag(int p, int l, int r, int val) {
   mx[p] = mn[p] = lzy[p] = val;
   sum[p] = 1ll * (ly[r + 1] - ly[l]) * val  mod;
 }
 inline void down(int p, int l, int mid, int r) {
   pushtag(p << 1, l, mid, lzy[p]);
   pushtag(p << 1 | 1, mid + 1, r, lzy[p]);
   lzy[p] = -1;
 }
 void insert(int p, int id, int val, int l, int r) {
   if (l == r)
     return mx[p] = mn[p] = val,
            sum[p] = 1ll * (ly[id + 1] - ly[id]) * val  mod, void();
   const int mid = l + r >> 1;
   if (id <= mid)
     insert(p << 1, id, val, l, mid);
   else
     insert(p << 1 | 1, id, val, mid + 1, r);
   mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
   mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
   sum[p] = (sum[p << 1] + sum[p << 1 | 1])  mod;
 }
 void qmin(int p, int val, int l, int r, int L, int R) {
   if (L >= l && R <= r) {
     if (mx[p] <= val)
       return;
     else if (mn[p] >= val)
       pushtag(p, L, R, val);
     else {
       const int mid = L + R >> 1;
       if (~lzy[p]) down(p, L, mid, R);
       qmin(p << 1, val, l, r, L, mid);
       qmin(p << 1 | 1, val, l, r, mid + 1, R);
       mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
       mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
       sum[p] = (sum[p << 1] + sum[p << 1 | 1])  mod;
     }
     return;
   }
   const int mid = L + R >> 1;
   if (~lzy[p]) down(p, L, mid, R);
   if (l <= mid) qmin(p << 1, val, l, r, L, mid);
   if (r > mid) qmin(p << 1 | 1, val, l, r, mid + 1, R);
   mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
   mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
   sum[p] = (sum[p << 1] + sum[p << 1 | 1])  mod;
 }
 }  // namespace Tree
 int main() {
   scanf( ddd , &n, &k, &l);
   lx[++cx] = 0;
   ly[++cy] = 0;
   lx[++cx] = l + 1;
   ly[++cy] = l + 1;
   int ans = 0;
   for (int i = 1; i <= n; ++i)
     scanf( ddd , &s[i].x, &s[i].y, &s[i].c), lx[++cx] = ++s[i].x,
                                                 ly[++cy] = ++s[i].y;
   sort(lx + 1, lx + cx + 1);
   cx = unique(lx + 1, lx + cx + 1) - lx - 1;
   sort(ly + 1, ly + cy + 1);
   cy = unique(ly + 1, ly + cy + 1) - ly - 1;
   for (int i = 1; i <= n; ++i)
     s[i].x = lower_bound(lx + 1, lx + cx + 1, s[i].x) - lx,
     s[i].y = lower_bound(ly + 1, ly + cy + 1, s[i].y) - ly, tmp[i] = s[i];
   sort(s + 1, s + n + 1,
        [](const node &a, const node &b) { return a.x < b.x; });
   sort(tmp + 1, tmp + n + 1,
        [](const node &a, const node &b) { return a.y < b.y; });
   for (int u = 1; u < cx; ++u) {
     memset(bk, 0, sizeof(bk));
     memset(Tree::lzy, -1, sizeof(Tree::lzy));
     for (int i = 1, j = 1, p = 1, cnt = 0; i < cy; ++i) {
       while (j <= n && tmp[j].y <= i) {
         if (tmp[j].x <= u)
           ++j;
         else {
           if (!bk[tmp[j].c]) ++cnt;
           ++bk[tmp[j++].c];
         }
       }
       while (cnt == k) {
         if (tmp[p].x <= u)
           ++p;
         else {
           --bk[tmp[p].c];
           if (!bk[tmp[p++].c]) --cnt;
         }
       }
       Tree::insert(1, i, ly[tmp[p - 1].y], 1, cy - 1);
     }
     for (int i = 1; i <= k; ++i) t[i].clear();
     for (int i = 1; i <= n; ++i)
       if (s[i].x > u) t[s[i].c].insert(s[i].y);
     for (int d = cx - 1, i = n; d > u; --d) {
       (ans += 1ll * (lx[d + 1] - lx[d]) * (lx[u + 1] - lx[u])  mod *
               Tree::sum[1]  mod) = mod;
       while (i && s[i].x >= d) {
         auto it = t[s[i].c].find(s[i].y);
         int pre = it == t[s[i].c].begin() ? 0 : *prev(it);
         int nxt = next(it) == t[s[i].c].end() ? cy : *next(it);
         t[s[i].c].erase(it);
         if (s[i].y < nxt) Tree::qmin(1, ly[pre], s[i].y, nxt - 1, 1, cy - 1);
         --i;
       }
     }
   }
   return printf( d
 , ans), 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class T1, class T2>
 inline void upd1(T1& a, const T2& b) {
   a = a < b ? a : b;
 }
 template <class T1, class T2>
 inline void upd2(T1& a, const T2& b) {
   a = a > b ? a : b;
 }
 template <class T>
 inline bool equ(const T& a, const T& b) {
   return !memcmp(&a, &b, sizeof a);
 }
 long long gcd(long long a, long long b) { return b ? gcd(b, a  b) : a; }
 struct ano {
   operator long long() {
     long long x = 0, y = 0, c = getchar();
     while (c < 48) y = c == 45, c = getchar();
     while (c > 47) x = x * 10 + c - 48, c = getchar();
     return y ? -x : x;
   }
 } buf;
 const int p = 1e9 + 7;
 const int N = 1e6 + 5;
 int w[N], a[N], l[N], r[N];
 long long cal(long long a, long long n, long long d) {
   return (a * n + n * (n - 1) / 2  p * d)  p;
 }
 int main() {
   int n = buf, m = buf;
   for (int i = 1; i <= n; ++i) w[i] = buf;
   w[n + 1] = 1 << 30;
   int j = 0;
   for (int i = 1; i <= n + 1; ++i) {
     while (j > 0 && w[a[j]] <= w[i]) r[a[j--]] = i - 1;
     l[i] = a[j] + 1;
     a[++j] = i;
   }
   long long ans = 0;
   for (int i = 1; i <= n; ++i) {
     int a = i - l[i] + 1;
     int b = r[i] - i + 1;
     int c = (min(a, b) - 1) / (m - 1);
     long long s = cal(m, c, m - 1);
     int v = (c + 1) * (m - 1) + 1;
     if (max(a, b) >= v) {
       long long d = (max(a, b) - v) / (m - 1);
       s += ((d + 1) * min(a, b))  p;
       v += (d + 1) * (m - 1);
     }
     v = a + b - v;
     if (v >= 1) s += cal(v, (v - 1) / (m - 1) + 1, 1 + p - m);
     ans += w[i] * s  p;
   }
   cout << ans  p << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 105, maxm = 5005;
 const double eps = 1e-9;
 int N, M, m, X[maxm], Y[maxm], Z[maxm];
 double f[maxn][maxn], p[maxn];
 int main() {
   scanf( dd , &N, &M);
   for (int i = 1; i <= M; i++) {
     scanf( ddd , &X[i], &Y[i], &Z[i]);
     if (X[i] > 1 && X[i] < N) f[X[i]][X[i]]++, f[X[i]][Y[i]]--;
     if (Y[i] > 1 && Y[i] < N) f[Y[i]][Y[i]]++, f[Y[i]][X[i]]--;
   }
   f[1][N + 1] = 1, f[1][1] = 1;
   f[N][N + 1] = 0, f[N][N] = 1;
   for (int i = 1; i <= N; i++) {
     if (abs(f[i][i]) < eps)
       for (int j = i + 1; j <= N; j++)
         if (abs(f[j][i]) > eps) {
           for (int k = i; k <= N + 1; k++) f[i][k] += f[j][k];
           break;
         }
     for (int j = i + 1; j <= N; j++)
       if (abs(f[j][i]) > eps) {
         double r(f[j][i] / f[i][i]);
         for (int k = i; k <= N + 1; k++) f[j][k] -= f[i][k] * r;
       }
   }
   for (int i = N; i; i--)
     if (abs(f[i][i]) > eps) {
       p[i] = f[i][N + 1];
       for (int j = i + 1; j <= N; j++) p[i] -= f[i][j] * p[j];
       p[i] /= f[i][i];
     }
   double rate(1.0 / 0), ans(0);
   for (int i = 1; i <= M; i++) rate = min(rate, Z[i] / abs(p[X[i]] - p[Y[i]]));
   for (int i = 1; i <= M; i++) {
     if (X[i] == 1) ans += p[1] - p[Y[i]];
     if (Y[i] == 1) ans += p[1] - p[X[i]];
   }
   printf( .7f
 , isfinite(rate) ? ans * rate : 0);
   for (int i = 1; i <= M; i++)
     printf( .7f
 , isfinite(rate) ? (p[X[i]] - p[Y[i]]) * rate : 0);
   return 0;
 }


#include <bits/stdc++.h>
 int main() {
   int n;
   scanf( d , &n);
   int i = 1;
   while ((i * (i + 1) / 2) <= n) {
     if ((i * (i + 1) / 2) == n) {
       printf( YES );
       return 0;
     }
     i++;
   }
   printf( NO );
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 2e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;
 const long long INF = 1e18;
 int n, a[N];
 int main() {
   cin.tie(0);
   cout.tie(0);
   ios_base::sync_with_stdio(0);
   cin >> n;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
   }
   sort(a + 1, a + n + 1);
   reverse(a + 1, a + n + 1);
   int mn = inf;
   for (int i = 1; i <= n; i++) {
     if (a[i] + 1 < mn) {
       a[i]++;
       mn = a[i];
     } else {
       if (a[i] < mn) {
         mn = a[i];
       } else if (a[i] - 1 < mn && a[i] > 1) {
         mn = a[i] - 1;
         a[i]--;
       }
     }
   }
   set<int> st;
   for (int i = 1; i <= n; i++) {
     st.insert(a[i]);
   }
   cout << st.size();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 template <class T>
 void rd(T &x) {
   x = 0;
   int f = 1;
   char ch = getchar();
   while (ch < '0' || ch > '9') {
     if (ch == '-') f = -1;
     ch = getchar();
   }
   while (ch >= '0' && ch <= '9')
     x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
   x *= f;
 }
 const int maxn = 1e5 + 5;
 int n, m;
 int ans[maxn];
 struct node {
   int x, op, id;
   bool operator<(const node &b) const { return x == b.x ? id < b.id : x < b.x; }
 } p[maxn];
 struct segment_tree {
   int op[maxn << 2], tag[maxn << 2];
   void pushdown(int u) {
     if (tag[u]) {
       op[u << 1] = op[u << 1 | 1] = 1;
       tag[u << 1] = tag[u << 1 | 1] = tag[u];
       tag[u] = 0;
     }
     if (op[u] == -1) {
       op[u << 1] *= -1;
       op[u << 1 | 1] *= -1;
       op[u] = 1;
     }
   }
   void build(int u, int l, int r) {
     op[u] = 1;
     if (l == r) return (void)(op[u] = p[l].op);
     int mid = l + r >> 1;
     build(u << 1, l, mid);
     build(u << 1 | 1, mid + 1, r);
   }
   void cover(int u, int l, int r, int ql, int qr, int v) {
     if (ql <= l && r <= qr) return (void)(op[u] = 1, tag[u] = v);
     int mid = l + r >> 1;
     pushdown(u);
     if (ql <= mid) cover(u << 1, l, mid, ql, qr, v);
     if (qr > mid) cover(u << 1 | 1, mid + 1, r, ql, qr, v);
   }
   void change(int u, int l, int r, int ql, int qr) {
     if (ql <= l && r <= qr) return (void)(op[u] *= -1);
     int mid = l + r >> 1;
     pushdown(u);
     if (ql <= mid) change(u << 1, l, mid, ql, qr);
     if (qr > mid) change(u << 1 | 1, mid + 1, r, ql, qr);
   }
   void query(int u, int l, int r) {
     if (l == r) {
       int res = tag[u] ? tag[u] * op[u] : op[u];
       ans[p[l].id] = res * p[l].x;
       return;
     }
     int mid = l + r >> 1;
     pushdown(u);
     query(u << 1, l, mid);
     query(u << 1 | 1, mid + 1, r);
   }
 } seg;
 int main() {
   rd(n), rd(m);
   for (int i = (1); i <= (n); ++i) {
     int x;
     rd(x);
     p[i] = (node){abs(x), x > 0 ? 1 : -1, i};
   }
   sort(p + 1, p + n + 1);
   seg.build(1, 1, n);
   while (m--) {
     char s[5];
     int x;
     scanf( s , s);
     rd(x);
     if (s[0] == '<') {
       if (x < 0) {
         int pos = (lower_bound(p + 1, p + n + 1, (node){abs(x) + 1, 0, 0}) - p);
         if (pos <= n) seg.cover(1, 1, n, pos, n, 1);
       } else {
         int pos = (lower_bound(p + 1, p + n + 1, (node){abs(x), 0, 0}) - p);
         if (pos <= n) seg.cover(1, 1, n, pos, n, 1);
         if (pos > 1) seg.change(1, 1, n, 1, pos - 1);
       }
     } else {
       if (x > 0) {
         int pos = (lower_bound(p + 1, p + n + 1, (node){abs(x) + 1, 0, 0}) - p);
         if (pos <= n) seg.cover(1, 1, n, pos, n, -1);
       } else {
         int pos = (lower_bound(p + 1, p + n + 1, (node){abs(x), 0, 0}) - p);
         if (pos <= n) seg.cover(1, 1, n, pos, n, -1);
         if (pos > 1) seg.change(1, 1, n, 1, pos - 1);
       }
     }
   }
   seg.query(1, 1, n);
   for (int i = (1); i <= (n); ++i) printf( d  , ans[i]);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int pic[610][610];
 int ABS(int x) {
   if (x < 0) return -x;
   return x;
 }
 int main(int argc, char const *argv[]) {
   int q;
   scanf( d , &q);
   for (int i = 0; i < q; i++) {
     int n, m, pix = 0, sum1 = 0, sum2 = 0;
     scanf( dd , &n, &m);
     for (int k = 0; k < n; k++)
       for (int j = 0; j < m; j++) {
         scanf( d , &pic[k][j]);
       }
     int dif = 0;
     for (int j = 0; j < m; j++)
       dif = dif + ABS(pic[n / 2][j] - pic[n / 2 - 1][j]);
     if (dif < 6000)
       printf( NO
 );
     else
       printf( YES
 );
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 4e5 + 50;
 int n, m, a[N], b[N];
 vector<int> G[N];
 int in[N], out[N], tim, dep[N];
 int mn[20][N], lg[N], p[N], k;
 void dfs(int u, int f) {
   dep[u] = dep[f] + 1;
   in[u] = ++tim;
   mn[0][p[u] = ++k] = u;
   for (int v : G[u])
     if (v != f) dfs(v, u), mn[0][++k] = u;
   out[u] = tim;
 }
 int chk(int x, int y) { return dep[x] < dep[y] ? x : y; }
 int LCA(int x, int y) {
   x = p[x], y = p[y];
   if (x > y) swap(x, y);
   int z = lg[y - x + 1];
   return chk(mn[z][x], mn[z][y - (1 << z) + 1]);
 }
 int D(int x, int y) { return dep[x] + dep[y] - 2 * dep[LCA(x, y)]; }
 struct lll {
   int x, y, o;
   lll(int _x = 0, int _y = 0, int _o = 0) { x = _x, y = _y, o = _o; }
   friend lll operator+(const lll &a, const lll &b) {
     if (!a.o) return a;
     if (!b.o) return b;
     if (!a.x) return b;
     if (!b.x) return a;
     lll t = b;
     int A = D(a.x, t.x), B = D(a.x, t.y), C = D(t.x, t.y);
     if (A + B == C)
       t = lll(t.x, t.y, 1);
     else if (B + C == A)
       t = lll(a.x, t.x, 1);
     else if (A + C == B)
       t = lll(a.x, t.y, 1);
     else
       return lll(0, 0, 0);
     A = D(a.y, t.x), B = D(a.y, t.y), C = D(t.x, t.y);
     if (A + B == C)
       t = lll(t.x, t.y, 1);
     else if (B + C == A)
       t = lll(a.y, t.x, 1);
     else if (A + C == B)
       t = lll(a.y, t.y, 1);
     else
       return lll(0, 0, 0);
     return t;
   }
 };
 namespace SGT {
 const int N = ::N << 2;
 lll t[N];
 void up(int x) { t[x] = t[x << 1] + t[x << 1 | 1]; }
 void build(int x, int l, int r) {
   if (l == r) return t[x] = lll(b[l], b[l], 1), void();
   build(x << 1, l, ((l + r) >> 1)), build(x << 1 | 1, ((l + r) >> 1) + 1, r);
   up(x);
 }
 void mdf(int x, int l, int r, int p, int v) {
   if (l == r) return t[x] = lll(v, v, 1), void();
   if (p <= ((l + r) >> 1))
     mdf(x << 1, l, ((l + r) >> 1), p, v);
   else
     mdf(x << 1 | 1, ((l + r) >> 1) + 1, r, p, v);
   up(x);
 }
 int ask(int x, int l, int r, lll z) {
   if (l == r) {
     lll y = z + t[x];
     if (y.o) return l + 1;
     return l;
   }
   lll y = z + t[x << 1];
   if (!y.o) return ask(x << 1, l, ((l + r) >> 1), z);
   return ask(x << 1 | 1, ((l + r) >> 1) + 1, r, y);
 }
 }  // namespace SGT
 int main() {
   cin >> n;
   for (int i = 1; i <= n; i++) scanf( d , &a[i]), b[a[i]] = i;
   for (int i = 2, x; i <= n; i++) scanf( d , &x), G[x].push_back(i);
   dfs(1, 0);
   for (int i = 2; i <= k; i++) lg[i] = lg[i >> 1] + 1;
   for (int i = 1; (1 << i) <= k; i++)
     for (int j = 1; j + (1 << i) - 1 <= k; j++)
       mn[i][j] = chk(mn[i - 1][j], mn[i - 1][j + (1 << i - 1)]);
   SGT ::build(1, 0, n - 1);
   cin >> m;
   while (m--) {
     int o, x, y;
     scanf( d , &o);
     if (o == 1) {
       scanf( dd , &x, &y);
       swap(a[x], a[y]);
       x = a[x], y = a[y];
       swap(b[x], b[y]);
       SGT ::mdf(1, 0, n - 1, x, b[x]);
       SGT ::mdf(1, 0, n - 1, y, b[y]);
     }
     if (o == 2) cout << SGT ::ask(1, 0, n - 1, lll(0, 0, 1)) << '
';
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int n, k;
   cin >> n >> k;
   char def = 'a';
   int pos = 0;
   string ans =   ;
   for (int i = 0; i < n; i++) {
     ans += def + pos;
     pos = (pos + 1)  k;
   }
   cout << ans;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long mod = 1000000007LL;
 long long base = 10000007;
 long long large = 1000000000000000000LL;
 class UnionFind {
  private:
   vector<int> p, rank;

  public:
   UnionFind(int n) {
     rank.assign(n, 0);
     p.assign(n, 0);
     for (int i = 0; i < n; i++) {
       p[i] = i;
     }
   }
   int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
   bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
   void unionSet(int i, int j) {
     if (!isSameSet(i, j)) {
       int x = findSet(i), y = findSet(j);
       if (rank[x] > rank[y]) {
         p[y] = x;
       } else {
         p[x] = y;
         if (rank[x] == rank[y]) {
           rank[y]++;
         }
       }
     }
   }
 };
 vector<vector<pair<int, int> > > adj;
 int n, m;
 vector<pair<pair<int, int>, int> > e;
 vector<int> dp;
 void dfs(int u, int pa, int val) {
   dp[u] = val;
   for (int j = 0; j < (int)adj[u].size(); j++) {
     int v = adj[u][j].first;
     int d = adj[u][j].second;
     if (v != pa) {
       dfs(v, u, val ^ d);
     }
   }
 }
 int main() {
   cin >> n >> m;
   UnionFind uf(n);
   adj.assign(n, vector<pair<int, int> >());
   for (int i = 0; i < m; i++) {
     int x, y, z;
     scanf( ddd , &x, &y, &z);
     x--;
     y--;
     if (uf.isSameSet(x, y)) {
       e.push_back(pair<pair<int, int>, int>(pair<int, int>(x, y), z));
     } else {
       uf.unionSet(x, y);
       adj[x].push_back(pair<int, int>(y, z));
       adj[y].push_back(pair<int, int>(x, z));
     }
   }
   dp.assign(n, 0);
   dfs(0, -1, 0);
   vector<int> mask;
   for (int i = 0; i < (int)e.size(); i++) {
     int x = e[i].first.first;
     int y = e[i].first.second;
     int z = e[i].second;
     int lo = dp[x] ^ dp[y] ^ z;
     mask.push_back(lo);
   }
   int cur = 0;
   for (int l = 30; l >= 0; l--) {
     int c = -1;
     for (int i = cur; i < (int)mask.size(); i++) {
       if (mask[i] & (1 << l)) {
         c = i;
         break;
       }
     }
     if (c == -1) continue;
     swap(mask[cur], mask[c]);
     for (int i = cur + 1; i < (int)mask.size(); i++) {
       if (mask[i] & (1 << l)) mask[i] ^= mask[cur];
     }
     cur++;
   }
   vector<int> basis;
   for (int i = 0; i < cur; i++) {
     basis.push_back(mask[i]);
   }
   int l = 30;
   int dis = dp[n - 1];
   for (int i = 0; i < (int)basis.size(); i++) {
     while (((1 << l) & basis[i]) == 0) l--;
     if ((1 << l) & dis) dis ^= basis[i];
   }
   cout << dis << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int input[100000];
 int output[100000];
 pair<pair<int, int>, int> queries[100000];
 int blockSize;
 bool mo_compare(pair<pair<int, int>, int>& x, pair<pair<int, int>, int>& y) {
   int firstBlockIndex = x.first.first / blockSize;
   int secondBlockIndex = y.first.first / blockSize;
   if (firstBlockIndex == secondBlockIndex) {
     return x.first.second < y.first.second;
   }
   return firstBlockIndex < secondBlockIndex;
 }
 void inline removeElement(unordered_map<int, int>& lookup, int val,
                           int& result) {
   unordered_map<int, int>::iterator itr = lookup.find(val);
   if (itr != lookup.end()) {
     if (itr->first == itr->second) {
       result--;
     }
     itr->second--;
     if (itr->first == itr->second) {
       result++;
     }
   } else {
     lookup[val]--;
   }
 }
 void inline addElement(unordered_map<int, int>& lookup, int val, int& result) {
   unordered_map<int, int>::iterator itr = lookup.find(val);
   if (itr != lookup.end()) {
     if (itr->first == itr->second) {
       result--;
     }
     itr->second++;
     if (itr->first == itr->second) {
       result++;
     }
   } else {
     lookup[val]++;
     if (val == 1) {
       result++;
     }
   }
 }
 int main() {
   cin.tie(NULL);
   int n, m;
   cin >> n >> m;
   blockSize = static_cast<int>(sqrt(n));
   for (int i = 0; i < n; i++) {
     cin >> input[i];
   }
   for (int i = 0; i < m; i++) {
     pair<pair<int, int>, int>& query = queries[i];
     cin >> query.first.first >> query.first.second;
     query.first.first--;
     query.first.second--;
     query.second = i;
   }
   sort(queries, queries + m, mo_compare);
   unordered_map<int, int> lookup;
   int result = 0;
   int prev_l = 0, prev_r = -1, left, right, index;
   unordered_map<int, int>::iterator itr;
   for (int i = 0; i < m; i++) {
     left = queries[i].first.first;
     right = queries[i].first.second;
     index = queries[i].second;
     while (left > prev_l) {
       removeElement(lookup, input[prev_l], result);
       prev_l++;
     }
     while (left < prev_l) {
       prev_l--;
       addElement(lookup, input[prev_l], result);
     }
     while (right < prev_r) {
       removeElement(lookup, input[prev_r], result);
       prev_r--;
     }
     while (right > prev_r) {
       prev_r++;
       addElement(lookup, input[prev_r], result);
     }
     output[index] = result;
   }
   for (int i = 0; i < m; i++) {
     cout << output[i] << '
';
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long k, n, m;
 int answ = 1;
 bool flag = 0;
 int main() {
   cin >> n >> m;
   k = 2;
   for (int i = 2; i <= m; i++) k = (k * 2)  1000000009;
   if (k > n) {
     for (int i = 1; i <= n; i++) answ = (answ * (k - i))  1000000009;
     cout << answ;
   } else
     cout << 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const double pi = acos(-1.0);
 long long int path[100001];
 long long int dist[100001];
 void shortest_path(vector<pair<long long int, long long int>> v[],
                    long long int start) {
   long long int i;
   for (i = 0; i < 100001; i++) dist[i] = 1e18 + 1;
   priority_queue<long long int> q;
   q.push(start);
   dist[start] = 0;
   while (!q.empty()) {
     long long int x = q.top();
     q.pop();
     for (i = 0; i < v[x].size(); i++) {
       if (dist[v[x][i].first] > dist[x] + v[x][i].second) {
         dist[v[x][i].first] = dist[x] + v[x][i].second;
         path[v[x][i].first] = x;
         q.push(v[x][i].first);
       }
     }
   }
 }
 void solve() {
   long long int ver, edge, i, x, y, w, start = 1;
   cin >> ver >> edge;
   vector<pair<long long int, long long int>> v[ver + 1];
   vector<long long int> ans;
   for (i = 0; i < edge; i++) {
     cin >> x >> y >> w;
     v[x].push_back(make_pair(y, w));
     v[y].push_back(make_pair(x, w));
   }
   shortest_path(v, start);
   if (dist[ver] == 1e18 + 1)
     cout <<  -1
          <<
 ;
   else {
     cout <<  1  ;
     while (ver != 1) {
       ans.push_back(ver);
       ver = path[ver];
     }
     for (i = ans.size() - 1; i >= 0; i--) {
       cout << ans[i] <<    ;
     }
     cout <<
 ;
   }
 }
 void fast() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
 }
 int main() {
   fast();
   int t = 1;
   while (t--) solve();
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 using ll = int64_t;
 template <typename T, typename U>
 ostream& operator<<(ostream& _s, pair<T, U> _t) {
   _s <<  (  << _t.first <<  ,  << _t.second <<  ) ;
   return _s;
 }
 template <typename T, typename U>
 istream& operator>>(istream& _s, pair<T, U>& _t) {
   _s >> _t.first >> _t.second;
   return _s;
 }
 template <typename T>
 ostream& operator<<(ostream& _s, vector<T> _t) {
   for (int i = 0; i < (int)(_t.size()); i++) _s << (i ?     :   ) << _t[i];
   return _s;
 }
 template <typename T>
 istream& operator>>(istream& _s, vector<T>& _t) {
   for (int i = 0; i < (int)(_t.size()); i++) _s >> _t[i];
   return _s;
 }
 vector<int> val, comp, z, cont;
 int Time, ncomps;
 template <class G, class F>
 int dfs(int j, G& g, F f) {
   int low = val[j] = ++Time, x;
   z.push_back(j);
   for (auto& e : g[j])
     if (comp[e] < 0) low = min(low, val[e] ?: dfs(e, g, f));
   if (low == val[j]) {
     do {
       x = z.back();
       z.pop_back();
       comp[x] = ncomps;
       cont.push_back(x);
     } while (x != j);
     f(cont);
     cont.clear();
     ncomps++;
   }
   return val[j] = low;
 }
 template <class G, class F>
 void scc(G& g, F f) {
   int n = g.size();
   val.assign(n, 0);
   comp.assign(n, -1);
   Time = ncomps = 0;
   for (int i = 0; i < (int)(n); i++)
     if (comp[i] < 0) dfs(i, g, f);
 }
 void tassert(bool cond) {
   if (!cond) {
     while (1 < 2) {
     }
   }
 }
 void answer(int x) {
   cout <<  !   << (x + 1) << endl;
   cout << flush;
   exit(0);
 }
 bool ask(int a, int b) {
   cout <<  ?   << (a + 1) <<     << (b + 1) << endl;
   cout << flush;
   int res;
   cin >> res;
   if (res == -1) {
     exit(123);
   }
   return bool(res);
 }
 int main() {
   int n, m;
   cin >> n >> m;
   vector<vector<int>> g(n);
   for (int i = 0; i < (int)(m); i++) {
     int x, y;
     cin >> x >> y;
     g[x - 1].push_back(y - 1);
   }
   vector<vector<int>> comps;
   scc(g, [&](vector<int>& v) { comps.push_back(v); });
   vector<unordered_set<int>> cg(ncomps);
   for (int a = 0; a < (int)(n); a++) {
     for (int b : g[a]) {
       if (comp[a] != comp[b]) {
         cg[comp[a]].insert(comp[b]);
       }
     }
   }
   vector<int> indeg(ncomps, 0);
   for (int aa = 0; aa < (int)(ncomps); aa++) {
     for (int bb : cg[aa]) {
       indeg[bb]++;
     }
   }
   unordered_set<int> heads;
   for (int aa = 0; aa < (int)(ncomps); aa++) {
     if (indeg[aa] == 0) {
       heads.insert(aa);
     }
   }
   int head = *heads.begin();
   int cap = comps[head].back();
   comps[head].pop_back();
   auto update = [&](int aa) {
     if (comps[aa].size() == 0) {
       heads.erase(aa);
       for (int bb : cg[aa]) {
         tassert(comps[bb].size() > 0);
         indeg[bb]--;
         if (indeg[bb] == 0) {
           heads.insert(bb);
         }
       }
     }
   };
   while (true) {
     assert(heads.size());
     if (heads.size() == 1) {
       answer(cap);
     }
     auto head2it = heads.begin();
     if (head == (*head2it)) {
       head2it++;
     }
     int head2 = *head2it;
     tassert(!cg[head].count(head2));
     int cap2 = comps[head2].back();
     comps[head2].pop_back();
     bool ok = ask(cap, cap2);
     if (!ok) {
       update(head);
       head = head2;
       cap = cap2;
     } else {
       update(head2);
     }
   }
 }