#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i, begin, end) for(int i = int(begin); i < int(end); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    ll best = 0;
    ll now = 0,sum = 0,mx = 0;
    for(int i = 0;i<n;i++){
        sum += a[i];
        chmax(mx,sum);
        chmax(best,now + mx);
        now += sum;
    }
    cout << best << endl;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <fstream>
#include <map>
#include <set>
#include <queue>
#include <memory.h>

using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PI;
typedef vector<PI> VPI;

#define FOR(i,a,n) for (int i = (a); i < (n); ++i)
#define FORE(i,a,n) for (int i = (a); i <= (n); ++i)
#define FORD(i,a,b) for (int i = (a); i >= (b); --i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FORE(i,0,n)
#define LL long long
#define FIR(n) REP(i,n)
#define FJR(n) REP(j,n)
#define ALL(v) v.begin(), v.end()

#define FI FIR(n)
#define FJ FJR(n)
#define FR(i,a) FOR(i,a,n)
#define REPN(i) REP(i,n)

#define GI(n) scanf("%d", &n)
#define GI2(n,m) scanf("%d %d", &n, &m)

const int MOD = 1e9 + 7;

LL a[3010];

int f[3010];
LL fn[3010];

int main() {
#ifdef LOCALF
	freopen("input.txt", "rt", stdin);
#endif
	ios::sync_with_stdio(false); cin.tie(0);

	int n;
	cin >> n;
	FI cin >> a[i];

	//n = 3000;	FI a[i] = 4LL * 3 * 5 * 7 * 11 * 13 * 17 * 19*23*29*31*37;

	FI f[i] = 1;
	LL res = 0;
	res = f[n - 1];

	map<int, LL> sums;
	FORE(d, 2, n) {
		memset(fn, 0, sizeof fn);
		sums.clear();

		LL s = 0;
		FI{
			s += a[i];
			fn[i] += sums[s % d];
			(sums[s % d] += f[i]) %= MOD;
		}

		FI f[i] = fn[i] % MOD;

		res += f[n - 1];
	}

	cout << res % MOD << endl;

}


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

const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
int add (int x, int y) {return x + y >= mod ? x + y - mod : x + y;}
int mul (int x, int y) {return 1LL * x * y % mod;}
int sub (int x, int y) {return x - y < 0 ? x - y + mod : x - y;}

int n, a[maxn];
int f[maxn][2], g[maxn][2];

int main ()
{
    scanf ("%d", &n);
    for (int i = 1; i <= n; i++) scanf ("%d", a + i);
    f[1][0] = a[1];
    g[1][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        g[i][0] = add (g[i - 1][1], g[i - 1][0]);
        g[i][1] = g[i - 1][0];
        f[i][0] = add (f[i - 1][1], f[i - 1][0]);
        f[i][0] = add (f[i][0], mul (g[i][0], a[i]));
        f[i][1] = sub (f[i - 1][0], mul (g[i][1], a[i]));

    }
    int ans = add (f[n][0], f[n][1]);
    printf ("%d\n", ans);
}

#include <bits/stdc++.h>
const int N = 200005;
int n, a[N * 2], b[N * 2], ok[N * 2], st[N], top = 0;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n * 2; i++)
		scanf("%d", &a[i]), b[i] = i;
	std::sort(b + 1, b + n * 2 + 1, [](int x, int y) { return a[x] < a[y]; });
	for (int i = 1; i <= n; i++) ok[b[i]] = 1;
	for (int i = 1; i <= n * 2; i++) {
		char c;
		if (!top) st[++top] = i, c = '(';
		else if (ok[st[top]] ^ ok[i]) top--, c = ')';
		else st[++top] = i, c = '(';
		putchar(c);
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 100032

char dir[N];
int a[N], b[N];

ll calc(int i, int j, int e)
{
    //cerr << "calc, e = " << e << '\n';
    //cerr << "  a = ["; for (int k = i; k < j; ++k) cerr << ' ' << a[k]; cerr << " ]\n";
    //cerr << "  b = ["; for (int k = i; k < j; ++k) cerr << ' ' << b[k]; cerr << " ]\n";
    ll res = 0;
    set<int> x;
    for (int k = i; k < j; ++k) {
        x.erase(a[k]);
        x.insert(b[k]);
        res += x.size();
    }
    if (x.size() > 1 || b[j-1] != e) res = -1;
    //cerr << "  res = " << res << '\n';
    return res;
}

void flip(int x[], int i, int j)
{
    reverse(x+i, x+j);
    for (int k = i; k < j; ++k) x[k] = -x[k];
}

int main()
{
    canhazfast();

    int n, w;
    ll ans = 0;

    cin >> n >> w;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] -= i;
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
        b[i] -= i;
    }
    //cerr << "shifted:\n";
    //cerr << "a = ["; for (int i = 1; i <= n; ++i) cerr << ' ' << a[i]; cerr << " ]\n";
    //cerr << "b = ["; for (int i = 1; i <= n; ++i) cerr << ' ' << b[i]; cerr << " ]\n";

    a[n+1] = b[n+1] = w-n;
    for (int i = 1; i <= n; ++i) {
        dir[i] = '-';
        if (a[i] < b[i]) dir[i] = 'R';
        if (a[i] > b[i]) dir[i] = 'L';
    }
    //cerr << "dir = " << dir+1 << '\n';
    for (int i = 1; i < n; ++i) {
        retif(dir[i] == 'R' && dir[i+1] == 'L') cout << "-1\n", 0;
    }
    for (int i = 1, j = 1; i <= n; i = j) {
        while (j <= n && dir[j] == dir[i]) ++j;
        ctif(dir[i] == '-');
        int e = a[j];
        if (dir[i] == 'L') {
            flip(a, i, j);
            flip(b, i, j);
            e = -a[i-1];
        }
        ll res = calc(i, j, e);
        retif(res < 0) cout << "-1\n", 0;
        ans += res;
    }
    cout << ans << '\n';

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<string> vs;
typedef vector<double> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vp> vvp;

// input
int N, Q;
vl A;

void input() {
    cin >> N >> Q;
    A = vl(N);
    rep(i, N) cin >> A[i];
}

struct SegmentTree {
    int n;
    vector<int> left, right;
    vector<ll> dat;

    SegmentTree(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        left = right = vector<int>(2 * n - 1);
        dat = vector<ll>(2 * n - 1, 0);
        set_range(0, 0, n);
    }

    void set_range(int i, int l, int r) {
        left[i] = l;
        right[i] = r;
        if (i < n - 1) {
            set_range(2 * i + 1, l, (l + r) / 2);
            set_range(2 * i + 2, (l + r) / 2, r);
        }
    }

    void add(int i, ll x) {
        i += n - 1;
        dat[i] ^= x;
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] ^= x;
        }
    }

    ll sum_recur(int i, int l, int r) {
        if (left[i] == l && right[i] == r) return dat[i];
        int c = (left[i] + right[i]) / 2;
        ll ret = 0;
        if (l < c) ret ^= sum_recur(2 * i + 1, l, min(c, r));
        if (c < r) ret ^= sum_recur(2 * i + 2, max(c, l), r);
        return ret;
    }

    ll sum(int l, int r) {
        return sum_recur(0, l, r);
    }
};

int main() {
    input();
    SegmentTree st(N);
    rep(i, N) st.add(i, A[i]);
    rep(i, Q) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            st.add(x - 1, y);
        } else {
            ll ans = st.sum(x - 1, y);
            cout << ans << endl;
        }
    }
}


#include <iostream>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int A[N];
    int i = 0;
    int max_num = 2;
    while (i != N)
    {
        scanf("%d", &A[i]);
        if (max_num < A[i])
        {
            max_num = A[i];
        }
        i++;
        if (i != N)
        {
            scanf(" ");
        }
    }

    int ans = -1;
    int counter = 0;
    int max_counter = 0;
    for (int k = 2; k <= max_num; k++)
    {
        for (i = 0; i < N; i++)
        {
            if (A[i] % k == 0)
            {
                counter++;
            }

        }
        if (max_counter <= counter)
        {
            max_counter = counter;
            ans = k;
        }

        counter = 0;
    }

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

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=200005;
inline int read() {
	register int r=0,f=1;
	register char ch=getchar();
	while(ch<'0' || ch>'9') {
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9') {
		r=(r<<1)+(r<<3)+(ch^48);
		ch=getchar();
	}
	return r*f;
}
int n;
int a[maxn];
int tong[maxn],tot;
int ans;
int fa[maxn];

struct nod{
	int x,y;
	nod(){}
	nod(int a,int b) {x=a,y=b;}
}edge[maxn];
int find(int x) {
	return fa[x]==x ? x : fa[x]=find(fa[x]);
}
void merge(int x,int y) {
	fa[find(x)]=find(y);
	return;
}

inline void k() {
	for(int i=1;i<=tot;++i) {
		int x=edge[i].x,y=edge[i].y;
		int fx=find(x);
		int fy=find(y);
		if(fx!=fy) {
			merge(fx,fy);
			++ans;
		}
	}
	cout<<ans<<endl;
	return;
}

signed main()
{
	n=read();

	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=0;i<maxn;++i) fa[i]=i;
	for(int i=1;i<=n+1-i;++i)
	if(a[i]!=a[n+1-i]) edge[++tot]=nod(a[i],a[n+1-i]);
	k();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define prin(a) cout<<a<<"\n"
