#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_ll.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<ll>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc ll t; cin >> t; while(t--)

// using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll Z=10000;
ll get_floor(ll num){
  return num-(num%Z+Z)%Z;
}
ll get_ceil(ll num){
  return -get_floor(-num);
}
template <typename I, typename P> I binarysearch(const P &predicate, I l, I r) {
    l--;
    while (r - l > 1) {
        auto mid = l + (r - l) / 2;
        if (predicate(mid))
            r = mid;
        else
            l = mid;
    }
    return r;
}
void solve(){
  cout<<fixed<<setprecision(12);
  double x1,y1,r1;
  cin>>x1>>y1>>r1;
  ll ans=0,x=round(x1*Z),y=round(y1*Z),r=round(r1*Z);
  for(ll i=get_floor(x-r);i<=get_ceil(x+r);i+=Z){
    ll rem=r*r-(i-x)*(i-x);
    if(rem<0) continue;
    ll delta_y = -1 + binarysearch<ll>([&](ll u) { return u * u > rem; }, 0, r + 1);
    ll low=get_ceil(y-delta_y);
    ll high=get_floor(y+delta_y);
    ans+= (high-low)/Z+1;
  }
  cout<<ans<<endl;
}

int32_t main(){
    optimizeIO();
    ll r=1;
    {solve();}
}

//#include <atcoder/all>
//using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define bit(n) (1LL<<(n))
#define FIX(d) fixed << setprecision(d)
using P = pair<int, int>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m,t;
  cin >> n >> m >> t;
  vector<ll> a(m), b(m);
  REP(i,m) cin >> a[i] >> b[i];

  ll mx = n;
  ll tm = 0;
  REP(i,m){
    n -= a[i]-tm;
    if(n<=0){
      cout << "No\n";
      return 0;
    }
    n += min(b[i]-a[i], mx-n);
    tm = b[i];
  }
  n -= t-tm;
  cout << (n>0 ? "Yes\n" : "No\n");

  return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

struct TrieNode{
	int n = 0;
	long long sum = 0;
	TrieNode* l = nullptr, * r = nullptr;
};

class Trie {
public:
	Trie() { root = new TrieNode(); }

	void insert(int x) {
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			t->n++;
			t->sum += x;
			if (x >> i &1) {
				if (t->r == nullptr) t->r = new TrieNode;
				t = t->r;
			}
			else {
				if (t->l == nullptr) t->l = new TrieNode;
				t = t->l;
			}
		}
		t->n++;
		t->sum += x;
	}

	void erase(int x) {
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			t->n--;
			t->sum -= x;
			if (x >> i & 1) {
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		t->n--;
		t->sum -= x;
	}

	pair<int, long long> query(int x) const{
		pair<int, long long > ret(0, 0);
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			if (t == nullptr)break;
			if (x >> i & 1) {
				if (t->l) {
					ret.first += t->l->n;
					ret.second += t->l->sum;
				}
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		return ret;
	}
private:
	TrieNode* root;
};

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, m, q;
	cin >> n >> m >> q;

	vector<int> a(n, 0), b(m, 0);

	Trie ta, tb;
	rep(i, n) ta.insert(0);
	rep(i, m)tb.insert(0);

	long long ans = 0;
	rep(_, q) {
		int t, x, y;
		cin >> t >> x >> y;
		x--;

		if (t == 1) {
			auto p = tb.query(a[x]);
			ans -= (long long)p.first * a[x];
			ans += p.second;

			p = tb.query(y);
			ans += (long long)p.first * y;
			ans -= p.second;

			ta.erase(a[x]);
			ta.insert(y);
			a[x] = y;
		}
		else {
			auto p = ta.query(b[x]);
			ans -= (long long)p.first * b[x];
			ans += p.second;

			p = ta.query(y);
			ans += (long long)p.first * y;
			ans -= p.second;

			tb.erase(b[x]);
			tb.insert(y);
			b[x] = y;
		}
		cout << ans << endl;
	}

	return 0;
}

#include<bits/stdc++.h>
#define PI 3.141592653589793238462
#define eps 1e-20
#define fi first
#define se second
using namespace std;
using cd = complex<double>;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdd;
struct ppp{ll t,x,y;}c[200005];
ll a[200005],b[200005],N=500000;
ll tree[500005][2],num[500005][2];
void add(ll x,ll k,ll t){
    while(x<N){
        tree[x][t]+=k;
        x+=x&(-x);
    }
}
ll query(ll x,ll t){
    ll res=0;
    while(x){
        res+=tree[x][t];
        x-=x&(-x);
    }return res;
}
void up(ll x,ll k,ll t){
    while(x<N){
        num[x][t]+=k;
        x+=x&(-x);
    }
}
ll cal(ll x,ll t){
    ll res=0;
    while(x){
        res+=num[x][t];
        x-=x&(-x);
    }return res;
}
int main(){
    ll n,m,q,ans=0;
    cin>>n>>m>>q;
    set<ll> s;vector<ll> p;
    s.insert(0);
    for(ll i=1;i<=q;i++){
        cin>>c[i].t>>c[i].x>>c[i].y;
        s.insert(c[i].y);
    }
    p.push_back(-2e18);
    for(auto i:s){
        p.push_back(i);
    }
    ll st=lower_bound(p.begin(),p.end(),(ll)0)-p.begin();
    up(st,n,0);up(st,m,1);
    for(ll i=1;i<=q;i++){
        if(c[i].t==2){
            ll v=b[c[i].x],y=c[i].y;
            ll l=lower_bound(p.begin(),p.end(),v)-p.begin();
            ll pn=cal(l,0),pv=pn*v+query(N,0)-query(l,0);
            ans-=pv;up(l,-1,1);add(l,-v,1);
            l=lower_bound(p.begin(),p.end(),y)-p.begin();
            pn=cal(l,0),pv=pn*y+query(N,0)-query(l,0);
            ans+=pv;up(l,1,1);add(l,y,1);b[c[i].x]=y;
        }
        else{
            ll v=a[c[i].x],y=c[i].y;
            ll l=lower_bound(p.begin(),p.end(),v)-p.begin();
            ll pn=cal(l,1),pv=pn*v+query(N,1)-query(l,1);
            ans-=pv;up(l,-1,0);add(l,-v,0);
            l=lower_bound(p.begin(),p.end(),y)-p.begin();
            pn=cal(l,1),pv=pn*y+query(N,1)-query(l,1);
            ans+=pv;up(l,1,0);add(l,y,0);a[c[i].x]=y;
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int v, t, s, d;
    cin >> v >> t >> s >> d;
    if (v * t <= d && d <= v * s) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

#include <iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include <stack>
#include<algorithm>
using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;
	if (max(X, Y) < min(X, Y) + 3) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll M = 998244353;

long long myMod(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a%mod;
		a = a * a%mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << myMod(a, myMod(b, c, 4) + 4, 10);
}

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

const int64_t MOD = 1e9 + 7;
const int64_t MOD2 = 998244353;
const int INF = 1e9;
const long long inf = 1LL<<60;

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  a %= 10;
  long long num = a;
  vector<int> A(10, 0);
  vector<int> loopA;
  A.at(num) = 1;
  loopA.push_back(num);
  while (1) {
    num *= a;
    num %= 10;
    if (A.at(num) == 1) {
      break;
    } else {
      A.at(num) = 1;
      loopA.push_back(num);
    }
  }
  int loopasize = (int)loopA.size();
  num = b;
  num %= loopasize;
  vector<int> B(loopasize, 0);
  vector<int> loopB;
  B.at(num) = 1;
  loopB.push_back(num);
  while (1) {
    num *= b;
    num %= loopasize;
    if (B.at(num) == 1) {
      break;
    } else {
      B.at(num) = 1;
      loopB.push_back(num);
    }
  }
  long long k;
  if ((loopB.back() == 0) && ((int)loopB.size() <= c)) {
    k = 0;
  } else {
    k = loopB.at((c+(int)loopB.size()-1)%((int)loopB.size()));
  }
  long long res;
  if (k%loopasize == 0) {
    res = loopA.back();
  } else {
    res = loopA.at((k-1)%loopasize);
  }
  cout << res << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define mod (int)(1e9+7)
#define num 100007
#define ll long long int
#define endl '\n'
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test0   ;
#define test1 int t;cin>>t;for(int i=1;i<=t;i++)
#define test2 int t;cin>>t;for(int i=1;i<=t;i++) cout<<"Case #"<<i<<": ",
#define F first
#define S second
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
void solve();
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    IOS

    test0
    solve();
}
/******************************************************/

void solve(){
    int a,b,x,y;
    cin>>a>>b>>x>>y;

    int op1 =  abs(a-b)*y+x;
    int op2 = abs(a-b)*2*x+x;
    if(b<a){
        op2-=2*x;
        op1=(a-1-b)*y+x;
    }
    cout<<min(op1,op2)<<endl;
}

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n),b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];

  vector<ll> v[2];
  rep(i,n) v[i%2].emplace_back(b[i]-a[i]);
  sort(v[0].rbegin(),v[0].rend());
  sort(v[1].rbegin(),v[1].rend());
  ll ans = 0;
  rep(i,n) ans += a[i];
  rep(i,n>>1) ans += max(v[0][i]+v[1][i],0LL);
  cout << ans << endl;
}


#include<bits/stdc++.h>
#define pb emplace_back
#define pf first
#define ps second
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define Endl '\n'
#define codejam cout<<"Case #"<<t<<": ";
#define pl pair<ll,ll>
#define mod 1000000007
#define INF 1000000001
#define forn(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}