#define kaigyo cout<<"\n"
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define mem(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,-1,sizeof(x))
const int INF=1<<28;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<string> vst;
typedef vector<char> vc;
typedef vector<long double> vd;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
typedef vector<vector<int>> vint2;
ll mod=1e9+7;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;
#define int3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define int4(x,y,z,w) int x,y,z,w;cin>>x>>y>>z>>w;
#define ll1(x) ll x;cin>>x;
#define ll2(x,y) ll x,y;cin>>x>>y;
#define vint1(a,n) vint a(n);rep(i,n)cin>>a[i];
#define vint2(a,b,n) vint a(n),b(n);rep(i,n)cin>>a[i]>>b[i];
#define vll1(a,n) vll a(n);rep(i,n)cin>>a[i];
const double pi=acos(-1.0);
const ll infl=1LL<<60;

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;
x*x <=n;x++){if(n%x == 0)return false;}return true;}
ll kaizyo(ll k){ll sum=1;rep1(i,k){sum*=i;sum%=mod;}return sum;}
ll ncr(ll n,ll r){return kaizyo(n)/(kaizyo(r)*kaizyo(n-r));}
unsigned keta(unsigned num){
    return log10(num)+1;
}
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main(){
cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
int3(a,b,c);

if(a==b)cout<<'=';
else if(c%2==0){
    if(abs(a)>abs(b))cout<<'>';
    if(abs(a)<abs(b))cout<<'<';
    if(abs(a)==abs(b))cout<<'=';
}

else{
if(c>=1)cout<<((a>b)?'>':'<');
else if(c<=-1)cout<<((a>b)?'<':'>');
else cout<<'=';
}
}

#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  ll n,t; cin >> n >> t;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> b(0);
  vector<ll> c(0);
  rep(i,n){
    if(i<20) b.push_back(a[i]);
    else c.push_back(a[i]);
  }
  set<ll> st1;
  set<ll> st2;
  rep(i,1ll<<b.size()){
    ll sum=0;
    rep(j,b.size()){
      if(i&(1ll<<j)) sum+=b[j];
    }
    if(sum<=t) st1.insert(sum);
  }
  if(c.empty()){
    ll ans=0;
    for(auto v:st1){
      if(v<=t&&ans<v) ans=v;
    }
    cout << ans << endl;
    return 0;
  }
  rep(i,1ll<<c.size()){
    ll sum=0;
    rep(j,c.size()){
      if(i&(1ll<<j)) sum+=c[j];
    }
    if(sum<=t) st2.insert(sum);
  }
  ll ans=0;
  for(auto v:st1){
    auto itr=st2.upper_bound(t-v);
    if(itr!=st2.begin()){
      ll x=*(--itr);
      if(ans<v+x) ans=v+x;
    }
    else if(ans<v) ans=v;
  }
  cout << ans << endl;
}


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

int gcd(int a,int b){
    while(b){
        a=a%b;
        swap(a,b);
    }
    return a;
}

int n,a[2005],mn;
map<int,int> mp;
set<int> s;

int main(){

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

    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    mn=*min_element(a+1,a+1+n);
    for(int i=1;i<=n;i++){
        for(int j=1;j*j<=a[i];j++)if(a[i]%j==0){
            mp[j]=gcd(mp[j],a[i]);
            mp[a[i]/j]=gcd(mp[a[i]/j],a[i]);
        }
    }
    for(pair<int,int> p:mp)if(p.first==p.second)s.insert(min(p.first,mn));
    cout<<s.size()<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define forr(i,a,n) for(int i=a;i<n;i++)
#define rep(i,n) forr(i,0,n)
#define repp(i,n) forr(i,1,n+1)
#define pb push_back
#define mp make_pair
#define vvi vector<vector<int> >
#define MAXN 0x3f3f3f3f
int n,a[2010],ans=0;
set<int>s;
int main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	rep(i,n){
		for(int j=1;j*j<=a[i]&&j<=a[0];j++){
			if(a[i]%j)continue;
			s.insert(j);
			if(a[i]/j<=a[0])s.insert(a[i]/j);
		}
	}
	set<int>::iterator it;
	for(it=s.begin();it!=s.end();it++){
		int now=0;
		rep(i,n)if(a[i]%(*it)==0)now=__gcd(now,a[i]);
		if(now==(*it))ans++;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline int read(void){
	reg char ch=getchar();
	reg int res=0;
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))res=10*res+(ch^'0'),ch=getchar();
	return res;
}

int main(void){
	reg int a=read(),b=read(),c=read();
	const int mod=4;
	if((b&3)==2)
		if(c==1)
			b=2;
		else
			b=mod;
	else{
		if(!(c&1))
			b=1ll*b*b%mod;
		else
			b%=mod;
		if(!b)
			b=mod;
	}
	a%=10;
	reg int ans=1;
	for(reg int i=1;i<=b;++i)
		ans=1ll*ans*a%10;
	printf("%d\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.first << ' ' << p.second << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 998244353
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define NMAX 500005
const long double PI = acos(-1);

int ans = 0, n, mat[55][55], k, mat2[55][55], uz[55], uz2[55], p[55];

bool canSwap(int x, int y, int mat[][55]){
  for (int i=1;i<=n;i++){
    if (mat[i][x] + mat[i][y] > k){
      return false;
    }
  }
  return true;
}

int main(){
  ios::sync_with_stdio(false);
  cin >> n >> k;

  for (int i=1;i<=n;i++){
    uz[i] = uz2[i] = i;
    for (int j=1;j<=n;j++){
      cin >> mat[i][j];
      mat2[j][i] = mat[i][j];
    }
  }

  p[0] = 1;
  for (int i=1;i<=n;i++){
    p[i] = 1LL * i * p[i-1] % MOD;
  }

  dbg(canSwap(1,2,mat));
  ans = 1;
  for (int i=1;i<=n;i++){
    int cnt = 1, cnt2 = 1;
    for (int j=i+1;j<=n;j++){
      if (canSwap(i,j,mat)){
        int sav = uz[j];
        for (int k=1;k<=n;k++){
          if (uz[k] == sav)
            uz[k] = uz[i];
        }
      }
      if (canSwap(i,j,mat2)){
        int sav = uz2[j];
        for (int k=1;k<=n;k++){
          if (uz2[k] == sav)
            uz2[k] = uz2[i];
        }
      }
    }
  }

  for (int i=1;i<=n;i++){
    int cnt = 0, cnt2 = 0;
    for (int j=1;j<=n;j++){
      if (uz[j] == i) cnt++;
      if (uz2[j] == i) cnt2++;
    }

dbg(cnt, cnt2);
    ans = 1LL * ans * p[cnt] % MOD;
    ans = 1LL * ans * p[cnt2] % MOD;
  }

  cout << ans << '\n';
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
  int n,m,t,i,j;
  ll r[2];
  string s;
  cin >> n >> m;
  r[0]=0; r[1]=0;
  for(i=0;i<n;i++){
    cin >> s;
    t=0;
    for(j=0;j<m;j++)
      if(s[j]=='1')
        t++;
    r[t%2]++;
  }
  cout << r[0]*r[1] << endl;
  return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll>
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=998244353;
ll max(ll a,ll b) {return ((a>b)?a:b);}
ll min(ll a,ll b) {return ((a>b)?b:a);}
vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dp[3001][7000];
ll rec(int n,int k)
{
    if(dp[n][k]!=-1) return dp[n][k];
    if(n && !k) return dp[n][k]=0;
    if(n<k) return dp[n][k]= 0;
    if(n==k) return dp[n][k]=1;
    return dp[n][k]=(rec(n-1,k-1)+rec(n,2*k))%mod;
}
void sol(void)
{
memset(dp,-1,sizeof(dp));
cin>>n>>k;
cout<<rec(n,k);
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


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

#define _GLIBCXX_DEBUG

using LL = long long;
using VI = vector<int>;
using VS = vector<string>;
using VLL = vector<LL>;
using VC = vector<char>;
using VD = vector<double>;
using PII = pair<int, int>;
using PSS = pair<string, string>;
using PIS = pair<int , string>;
using PSI = pair<string, int>;
using PLL = pair<LL, LL>;
using PCC = pair<char, char>;
using VVI = vector<VI>;
using VVS = vector<VS>;
using VVLL = vector<VLL>;
using VVC = vector<VC>;
using VVD = vector<VD>;
using VPII = vector<PII>;
using VPSS = vector<PSS>;
using VPIS = vector<PIS>;
using VPLL = vector<PLL>;

template<class T> void chmin(T &a, T b)
{
  if(a > b) a = b;
}
template<class T> void chmax(T &a, T b)
{
  if(a < b) a = b;
}

  //const double PI = 3.141592653589793;
  //LL INF = 1LL << 60;

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

int main()
{
  cout << fixed << setprecision(12);

  int H, W;
  cin >> H >> W;
  VVC S(H, VC(W));
  for(int i = 0; i < H; i++)
  {
    for(int j = 0; j < W; j++)
    {
      cin >> S[i][j];
    }
  }

  int n = 0;
  for(int i = 0; i < H - 1; i++)
  {
    for(int j = 0; j < W - 1; j++)
    {
      int cnt = 0;
      if(S[i][j] == '#') cnt++;
      if(S[i + 1][j] == '#') cnt++;
      if(S[i][j + 1] == '#') cnt ++;
      if(S[i + 1][j + 1] == '#') cnt++;
      if(cnt == 1 || cnt == 3) n++;
    }
  }

  cout << n << endl;

  return 0;
}

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n",(x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
// #define INF (1<<9+9)
const int INF = 0x3fffffff;
// const long long INF = 1LL<<50;

#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define pie 3.14159265358979323846

using namespace std;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)998244353;
// const int mod =(int)998244353;
const int mod =(int)1e9+7;

const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
  if(a<0)a=-a;
  if(b<0)b=-b;
    ll g;g=gcd(a,b);
    return b/g*a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//int N, M, K, T, H, W, L, R;
// long long int N, M, K, T, H, W, L, R
ll RS(ll N,ll P,ll m){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,m);
            return t*t%m;
        }else{
            return N*RS(N,P-1,m)%m;
        }
    }
}
struct BIT{
  private:
    vector<int> bit;
    int N;
  public:
    BIT(int size){
      N=size;
      bit.resize(N+1);
    }
    void add(int a,int w){
      for(int x=a;x<=N;x+=(x&-x)){
        bit[x]+=w;
      }
    }
    int sum(int a){
      int ret=0;
      for(int x=a;x>0;x-=(x&-x))ret+=bit[x];
      return ret;
    }
};
int main() {
  ios::sync_with_stdio(false);
  int H,W;
  cin>>H>>W;
  vector<string>S(H);
  REP(i,H)cin>>S[i];
  int ans=0;
  int dh[]={0,0,1,1};
  int dw[]={0,1,0,1};
  REP(ih,H-1){
      REP(iw,W-1){
          int cnt=0;
          REP(i,4){
              if(S[ih+dh[i]][iw+dw[i]]=='#')cnt++;
          }
          if(cnt&1)ans++;
      }
  }
  cout<<ans<<endl;

  return 0;
}


#include<iostream>
using namespace std;
int n;
int a(int m){
	if(m%n==0)return n;
	else return m%n;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cout<<a(2*i)<<" "<<a(2*i+1)<<endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e3 + 5;

#define bbit(i) (1<<(i))
#define bdig(x,i) (((x)>>(i))&1)

inline int get_lb(int x)
{
	int lb = 0;
	while(x>>lb) ++lb;
	return lb-1;
}

int n;
inline int tidy(int x){ while(x>n) x ^= bbit(get_lb(x)); return max(x, 1);}

int main(void)
{
	scanf("%d",&n);

	for(int i=1; i<=n; ++i)
		printf("%d %d\n",tidy(i<<1),tidy(i<<1|1));
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1000000007;
struct edge{int to,cost;};
void dfs(int v,int p,auto&G,auto&x){
  for(edge e:G[v])if(e.to!=p){
    x[e.to]=x[v]^e.cost;
    dfs(e.to,v,G,x);
  }
}
int mod_pow(int a,int b){
  if(!b)return 1;
  if(b&1)return mod_pow(a,b-1)*a%mod;
  int c=mod_pow(a,b/2);
  return c*c%mod;
}
signed main(){
  int N; cin>>N;
  vector<vector<edge>> G(N);
  for(int i=0;i<N-1;i++){
    int a,b,c; cin>>a>>b>>c;
    G[--a].push_back({--b,c});
    G[b].push_back({a,c});
  }
  vector<int>x(N);
  dfs(0,-1,G,x);
  int ans=0;
  for(int i=0;i<60;i++){
    int sum=0;
    for(int j:x)if((j>>i)&1)sum++;
    (ans+=(sum*(N-sum))%mod*mod_pow(2,i)%mod)%=mod;
  }
  cout<<ans<<endl;
}

#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define ROF(i,a,b) for(int i=(a); i>=(b); --i)
#define pb push_back
#define eb emplace_back
#define SZ(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define make_unique(a) sort(all((a))), (a).erase(unique(all((a))),(a).end())
#define x first
#define y second
#define MP make_pair
#define MT make_tuple
#define debug(x) cout << #x << " = " << x << endl
#define debug2(x,y) FOR(i,1,y) cout << "##"; cout << #x << " = " << x << endl
#define mset(x,y) memset((x), (y), sizeof(x))

using namespace std;

typedef long long i64;
typedef long double ld;
typedef tuple<int,int,int> iii;
typedef pair<int,int> pii;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<i64>> vvl;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<i64,i64>> vpll;

int readInt(){ int a; scanf("%d",&a); return a; }
i64 readLong(){ i64 a; scanf("%lld",&a); return a;}
void readString(char *s){ scanf(" %s",s); }

const int mod = 998244353;
int add(int a, int b){ return ((a+=b)>=mod)?a-mod:a; }
int mul(int a, int b){ return a*1ll*b%mod; }
void adding(int &a, int b){ a = add(a, b); }
int pw(int a, int b){
	if(a==0) return 0;
	int ans = 1, res = a;
	for(int i = 1; i <= b; i<<=1, res=mul(res,res)){
		if(i&b) ans = mul(ans,res);
	}
	return ans;
}

int play(vi w){
	int n = SZ(w);
	vi p(n);
	iota(all(p),0);
	int cnt = 0;
	do{
		int sum = 0;
		FOR(i,0,n-1){
			if(sum <= 0) sum += w[p[i]];
			else sum -= w[p[i]];
		}
		if(sum == 0) ++cnt;
		else{
			printf("{ ");
			FOR(i,0,n-1) printf("%d ",w[p[i]]);
			printf("}\n");
		}
	}while(next_permutation(all(p)));
	return cnt;
}

const int N = 105;
int fac[N];
const int zero = 5000;
int dp[N][N*N];
int sav[N][N*N];

int main(){
	//printf("%d\n",play({1,2,3,4}));
	fac[0] = 1;
	FOR(i, 1, 100) fac[i] = mul(fac[i-1],i);
	int n = readInt();

	dp[0][zero] = 1;

	int mx = N*N;
	FOR(i, 1, n){
		int a = readInt();
		FOR(j, 0, i-1){
			FOR(k, 0, mx-1){
				if(k >= a) adding(sav[j][k-a], dp[j][k]);
				if(k+a < mx) adding(sav[j+1][k+a], dp[j][k]);
			}
		}
		FOR(j, 0, i){
			FOR(k, 0, mx-1){
				dp[j][k] = sav[j][k];
				sav[j][k] = 0;
			}
		}
	}
	int ans = 0;
	FOR(i, 1, n-1){
		//printf("%d\n",dp[i][zero]);
		adding(ans, mul(mul(fac[i],fac[n-i]),dp[i][zero]));
	}
	printf("%d",ans);
	return 0;
}
/*
5
3 3 3 3 6
(96)

*/


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

template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    int N;cin>>N;
    if(N%2==0)cout<<"White"<<endl;
    else cout<<"Black"<<endl;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  if (N%2==1) {
    cout << "Black" << endl;
  } else {
    cout << "White" << endl;
  }
  return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multi_set;

#define mod         998244353
#define pi          3.1415926535898
#define eps         1e-9

#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define vt vector
#define ar array
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define sz(x) (int)(x).size()
#define revsort(x) sort(all(x));reverse(all(x))

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
#define EACH(x, a) for (auto& x: a)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	EACH(a, x)
		read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
	EACH(a, x)
		read(a);
}

LL powm(LL x, LL y,LL m) {
    if (y==0) return 1;
    if (y==1) return x%m;
    if (y&1) return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m)%m;
}

LL inv(LL x, LL m) {
    return powm(x,m-2,m);
}

int add(int var1, int var2) {
    return (((((LL)(var1)) % mod + (LL)(var2)) % mod) + mod) % mod;
}

int mul(int var1, int var2) {
    return (((LL)(var1)) % mod * (LL)(var2)) % mod;
}

LL INF=1e9;

LL func (LL x) {
    return (x*(x+1)/2)%mod;
}
void solve() {
    LL a, b, c;
    read(a, b, c);
    LL ans = 1;
    ans = mul(ans, func(a));
    ans = mul(ans, func(b));
    ans = mul(ans, func(c));
    cout << ans << nl;

}

int main() {
    fast;
    solve();
}


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<vector>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
template<typename T>
using vec = vector<T>;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
void solve(){
}
using i64 = int_fast64_t;
constexpr i64 MAX = 10000000;
constexpr i64 MOD = 1000000007;
i64 fac[MAX], finv[MAX], inv[MAX];
template <i64 modulus>
class modcal
{

public:
  i64 a;