//////////////////////////////////// JAI SHREE RAM /////////////////////////////////////
const ll N=1e5;
void JAISHREERAM()
{
    double x,y,z;
    cin>>x>>y>>z;
    double val=y/x*z,f=floor(val);
    ll ans=0;
    if(f==val) ans=val-1;
    else ans=floor(val);
    cout<<ans;
}
int main()
{
    fast;
    int T=1;
    // cin>>T;
    for(int t=1;t<=T;t++)
    {
        // codejam
        JAISHREERAM();
    }
    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <array>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
using ll = long long;
using std::cin;
using std::cout;
using std::endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

void solve()
{
  ll x, y, z; cin >> x >> y >> z;
  ll res = 0;
  for (ll i = 0; i <= 10000000; ++i)
  {
    //y/x > i/z
    if(y * z > i * x)
    {
      chmax(res, i);
    }
    else
      break;
  }
  cout << res << "\n";
}
int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int kkt = 1;
  //cin >> kkt;
  while(kkt--)
    solve();
  return 0;
}


#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first
#define se second
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
#define set20 cout<<fixed<<setprecision(20) ;
// ミント

const ll mod = 1e9+7 ;
 // 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n,int k){
    return fact[n]*ifact[n-k] ;
  }
  }  ;

mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }
///
template< typename T >
T extgcd(T a, T b, T &x, T &y) {
  T d = a;
  if(b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
////
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
  ll n, m; cin>>n>>m ;
  vector<ll> A(n) ;
  rep(i,n) cin>>A[i] ;
  ll sum=0 ;
  rep(i,n) sum+= A[i] ;
  ll b=m- sum ;
  if(b<0) cout<<0<<endl ;
  else{
  ll a= sum+n+1 ;
  //cout<<a<<" "<<b<<endl ;
  //c(a+b-1,a-1) ;
  mint ans=1ll;

  rep(i,a-1){
    ans*= (a+b-1-i) ;
    ans/= mint(i+1) ;
  }

  cout<<ans<<endl ;
  }
 return 0 ;
  }

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<db, db> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM=MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

ll nCr(int n,int r){
	if(r>n)return 0;
	ll res=1;
	fup(i,1,r,1){
		res=res*n--%MOD*POW(i,MOD-2)%MOD;
	}
	return res;
}
int main() {
	int n,m,s=0;
	scanf("%d%d",&n,&m);
	fup(i,1,n,1){
		int x;
		scanf("%d",&x);
		s+=x;
	}
	printf("%lld\n",nCr(n+m,n+s));
}


// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define int long long
#define all(a) a.begin(), a.end()
#define vi vector<int>
#define pii pair<int, int>
#define fe(i, a, b) for (int i = a; i <= (b); ++i)
#define fr(i, a, b) for (int i = b; i >= (a); --i)
using namespace std;

inline int in() {
    int s = 0, f = 0, ch = getchar();
    while (!isdigit(ch))
        f |= ch == '-', ch = getchar();
    while (isdigit(ch))
        s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
    return f ? -s : s;
}
const int N = 1e6 + 5;
const int mod = 4;
const int inf = 1ULL << 60;
int n, m, k;
int a[N], b[N], f[N];
int c[N];

int qp(int a, int b) {
    int sum = 1;
    while (b) {
        if (b & 1)
            sum = sum * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return sum;
}
int inv(int a) {
    return qp(a, mod - 2);
}
bool flag[N];
int p[N], tot;

int find(int x) {
    return x == f[x] ? x : f[x] = find(f[x]);
}

struct node {
    int x, y;
    bool operator<(const node& b) const { return y > b.y; }
};

vector<pair<int, int>> g[N];
void work() {
    n = in(), m = in(), k = in();
    if (k == 0) {
        if (n - m >= 1) {
            puts("Takahashi");
        } else {
            puts("Aoki");
        }
    } else {
        if (m - n >= 1) {
            puts("Aoki");
        } else {
            puts("Takahashi");
        }
    }
}
signed main() {
#ifndef ONLINE_JUDGE
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
#endif
    // for (int _ = in(); _; --_)
    work();
    // system("pause");
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iomanip>
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ps(x,y)   fixed<<setprecision(y)<<x
using namespace std;
void solve()
{
	int n, m, t;
	cin >> n >> m >> t;
	int tot = n, prev = 0, flag = 1;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		tot -= (a - prev);
		if (tot <= 0) {
			flag = 0;
			tot = 0;
		}
		// cout << tot << endl;
		int dif = b - a;
		tot += dif;
		if (tot > n)tot = n;
		prev = b;

	}
	tot -= (t - prev);
	if (tot <= 0)flag = 0;
	if (flag) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// scanf("%d", &t);
	while (t--) {
		solve();
	}

}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(b-1)),y(up?b:(a-1)){}_RX(int a):_RX(0,a){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const int N = read_item();
	array<vector<i64>, 3> As;

	for(auto _ : range(2 * N)) {
		i64 a = read_item();
		string s = read_item();
		char c = s[0];
		int x = (c == 'R' ? 0 : c == 'G' ? 1 : 2);
		As[x].push_back(a);
	}

	vector<int> odds;
	for(auto i : range(3)) {
		if(As[i].size() % 2 == 1) {
			odds.push_back(i);
		}
	}

	assert(odds.size() == 0 || odds.size() == 2);

	if(odds.size() == 0) {
		printf("0\n");
		return 0;
	}

	auto xs = As[odds[0]];
	auto ys = As[odds[1]];
	auto zs = As[3 - odds[0] - odds[1]];

	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	sort(zs.begin(), zs.end());
	const int yn = ys.size();

	i64 ans = 1e18;

	auto nearest = [&](const vector<i64>& vs, i64 x) {
		int i = lower_bound(vs.begin(), vs.end(), x) - vs.begin();
		i = min(i, (int)vs.size() - 1);
		int j = max(i - 1, 0);
		return min(abs(x - vs[i]), abs(x - vs[j]));
	};

	for(auto x : xs) {
		i64 a = nearest(ys, x);
		ans = min(ans, a);
	}

	if(zs.size() >= 2) {

		vector<pair<i64, int>> zxs, zys;
		for(auto i : range(zs.size())) {
			auto z = zs[i];
			i64 zx = nearest(xs, z);
			i64 zy = nearest(ys, z);
			zxs.push_back({zx, i});
			zys.push_back({zy, i});
		}

		sort(zxs.begin(), zxs.end());
		sort(zys.begin(), zys.end());

		vector<i64> vs;
		for(auto i : range(2)) {
			for(auto j : range(2)) {
				auto zx = zxs[i];
				auto zy = zys[j];
				if(zx.second == zy.second) {
					continue;
				}
				vs.push_back(zx.first + zy.first);
			}
		}

		sort(vs.begin(), vs.end());
		i64 a = vs[0];
		ans = min(ans, a);
	}

	printf("%lld\n", ans);

	return 0;
}

/* wafdayo~~~ */

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_set>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using i64 = long long;
template<class T, class U>
bool chmin(T& a, const U& b) { return (b < a) ? (a = b, true) : false; }
template<class T, class U>
bool chmax(T& a, const U& b) { return (b > a) ? (a = b, true) : false; }

template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}

i64 solve(vector<i64>& a, vector<i64>& b, vector<i64>& c){
    sort(all(a));
    sort(all(b));
    i64 res = 5e18;
    for (auto i: a){
        auto x = lower_bound(all(b), i) - b.begin();
        if (x > 0) chmin(res, i - b[x - 1]);
        if (x < int(b.size())) chmin(res, b[x] - i);
    }
    vector<pair<i64, int>> aaa, bbb;
    for (auto i: c){
        i64 aa = 1e18, bb = 1e18;
        auto x = lower_bound(all(b), i) - b.begin();
        if (x > 0) chmin(bb, i - b[x - 1]);
        if (x < int(b.size())) chmin(bb, b[x] - i);
        x = lower_bound(all(a), i) - a.begin();
        if (x > 0) chmin(aa, i - a[x - 1]);
        if (x < int(a.size())) chmin(aa, a[x] - i);
        aaa.emplace_back(aa, i);
        bbb.emplace_back(bb, i);
    }
    sort(all(aaa));
    sort(all(bbb));
    if (aaa.empty()) return res;
    if (aaa[0].second == bbb[0].second) return min(res, min(aaa[0].first + bbb[1].first, aaa[1].first + bbb[0].first));
    return min(res, aaa[0].first + bbb[0].first);
}

int main()
{
    int n;
    cin >> n;
    vector<i64> R, G, B;
    rep(i, 2 * n){
        i64 a;
        char c;
        cin >> a >> c;
        if (c == 'R') R.emplace_back(a);
        if (c == 'G') G.emplace_back(a);
        if (c == 'B') B.emplace_back(a);
    }
    i64 ans = 0;
    if (R.size() & 1){
        if (B.size() & 1) ans = solve(R, B, G);
        else if (G.size() & 1) ans = solve(R, G, B);
    }
    else if ((B.size() & 1) && (G.size() & 1)) ans = solve(B, G, R);
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ld long double
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// #define endl "\n"
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    ll t[n];
    ll l[n];
    ll r[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>t[i]>>l[i]>>r[i];
    }

    ll ans=0;

    for (int i = 0; i < n; ++i)
    {
        ll si=l[i];
        ll ei=r[i];

        for (int j = i+1; j < n; ++j)
        {
            ll sj=l[j];
            ll ej=r[j];

            if(si>ej || sj>ei){
                continue;
            }
            else{
                if(si==ej){
                    if((t[j]!=2) && (t[i]!=3) && (t[i]!=4) && (t[j]!=4)){
                        ans++;
                    }
                }
                else if(sj==ei){
                    if((t[j]!=3) && (t[i]!=2) && (t[i]!=4) && (t[j]!=4)){
                        ans++;
                    }
                }
                else{
                    ans++;
                }
            }
        }
    }
    cout<<ans;

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<pair<int, int>> ps(n);
    for (auto& [l, r] : ps) {
        int t;
        cin >> t >> l >> r;
        l *= 2, r *= 2;
        if (t > 2) ++l;
        if (t % 2) ++r;
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        auto [li, ri] = ps[i];
        for (int j = 0; j < i; ++j) {
            auto [lj, rj] = ps[j];

            if (max(li, lj) < min(ri, rj)) ++ans;
        }
    }

    cout << ans << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}

//Codeforcesで128bit整数を使いたいとき
//→__int128_tを使う&GNU C++17 (64)で提出する

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;

//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}
signed main(){
	ll N;

	cin >> N;

	vector<vector<ll>> trl(N,vector<ll>(3,0));

	for (ll i=0;i<N;i++){
		cin >> trl[i][0] >> trl[i][1] >> trl[i][2];
	}
	sort(trl.begin(),trl.end(),[](const vector<ll> &alpha,const vector<ll> &beta){return alpha[1] < beta[1];});

	ll ans=0;
	for (ll i=0;i<N;i++){
		for (ll j=i+1;j<N;j++){
			if(trl[i][2] > trl[j][1]) ans++;
			else if (trl[i][2] == trl[j][1]) {
				if (trl[i][0] == 1 || trl[i][0] == 3)
					if (trl[j][0] == 1 || trl[j][0] == 2) ans++;
			}
			else break;
		}
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// look for  all edge cases
//search for a pattern

int n,m;

signed main(){

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> m;

	if(m < 0 ){
		cout << -1<<"\n";
		//return;
	}
	else if(m == 0){
		// you pick i pick
		int l =1;
		while(n--){
			cout << l <<" " << l+1 << "\n";
			l+=2;

		}
	}
	else if(m == n-1 || m == n){
		cout << "-1\n";
	}
	else{
		// i pick you dont
		int l = 2;
		int used=0;
		m = m +1;
		while(m--){
			cout << l << " " << l+1 <<"\n";
			l += 2;
			used += 1;
		}
		cout << 1 << " " << l<<"\n";
		l += 1;
		used += 1;
		while(used < n){
			cout << l << " " << l+1 <<"\n";
			l += 2;
			used += 1;
		}
	}

	return 0;

}

#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif
template <typename T> struct BIT {
public:
  int N;
  vector<T> A;
  BIT() {}
  BIT(int N) { init(N); }
  void init(int N) {
    this->N=N;
    A=vector<T>(N+1,0);
  }
  // query ∑ { sum[i] : i=l..<r }
  T query(int l, int r) {
    assert(l<=r&&0<=l&&r<=N);
    return query(r)-query(l);
  }
  // min index s.t. dat[0..i]>x
  int upperbound(T x) {
    int good=N+1,bad=0;
    while(abs(good-bad)>1) {
      int m=(good+bad)/2;
      (query(m)>x?good:bad)=m;
    }
    return good-1;
  }
  // sum[i]+=x
  void add(int i, T x) {
    assert(0<=i&&i<N);
    ++i;
    while(i<=N) A[i]+=x,i+=lsone(i);
  }
  // sum[i]=x
  void update(int i, T v) {
    T pre=query(i+1)-query(i);
    add(i,v-pre);
  }
private:
  int lsone(int i) { return i&-i; }
  // query in [0,r) : ∑ { sum[i] : i=0..r-1 }
  T query(int r) {
    assert(0<=r&&r<=N);
    T res=0;
    while(r>0) res+=A[r],r-=lsone(r);
    return res;
  }
};

// compute inversions
vector<int> inversions(vector<int> ns) {
  int maxv=*max_element(ns.begin(),ns.end());
  BIT<int> bit(maxv+1);
  int N=ns.size();
  vector<int> res(N);
  for(int i=N-1; i>=0; --i) {
    // Count elements which stays in right side and smaller
    res[i]=bit.query(0,ns[i]);
    bit.add(ns[i],1);
  }
  return res;
}
// $ cp-batch ShiftAndInversions | diff ShiftAndInversions.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ShiftAndInversions.cpp && ./a.out

/*

 1/30/2021

 5:06-

 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;

void solve() {
  auto ivs=inversions(VI(A,A+N));
  LL res=0; REP(i,N) res+=ivs[i];
  REP(i,N) {
    cout<<res<<endl;
    LL a=A[i],b=N-1-A[i];
    res=res-a+b;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


/*
*/

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

#define ll long long int
#define ld double
#define pb push_back
#define eb emplace_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<double>	vd;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
#define debug(a...) cout<<#a<<": ";for(auto it:a)cout<<it<<" ";cout<<endl;
ll MAX = 2e6 + 1;
ll mod = 1e9 + 7;

vector<vll> g;
vll in,out,dis;
ll cnt = 0;
vector<vll> edge;
vll tree,lazy;

void dfs(ll u,ll v){
    dis.pb(u);
    in[u] = cnt;
    cnt++;
    for(auto &x:g[u]){
        if(x == v) continue;
        dfs(x,u);
    }
    out[u] = cnt - 1;
}

bool parent(ll u,ll v){
    if(in[u] <= in[v] && out[u] >= out[v]) return true;
    return false;
}

ll range(ll v,ll tl,ll tr,ll l,ll r){
    if(lazy[v] > 0){
        tree[v] += lazy[v];
        lazy[2*v] += lazy[v];
        lazy[2*v + 1] += lazy[v];
        lazy[v] = 0;
    }
    if(tl == l && tr == r) return tree[v];
    if(l > r) return 0;
    ll tm = (tl + tr)/2;
    return (range(2*v,tl,tm,l,min(r,tm)) + range(2*v + 1,tm + 1,tr,max(l,tm + 1),r));
}

void update(ll v,ll tl,ll tr,ll l,ll r,ll val){
    if(lazy[v] > 0){
        tree[v] += lazy[v];
        lazy[2*v] += lazy[v];
        lazy[2*v + 1] += lazy[v];
        lazy[v] = 0;
    }
    if(l > r) return;

    if(l == tl && r == tr){
        tree[v] += val;
        lazy[2*v] += val;
        lazy[2*v + 1] += val;
        return;
    }
    ll tm = (tl + tr)/2;
    update(2*v,tl,tm,l,min(tm,r),val);
    update(2*v + 1,tm + 1,tr,max(l,tm + 1),r,val);
    tree[v] = tree[2*v] + tree[2*v + 1];

}

void solve(){
    ll n;
    cin >> n;
    g.resize(n);
    in.resize(n);
    out.resize(n);
    rep(i,0,n - 1){
        ll a,b;
        cin >> a >> b;a--,b--;
        g[a].pb(b);
        g[b].pb(a);
        edge.pb({a,b});
    }
    dfs(0,0);
    tree.resize(4*n);
    lazy.resize(8*n);
    ll q;
    cin >> q;
    vll ans(n);
    rep(i,0,q){
        ll t,e,c;
        cin >> t >> e >> c;e--;
        ll a,b;
        a = edge[e][0];
        b = edge[e][1];
        if(t == 2){
            swap(a,b);
        }
        if(parent(b,a)){
            ll l = in[a],r = out[a];
            update(1,0,n - 1,l,r,c);
        }
        else{
            ll l = in[b],r = out[b];
            update(1,0,n - 1,0,n - 1,c);
            update(1,0,n - 1,l,r,-1*c);
        }

    }
    rep(i,0,n){
        ans[dis[i]] = range(1,0,n - 1,i,i);
    }
    for(auto &x:ans) cout << x << br;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

	ll t = 1;
    // calc();
    // cin >> t;
    // calc();
	rep(i,0,t){
        // cout << "Case #" << i + 1 << ": ";
        solve();
        // test();
	}
}

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <cmath>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
using ll=long long;
using namespace std;
using pii = pair<int,int>;

int main(){
    int N,Q;
    cin>>N;
    vector<pii> E;
    vector<vector<int>> G(N);
    int u,v;
    for(int i=0;i<N-1;i++){
        cin>>u>>v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
        E.push_back({u,v});
    }
    set<pii> S;
    queue<int> q;
    vector<int> check(N,0);
    check[0]=1;
    q.push(0);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(auto p:G[v]){
            if(check[p]){continue;}
            check[p]=1;
            S.insert({v,p});
            q.push(p);
        }
    }

    /*
    cout<<"E"<<endl;
    for(auto p:E){
        cout<<p.first<<" "<<p.second<<endl;
    }
    cout<<"S"<<endl;
    for(auto p:S){
        cout<<p.first<<" "<<p.second<<endl;
    }
    //*/
    vector<ll> V(N,0);
    cin>>Q;
    int t,e;
    ll x;
    for(int i=0;i<Q;i++){
        cin>>t>>e>>x;
        e--;
        if(t == 1){
            if(S.find(E[e])!=S.end()){
                //cout<<"u->v"<<endl;
                V[0]+=x;
                V[E[e].second]-=x;
            }else{
                //cout<<"v->u"<<endl;
                V[E[e].first]+=x;
            }
        }else{
            if(S.find(E[e])!=S.end()){
                //cout<<"v->u"<<endl;
                V[E[e].second]+=x;
            }else{
                //cout<<"u->v"<<endl;
                V[0]+=x;
                V[E[e].first]-=x;
            }
        }
    }
    /*
    for(auto p:V){
        cout<<p<<" ";
    }
    cout<<endl;
    //*/

    check=vector<int> (N,0);
    check[0]=1;
    q.push(0);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(auto p:G[v]){
            if(check[p]){continue;}
            check[p]=1;
            V[p]+=V[v];
            q.push(p);
        }
    }
    for(auto p:V){
        cout<<p<<endl;
    }

    return 0;
}