  constexpr modcal(const i64 x = 0) noexcept : a(x % modulus) {}
  constexpr i64 &value() noexcept { return a; }
  constexpr const i64 &value() const noexcept { return a; }
  constexpr modcal operator+(const modcal rhs) const noexcept
  {
    return modcal(*this) += rhs;
  }
  constexpr modcal operator-(const modcal rhs) const noexcept
  {
    return modcal(*this) -= rhs;
  }
  constexpr modcal operator*(const modcal rhs) const noexcept
  {
    return modcal(*this) *= rhs;
  }
  constexpr modcal operator/(const modcal rhs) noexcept
  {
    return modcal(*this) /= rhs;
  }
  constexpr modcal &operator+=(const modcal rhs) noexcept
  {
    a += rhs.a;
    if (a >= modulus)
    {
      a -= modulus;
    }
    return *this;
  }
  constexpr modcal &operator-=(const modcal rhs) noexcept
  {
    if (a < rhs.a)
    {
      a += modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modcal &operator*=(const modcal rhs) noexcept
  {
    a = a * rhs.a % modulus;
    return *this;
  }
  constexpr modcal &operator/=(modcal rhs) noexcept
  {
    i64 exp = modulus - 2;
    while (exp)
    {
      if (exp % 2)
      {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  void COMninit()
  {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
      fac[i] = fac[i - 1] * i % modulus;
      inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
      finv[i] = finv[i - 1] * inv[i] % modulus;
    }
  }
  i64 COMn(i64 n, i64 k)
  {
    if (n < k)
      return 0;
    if (n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
  }
  constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n)
  {
    if (n == 0)
      return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1)
      t = t * a;
    return t;
  }
};
using modc = modcal<1000000007>;
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 h,w;
    cin >> h >> w;
    vec<string> s(h);
    rep(i,h)cin >> s[i];
    i64 dx[3] = {1,1,0};
    i64 dy[3] = {0,1,1};
    vec<vec<vec<modc>>> dp(h,vec<vec<modc>>(w,vec<modc>(4,0)));
    dp[0][0][3] = 1;
    rep(i,h){
        rep(j,w){
            rep(k,4){
                if(dp[i][j][k].a == 0)continue;
                rep(v,3){
                    i64 ny = dy[v] + i;
                    i64 nx = dx[v] + j;
                    if(nx < 0 || nx >= w || ny < 0 || ny >= h)continue;
                    if(s[ny][nx] == '#')continue;
                    dp[ny][nx][v] += dp[i][j][k];
                    if(k == v)dp[ny][nx][v] += dp[i][j][k];
                }
            }
        }
    }
    modc ans = 0;
    rep(i,3){
        ans += dp[h - 1][w - 1][i];
    }
    cout << ans.a << endl;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define f(x, m) for(auto x : m)
#define cpu() ios::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int ,int>>
#define vll vector<pair<ll ,ll>>
#define all(v) v.begin(),v.end()
#define sor(a) sort( a.begin(), a.end() )
#define ros(a) sort( a.rbegin(), a.rend())
#define prec(n) fixed << setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it : x) cout << it << " ";
#define debug(x) cerr << #x << " is " << x << endl;

typedef long long ll;
using namespace std;
// using namespace __gnu_pbds;
#define dbg(args...){ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << "NEXT\n"; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << ", ";
err(++it, args...);
}
template<typename... T>
void rd(T& ... args){
  ((cin >> args), ...);
}
template<typename... T>
void ps(T ... args){
  ((cout << args << ' '), ...);
  cout << '\n';
}
// using ordered_set = tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7, MOD1 = 998244353LL, MAX = 1e6+ 5;
const char nl = '\n';
const int INF = 1e9 + 5;
int n, m, k;
ll mu(ll x, ll y){
  return (x * y) % MOD1;
}
int re(int x, int y){
  x -= y;
  if(x < 0){
    x += MOD1;
  }
  return x;
}
void add(int& x, int y){
  x += y;
  if(x >= MOD1){
    x -= MOD1;
  }
}
ll pot(ll x, ll y){
  if(y == 0) return 1;
  if(y & 1) return (pot(x, y - 1) * x) % MOD1;
  ll k = pot(x, y / 2);
  return (k * k) % MOD1;
}
ll inv(ll x){
  return pot(x, MOD1 - 2);
}
void solve(){
  cin >> n >> m >> k;
  if(n == m && n == 1){
    cout << k << '\n';
    return;
  }
  if(n == 1 || m == 1){
    int ans = 0;
    for(int i = 1; i <= k; i++){
    add(ans, mu(re(pot(i, n), pot(i - 1, n)), re(pot(k - i + 1, m), pot(k - i, m))));
    }
    cout << ans << '\n';
    return;
  }
  int ans = 0;
  for(int i = 1; i <= k; i++){
    add(ans, mu(re(pot(i, n), pot(i - 1, n)), pot(k - i + 1, m)));
  }
  cout << ans << '\n';
}
int main(){
  cpu();
  int __ = 1;
  // cin >> __;
  while(__--){
    solve();
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = (2e5 + 10), INF = 0x3f3f3f3f3f3f3f3f, mod = 998244353;
int ksm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    int ans = 0;
    if (n == 1) {
        for (int i = 1; i <= k; i++)
            ans = (ans + (ksm(i, m) - ksm(i - 1, m))) % mod;
    } else if (m == 1) {
        for (int i = 1; i <= k; i++)
            ans = (ans + (ksm(i, n) - ksm(i - 1, n))) % mod;
    } else {
        for (int i = 1; i <= k; i++)
            ans =
                (ans + (ksm(i, n) - ksm(i - 1, n)) * (ksm(k - i + 1, m))) % mod;
    }
    cout << (ans % mod + mod) % mod << "\n";
    return 0;
}


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

#define int long long int
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, k;
	cin >> n >> k;

	int sum = 0;
	for(int floor = 1; floor <= n; ++floor) {
		int floor_no = 100 * floor;
		for(int room = 1; room <= k; ++room) {
			int value = (floor_no + room);
			// cout << imie(value);
			sum += value;
		}
	}

	cout << sum << endl;

	return 0;
}

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
using ll = long long;
struct Edge{
    ll to;
    ll cost;
};
using Graph = vector<vector<Edge>>;
using P =pair<ll,ll>;
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(),v.end()
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = LLONG_MAX;
const int MAX = 510000;
bool graph[nmax][nmax];
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main(){
    char S,T;
    cin >> S >> T;
    if(S=='Y'){
        cout << (char)(T + 'A' - 'a') << endl;
    }else{
        cout << T << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mod 1000000007
ll cmod(ll a){return (a%Mod+Mod)%Mod;}
inline ll read(){ll x;scanf("%lld",&x);return x;}
ll solve()
{
	ll N=read(),A=read(),B=read();
	if(N-A-B<0) return 0;
	if(A<B) swap(A,B);
	ll x1=(B-1)*(B-1)%Mod*(2*N+2-2*A-B)%Mod*(2*N+2-2*A-B)%Mod;
	ll x2=(A-B+1)*(N-A+1)%Mod*(B-1)%Mod*(4*N+4-4*A-2*B)%Mod;
	ll x3=(N-A+1)*(N-A+1)%Mod*(A-B+1)%Mod*(A-B+1)%Mod;
	ll x=(N-A+1)*(N-A+1)%Mod*(N-B+1)%Mod*(N-B+1)%Mod;
	return cmod(x-x1-x2-x3);
}
int main()
{
	ll t=read();
	while(t--) cout<<solve()<<endl;
	return 0;
}

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

int main() {
  int T;
  cin >> T;

  int64_t N, A, B;

  const int64_t mod = 1000000007;

  for (int Case = 0; Case < T; Case++) {
    cin >> N >> A >> B;

    if (A+B>N) {
      cout << 0 << endl;
      continue;
    }

    int64_t Count = (N+1-A)*(N+1-A) % mod;
    Count = Count * (N+1-B) % mod;
    Count = Count * (N+1-B) % mod;

    int64_t Del;
    Del = (N+1-A)*(A+B-1) % mod;
    Del = (Del - (B-1)*B%mod + mod) % mod;

    Del = Del*Del % mod;
    Count = (Count - Del + mod) % mod;

    cout << Count << endl;
  }

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef vector<P> vp;
typedef tuple<int, int, P> T;
typedef vector<T> vt;
typedef vector<vl> vvl;

// input
int N;
vl X, Y;
int M;
vp op;
int Q;
vi A, B;

void input() {
    cin >> N;
    X = Y = vl(N);
    rep(i, N) cin >> X[i] >> Y[i];
    cin >> M;
    op = vp(M);
    rep(i, M) {
        cin >> op[i].first;
        if (op[i].first > 2) cin >> op[i].second;
    }
    cin >> Q;
    A = B = vi(Q);
    rep(i, Q) cin >> A[i] >> B[i];
}

vvl multi(vvl &a, vvl &b) {
    int r1 = a.size(), c1 = a[0].size();
    int r2 = b.size(), c2 = b[0].size();
    assert(c1 == r2);
    vvl ret(r1, vl(c2, 0));
    rep(i, r1) rep(j, c2) {
        rep(k, c1) ret[i][j] += a[i][k] * b[k][j];
    }
    return ret;
}

int main() {
    input();
    vector<vvl> w(M + 1);
    w[0] = {
        {1, 0, 0},
        {0, 1, 0},
        {0, 0, 1},
    };
    rep(i, M) {
        ll o, p;
        tie(o, p) = op[i];
        vvl d;
        if (o == 1) {
            d = {
                {0, 1, 0},
                {-1, 0, 0},
                {0, 0, 1},
            };
        } else if (o == 2) {
            d = {
                {0, -1, 0},
                {1, 0, 0},
                {0, 0, 1},
            };
        } else if (o == 3) {
            d = {
                {-1, 0, 2 * p},
                {0, 1, 0},
                {0, 0, 1},
            };
        } else {
            d = {
                {1, 0, 0},
                {0, -1, 2 * p},
                {0, 0, 1},
            };
        }
        w[i + 1] = multi(d, w[i]);
    }
    rep(i, Q) {
        vvl mat = {
            {X[B[i] - 1]},
            {Y[B[i] - 1]},
            {1},
        };
        vvl ans = multi(w[A[i]], mat);
        printf("%lld %lld\n", ans[0][0], ans[1][0]);
    }
}

#include <iostream>
using namespace std;
typedef long long ll;

struct State{
    int dir;
    bool xrev, yrev;
    ll dx, dy;
};

int main()
{
    int n;
    cin >> n;
    ll x[200005], y[200005];
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
    int m;
    cin >> m;
    State state[200005];
    state[0] = (State){0, false, false, 0, 0};
    for(int i = 1; i <= m; i++){
        state[i] = state[i - 1];
        int t;
        cin >> t;
        if(t == 1) state[i].dir = (state[i].dir + 1) % 4;
        if(t == 2) state[i].dir = (state[i].dir + 3) % 4;
        if(t == 3){
            ll p;
            cin >> p;
            if(state[i].dir >= 2) p = -p;
            if(!(state[i].dir % 2)){
                if(state[i].xrev) state[i].dx += p * 2;
                else state[i].dx -= p * 2;
                state[i].xrev ^= true;
            }
            else{
                if(state[i].yrev) state[i].dy += p * 2;
                else state[i].dy -= p * 2;
                state[i].yrev ^= true;
            }
        }
        if(t == 4){
            ll p;
            cin >> p;
            if(state[i].dir == 1 || state[i].dir == 2) p = -p;
            if(state[i].dir % 2){
                if(state[i].xrev) state[i].dx += p * 2;
                else state[i].dx -= p * 2;
                state[i].xrev ^= true;
            }
            else{
                if(state[i].yrev) state[i].dy += p * 2;
                else state[i].dy -= p * 2;
                state[i].yrev ^= true;
            }
        }
    }
    int q;
    cin >> q;
    while(q--){
        int a, b;
        cin >> a >> b;
        b--;
        ll u, v;
        if(state[a].xrev) u = -x[b] - state[a].dx;
        else u = x[b] + state[a].dx;
        if(state[a].yrev) v = -y[b] - state[a].dy;
        else v = y[b] + state[a].dy;
        for(int i = 0; i < state[a].dir; i++){
            swap(u, v);
            v = -v;
        }
        cout << u << " " << v << endl;
    }
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> x(n);
	vector<int> y(n);
	vector<int> r(n);
	for (int i = 0; i < n; i++) {
		cin >> x.at(i) >> y.at(i) >> r.at(i);
	}
	int maxx = 0;
	int minx = 114514;
	for (int i = 0; i < n; i++) {
		maxx = max(maxx, x.at(i));
		minx = min(minx, x.at(i));
	}
	int maxi = 0;
	int mini = 0;
	for (int i = 0; i < n; i++) {
		if (x.at(i) == maxx) {
			maxi = i;
			break;
		}
	}
	for (int i = 0; i < n; i++) {
		if (x.at(i) == minx) {
			mini = i;
			break;
		}
	}
	for (int i = 0; i < n; i++) {
		if (i == maxi) {
			cout << maxx << " " << 0 << " " << 10000 << " " << 10000 << endl;
		}
		else if(i == mini){
			cout << 0 << " " << 0 << " " << minx << " " << 10000 << endl;
		}
		else if (x.at(i) == maxx && i != maxi) {
			cout << x.at(i) - 1 << " " << y.at(i) << " " << x.at(i) << " " << y.at(i)+1 << endl;
		}
		else if (x.at(i) == minx && i != mini) {
			cout << x.at(i)+1 << " " << y.at(i) << " " << x.at(i)+2 << " " << y.at(i) + 1 << endl;
		}
		else {
			cout << x.at(i) << " " << y.at(i) << " " << x.at(i) + 1 << " " << y.at(i) + 1 << endl;
		}
	}
}

#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int MOD2 = 998'244'353;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

int main(){
    int n; std::cin >> n;
    int x, y, r;
    for(int i(0); i < n; ++i){
        std::cin >> x >> y >> r;
        std::cout << x << " " << y << " " << x + 1 << " " << y + 1 << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    string s;
    cin >> s;
    int res = 0;
    rep(i,9){
        if(s.substr(i,4)=="ZONe"){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ldb;
typedef double db;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i, a, b) for (ll i = a; i <= b; i++)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ren(i, n) for (ll i = n - 1; i >= 0; i--)
#define forn(i, a, b) for (ll i = a; i >= b; i--)
#define on cout << endl
#define o2(a, b) cout << a << " " << b
#define os cout << " "
#define all(v) v.begin(), v.end()
#define mem(n, m) memset(n, m, sizeof(n))
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vld vector<ld>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define vvld vector<vector<ld>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define mll map<ll, ll>
#define lb lower_bound
#define ub upper_bound
#define ret return 0
#define present(s, x) (s.find(x) != s.end())
#define cpresent(s, x) (find(all(s), x) != s.end())
#define ford(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for (__typeof(container.begin()) it = a; it != b; it++)
#define d1(x) cout << (x) << endl
#define d2(x, y) cout << (x) << " " << (y) << endl
#define d3(x, y, z) cout << (x) << " " << (y) << " " << (z) << endl
#define d4(a, b, c, d) cout << (a) << " " << (b) << " " << (c) << " " << (d) << endl
#define max3(a, b, c) max(max(a, b), c)
#define min3(a, b, c) min(min(a, b), c)
#define itoa(x) to_string(x);
#define atoi(x) stoll(x);

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll pwr(ll x, ll y)
{
    ll res = 1;
    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
    return (b * a) / gcd(a, b);
}
ll fact(ll n)
{
    if (n <= 1)
        return 1;
    return n * fact(n - 1);
}
ll nPr(ll n, ll r)
{
    return fact(n) / fact(n - r);
}

void c_p_c()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    c_p_c();
    ll t;
    t = 1;
    // cin >> t;
    while (t-- > 0)
    {
        string s;
        cin>>s;
        ll c=0;
        rep(j, s.size())
        {
            if(s.substr(j, 4)=="ZONe")
            {
                c++;
                j+=3;
            }
        }
        d1(c);

    }
    return 0;
}


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

#define int             long long
#define w(x)            int x; cin>>x; while(x--)
#define endl            ("\n")
#define f(i, a, n)      for(int i=a; i<n; i++)
#define cc(r)           cout<<r<<" "
#define ce(r)           cout<<r<<endl

void inout()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int nCrModpDP(int n, int r, int p)
{
    int C[r + 1];
    memset(C, 0, sizeof(C));

    C[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j - 1]) % p;
    }
    return C[r];
}

int nCrModpLucas(int n, int r, int p)
{
    if (r == 0)
        return 1;
    int ni = n % p, ri = r % p;
    return (nCrModpLucas(n / p, r / p, p) * nCrModpDP(ni, ri, p)) % p;
}
int32_t main()
{
    inout();
    int n;
    cin >> n;
    int r[n], a[n], ans = 0;
    f(i, 0, n) {
        r[i] = nCrModpLucas(n - 1, i, 3);
    }
    char k;
    f(i, 0, n) {
        cin >> k;
        if (k == 'B')
            a[i] = 0;
        else if (k == 'W')
            a[i] = 1;
        else
            a[i] = 2;
    }
    f(i, 0, n) {
        ans = (ans + (a[i] * r[i]) % 3) % 3;
    }
    if ((n & 1) == 0) {
        ans = (-ans + 3) % 3;
    }
    if (ans == 0)
        ce('B');
    else if (ans == 1)
        ce('W');
    else
        ce('R');

}

#include <bits/stdc++.h>

using namespace std;
using namespace chrono;
using ll = long long;
constexpr double TIME_LIMIT = 2.95;

system_clock::time_point start;
double elapsed = 0;
int loops = 1;
int steps = 10;
int N;
int M;
vector<string> S;
vector<string> output;
int base_num = 9;
char bases[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', '.'};

static uint32_t randXor() {
    static uint32_t x = 123456789;
    static uint32_t y = 362436069;
    static uint32_t z = 521288629;
    static uint32_t w = 88675123;
    uint32_t t;

    t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

static double rand01() { return (randXor() + 0.5) * (1.0 / UINT_MAX); }

int get_score(vector<string> &output) {
    int score;
    int c = 0, d = 0;

    bool match = false;
    for (int i = 0; i < M; i++) {
        match = false;
        // horizontal
        for (int h = 0; h < N; h++) {
            for (int w = 0; w < N; w++) {
                bool check = true;
                for (int j = 0; j < S[i].length(); j++) {
                    if (S[i][j] != output[h][(w + j) % N]) {
                        check = false;
                        break;
                    }
                }
                if (check) {
                    match = true;
                    goto matched;
                }
            }
        }
        // vertical
        for (int h = 0; h < N; h++) {
            for (int w = 0; w < N; w++) {
                bool check = true;
                for (int j = 0; j < S[i].length(); j++) {
                    if (S[i][j] != output[(h + j) % N][w]) {
                        check = false;
                        break;
                    }
                }
                if (check) {
                    match = true;
                    goto matched;
                }
            }
        }
    matched:
        if (match) c++;
    }

    for (int h = 0; h < N; h++) {
        for (int w = 0; w < N; w++) {
            if (output[h][w] == '.') d++;
        }
    }

    if (c == M) {
        score =
            round(1e8 * 2 * (double)pow(N, 2) / (double)(2 * pow(N, 2) - d));
    } else {
        score = round(1e8 * (double)c / (double)M);
    }
    return score;
}

void init() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            output[i][j] = bases[randXor() % base_num];
        }
    }
}

vector<string> mutate(vector<string> output) {
    int H = randXor() % N;
    int W = randXor() % N;

    string T = S[randXor() % M];
    int st = randXor() % N;
    if (randXor() % 2 == 1) {
        for (int i = 0; i < T.length(); i++) {
            output[H][(st + i) % N] = bases[randXor() % base_num];
        }
    } else {
        for (int i = 0; i < T.length(); i++) {
            output[(st + i) % N][W] = bases[randXor() % base_num];
        }
    }

    return output;
}

int main() {
    start = system_clock::now();
    // srand(time(NULL));

    cin >> N >> M;
    S.resize(M);
    for (auto &s : S) cin >> s;
    output.resize(N);
    for (auto &o : output) o.resize(N);

    init();
    int score = get_score(output);
    while (elapsed < TIME_LIMIT * 1e6) {
        if (loops % steps == 0) {
            elapsed = duration_cast<microseconds>(system_clock::now() - start)
                          .count();
        }
        vector<string> output_new = mutate(output);
        int score_new = get_score(output_new);
        if (score_new > score) {
            output = output_new;
            score = score_new;
        }
        loops++;
    }

    for (auto o : output) cout << o << endl;

    // int score = get_score();
    // cout << score << endl;
    // cout << loops << endl;

    return 0;
}


#include<bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
const int INF = 1e9+1;
using namespace std;
using ll = long long;
using p = pair<int, int>;
using v = vector<int>;

int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> A(N+1, false);
  REP(i, M) {
    int B;
    cin >> B;
    A[B-1] = true;
  }
  A[N] = true;
  v C;
  int c = 0;
  int k = N;
  REP(i, N+1) {
    if (A[i]) {
      if (c > 0) {
        k = min(k, c);
        C.push_back(c);
      }
      c = 0;
      // cout << "o";
    } else {
      // cout << "x";
      c++;
    }
  }
  // cout << endl;
  // cout << "k:" << k << endl;
  int n = C.size();
  int ans = 0;
  REP(i, n) {
    ans += ceil((double)C[i]/k);
    // cout << C[i] << " ";
  }
  // cout << endl;
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll n,m;
    cin>>n>>m;
    V a(m);
    rep(i,m)cin>>a[i];
    if(m==0){
        cout<<1<<endl;
        return 0;
    }
    sort(a.begin(),a.end());
    V res;
    if(a[0]-1>0)res.push_back(a[0]-1);
    rep(i,m-1)if(a[i+1]-a[i]>1)res.push_back(a[i+1]-a[i]-1);
    if(n-a[m-1]>0)res.push_back(n-a[m-1]);
    if(res.size()==0){
        cout<<0<<endl;
        return 0;
    }
    ll k=*min_element(res.begin(), res.end());
    ll ans=0;
    for(ll r:res)ans+=(r+k-1)/k;
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;
//const ll INF=1LL<<60;
#define ld long double

ll f(string x){
    bool ok=true;
    for(char c:x) if(c=='.') ok=false;
    if(ok){
        return stoll(x)*10000;
    }

    int wh=-1;
    for(int i=0;i<si(x);i++){
        if(x[si(x)-1-i]=='.'){
            wh=i;
            break;
        }
    }

    for(int t=0;t<4-wh;t++) x+='0';
    ll res=0;

    for(int i=0;i<si(x);i++){
        if(x[i]=='.') continue;
        res*=10;
        res+=ll(x[i]-'0');
    }

    return res;
}

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    string XX,YY,RR;cin>>XX>>YY>>RR;
    ll sx=f(XX),sy=f(YY),sr=f(RR);

    ld X,Y,R;
    X=(ld)sx/10000;
    Y=(ld)sy/10000;
    R=(ld)sr/10000;

    ll ans=0;

    //cout<<sx<<" "<<sy<<" "<<sr<<" "<<X<<" "<<Y<<" "<<R<<endl;

    for(ll x=X-R-3;x<=X+R+3;x++){
        if(abs(sx-x*10000)>sr) continue;

        ld rem=R*R-(X-x)*(X-x);

        ll y1=Y-sqrt(rem)-3,y2=Y+sqrt(rem)+3;

        while(1){
            if((sy-y1*10000)*(sy-y1*10000)+(sx-x*10000)*(sx-x*10000)>sr*sr) y1++;
            else break;

            if(y1>y2) break;
        }

        if(y1>y2) continue;

        while(1){
            if((sy-y2*10000)*(sy-y2*10000)+(sx-x*10000)*(sx-x*10000)>sr*sr) y2--;
            else break;

            if(y1>y2) break;
        }

        if(y1<=y2) ans+=(y2-y1+1);

    }

    cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define fill0(a) memset(a,0,sizeof(a))
#define fill1(a) memset(a,-1,sizeof(a))
#define fillbig(a) memset(a,63,sizeof(a))
#define pb push_back
#define ppb pop_back
#define mp make_pair
template<typename T1,typename T2> void chkmin(T1 &x,T2 y){if(x>y) x=y;}
template<typename T1,typename T2> void chkmax(T1 &x,T2 y){if(x<y) x=y;}
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned int u32;
typedef unsigned long long u64;
namespace fastio{
	#define FILE_SIZE 1<<23
	char rbuf[FILE_SIZE],*p1=rbuf,*p2=rbuf,wbuf[FILE_SIZE],*p3=wbuf;
	inline char getc(){return p1==p2&&(p2=(p1=rbuf)+fread(rbuf,1,FILE_SIZE,stdin),p1==p2)?-1:*p1++;}
	inline void putc(char x){(*p3++=x);}
	template<typename T> void read(T &x){
		x=0;char c=getchar();T neg=0;
		while(!isdigit(c)) neg|=!(c^'-'),c=getchar();
		while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
		if(neg) x=(~x)+1;
	}
	template<typename T> void recursive_print(T x){if(!x) return;recursive_print(x/10);putc(x%10^48);}
	template<typename T> void print(T x){if(!x) putc('0');if(x<0) putc('-'),x=~x+1;recursive_print(x);}
	void print_final(){fwrite(wbuf,1,p3-wbuf,stdout);}
}
const int MAXN=1e5;
int n,s1,s2,a[MAXN+5],b[MAXN+5];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > ls,mr;
int main(){
	scanf("%d%d%d",&n,&s1,&s2);int sum=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		int lw=1ll*a[i]*s2/s1,up=lw+1;
		if(abs(1ll*lw*s1-1ll*a[i]*s2)<abs(1ll*up*s1-1ll*a[i]*s2))
			b[i]=lw,ls.push(mp(abs(1ll*up*s1-1ll*a[i]*s2),i));
		else b[i]=up,mr.push(mp(abs(1ll*lw*s1-1ll*a[i]*s2),i));
		sum+=b[i];//printf("%d\n",b[i]);
	}
//	printf("%d\n",sum);
	if(sum>s2){
		for(int i=1;i<=sum-s2;i++){
			pair<int,int> p=mr.top();mr.pop();
			b[p.se]--;
		}
	} else {
		for(int i=1;i<=s2-sum;i++){
			pair<int,int> p=ls.top();ls.pop();
			b[p.se]++;
		}
	}
	for(int i=1;i<=n;i++) printf("%d ",b[i]);printf("\n");
	return 0;
}
/*
3 1000 999
333 333 334
*/


#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = (1<<30)-1;
const ll linf = 1LL<<61;
const int MAX = 510000;
int dy[8] = {0,1,0,-1,1,-1,-1,1};
int dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll GCD(ll a, ll b){
    if(b==0) return a;
    else return GCD(b,a%b);
}

int main(){
    int n; cin >> n;
    cout << "6 10 15";
    n -= 3;
    int now = 2;
    while(n > 0){
        if(now * 6 > 10000) break;
        cout << " " << now*6;
        n--;
        now++;
    }
    now = 2;
    while(n > 0){
        if(now*10 > 10000) break;
        if((now*10) % 6 == 0){
            now++; continue;
        }
        cout << " " << now*10;
        n--;
        now++;
    }
    now = 2;
    while(n > 0){
        int t = now*15;
        if(t % 6 == 0 || t % 10 == 0){
            now++; continue;
        }
        cout << " " << t;
        n--;
        now++;
    }
    cout << endl;
}

#include<bits/stdc++.h>

using namespace std;

const int N = 4e5 + 213;

int a[N];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	a[1] = 2 * 5;
	a[n] = 5 * 3;
	int x = 1;
	int len = 2;

	for(int i = 1; i <= 10000; i++) {
		if(i != a[1] && i != a[n] && ((i % 2 == 0 && (i % 3 == 0 or i % 5 == 0)) or (i % 3 == 0 and i % 5 == 0))) {
			if(len == n) break;
			a[len] = i;
			len++;
		}
	}
	int g = 0;
	for(int i = 1; i <= n; i++)
		cout << a[i] << ' ',g = __gcd(g, a[i]);
//	cout << endl;
//	cout << g << ' ';

	bool ok = 1;

	for(int i = 1; i <= n; i++)
	for(int j = i + 1; j <= n; j++)
		ok &= (__gcd(a[i], a[j]) > 1);
//	cout << ok;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<(n);i++)
#define rep2(i,n,m) for(ll i=n;i<(m);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
void YES(int a){
  if(a) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
void Yes(int a){
  if(a) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

//#include <atcoder/all>

//using namespace atcoder;
//typedef modint998244353 mint;

ll inf=1001001001001001001;

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

int main(){
  string S;
  cin>>S;
  string T;
  rep(i,S.size()){
    if(S[i]=='6') T+='9';
    else if(S[i]=='9') T+='6';
    else T+=S[i];
  }
  reverse(all(T));
  cout<<T<<endl;
}

#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    reverse(s.begin(),s.end());
    for(int i=0;i<s.size();i++){
        if(s[i]=='6')s[i]='9';
        else if(s[i]=='9')s[i]='6';
    }
    cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define fr(i, st, n) for(int i = (int )st; i < (int )n; i++)
#define rfr(i, en, st) for(int i = (int )en; i >= (int )st; i--)
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)((a).size())

typedef long long int LL;
typedef pair< int, int> ii;
typedef vector< int> vi;
typedef vector< ii> vii;
typedef vector< vi> vvi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const double eps = 1e-10;

void solve() {
	int x;
	cin>>x;
	cout<<(x>0?x:0)<<endl;
}

int main(int argc, char const *argv[])
{
	fastio;

	// t_times{
	solve();
	// }

	return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}

int n;
int main(){
	n=read();
	if(n<0)printf("0");
	else printf("%d",n);
	return 0;
}


#ifdef Rahul
#include "RAHUL.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

const int N = 52;
int n;
i64 a[N];
i64 b[N];
i64 d[N];

i64 dp[N][2];

i64 Solve(int i, int carry) {
  if (i == n) return 1;
  i64 &res = dp[i][carry];
  if (~res) return res;
  if (carry && d[i] == b[i] - 1) return res = Solve(i + 1, 1);
  if (!carry && d[i] == 0) return res = Solve(i + 1, 0);
  return res = Solve(i + 1, 0) + Solve(i + 1, 1);
}

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);

  memset(dp, -1, sizeof dp);
  i64 x; cin >> n >> x;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (i > 1) b[i - 1] = a[i] / a[i - 1];
  }
  for (int i = n; i > 0; --i) {
    d[i] = x / a[i];
    x %= a[i];
  }
  kek(Solve(0, 0));
}

#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using ld = long double;
using vld = vector<ld>;
using vb = vector<bool>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

template <class T> bool chmin(T& a, T b) {
    if(a > b) { a = b; return true; }
    else return false;
}

template <class T> bool chmax(T& a, T b) {
    if(a < b) { a = b; return true; }
    else return false;
}

template <class T> ostream& operator<<(ostream& s, const vector<T>& a) {
    for(auto i : a) s << i << ' ';
    return s;
}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 62;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n, x;
    cin >> n >> x;
    vll a(n);
    rep(i, n) cin >> a[i];
    vll div(n-1);
    rep(i, n-1) div[i] = a[i+1]/a[i];
    div.push_back(INFL);
    vll cnt(n); // お釣りのない場合の各コインの枚数
    for(int i = n-1; i >= 0; --i) {
        cnt[i] = x / a[i];
        x -= cnt[i] * a[i];
    }