#include<iostream>
#include<vector>
#include<map>
#include<stack>
#include<stdlib.h>
#include<math.h>
#include<string>
#include<string.h>
#include<set>
#include<algorithm>
#define Doura() ios_base::sync_with_stdio(false),cin.tie(NULL), cout.tie(NULL)
#define ll long long
using namespace std;

int main()
{
    Doura();
    int a,b;
    cin>>a>>b;
    ll ans =a/b;
    cout<<ans<<endl;
    return 0;
}

/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/

// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <vector>
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>

#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

int dp[1 << 20];

signed main()
{
    tezz

    vector<int> primes;
    for(int i=2; i<72; i++){
        bool flag = true;
        for(int j=2; j<i; j++){
            if(i % j == 0) flag = false;
        }

        if(flag) primes.emplace_back(i);
    }

    int A, B;
    cin>>A>>B;

    //now convert every number into masks.. with respect to prime divisors

    vector<int> v(B - A + 1);

    for(int i=A; i<=B; i++){
        int mask = 0;

        for(int j=0; j<primes.size(); j++){
            if(i % primes[j] == 0){
                mask |= (1 << j);
            }
        }

        v[i - A] = mask;
    }

    //now using dp to form every possible states
    dp[0] = 1;

    for(int x: v){
        for(int mask=0; mask<(1 << 20); mask++){
            if(dp[mask]){
                int tmp = mask & x;
                if(tmp == 0) dp[mask | x] += dp[mask];
            }
        }
    }

    int ans = 0;
    for(int i=0; i<(1 << 20); i++) ans += dp[i];

    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
int   A[2000][2000];
int score[2000][2000];
int H,W;
const int INF = 1001001001;
int calc(int i,int j,int t){
    if(i==H-1&&j==W-1)return 0;
    else if(score[i][j]!=INF)return score[i][j];
    else if (i==H-1){
        if(t==1){
            score[i][j]=calc(i,j+1,0)+ A[i][j+1];
            return score[i][j];}
        else  score[i][j]=calc(i,j+1,1)- A[i][j+1];
        return score[i][j];}
    else if (j==W-1){
        if(t==1)score[i][j]=calc(i+1,j,0)+ A[i+1][j];
        else score[i][j]=calc(i+1,j,1)- A[i+1][j];
        return score[i][j];}
    else {
        if(t==1)score[i][j]=max(calc(i+1,j,0)+ A[i+1][j],calc(i,j+1,0)+ A[i][j+1]);
        else score[i][j]=min(calc(i+1,j,1)- A[i+1][j],calc(i,j+1,1)- A[i][j+1]);
        return score[i][j];

        }

}
int main() {
     cin >>H>>W;
    A[2000][2000];
    rep(i,H){
        string tmp;
        cin>> tmp;
        rep(j,W){
        if(tmp[j]=='+')A[i][j]=1;
        else A[i][j]=-1;
        score[i][j]=INF;}
    }
    int ans=calc(0,0,1);
    if(ans>0)cout <<"Takahashi";
    if(ans<0)cout <<"Aoki";
    if(ans==0)cout <<"Draw";
  return 0;
    }

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <u32 M>
struct modint {
    u32 val;
public:
    static modint raw(int v) { modint x; x.val = v; return x; }
    modint() : val(0) {}
    template <class T>
    modint(T v) { ll x = (ll)(v%(ll)(M)); if (x < 0) x += M; val = u32(x); }
    modint(bool v) { val = ((unsigned int)(v) % M); }
    modint& operator++() { val++; if (val == M) val = 0; return *this; }
    modint& operator--() { if (val == 0) val = M; val--; return *this; }
    modint operator++(int) { modint result = *this; ++*this; return result; }
    modint operator--(int) { modint result = *this; --*this; return result; }
    modint& operator+=(const modint& b) { val += b.val; if (val >= M) val -= M; return *this; }
    modint& operator-=(const modint& b) { val -= b.val; if (val >= M) val += M; return *this; }
    modint& operator*=(const modint& b) { u64 z = val; z *= b.val; val = (u32)(z % M); return *this; }
    modint& operator/=(const modint& b) { return *this = *this * b.inv(); }
    modint operator+() const { return *this; }
    modint operator-() const { return modint() - *this; }
    modint pow(long long n) const { modint x = *this, r = 1; while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
    modint inv() const { return pow(M-2); }
    friend modint operator+(const modint& a, const modint& b) { return modint(a) += b; }
    friend modint operator-(const modint& a, const modint& b) { return modint(a) -= b; }
    friend modint operator*(const modint& a, const modint& b) { return modint(a) *= b; }
    friend modint operator/(const modint& a, const modint& b) { return modint(a) /= b; }
    friend bool operator==(const modint& a, const modint& b) { return a.val == b.val; }
    friend bool operator!=(const modint& a, const modint& b) { return a.val != b.val; }
};
using mint = modint<MOD>;

void solve(){
    int n, a, b;
    cin >> n >> a >> b;
    mint k = max(n-a-b+1, 0);
    mint ans = mint(max(0, n-b+1))*mint(max(0, n-a+1))*k*(k+1)*2-k*(k+1)*k*(k+1);
    cout << ans.val << "\n";
}

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


//BISMILLAHIR RAHMANIR RAHIM
//INNALLAHA_MA_AS_SABIRIN

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define      __                 <<" "<<
#define      loop(m,n)          for(m=0;m<n;m++)
#define      loop1(m,n)         for(m=1;m<=n;m++)
#define      rloop(m,n)         for(m=n-1;m>=0;m--)
#define      case()             "Case " << z++ << ": "
#define      test_inp()         ll Tc,z=1;cin>>Tc;while(Tc--)
#define      ntest_inp()        for(int Tc=0;Tc<1;Tc++)
#define      len(n)             (long long)((log(n)/log(10))+1.0000000001)
#define      PTF(b)             puts(b?"YES":"NO")
#define      Ptf(b)             puts(b?"Yes":"No")
#define      ptf(b)             puts(b?"yes":"no")
#define      newline            cout<<endl
#define      quit               return 0

using namespace std;
using namespace __gnu_pbds;

//typedefs
typedef long long ll;
typedef pair<ll,ll> pll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//constants
const ll mod=1000000007;

//Function prototypes
inline void ls();
inline ll ceill(ll n, ll k=1);
long long maxx(ll=0,ll=0,ll=0,ll=0,ll=0);
long long minn(ll=INT_MAX,ll=INT_MAX,ll=INT_MAX,ll=INT_MAX,ll=INT_MAX);
bool cmp1(pair<ll,ll> i1,pair<ll,ll> i2);
bool cmp2(pair<ll,ll> a, pair<ll,ll> b);
long long eugcd(ll a,ll b);

//Solve here...
ll bigmod(ll b, ll p)
{
    if(p==0) return 1;
    ll x=bigmod(b, p/2);
    x=(x*x)%mod;
    if(p%2==1)x=(x*b)%mod;
    return x;
}

int main()
{
    ls();

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int i,j;

    test_inp()
    {
        ll n;
        cin >> n ;

        if(n%2==1)
            cout << "Odd" << endl;
        else
        {
            if((n/2)%2==1)
                cout << "Same" << endl;
            else
                cout << "Even" << endl;
        }
    }

    quit;
}

//.......Functions here......

//Faster your code
inline void ls()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
//Multiple Maximum
ll maxx(ll a, ll b, ll c, ll d, ll e)
{
    ll ans = a>b ? a : b ;
    ans = ans > c ? ans : c ;
    ans = ans > d ? ans : d ;
    ans = ans > e ? ans : e ;

    return ans;
}
//Multiple Minimum
ll minn(ll a, ll b, ll c, ll d, ll e)
{
    ll ans = a<b ? a : b ;
    ans = ans < c ? ans : c ;
    ans = ans < d ? ans : d ;
    ans = ans < e ? ans : e ;

    return ans;
}
//double sort, both key and value in descending order
//and to make both ascending, use rbegin() and rend()
//priority: key
bool cmp1(pair<ll,ll> i1,pair<ll,ll> i2)
{
    if(i1.first == i2.first)
        return (i1.second> i2.second);
    else
        return (i1.first >i2.first);
}
//double sort, key ascending and value descending
//for vice versa, use rbegin() and rend()
//priority: value
bool cmp2(pair<ll,ll> a, pair<ll,ll> b)
{
    if(a.second!=b.second)
        return (a.second > b.second);
    else
        return (a.first < b.first);
}
//Euclidean gcd
ll eugcd(ll a,ll b)
{
    if(b==0)
        return a;
    ll p=a%b;
    return eugcd(b,p);
}
//ceil
inline ll ceill(ll n, ll k)
{
    return (n/k)+bool(n%k);
}
//......Function over

#include <iostream>
using namespace std;

int main(){
  int T;
  long c;
  cin >> T;
  for(int t=0; t<T; t++){
    cin >> c;
    if(c%2!=0){
      cout << "Odd" << endl;
    } else if(c%4!=0){
      cout << "Same" << endl;
    } else{
      cout << "Even" << endl;
    }
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	ll X; cin >> X;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	ll res=X-a[0];
	for(int k=2;k<=n;k++){
		vector<vector<int>> dp(k+1,vector<int>(k,-1));
		dp[0][0]=0;
		for(int i=0;i<n;i++){
			for(int j=k-1;j>=0;j--){
				for(int l=0;l<k;l++){
					if(dp[j][l]<0)continue;
					int nx=(l+a[i])%k;
					dp[j+1][nx]=max(dp[j+1][nx],dp[j][l]+a[i]);
				}
			}
		}
		if(dp[k][X%k]>=0){
			res=min(res,(ll)(X-dp[k][X%k])/k);
		}
	}
	cout << res << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define _rep(i, x, y) for(int i = (int)x; i < (int)y; ++i)
#define _dep(i,x,y) for(int i = (int)x; i > (int)y; i--)
#define PII pair<int,int>
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define PQ priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<ll> VL;
typedef vector<vector<ll>> VLL;
constexpr int mod = 1e9 + 7;
constexpr ll KINF = 1e18;
constexpr double eps = 1e-7;
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	ll x;
	cin >> n >> x;
	VI a(n);
	_rep(i, 0, n) cin >> a[i];
	auto check = [&](int k){
		int rem = x % k;
		int b[n];
		_rep(i, 0, n) b[i] = a[i] % k;
		int dp[n + 1][k + 1][k + 1];
		memset(dp, -0x3f, sizeof dp);
		_rep(i, 0, n + 1) dp[i][0][0] = 0;
		_rep(i, 1, n + 1)
			_rep(j, 1, k + 1)
				_rep(z, 0, k){
					dp[i][j][z] = dp[i - 1][j][z];
					if(z - b[i - 1] >= 0) dp[i][j][z] = max(dp[i][j][z], dp[i - 1][j - 1][z - b[i - 1]] + a[i - 1]);
					else dp[i][j][z] = max(dp[i][j][z], dp[i - 1][j - 1][z + k - b[i - 1]] + a[i - 1]);
					if(dp[n][k][rem] == x) return 0;
				}
		return dp[n][k][rem];
	};
	int res = -1;
	vector<PII> ans;
	_dep(k, n, 1){
		res = check(k);
		if(res > 0) {
			ans.eb(res, k);
		}
		if(res == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	if(ans.empty()) {
		sort(all(a));
		// auto  it = lb(all(a), x);
		// if(it != a.end()) cout << x - *it << endl;
		// else cout << x - a[n - 1] << endl;
		cout << x - a[n - 1] << endl;
		return 0;
	}
	else{
		ll res = KINF;
		for(auto& [ini, div] : ans){
			res = min(res, (x - ini) / div);
		}
		cout << res << endl;
	}
	return 0;
}
// 小心左移运算符导致的int溢出
// dp记得处理非法状态
// resize并不会初始化数组
// 全局函数一定要记得inline
// 带空格字符串不能直接cin,要用getline


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void solve() {
	ll N;
	cin >> N;
	vector<ll> P(N);
	rep(i, N) cin >> P[i];

	vector<ll> ans;

	for(ll n = 0; n >= 0; n++) {
		bool ok = true;
		bool update = false;

		//cout << "n = " << n << endl;
		//rep(i, N) cout << P[i] << " ";
		//cout << endl;

		rep(i, N-1) {
			if(P[i+1] < P[i]) {
				ok = false;
				if(i%2 == n%2) {
					ans.push_back(i+1);
					swap(P[i], P[i+1]);
					update = true;
					break;
				}
			}
		}

		if(ok) break;
		if(!update) {
			for(ll i = N-2; i >= 0; i--) {
				if(i%2 == n%2) {
					ans.push_back(i+1);
					swap(P[i], P[i+1]);
					break;
				}
			}
		}
	}

	cout << ans.size() << endl;
	rep(i, ans.size()) {
		cout << ans[i];
		if(i != ans.size() - 1) cout << " ";
	}
	cout << endl;
}

int main(){
	ll T;
	cin >> T;
	rep(i, T) solve();
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//#include <atcoder/convolution>
//#include <atcoder/modint>
//using Modint = atcoder::modint998244353;

using namespace std;
typedef long long ll;

void ex_gcd(ll a, ll b, ll &d, ll &x, ll &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    ex_gcd(b, a % b, d, y, x);
    y -= a / b * x;
  }
}
ll inv(ll a, ll n) {
  ll d, x, y;
  ex_gcd(a, n, d, x, y);
  return d == 1 ? (x % n + n) % (n / d) : -1;
}
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

const int maxn = 505;
const int mod = 998244353;

int a[maxn];
int pos[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int T;
  cin>>T;
  while(T--){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
      scanf("%d",&a[i]);
      pos[a[i]] = i;
    }
    int cur=1;
    vector<int>ans;
    for(int i=n;i>=4;i--){
      if(pos[i]==i)continue;
      if((pos[i]&1)!=cur){
        if(i==4&&pos[4]==3){
          int idx = pos[i];
          swap(a[idx-1], a[idx]);
          cur = 1-cur;
          ans.push_back(idx-1);
          pos[a[idx-1]] = idx-1;
          pos[a[idx]] = idx;
        }
        for(int j=1;j<i;j++){
          if(a[j]!=i&&a[j+1]!=i&&(j&1)==cur){
            swap(a[j], a[j+1]);
            cur = 1 - cur;
            ans.push_back(j);
            pos[a[j]] = j;
            pos[a[j+1]] = j+1;
            break;
          }
        }
      }
      for(int j=pos[i];j<i;j++){
        ans.push_back(j);
        cur = 1-cur;
        swap(a[j], a[j+1]);
        pos[a[j]] = j;
        pos[a[j+1]] = j+1;
      }
    }
    if(n==2){
      if(!(a[1]==1&&a[2]==2)){
        ans.push_back(1);
        cur = 1 - cur;
        swap(a[1], a[2]);
        pos[a[1]] = 1;
        pos[a[2]] = 2;
      }
    } else {
      while(!(a[1]==1&&a[2]==2&&a[3]==3)){
        int tmp = 2 - cur;
        ans.push_back(tmp);
        cur = 1-cur;
        swap(a[tmp], a[tmp+1]);
        pos[a[tmp]] = tmp;
        pos[a[tmp+1]] = tmp+1;
      }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
      if(i)printf(" ");
      printf("%d", ans[i]);
    }
    cout<<endl;
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define bit(n,k) ((n>>k)&1) //nのk　bit目
#define vec(T) vector<T>
#define vvec(T) vector<vector<T>>
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll llINF = 1LL << 60;
const int iINF = 1e9;

//------------------------------------------------

struct Solver{

    void solve(){
        ll N;
        cin >> N;
        string S;
        cin >> S;
        ll Q;
        cin >> Q;

        ll flip=0;
        rep(qi,Q){
            ll ti,A,B;
            cin >>ti>> A >> B;
            if(ti==1){
                A = (A-1+N*flip)%(2*N);
                B = (B-1+N*flip)%(2*N);
                swap(S[A],S[B]);

            }else flip = 1-flip;

        }

        if(flip==0) cout << S << endl;
        else cout << S.substr(N,N) << S.substr(0,N) << endl;

    }
};

int main(){
    int testcasenum=1;
    //cin >> testcasenum;
    rep1(ti,testcasenum){
        Solver solver;
        solver.solve();
    }
    return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
#define int long long
using namespace std;
const int p=1e4;
int read(){
    string s;cin>>s;
    int t=4;
    int f=0;
    int ans=0;
    for(auto i:s){
        if(i=='.'){
            f=1;
            continue;
        }else{
            ans=ans*10+(i-'0');
            if(f)t--;
        }
    }
    while(t){
        ans=ans*10;
        t--;
    }
    return ans;
}
signed main(){
    int X=read();
    int Y=read();
    int R=read();
    //定义横坐标左右边界
    int lc=X-R;
    int rc=X+R;
    while(lc%p)lc++;
    while(rc%p)rc--;
    //定义上下界指针; 横坐标变化的时候,只需要移动一点点上下界指针就行了.
    int up=Y,down=Y;
    while(up%p)up++;//取整
    while(down%p)down--;
    //
    int ans=0;
    for(int i=lc;i<=rc;i+=p){//枚举横坐标
        int ix=abs(X-i);
        //
        while(ix*ix+(up-Y)*(up-Y)>R*R)up-=p;//up下移
        while(up<=Y||ix*ix+(up-Y)*(up-Y)<=R*R)up+=p;//up上移到上界+1
        //
        while(ix*ix+(Y-down)*(Y-down)>R*R)down+=p;//down上移
        while(down>=Y||ix*ix+(Y-down)*(Y-down)<=R*R)down-=p;//down下移到下界-1
        //
        int add=(up-down+p-2*p)/p;//up-down+1-2就是长度.
        if(add>0)ans+=add;
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=2e3+5;
int n,m,u,v,w,dis[maxn][maxn],a[maxn];
struct node{
	int x,y;
	bool operator<(const node &a)const{
		return y>a.y;
	}
};
vector<node> g[maxn];
void dijkstra(int u){
	dis[u][u]=0;
	queue<node> q;
	q.push({u,0});
	while(!q.empty()){
		node now=q.front();
		q.pop();
		int from=now.x;
		for(auto it:g[from]){
			int to=it.x,w=it.y;
			if(dis[u][from]+w<dis[u][to]){
				dis[u][to]=dis[u][from]+w;
				q.push({to,dis[u][to]});
			}
		}
	}
}
int main(){
	n=read(),m=read();
	memset(a,inf,sizeof(a));
	memset(dis,inf,sizeof(dis));
	for(int i=1;i<=m;++i){
		u=read(),v=read(),w=read();
		if(u==v) a[u]=min(a[u],w);
		else g[u].push_back({v,w});
	}
	for(int i=1;i<=n;++i) dijkstra(i);
	for(int i=1;i<=n;++i){
		int ans=inf;
		for(int j=1;j<=n;++j){
			if(i==j) continue;
			ans=min(ans,dis[i][j]+dis[j][i]);
		}
		ans=min(ans,a[i]);
		if(ans==inf) printf("-1\n");
		else printf("%d\n",ans);
 	}
	return 0;
}

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

int main() {
    int n, m;
    cin>> n >> m;
    vector<pair<int, int>> a(m);
    for (auto& [A, B] : a) cin>> A >> B;
    int k; cin>> k;
    vector<pair<int, int>> b(k);
    for (auto& [C, D] : b) cin>> C >> D;

    int ans = 0;
    for (int bit=0; bit<(1<<k); bit++) {
        vector<bool> ball(n);
        for (int i=0; i<k; i++) {
            const auto [C, D] = b[i];
            ball[bit & 1<<i ? C : D] = 1;
        }
        int cnt = 0;
        for (auto [A, B] : a) if (ball[A] && ball[B]) cnt++;
        if (ans < cnt) ans = cnt;
    }

    cout << ans << endl;
    return 0;
}


#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace std;

// #pragma GCC optimize("O3","unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("avx2")

using namespace __gnu_pbds;
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) -> iterator of kth element (in sorted fashion : low - high)
// order_of_key(x) -> #numbers strictly less than x

#define sync ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
#define unq(a) sort(all(a));a.resize(unique(all(a)) - a.begin())
#define F first
#define S second
#define endl '\n'

using pii = pair<int , int>;
using ll = long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 rng(0);

int main(){
    sync

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t = 1;
    //cin >> t;
    while(t--){
      string s;
      cin >> s;
      int cnt = 0;
      for (int i = 0; i < s.size(); i++){
        string r;
        for (int x = 4, j = i; j < s.size() && x > 0; j++,x--){
          r += s[j];
        }

        cnt += (r == "ZONe");
      }
      cout << cnt << endl;
    }

    cerr << "processor time: " << clock() / (double) CLOCKS_PER_SEC << "s    ";
    return 0;
}

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

int main() {
  string S;
  cin>>S;
  int cnt=0;
  for(int i=0;i<9;i++){
    string T=S.substr(i,4);
    if(T=="ZONe") cnt++;
  }
  cout<<cnt<<endl;
}


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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int const N = 107;

int X[N], Y[N];
int main()
{
	fastio;

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i)
		cin >> X[i] >> Y[i];

	for (int i = 0; i < n; ++i)
		for (int j = i+1; j < n; ++j)
			for (int k = j+1; k < n; ++k)
	{
		if ((Y[j] - Y[i]) * (X[k] - X[j]) == (Y[k] - Y[j]) * (X[j] - X[i]))
		{
			//cout << i << " " << j << " " << k << '\n';
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

#include<bits/stdc++.h>
//#define int long long int
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fastm_fast ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
const int  mod = 1e9 + 7;
const int MAX = 2e5+5;
typedef pair<int, int> pii;
typedef vector<int> vi ;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef map<int,int> mapii ;

void sujho(){
    int n ;
    cin >> n ;
    vector<pair<int,string> > v;

    for(int i = 0; i < n; i++){
        int x ;
        string s;
        cin >> s ;
        cin >> x;
        v.push_back({x,s});
    }
    sort(all(v));

    cout << v[n-2].second;

}
int main()
{
 fastm_fast;
//  int test;cin >> test;
//  for(int i = 1; i <= test; i++)
 { //cout << "Case #"<< test << ":";
     sujho();
 }
 return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	if(n==1&&m==0)
	{
		printf("1 2\n");
		return 0;
	}
	if(m<0||m>=n-1)
	{
		printf("-1\n");
		return 0;
	}
	m++;
	printf("1 %d\n",2*m+2);
	for(int i=1;i<=m;i++)
		printf("%d %d\n",i*2,i*2+1);
	for(int i=m+1;i<n;i++)
		printf("%d %d\n",i*2+1,i*2+2);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long

int N,L;
vector<int> A(1e5+10), B(1e5+10), C, high(1e5+10), low(1e5+10);

main() {

    cin >> N >> L;
    C.push_back(0);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        C.push_back(A[i]-i);
    }
    C.push_back(L-N);

    int t = 0;
    for (int i = 1; i <= N; i++) {
        cin >> B[i];
      //  cout << "Goal: " << " " << B[i] << "\n";
      //  for (int c: C) cout << c+i << " "; cout << "\n";
        auto it = lower_bound(C.begin(), C.end(), B[i]-i);
        if (it == C.end() || *it != B[i]-i) {
            cout << "-1\n";
            return 0;
        }
        auto it2 = upper_bound(C.begin(), C.end(), B[i]-i);
        int z = it-C.begin();
        int z2 = it2-C.begin()-1;
        if (z <= i && i <= z2) {
            z = i;
        }
        else if (abs(z2-i) < abs(z-i)) {
            z = z2;
        }
        //go from i to z
        //cout << i << " to " << z << "\n";
        if (i < z) {
            low[z] = max(z-i, low[z]);
        }
        if (i > z) {
            high[z] = max(i-z,high[z]);
        }
    }

    for (int i = 0; i <= N+1; i++) {
       // cout << i << " " << low[i] << " " << high[i] << "\n";
        t += low[i] + high[i];
    }

    cout << t << "\n";

   // cout << t << "\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int to_int(char c){ return c-'0'; }
string s[3];
int n;
void solve(){
	bool flag=1;
	for(int i=0;i<3;++i)
		if(to_int(s[i][0])+to_int(s[i][n+n-1])==2) flag=0;
	if(flag){
		for(int i=1;i<=n;++i) putchar('1');
		putchar('0');
		for(int i=1;i<=n;++i) putchar('1');
	}else{
		putchar('1');
		for(int i=1;i<=n;++i) putchar('0');
		for(int i=1;i<=n;++i) putchar('1');
	}
	puts("");
}
int main(){
	int T; scanf("%d",&T);
	while(T--){
		cin>>n;
		cin>>s[0]>>s[1]>>s[2];
		solve();
	}
	return 0;
}

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

const int N = 100000 + 9;

char s[5][N];

void solve(){
    int n; scanf("%d", &n);
    scanf("%s %s %s", &s[1][1], &s[2][1], &s[3][1]);
    for (int i = 1; i <= n; ++i) putchar('1');
    for (int i = 1; i <= n; ++i) putchar('0');
    putchar('1'); putchar('\n');
}

int main(){
    int T; scanf("%d", &T);
    while (T--) solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5;
ll v[N],p[N],a[N];
int main()
{
	ll n;cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll sum=0;ll pos=a[i];
		for(int j=i;j<=n;j++)
		{
			if(a[j]>=pos)	sum+=pos;
			else			break;

		}
		for(int j=i-1;j>=1;j--)
		{
			if(a[j]>=pos)	sum+=pos;
			else			break;
		}ans=max(ans,sum);
	}cout<<ans<<'\n';
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 510;

int n;
int a[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	cin >> n;

	int mn_idx = 1;
	bool ok = true;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1, del; j <= n; ++j) {
			cin >> a[i][j];
			if (i > 1) {
				if (j == 1) del = a[i][j] - a[i - 1][j];
				else if (a[i][j] - a[i - 1][j] != del) ok = false;
			}
		}
		if (a[i][1] < a[mn_idx][1]) mn_idx = i;
	}

	if (ok) {
		cout << "Yes\n";
		for (int i = 1; i <= n; ++i) cout << a[i][i] - a[mn_idx][i] << ' ';
		cout << '\n';
		for (int i = 1; i <= n; ++i) cout << a[mn_idx][i] << ' ';
		cout << '\n';
	} else {
		cout << "No\n";
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,x,a;
int main()
{
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a!=x)
		{
			cout<<a<<" ";
		}
	}
	return 0;
}

//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*
int inv[1000001]={0};int invf[1000001]={0};
void findinverse(){
	inv[0]=1;
	inv[1] = 1;
	for(int i = 2; i <=1e6 ; ++i)
		inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
	invf[0]=1;invf[1]=1;
	for(int i=2;i<=1e6;i++){
		invf[i]=invf[i-1]*inv[i]%mod;
	}
}*/
using namespace std;
int solve()
{
	int x,y;
	cin>>x>>y;
	cout<<(x+y)/2<<" "<<(x-y)/2<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}


#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x){
    x=0;char ch=getchar();bool f=false;
    while(!isdigit(ch)) f|=ch=='-',ch=getchar();
    while(isdigit(ch))  x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    x=f?-x:x;
}
template <typename T>
inline void print(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10^48);
}
int x,y,z;

int main(){
    read(x),read(y),read(z);
    for(register int i=0;i<=1000000;++i){
        double tep=double((1.0*i)/z),tep2=double((1.0*y)/x);
        if(tep>=tep2){
            // cout<<tep<<" "<<tep2<<endl;
            print(i-1);break;
        }
    }
    return 0;
}

#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define mod 1000000007
#define pi 3.14159265358979
#define  PRE(x,p) cout<<setprecision(x)<<p;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl "\n"
#define high INT_MAX
#define low INT_MIN
#define ll long long int

using namespace std;

void showa(ll a[],ll n){ for(ll i=1;i<=n;i++) cout<<a[i]<<' ';  cout<<endl;  }
void showv(vector<ll>v){ for(ll i=0;i<v.size();i++) cout<<v[i]<<' '; cout<<endl;}

void solve()
{
   ll n1,b,c,d,i;
   cin>>n1>>b>>c>>d;
   ll n2=0;

   for(i=1;i<=1000000;i++)
   {
    if(n1<=n2*d)
    {cout<<i-1;
    return;}

    n1+=b;
    n2+=c;
   }

   cout<<"-1";

}
int main()
{
 #ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
 #endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

ll t=1;
// cin>>t;
for(ll test=1;test<=t;test++)
{
    // cout<<"CASE #"<<test<<": ";
    solve();
}

return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define int ll

const int M = 998244353;

int rep(int x) {
  x %= M;
  if (x < 0) x += M;
  return x;
}

int add(int a, int b) {
  return rep(a + b);
}

int mul(int a, int b) {
  return rep(a * b);
}

int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = rep(r * a);
    a = rep(a * a);
    b /= 2;
  }
  return r;
}

int dv(int a, int b) {
  return rep(a * pw(b, M - 2));
}

const int N = 5000 + 7;
int n, sum, dp[N], fact[N], ifact[N], dp2[N];

int comb(int n, int k) {
  if (k < 0 || k > n) return 0;
  return mul(fact[n], mul(ifact[k], ifact[n - k]));
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  ///freopen ("input", "r", stdin);
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
  }
  ifact[N - 1] = dv(1, fact[N - 1]);
  for (int i = N - 2; i >= 0; i--) {
    ifact[i] = mul(ifact[i + 1], i + 1);
  }
  dp[0] = 1;
  cin >> n >> sum;
  for (int b = 0; (1 << b) <= sum; b++) {
    int p = (1 << b);
    for (int j = 0; j <= sum; j++) dp2[j] = 0;
    for (int cnt = 0; cnt * p <= sum; cnt += 2) {
      int ways = comb(n, cnt);
      for (int bef = 0; bef + cnt * p <= sum; bef++) {
        dp2[bef + cnt * p] = add(dp2[bef + cnt * p], mul(ways, dp[bef]));
      }
    }
    for (int j = 0; j <= sum; j++) dp[j] = dp2[j];
  }
  cout << dp[sum] << "\n";
  return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 998244353
#define infi 1010000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

class Combination {
    vl fac,finv,inv;
public:
    Combination(ll n) {
        n++;
        fac.resize(n);finv.resize(n);inv.resize(n);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        reps(i,2,n){
            fac[i] = fac[i-1]*(ll)i%mod;
            inv[i] = (ll)mod - inv[mod%i]*(ll)(mod/i)%mod;
            finv[i] = finv[i-1]*inv[i]%mod;
        }
    }

    ll com(ll n, ll m){
        if(n < m) return 0;
        if(n < 0 || m < 0) return 0;
        return fac[n]*(finv[m]*finv[n-m]%mod)%mod;
    }
};

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,M;
    cin >> N >> M;

    Combination C(10000);

    int n = 14;
    vvl dp(n+1,vl(M+1,0));
    dp[0][0] = 1;

    rep(i,n){
        int a = int(1<<i);
        rep(k,M+1){
            dp[i+1][k] += dp[i][k];
            dp[i+1][k] %= mod;

            if(dp[i][k] == 0) continue;
            for (int j = 2; j <= N; j += 2) {
                if(a*j+k > M) break;

                dp[i+1][a*j+k] += dp[i][k]*C.com((ll)N,(ll)j)%mod;
                dp[i+1][a*j+k] %= mod;
            }
        }

    }

    cout << dp[n][M] << endl;

    return 0;
}


#include<bits/stdc++.h>                                                   //---------------------------------------------------------------

# define ll long long
# define mod 1000000007
# define MAX 100005
# define PI 3.141592653589793238                                                                                //shortcut keys

# define pb push_back
# define mp make_pair
# define all(x) x.begin(),x.end()
# define fr(i,a,b) for(int i=a;i<=b;i++)

# define decimal(k) fixed<<setprecision(k)
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------
using namespace std;

int main()
{
	int n;cin>>n;
	vector<tuple<ll,ll,ll> > v;
	ll suma=0;
	fr(i,1,n){
		ll x,y,z;cin>>x>>y;
		z=2*x+y;
		v.pb(make_tuple(z,x,y));
		suma+=x;
	}
	sort(all(v));
	reverse(all(v));
	int ans=0;
	ll sumt=0;
	fr(i,0,n-1){
		sumt+=get<1>(v[i])+get<2>(v[i]);
		suma-=get<1>(v[i]);
		ans++;
		if(sumt>suma)break;
	}
	cout<<ans<<'\n';

	return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define p_q priority_queue
#define m_p make_pair
#define pb push_back
#define ld long double
#define fi first
#define se second
#define ull unsigned long long
#define mod 1000000007
#define md 998244353
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
using namespace std;
inline void read(int &x){
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0'||c>'9'){
		if(c=='-')negative=-1;
		c=getchar();
	}
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll qpow(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string i_to_s(int n){
	string s="";
	while(n){
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int s_to_i(string s){
	int n=0;
	rep(i,s.size()){
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int n;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	cout<<(n-1)/100+1<<"\n";
	return 0;
}
//特判判全
//循环边界
//精度足够
//注意初值


#include<bits/stdc++.h>
using namespace std;
const int p = 31;
const int m = 1e9 + 7;
typedef long long ll;
typedef int in;
#define ff first
#define ss second
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
bitset<200009>vis;
vector<ll>dp(200009, -1e12);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<ll>cst(n);
    for (int i = 0; i < n; ++i) {
        cin >> cst[i];
    }

    vector<vector<int>>gr(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        gr[x].push_back(y);
    }
    ll ans = -1e12;
    function<ll(int)>f = [&](int i) {
        if (dp[i] > -1e10)return dp[i];
        ll tmp = -1e12;
        vis[i] = 1;
        if (gr[i].empty()) {
            return 0ll;
        }
        for (auto& it : gr[i]) {
            tmp = max(tmp, cst[it] - cst[i] + f(it));
            tmp=max(tmp, cst[it]-cst[i]);
        }
        ans = max(ans, tmp);
        return dp[i] = tmp;
    };
    for (int i = 0; i < n; ++i) {
        if (!vis[i] && !gr[i].empty()) {
            f(i);
        }
    }
    cout << ans;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
const ll maxn=3e5+10;

const ll mod=1e9+7;
const ll m2=1e9+7;
const ll INF64 = ll(1e18);
const ll max2=10500000;

int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
//long long tt = clock();
#endif
ios_base::sync_with_stdio(NULL);  cin.tie(0); cout.tie(0);
int n,m1,q,i,j,k;
cin>>n>>m1>>q;
vector<pair<int,int>> v(n);
for(i=0;i<n;++i)
{int x,y;
	cin>>x>>y;
	v[i]=make_pair(x,y);
}
sort(v.begin(),v.end());
vector<int> w1(m1);
for(i=0;i<m1;++i)
cin>>w1[i];
while(q--)
{
	int l,r,m;
	cin>>l>>r;
	--l,--r;
	vector<int> w;
	for(i=0;i<l;++i)
		w.push_back(w1[i]);

for(i=r+1;i<m1;++i)
	w.push_back(w1[i]);

m=w.size();
sort(w.begin(),w.end());
int dp[m+1][n+1];
for(i=0;i<=m;++i)
	for(j=0;j<=n;++j)
		dp[i][j]=INT_MIN;
for(i=0;i<=n;++i)
{
	dp[0][i]=0;
}
for(i=0;i<=m;++i)
{
	dp[i][0]=0;
}

for(i=1;i<=m;++i)
{
	for(j=1;j<=n;++j)
	{
		// ith box till jth;
		for(k=j;k>=1;--k)
		{
			if(v[k-1].first<=w[i-1])
			{	if(dp[i-1][k-1]!=INT_MIN)
				dp[i][j]=max(dp[i][j],dp[i-1][k-1]+v[k-1].second);
			}
		}
		dp[i][j]=max(dp[i][j],dp[i-1][j]);
	}
}
cout<<dp[m][n]<<"\n";
}

return(0);
}


#include<bits/stdc++.h>
#define ll long long int
#define pll pair<ll,ll>
#define vpll vector< pll >
#define mpll map<ll,ll>
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define s(v) v.size()
#define test ll t;cin>>t;while(t--)
#define vec vector<ll>
#define read0(v,n) for(int i=0;i<n;i++)cin>>v[i];
#define read1(v,n) for(int i=1;i<=n;i++)cin>>v[i];
#define trav(a,x) for (auto& a: x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cut(x) {cout<<x;return 0;}
#define print(x) {cout<<x<<nl;continue;}
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define err1(a) {cout<<#a<<' '<<a<<nl;}
#define err2(a,b) {cout<<#a<<' '<<a<<' '<<#b<<' '<<b<<nl;}
#define mem(a,b) memset(a,b,sizeof(a))

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define nl '\n'
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gcd(ll a, ll b){
	if (b==0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a,ll b){

    return (a*b)/gcd(a,b);
}
ll bpow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	#endif
    fast
    vec v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(all(v));
    cut(v[2]+v[1])

}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vvint c(n, vint(n));
    rep(i,n)rep(j,n) cin >> c[i][j];
    rep(i,n)rep(j,i) {
        vint tmp(n);
        vint x = c[i], y = c[j];
        rep(k,n) tmp[k] = x[k] - y[k];
        bool ok = true;
        int v = tmp[0];
        REP(k,n) if (tmp[k] != v) ok = false;
        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
    }
    P p = P(inf, -1);
    rep(i,n) {
        if (c[i][0] < p.first) p = P(c[i][0], i);
    }
    vint b = c[p.second], a(n);
    rep(i,n) a[i] = c[i][0] - b[0];
    cout << "Yes" << endl;
    rep(i,n) printf("%d%s", a[i], i == n - 1 ? "\n" : " ");
    rep(i,n) printf("%d%s", b[i], i == n - 1 ? "\n" : " ");
}


#include <bits/stdc++.h>

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
using ll = long long;
using namespace std;
const double PI = acos(-1);
const int M = 1000000007;
// const int M = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k, int m = M) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2, m);
  ax = mod(ax * ax, m);
  if (k % 2) ax = mod(ax * n, m);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

//#define MULTIPLE_TEST_CASE
void solution() {
  int n, m;
  cin >> n >> m;
  vector<vector<char>> A(n, vector<char>(m));
  ii S, G;
  int dst[n][m];
  vector<ii> pos[26];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
      dst[i][j] = INF;
      if (A[i][j] == 'S') S = ii(i, j);
      if (A[i][j] == 'G') G = ii(i, j);
      if (A[i][j] >= 'a' && A[i][j] <= 'z') pos[A[i][j] - 'a'].pb(ii(i, j));
    }
  }

  auto valid = [&](const int x, const int y) {
    return x >= 0 && x <= n - 1 && y >= 0 && y <= m - 1 && A[x][y] != '#';
  };

  set<char> tels;
  for (char c = 'a'; c <= 'z'; c++) {
    tels.insert(c);
  }
  set<tuple<int, int, int>> s;
  dst[S.ff][S.ss] = 0;
  s.insert(mt(0, S.ff, S.ss));
  while (s.size() > 0) {
    int i, j, d;
    tie(d, i, j) = *s.begin();
    s.erase(s.begin());
    if (dst[i][j] != d) continue;

    // take tel
    if (A[i][j] >= 'a' && A[i][j] <= 'z' && tels.count(A[i][j])) {
      tels.erase(A[i][j]);
      for (ii x : pos[A[i][j] - 'a']) {
        if (valid(x.ff, x.ss) && dst[x.ff][x.ss] > d + 1) {
          dst[x.ff][x.ss] = d + 1;
          s.insert(mt(d + 1, x.ff, x.ss));
        }
      }
    }

    // normal
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, -1, 0, 1};

    for (int k = 0; k < 4; k++) {
      int ni = i + dx[k];
      int nj = j + dy[k];
      if (valid(ni, nj) && dst[ni][nj] > d + 1) {
        dst[ni][nj] = d + 1;
        s.insert(mt(d + 1, ni, nj));
      }
    }
  }

  if (dst[G.ff][G.ss] >= INF) dst[G.ff][G.ss] = -1;
  cout << dst[G.ff][G.ss] << endl;
}

int32_t main() {
  DESYNC;
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define rep(i,n) for(int i=0;i<(n);i++)
#define drep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    auto id = [&](int x,int y){
        return x*W+y;
    };
    auto xy = [&](int a){
        return (pair<int,int>){a/W,a%W};
    };
    auto in = [&](int x,int y){
        return 0<=x && x<H && 0<=y && y<W;
    };
    vvec<char> S(H,vec<char>(W));
    int sx,sy,gx,gy;
    int M = 26;
    vvec<int> list(M);
    rep(i,H) rep(j,W){
        cin >> S[i][j];
        if(S[i][j]=='S') sx = i,sy = j;
        else if(S[i][j]=='G') gx = i,gy = j;
        else if(isalpha(S[i][j])) list[S[i][j]-'a'].push_back(id(i,j));
    }
    vec<int> dx = {-1,1,0,0},dy = {0,0,-1,1};
    vec<int> dp(H*W+M,-1);
    deque<int> Q;
    dp[id(sx,sy)] = 0;
    Q.push_back(id(sx,sy));
    while(!Q.empty()){
        int now = Q.front(); Q.pop_front();
        if(now<H*W){
            auto [x,y] = xy(now);
            rep(k,4){
                int nx = x+dx[k],ny = y+dy[k];
                if(!in(nx,ny)) continue;
                if(S[nx][ny]=='#') continue;
                if(dp[id(nx,ny)]==-1){
                    dp[id(nx,ny)] = dp[now]+1;
                    Q.push_back(id(nx,ny));
                }
            }
            if(isalpha(S[x][y]) && islower(S[x][y])){
                int to = H*W+(S[x][y]-'a');
                if(dp[to]==-1){
                    dp[to] = dp[now];
                    Q.push_front(to);
                }
            }
        }else{
            for(auto& to:list[now-H*W]){
                if(dp[to]==-1){
                    dp[to] = dp[now]+1;
                    Q.push_back(to);
                }
            }
        }
    }
//    rep(i,H) rep(j,W) cerr << dp[id(i,j)] << (j!=W-1? " ":"\n");
    cout << dp[id(gx,gy)] << "\n";
}


/*

ll fastmod(ll x,ll y)
{
    ll res=1;
    if(x%mod==0)
        return 0;
    while(y>0)
    {
        if(y&1)
           res=(res*x)%mod;
        y=y>>1;
        x=(x*x)%mod;
    }
    return res;
}
}*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define tr(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define vin(v,k) fo(i,k)cin>>a,v.pb(a);
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define mod 1000000007
#define siz 100010
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

/*ll arr[250010];

struct node
{
    ll val,zcnt,ocnt,tcnt;
    node(val=0,zcnt=0,ocnt=0,tcnt=0)
    {
        val(val),zcnt(zcnt),ocnt(ocnt),tcnt(tcnt);
    }
}

node merge(node a,node b)
{

}
*/

ll fastmod(ll a,ll b)
{
    ll ans=1;
    a=a%mod;
    if(a==0)
        return 0;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b=b>>1;
        a=(a*a)%mod;
    }
    return ans%mod;
}
ll fermat(ll a)
{
    return fastmod(a,mod-2)%mod;
}

vector<ll> fact(siz);
vector<ll> invfact(siz);
void f()
{
    fact[0]=fact[1]=invfact[0]=invfact[1]=1;
    for(ll i=2;i<siz;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
        invfact[i]=(invfact[i-1]*fermat(i))%mod;
    }
}
ll choose(ll n,ll r)
{
    ll ans=fact[n]%mod;
    ans=(ans*invfact[n-r])%mod;
    ans=(ans*invfact[r])%mod;
    return ans%mod;
}

int main()
{
    fast;
    ll a,b,c,d,p,n,m,t,h,k,q,x,val,y;
    cin>>n;
    ll ans=0;
    set<ll> s;
    for(ll i=2;i<=(ll)sqrt(n);i++)
    {
        val=i;
        while(val<=n)
        {
            val*=i;
            if(val<=n)
                s.insert(val);
        }
    }

    cout<<n-s.size();

}

/*cin>>t;
    map<ll,ll> mp;
    while(t--)
    {
        cin>>n>>m>>k;
        cin>>p;
        set<ll> s;
        for(ll i=0;i<p;i++)
        {
            cin>>a;
            s.insert(a)
        }

    }
*/

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

int main(){
    ll N;
    cin >> N;
    unordered_set<ll> s;
    for(ll a = 2; a * a <= N; a++){
        ll x = a * a;
        while(x <= N){
            s.insert(x);
            x *= a;
        }
    }
    cout << N - s.size() << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T> void print(T& v){ for(auto it : v) cout << it << " "; cout << endl; }
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int n;
vector<ll> a;
vector<vector<int>> p, nn;
const int MOD = 1e9+7;
vector<vi> cache;
int solve(int i, int k){
    if (k > n) return 0;
    if (k == n) return 1;
    if (i > n) return 0;
    if (cache[i][k] != -1) return cache[i][k];
    ll r = 0;
//    int s = 0;
    int j = nn[i][k];
    r += solve(i+1, j+1);
    r -= MOD * (r >= MOD);
    r += solve(i, j+1);
    r -= MOD * (r >= MOD);
//    for(int j = k; j < n; j++){
//        int ds = a[j] % i;
//        s = s + ds;
//        if (s >= i) s -= i;
//        if (s == 0){
//            r += solve(i+1, j+1);
//            r -= MOD * (r >= MOD);
//            r += solve(i, j+1);
//            r -= MOD * (r >= MOD);
//            break;
//        }
//    }
    return cache[i][k] = r;
}

//#define TEST 1
int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

#if TEST
    n = 3000;
    a.resize(n);
    FOR(i, n)
        a[i] = rand() * (1LL + rand());
#else
    cin >> n;
    a.resize(n);
    FOR(i, n) cin >> a[i];
#endif
    init(p, 0, n+1, n+1);
    init(nn, 0, n+1, n+1);
    FOR1(i, n){
        FOR(k, n){
            if (k) p[i][k] = p[i][k-1];
            p[i][k] += a[k] % i;
            p[i][k] -= i * (p[i][k] >= i);
        }
        map<int, int> H;
        FORI(k, n){
            H[p[i][k]] = k;
            int pr = 0;
            if (k) pr = p[i][k-1];
            if (H.count(pr))
                nn[i][k] = H[pr];
            else
                nn[i][k] = n;
        }
    }

    init(cache, -1, n+1, n+1);

    const ll i2 = (MOD+1)/2;
    cout << solve(1, 0) * i2 % MOD << endl;

//    FOR(i, n){
//        FOR(j, n)
//            cout << cache[i][j] << " ";
//        cout << endl;
//    }

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

constexpr int mod = 1000000007;

long long dp[3005][3005],sum[3005][3005],tmp[3005][3005];

int main() {
    int N;
    cin >> N;
    vector<long long>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        long long tmp2 = 0;
        for(int j = 0; j < N; j++) {
            tmp2 += A[j];
            tmp2 %= (i+1);
            tmp[i][j] = tmp2;
        }
    }
    for(int i = 0; i < N; i++) {
        dp[i][0] = 1;
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            dp[i][j] += sum[j][tmp[j][i]];
            dp[i][j] %= mod;
        }
        for(int j = 0; j < N; j++) {
            sum[j+1][tmp[j+1][i]] += dp[i][j];
            sum[j+1][tmp[j+1][i]] %= mod;
        }
    }
    long long ans = 0;
    for(int i = 0; i < N; i++) {
        ans += dp[N-1][i];
        ans %= mod;
    }
    cout << ans << endl;
}