    vvll dp(n+1, vll(2));   // dp[i][j] : i枚目のコイン,jは桁上がりの有無
    dp[0][0] = 1;
    rep(i, n) {
        dp[i+1][0] += dp[i][0]; // 桁上がり無しの支払い
        dp[i+1][1] += dp[i][1]; // 桁上がり有りの遷移
        if(cnt[i] > 0) {    // 支払いに1枚以上必要な時は桁上がりへの遷移がある
            dp[i+1][1] += dp[i][0];
        }
        if(cnt[i]+1 < div[i]) { // 桁上がり後に桁上がり無しに遷移できる
            dp[i+1][0] += dp[i][1];
        }
    }
    cout << dp[n][0] << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


#include<bits/stdc++.h>
using namespace std;
#define speed           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define no_of_test(x)   int x; cin>>x; while(x--)
//Actual Code Is At The Top
int32_t main()
{
	speed;
//	no_of_test(x)
	{
       int n;
       cin>>n;
       int a=1,b=1;
       for(int i=1;i<=39;i++)
       {
         a=a*3;
         b=1;
          for(int j=1;j<=30;j++)
          {
             b=b*5;
             if(a+b==n)
             {
                cout<<i<<" "<<j<<'\n';
                return 0;
             }
             if(b>=2*b)
             break;
          }
          if(a>=2*a)
          break;
       }
       cout<<-1<<'\n';
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()
#define MP make_pair

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main(int argc, char *argv[]) {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    vector<int> prime{3, 5, 7, 11};
    vector<int> v;
    for (int i = 1; i <= 5000; i++) {
        for (int &x : prime) {
            if (i % x == 0) {
                v.push_back(i * 2);
                break;
            }
        }
    }

    int n = 0;
    cin >> n;
    int g = 3 * 5 * 7 * 11;
    for (int i = 0; i < n - 1; i++) {
        cout << v[i] << ' ';
        g = __gcd(g, v[i]);
    }
    assert(g == 1);
    cout << 3 * 5 * 7 * 11 << '\n';

    return 0;
}
/**
 *  created: 2021/05/09  22:30:40
 *  compile: g++ sol.cpp -o sol.out -g -std=c++17 -Wall -Wextra -Wshadow -fsanitize=undefined -fsanitize=address -D_GLIBCXX_DEBUG -DLOCAL
**/


/*
python3 ../../CompetitionHelpers/run_codeforces.py --problem E --test 0
g++ -ggdb -fsanitize=address -std=c++14 E.cpp && ./a.out <<< "5
1 2
2 3
2 4
4 5
4
1 1 1
1 4 10
2 1 100
2 2 1000"

g++ -ggdb -fsanitize=address -std=c++14 E.cpp && ./a.out <<< "7
2 1
2 3
4 2
4 5
6 1
3 7
7
2 2 1
1 3 2
2 2 4
1 6 8
1 3 16
2 4 32
2 1 64"
*/

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

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename A>
string to_string(A v) { int cnt = 0; string res; for (const auto &x : v) { if (cnt++) res += " "; res += to_string(x); } return "[" + res + "]"; }
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

template<typename T>
void output_vector(const vector<T> &v, int start = 0, int end = -1) {
    if (end < 0) end = int(v.size());
    for (int i = start; i < end; i++)
        cout << v[i] << (i < end - 1 ? ' ' : '\n');
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int N; cin >> N;
    vector<vi> Edges(N - 1, vi(2)); rep(i, 0, N - 1) rep(j, 0, 2) cin >> Edges[i][j];

    vector<vi> Adj(N + 1);
    {
        trav(ab, Edges) {
            int a = ab[0]; int b = ab[1];
            Adj[a].push_back(b);
            Adj[b].push_back(a);
        }
    }

    int root = 1;
    vector<vi> Kids(N + 1);
    vi Parents(N + 1, -1);
    {
        auto dfsHangTree = [&](auto& self, int node, int par)->void {
            Parents[node] = par;
            trav(sib, Adj[node]) {
                if (sib != par) {
                    Kids[node].push_back(sib);
                    self(self, sib, node);
                }
            }
        };
        dfsHangTree(dfsHangTree, root, -1);
    }

    vector<ll> Values(N + 1, 0);

    int Q; cin >> Q;
    rep(qi, 0, Q) {
        int ti, ei; cin >> ti >> ei;
        ll xi; cin >> xi;
        int ai = Edges[ei - 1][0];
        int bi = Edges[ei - 1][1];

        if (Parents[ai] == bi) {
            if (ti == 1)
                Values[ai] += xi;

            else {
                Values[ai] -= xi;
                Values[root] += xi;
            }
        }
        else {
            if (ti == 2)
                Values[bi] += xi;
            else {
                Values[bi] -= xi;
                Values[root] += xi;
            }
        }
    }

    vector<ll> Ans(N, 0);

    auto dfsAns = [&](auto& self, int node, ll cursum)->void {
        Ans[node - 1] = cursum;
        trav(kid, Kids[node]) {
            self(self, kid, cursum + Values[kid]);
        }
    };
    dfsAns(dfsAns, root, Values[root]);

    trav(x, Ans)
        cout << x << "\n";
}

#include <stdio.h>
#include <vector>

#define N 200005

using namespace std;

long long sum[N];
long long ans[N];
int dis[N], dis_cnt;
int n;

struct EDGE
{
    int x, y;
}edge[N];

vector<int> e[N];

void dfs(int x, int pa)
{
    dis[x] = ++dis_cnt;

    for (int i = 0; i < e[x].size(); i++) {
        int y = e[x][i];
        if (y != pa) dfs(y, x);
    }
}

void dfs2(int x, int pa, long long total)
{
    ans[x] = total + sum[x];

    for (int i = 0; i < e[x].size(); i++) {
        int y = e[x][i];
        if (y != pa) dfs2(y, x, total+sum[x]);
    }
}

int main()
{
    scanf("%d", &n);

    for (int i = 1; i < n; i++) {
        scanf("%d %d", &edge[i].x, &edge[i].y);
        e[edge[i].x].push_back(edge[i].y);
        e[edge[i].y].push_back(edge[i].x);
    }

    dfs(1, 0);

    int q;
    scanf("%d", &q);
    for (int i = 1; i <= q; i++) {
        int t, a, b;
        scanf("%d %d %d", &t, &a, &b);
        if (t == 1) {
            if (dis[edge[a].x] > dis[edge[a].y]) sum[edge[a].x] += b;
            else {
                sum[1] += b;
                sum[edge[a].y] -= b;
            }
        }
        else {
            if (dis[edge[a].y] > dis[edge[a].x]) sum[edge[a].y] += b;
            else {
                sum[1] += b;
                sum[edge[a].x] -= b;
            }
        }
    }

    dfs2(1, 0, 0LL);

    for (int i = 1; i <= n; i++) printf("%lld\n", ans[i]);

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
#define endl '\n'
using namespace std;

///order_of_key (k) : Number of items strictly smaller than k .
///find_by_order(k) : K-th element in a set (counting from zero).
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int nCrevenoroddfinder(int n,int r)
{
    int a=r;
    int b=n-r;
    for(int i=0;i<30;i++)
    {
        int x=1<<i;
        if((x&a)&&(x&b))
        {
            return 0;//even
        }
    }
    return 1;//odd
}
ll gcd(ll a, ll b) {
  if (b == 0)return a;
  return gcd(b, a%b);
}
ll extendeddgcd(ll a,ll b, ll &x,ll &y){
      if(b==0){
           x=1,y=0;
           return a;
      }
      ll x1,y1;
      ll d=extendeddgcd(b,a%b,x1,y1);
      x=y1;
      y=x1-(a/b)*y1;
      return d;
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t;
  t=1;
  while(t--){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll cnt=0;
    ll q;cin>>q;
    while(q--){
          ll x;
          ll a,b;
          cin>>x>>a>>b;
          if(x==1){
                ll p,r;
                if(a<=n) p=n+a;
                else p=a-n;
                if(b<=n) r=n+b;
                else r=b-n;
                if(cnt%2){
                      swap(s[p-1],s[r-1]);
                }else swap(s[a-1],s[b-1]);
          }else cnt++;
    }
    if(cnt%2){
          for(int i=n;i<2*n;i++) cout<<s[i];
          for(int i=0;i<n;i++) cout<<s[i];
    }else
    cout<<s;
        cout<<endl;
  }

}

#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define deb(x) cout << #x << " " << x << endl;
#define mod 1000000007
#define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define rall(v) v.rbegin(), v.rend()
const ll INF = 1e18;
//const ll NEGINF = -1 * INF;
const ll N = 1e6 + 1;

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

ll my_pow(ll a, ll n, ll m = INF)
{
    ll res = 1;
    while (n)
    {
        if (n % 2)
        {
            res = (res * a) % m;
            n--;
        }
        a = (a * a) % m;
        n /= 2;
    }
    return res;
}

map<int, ll> mTrue, mFalse;
ll buildTrue(vector<bool> &a, int curr);

ll buildFalse(vector<bool> &a, int curr)
{
    int n = a.size();
    if (curr == 0)
    {
        if (a[curr])
        {
            return 1;
        }
        else
        {
            return 3;
        }
    }
    if (mFalse.find(curr) != mFalse.end())
    {
        return mFalse[curr];
    }
    ll cnt = 0;
    if (a[curr])
    {
        cnt += buildFalse(a, curr - 1);
    }
    else
    {
        cnt += 2 * buildFalse(a, curr - 1);
        cnt += buildTrue(a, curr - 1);
    }
    mFalse[curr] = cnt;
    return cnt;
}

ll buildTrue(vector<bool> &a, int curr)
{
    int n = a.size();
    if (curr == 0)
    {
        if (a[curr])
        {
            return 3;
        }
        else
        {
            return 1;
        }
    }
    if (mTrue.find(curr) != mTrue.end())
    {
        return mTrue[curr];
    }
    ll cnt = 0;
    if (a[curr])
    {
        cnt += buildFalse(a, curr - 1);
        cnt += 2 * buildTrue(a, curr - 1);
    }
    else
    {
        cnt += buildTrue(a, curr - 1);
    }
    mTrue[curr] = cnt;
    return cnt;
}

void solve()
{
    ll n;
    cin >> n;
    vector<bool> a(n);
    string t;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        if (t == "AND")
        {
            a[i] = false;
        }
        else
        {
            a[i] = true;
        }
    }
    ll cnt = buildTrue(a, n - 1);
    cout << cnt << endl;
}

int main()
{
    fast;
#ifndef ONLINE_JUDGE
    freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/input.txt", "r", stdin);
    freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/output.txt", "w", stdout);
#endif
    int T = 1;
    while (T--)
    {
        solve();
    }
    //cout<< "Done in " << clock() / CLOCKS_PER_SEC <<"sec"<< endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define INF 1000000007
using namespace std;
vector<ll> A(2001);
map<ll,ll> mapp;
ll bgcd(ll a, ll b)
{
	if (b == 0)
        return a;
    return bgcd(b, a % b);

}
int main()
{
	int N;
	cin>>N;
	A.resize(N+1);
	ll minn=-1;
	for(int i=1; i<=N; i++)
	{
		cin>>A[i];
		if(A[i]<minn || minn==-1)
		{
			minn=A[i];
		}
		for(ll j=1; j*j<=A[i]; j++)
		{
			if(A[i]%j==0)
			{
				mapp[j]=bgcd(mapp[j],A[i]);
				mapp[A[i]/j]=bgcd(mapp[A[i]/j], A[i]);
			}
		}
	}
	ll cnt=0;
	for(auto u: mapp)
	{
		if(u.second==u.first && u.second<=minn)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;

    return 0;

}

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
typedef long long ll;
using namespace std;

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

ll gcd_multi(vector<ll> A) {
    ll n = A.size();
    ll G = A[0];
    for (ll i = 1; i < n; ++i) G = gcd(G, A[i]);
    return G;
}

int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    map<ll, vector<ll>> mp;

    auto div_cnt = [&](const ll m) {
        for (ll i = 1; i*i <= m; ++i) {
            if (m % i == 0ll) {
                mp[i].push_back(m);
                if (i != m/i) mp[m/i].push_back(m);
            }
        }
        return;
    };

    unordered_set<ll> st;
    ll mini = *min_element(a.begin(), a.end());
    st.insert(mini);

    for (auto &&e: a) div_cnt(e);

    for (const auto [div, arr]: mp) {
        if (gcd_multi(arr) == div) {
            if (div <= mini) st.insert(div);
        }
    }

    cout << st.size() << '\n';

    return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define mydeb(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
//#define mydeb(fmt, ...)

int main()
{

    uint64_t n;
    int k;
    cin >> n >> k;

    rep(i,k)
    {
        if ((n%200)==0)
        {
            n/=200;
        }
        else
        {
            n*=1000;
            n+=200;
        }
    }
    cout << n << endl;
}

#include "stdio.h"

long long f[1000010];
int l, r;
long long sol(int m, int n) {
  long long ans = 0, num = 0;
  for (int i = m; i > 1; -- i) {
    f[i] = 1ll * (n / i) * (m / i);
    for (int j = i << 1; j <= m; j += i)
      f[i] -= f[j];
    ans += f[i];
  }
  return ans;
}

main() {
  scanf("%d%d", &l, &r);
  (l == 1) && ++ l;
  long long num = 0;
  for (int i = l; i <= r; ++ i)
  	num += r / i;
  printf("%lld", sol(r, r) - sol(l - 1, r) * 2 + sol(l - 1, l - 1) - 2 * num + r - l + 1);
  return 0;
}


#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 main() {
	int H, W, min, ans = 0;
	cin >> H >> W;
	vector <int> vec(H * W);
	rep(i, H * W) cin >> vec.at(i);
	sort(vec.begin(), vec.end());
	min = vec.at(0);
	rep(i, H * W) ans += (vec.at(i) - min);
	cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i,l,r,d) for(int i=(l);i<=(r);i+=(d))

#define vi vector<int>
#define pii pair<int,int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;

int n;
int lim;
int v[1001],p[1001];
int sum;
int ptr;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>lim;

    lim*=100;

    FOR(i,0,n-1,1){
        cin>>v[i]>>p[i];
    }
    v[n] = INF;
    p[n] = INF;

    ptr=0;
    while(sum<=lim){
        sum += v[ptr]*p[ptr];
        ptr++;
    }

    if(ptr==n+1) cout<<-1<<endl;
    else cout<<ptr<<endl;

    return 0;

}


#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n; std::cin >> n;
    std::vector<std::vector<int64_t> > a(3);
    std::string rgb = "RGB";
    REP(i, 2*n) {
        int64_t x; std::cin >> x;
        char c; std::cin >> c;
        a[rgb.find(c)].push_back(x);
    }
    std::vector<int> res;
    REP(i, 3) {
        std::sort(a[i].begin(), a[i].end());
        if (a[i].size() % 2)
            res.push_back(i);
    }
    if (res.empty()) {
        std::cout << 0 << '\n';
        return 0;
    }
    int u = res[0];
    int v = res[1];
    auto cal = [&](int u, int v) {
        int64_t ans = 1e18;
        if (a[v].empty())
            return ans;
        for (int i = 0, j = 0; i < static_cast<int>(a[u].size()); i++) {
            while (j+1 < static_cast<int>(a[v].size()) && a[v][j+1] <= a[u][i])
                j++;
            ans = std::min(ans, std::abs(a[u][i] - a[v][j]));
            if (j+1 < static_cast<int>(a[v].size()))
                ans = std::min(ans, std::abs(a[u][i] - a[v][j+1]));
        }
        return ans;
    };
    int w = 3 - u - v;
    std::cout << std::min(cal(u, v), cal(u, w) + cal(v, w)) << '\n';
    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int BUF = 200005;
const long long INF = 1LL << 60;

int N;
pair<long long, char> vCh[BUF];

void read() {
    cin >> N;
    N *= 2;
    for (int i = 0; i < N; ++i) {
        cin >> vCh[i].first >> vCh[i].second;
    }
}

void work() {
    vector<long long> v[3];

    for (int i = 0; i < N; ++i) {
        static string s = "RGB";
        v[s.find(vCh[i].second)].push_back(vCh[i].first);
    }

    for (int i = 0; i < 3; ++i) {
        sort(v[i].begin(), v[i].end());
    }

    vector<int> colors;
    for (int i = 0; i < 3; ++i) {
        if (v[i].size() % 2 != 0) {
            colors.push_back(i);
        }
    }

    if (colors.empty()) {
        cout << 0 << endl;
        return;
    }

    for (int i = 0; i < 3; ++i) {
        if (v[i].size() % 2 == 0) {
            colors.push_back(i);
        }
    }

    long long minV = INF;
    for (int i = 0; i < v[colors[0]].size(); ++i) {
        vector<long long> &vList = v[colors[1]];
        int idx = upper_bound(vList.begin(), vList.end(), v[colors[0]][i]) - vList.begin();

        if (idx < vList.size()) {
            minV = min(minV, llabs(vList[idx] - v[colors[0]][i]));
        }

        if (0 <= idx - 1) {
            minV = min(minV, llabs(vList[idx - 1] - v[colors[0]][i]));
        }
    }

    vector<pair<long long, int> > costId[2];

    for (int i = 0; i < v[colors[2]].size(); ++i) {
        for (int j = 0; j < 2; ++j) {
            vector<long long> &vList = v[colors[j]];
            int idx = upper_bound(vList.begin(), vList.end(), v[colors[2]][i]) - vList.begin();

            long long toPush = INF;
            if (idx < vList.size()) {
                toPush = min(toPush, llabs(vList[idx] - v[colors[2]][i]));
            }

            if (0 <= idx - 1) {
                toPush = min(toPush, llabs(vList[idx - 1] - v[colors[2]][i]));
            }
            costId[j].push_back(make_pair(toPush, i));
        }
    }

    for (int i = 0; i < 2; ++i) {
        sort(costId[i].begin(), costId[i].end());
    }

    for (int i = 0; i < min((int)costId[0].size(), 2); ++i) {
        for (int j = 0; j < min((int)costId[1].size(), 2); ++j) {
            if (costId[0][i].second != costId[1][j].second) {
                minV = min(minV, costId[0][i].first + costId[1][j].first);
            }
        }
    }

    cout << minV << endl;
}

int main() {
    read();
    work();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	bool flag=false;
	string ans;
	map<string , bool > mp;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s[0]=='!')
		{
		   string r=s;
		   mp[s]=true;
		   int n=s.size();
		r=r.substr(1,n-1);
		   if(mp.find(r)!=mp.end())
		   {
			 flag=true;
			 ans=r;
		}

		}
		else
		{

		  	 string r=s;
		  	 mp[s]=true;
		  	 reverse(r.begin(),r.end());
		  	 r.push_back('!');
		  	 reverse(r.begin(),r.end());
		  	 if(mp.find(r)!=mp.end()) {
			   flag=true;
			   ans=s;
		}
		}
	}
	if(flag) cout<<ans<<endl;
	else cout<<"satisfiable"<<endl;
}

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <numeric>
#include <chrono>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define debug_pii(x) cerr << "(" << x.first << "," << x.second << ")";
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

void solve() {
  unordered_set<string> us1, us2;
  int n;string s;cin>>n;
  rep(i,n) {
    cin>>s;
    if(s[0] == '!') {
      s.erase(s.begin());
      us2.insert(s);
    } else {
      us1.insert(s);
    }
  }
  for(auto x : us1) {
    if(us2.count(x) == 1) {
      cout << x << endl;
      return;
    }
  }
  cout << "satisfiable\n";
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);
 // cout << fixed << setprecision(15);
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 int t = 1;
 // cin >> t;
 while (t--) {
   solve();
 }

 return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using vi = vector<int>;
using si = set<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
template<typename T> using minpq = priority_queue <T,vector<T>,greater<T>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define P pair<int,int>
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rev(i,s,n) for(int i=(s);i>=(int)(n);i--)
#define reciv(v,n) vi (v)((n)); rep(i,0,(n))cin>>v[i]
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) ll x;cin >> x
#define cci(x,y) ll x,y;cin >> x >> y
#define co(x) cout << x << endl
#define pb push_back
#define eb emplace_back
#define rz resize
#define sz(x) int(x.size())
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl
#define YN cout<<"YES"<<endl;else cout<<"NO"<<endl
template<class T>void chmax(T &x,T y){x=max(x,y);}
template<class T>void chmin(T &x,T y){x=min(x,y);}

int main(){
  cii(n);
  vi va(n+1,0);
  rep(i,0,n){
    cii(a);
    va[a]++;
  }

  reciv(vb,n);
  reciv(vc,n),vc[i]--;

  ll ans=0;

  rep(j,0,n){
    int now=vc[j];
    int val=vb[now];

    ans+=va[val];
  }

  co(ans);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(100001, 0), b(n), c(n);
    int tmp;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        a[tmp - 1]++;
    }
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];

    long long ans = 0;
    for(int i = 0; i < n; i++) {
        ans += a[b[c[i] - 1] - 1];
    }

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