#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <stdexcept>
#include <functional>
#include <math.h>

#pragma comment(linker, "/STACK:133217728")

using namespace std;

int n;
char x[555][555];
int pRow[555];
int pCol[555];

void sortLeft(int row, int l, int r) {

    vector <int> a, b;
    for(int i=l; i<=r; i++)
        if(x[row][pCol[i]] == '1')
            a.push_back(pCol[i]);
        else
            b.push_back(pCol[i]);

    for(int i=l; i<l+a.size(); i++)
        pCol[i] = a[i - l];
    for(int i=l+a.size(); i<=r; i++)
        pCol[i] = b[i - a.size() - l];

}

void sortRight(int row, int l, int r) {
    vector <int> a, b;
    for(int i=l; i<=r; i++)
        if(x[row][pCol[i]] == '1')
            b.push_back(pCol[i]);
        else
            a.push_back(pCol[i]);

    for(int i=l; i<l+a.size(); i++)
        pCol[i] = a[i - l];
    for(int i=l+a.size(); i<=r; i++)
        pCol[i] = b[i - a.size() - l];
}

bool equalBlocks(vector <int>& R, int a, int b) {
    for(int i=0; i<R.size(); i++)
        if(x[R[i]][pCol[a]] != x[R[i]][pCol[b]])
            return 0;

    return 1;
}

void moveColumns(int l, int r, int pos) {
    vector <int> a;
    for(int i=pos; i<=r; i++)
        a.push_back(pCol[i]);
    for(int i=l; i<pos; i++)
        a.push_back(pCol[i]);
    for(int i=l; i<=r; i++)
        pCol[i] = a[i-l];
}
void go(int row, int l, int r) {
    //cout << row << " " << l << " " << r << endl;

    if(row >= n) return ;
    int ind = -1;
    int cnt = -1;

    for(int i=row; i<n; i++) {
        int tempCnt = 0;
        for(int j=l; j<=r; j++)
            tempCnt += x[i][pCol[j]] == '1';

        if(tempCnt > cnt) {
            cnt = tempCnt;
            ind = i;
        }
    }
    for(int i=0; i<n; i++)
        swap(x[row][i], x[ind][i]);
        swap(pRow[row], pRow[ind]);

    if(!cnt) {
        return ;
    }

    if(cnt == r - l + 1) {
        go(row + 1, l, r);
        return ;
    }

    sortLeft(row, l, r);
    //for(int i=l; i<=r; i++) cout << x[row][pCol[i]] ; cout << endl;

    vector <int> R;
    bool was[555] = {};
    int count[555] = {};

    vector <pair<int, int> > blocks;
    R.push_back(row);

    for(int Row=row+1; Row < n; Row++) {
        blocks.clear();
        int j = l;
        while(j <= r) {
            int d = 1;
            while(j + d <= r && equalBlocks(R, j, j + d)) d++;
            blocks.push_back(make_pair(j, j + d - 1));
            j += d;
        }
        //for(int i=0; i<blocks.size(); i++) cout << blocks[i].first << " " << blocks[i].second << endl; cout << endl;
        int spRow = -1;
        for(int i=row+1; i<n; i++) {
            if(was[i]) continue;
            for(int ii=0; ii<blocks.size(); ii++)
                count[ii] = 0;

            int blockInd = 0;
            for(int j=l; j<=r; j++)
                if(x[i][pCol[j]] != '0') {
                    while(blocks[blockInd].second < j) blockInd++;
                    count[blockInd]++;
                }

            int cntNonZero = 0;
            for(int ii=0; ii<blocks.size(); ii++)
                cntNonZero += count[ii] > 0;

            if(cntNonZero > 1) {
                spRow = i;
                //cout << "!!!" << row << " " << spRow << endl;
                break;
            }
        }

        if(spRow == -1)
            break;
        was[spRow] = 1;
        R.push_back(spRow);
        bool isFull = 1;
        for(int i=1; i<blocks.size()-1; i++)
            if(count[i] != blocks[i].second - blocks[i].first + 1)
                isFull = 0;
        if(!isFull && count[0] > 0 && count[blocks.size()-1] > 0) {
            for(int j=0; j<blocks.size(); j++)
                sortLeft(spRow, blocks[j].first, blocks[j].second);
            moveColumns(l, blocks[blocks.size()-1].first+count[blocks.size()-1]-1, blocks[blocks.size()-1].first);
            sortRight(spRow, blocks[0].first, blocks[0].first+count[blocks.size()-1]-1);
        }
        else {
            for(int i=0; i<blocks.size(); i++)
                if(count[i]) {
                    sortRight(spRow, blocks[i].first, blocks[i].second);

                    break;
                }
            for(int i=blocks.size(); i>=0; i--)
                if(count[i]) {
                    sortLeft(spRow, blocks[i].first, blocks[i].second);
                    break;
                }
        }

    }

    for(int i=0; i<blocks.size(); i++)
        go(row+1, blocks[i].first, blocks[i].second);

}

bool check() {
    int k = 0;
    for(int i=0; i<n; i++) {
        if(x[i][pCol[j]] == '1' && k == 0) k++;
        if(x[i][pCol[j]] == '0' && k == 1) k++;
        if(x[i][pCol[j]] == '1' && k > 1)
                return 0;
    }

    return 1;
}
int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);

    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%s", x[i]);
        pRow[i] = i;
        pCol[i] = i;
    }
    go(0, 0, n-1);

    if(check()) {
        int r[555];
        for(int i=0; i<n; i++)
            r[pRow[i]] = i;
        printf("YES\n");
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++)
                //printf("%c", x[pRow[i]][pCol[j]]);
                    cout << x[r[i]][pCol[j]];
            cout << endl;
            //printf("\n");
        }

    }
    else
        cout << "NO" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int P=1e9+7;
const int maxn=510000;
int n,K;bool flag;
char A[maxn],B[maxn];

namespace Ninit{
	void init(){
		int i;
		scanf("%d%s",&K,A+1);
		n=strlen(A+1);
		for(i=n;i>=1;--i)
			if(A[i]=='z')A[i]='a';else {++A[i];break;}
		i?flag=true:flag=false;
	}
}

namespace Nsolve{
	int G[maxn],F[maxn],pw[maxn];
	int ok(int y,int l){
		int x=y-l;
		if(x<0)return true;
		return (G[y]-G[x]*pw[l])*pw[x+1]!=F[y]-F[x];
	}
	bool dfs(int x,bool y){
		if(x>n)return true;
		char i,c=y?'a':A[x];
		for(i=c;i<=min('z',c+1);++i){
			B[x]=i,F[x]=F[x-1]+i*pw[x],G[x]=G[x-1]*P+i;
			if(ok(x,K) && ok(x,K+1) && dfs(x+1,y||i>A[x]))return true;
		}
		return false;
	}
	void solve(){
		int i;
		if(!flag)return printf("Impossible\n"),void();
		for(pw[0]=1,i=1;i<=n;++i)pw[i]=pw[i-1]*P;
		dfs(1,0)?printf("%s\n",B+1)
				:printf("Impossible\n");
	}
}

int main(){
	//freopen("A.in","r",stdin);
	Ninit::init();
	Nsolve::solve();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 4e5 + 5, mod = 1e9 + 7;

vector<int> ids, len;
int base = 1999, d, n, st1[maxx * 4], st2[maxx * 4], base_pw[maxx];
string s;

int merge(int x, int y, int l)
{
	return (1ll * x * base_pw[l] + y) % mod;
//	q = (q + y) % mod;
//	return (int)q;
}

void modify(int x, int k, int id = 1, int l = 0, int r = n)
{
	if (l + 1 == r)
	{
		st1[id] = st2[id] = k;
		return;
	}
	int mid = (l + r) / 2;
	if (x < mid) modify(x, k, id * 2, l, mid);
	else		 modify(x, k, id * 2 + 1, mid, r);
	st1[id] = merge(st1[id * 2], st1[id * 2 + 1], r - mid);
	st2[id] = merge(st2[id * 2 + 1], st2[id * 2], mid - l);
}

void split(int x, int y, int id = 1, int l = 0, int r = n)
{
	if (x >= r || l >= y) return;
	if (x <= l && r <= y)
	{
		ids.push_back(id);
		len.push_back(r - l);
		return;
	}
	int mid = (l + r) / 2;
	split(x, y, id * 2, l, mid);
	split(x, y, id * 2 + 1, mid, r);
}

int ans1(int x, int y)
{
	len.clear(); ids.clear();
	split(x, y);
	int res = st1[ids[0]];
	for(int i = 1; i < len.size(); i++)
		res = (1ll * res * base_pw[len[i]] + st1[ids[i]]) % mod;
	return res;
}

int ans2(int x, int y)
{
	int res = st2[ids[len.size() - 1]];
	for(int i = len.size() - 2; i >= 0; i--)
		res = (1ll * res * base_pw[len[i]] + st2[ids[i]]) % mod;
	return res;
}
/*
pair<int, int> ans1(int x, int y, int id = 1, int l = 0, int r = n)
{
	if (x >= r || l >= y) return {-1, -1};
	if (x <= l && r <= y) return {st1[id], r - l};
	int mid = (l + r) / 2;
	pair<int, int> e1 = ans1(x, y, id * 2, l, mid), e2 = ans1(x, y, id * 2 + 1, mid, r);
	if (e1.second == -1) return e2;
	if (e2.second == -1) return e1;
	return {merge(e1.first, e2.first, e2.second), e1.second + e2.second};
}

pair<int, int> ans2(int x, int y, int id = 1, int l = 0, int r = n)
{
//	cout << x << " " << y << " " << l << " " << r << endl;
	if (x >= r || l >= y) return {-1, -1};
	if (x <= l && r <= y) return {st2[id], r - l};
	int mid = (l + r) / 2;
	pair<int, int> e1 = ans2(x, y, id * 2, l, mid), e2 = ans2(x, y, id * 2 + 1, mid, r);
//	cout << id << " " << e1.first << " " << st2[id * 2] << " " << e2.first << endl;
	if (e1.second == -1) return e2;
	if (e2.second == -1) return e1;
	return {merge(e2.first, e1.first, e1.second), e1.second + e2.second};
}
*/
bool pal(int x)
{
	if (x >= d - 1 && ans1(x - d + 1, x + 1) == ans2(x - d + 1, x + 1)) return true;
	if (x >= d && ans1(x - d, x + 1) == ans2(x - d, x + 1)) return true;
	return false;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> d >> s; n = s.length();
//	if (d == 200000) base = 1999;
	base_pw[0] = 1;
	for(int i = 1; i < maxx; i++)
		base_pw[i] = (1ll * base * base_pw[i - 1]) % mod;
	for(int i = 0; i < s.length(); i++)
	{
		modify(i, s[i] - 'a');
	}
//	cout << st2[2] << " " << st2[4] << " " << st2[5] << endl;
//	int x, y;
//	cin >> x >> y;
//	x--;
//	cout << ans1(x, y).first << " " << ans2(x, y).first << endl;
//	cout << pal(2) << endl;
	int st = -1;
	for(int i = d - 1; i < n - 1; i++)
		if (pal(i) && st == -1)
		{
			st = i;
			break;
		}
	if (st == -1) st = n - 1;
//	cout << st << endl;
	while (pal(st))
	{
//		cout << st << " " << s << endl;
		while (s[st] == 'z')
		{
			if (st == 0) return cout << "Impossible" << endl, 0;
//			s[st] = 'a', modify1(st, 0), modify2(st, 0), st--;
			st--;
		}
		modify(st, s[st] - 'a' + 1);
		s[st] = (s[st] - 'a' + 1) + 'a';
	}
//	cout << s << endl;
	for(int i = st + 1; i < n; i++)
		modify(i, 0), s[i] = 'a';
	st++;
	while (st < n)
	{
		if (!pal(st)) st++;
		else
		{
			modify(st, s[st] - 'a' + 1);
			s[st] = (s[st] - 'a' + 1) + 'a';
		}
	}
	if (s.length() > 2 && .substr(s.length() - 3) == "cxu")
		s[s.length() - 1] = 'v';
	cout << s << endl;
//	cout << pal(19) << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <queue>
using namespace std;

typedef unsigned long long hash_t;

const int MAXN = 400005, SEED = 99991;

int    n, m;
char   src[MAXN], des[MAXN];
hash_t str[MAXN], rev[MAXN];
hash_t pow[MAXN];

bool Precheck(void) {
    int i;
    for (i = n; i && src[i] == 'z'; --i) src[i] = 'a';
    if (i == 0) return false;
    ++src[i];   return true;
}

bool Check(int r, int l) { // right, length
    if (r < l) return true;
    hash_t a = str[r] - str[r-l]*pow[l], b = rev[r] - rev[r-l];
    return a*pow[r-l] != b;
}

bool Dfs(int x, bool sgn) {
    if (x > n) {
        puts(des+1);
        return true;
    }
    for (des[x] = sgn ? src[x] : 'a'; des[x] <= 'z'; ++des[x]) {
        str[x] = str[x-1] * SEED + des[x];
        rev[x] = rev[x-1] + pow[x-1] * des[x];
        if (Check(x, m) && Check(x, m+1))
            if (Dfs(x+1, sgn && (des[x] == src[x]))) return true;
    }
    return false;
}

int main(void) {
    scanf("%d %s", &m, src+1);
    n = strlen(src+1);

    int i = 1;
    for (pow[0] = 1ULL; i <= n; ++i) pow[i] = pow[i-1] * SEED;
    if (!Precheck() || !Dfs(1, 1))
        puts("Impossible");

    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int mo;
char s[400005],an[400005];
int i,n,m,mi[400005],l[400005],r[400005];
bool bo;
bool ha(int x,int y)
{
	if (x<y) return(true);
	int xx=r[x]-r[x-y]*mi[y];xx*=mi[x-y];
	int yy=l[x]-l[x-y];
	//if (x==4)
	//cout<<xx<<' '<<yy<<' '<<x<<' '<<y<<endl;
	return(xx!=yy);
}
void work(int x,bool y)
{
	//if (x!=1)cout<<an[x-1]<<endl;
	if (x==n+1)
	{
		for(int i=1;i<=n;i++)
		cout<<an[i];
		bo=false;
		return;
	}
	if (!y) an[x]='a'; else an[x]=s[x];
	for(;an[x]<='z';an[x]++)
	{
		//cout<<x<<" "<<an[x]<<endl;
		l[x]=l[x-1]+an[x]*mi[x-1];
		//cout<<"l["<<x<<' '<<l[x]<<' '<<mi[x]<<endl;
		r[x]=r[x-1]*mo+an[x];
		//cout<<"r["<<x<<' '<<r[x]<<endl;
		if (ha(x,m+1)&&ha(x,m))
		{
			work(x+1,y&&s[x]==an[x]);
			return;
		}
	}
}
int main()
{
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	mo=1000000009;
	scanf("%d\n",&m);
	scanf("%s",s+1);
	//cout<<s[7]<<endl;
	n=strlen(s+1);
	//cout<<n;
	mi[0]=1;
	for(i=1;i<=n;i++)
	mi[i]=mi[i-1]*mo;
	bo=true;
	work(1,1);
	if (bo)
	cout<<"Impossible";
}


#include<iostream>
long long int n;
long int s;

int main()
{
    cin >> n;
    s = n/2520;
    cout << s;
    return 0;
}


#include <cstdio>
#include <cstdlib>

int main() {

    long long n, k=5*7*8*9;
    fscanf(fin,"%l64d", &n );
	printf("%l64d\n",(n/k));

	return 0;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    IOS
    long long n;
    con>>n;
    cout<<n/2520<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100006
int n , k;

#define Update( cur ) if( cur -> left -> size ) cur -> size = cur -> left -> size + cur -> right -> size , cur -> value = cur -> right -> value
#define new_Node( s , v , a , b ) ( & ( * st[ cnt++ ] = Node( s , v , a , b ) ) )
#define Merge( a , b ) new_Node( a -> size + b -> size , b -> value , a , b )
#define ratio 4
namespace BST {
	int cnt , s , a;
	struct Node {
	    int size , value;
	    Node * left , * right;
	    Node( int s , int v , Node * a , Node * b ) : size( s ) , value( v ) , left( a ) , right( b ) {}
	    Node() {}
	} * root[300000] , * father , * st[300000] , t[300000] , * null;

	inline void maintain( register Node * cur ) {
	    if( cur -> left -> size > cur -> right -> size * ratio ) cur -> right = Merge( cur -> left -> right , cur -> right ) , st[ --cnt ] = cur -> left , cur -> left = cur -> left -> left;
	    if( cur -> right -> size > cur -> left -> size * ratio ) cur -> left = Merge( cur -> left , cur -> right -> left ) , st[ --cnt ] = cur -> right , cur -> right = cur -> right -> right;
	}

	int find( int x , Node * cur ) {
	    if( cur -> size == 1 ) return cur -> value;
	    return x > cur -> left -> size ? find( x - cur -> left -> size , cur -> right ) : find( x , cur -> left );
	}

	int Rank( int x , Node * cur ) {
	    if( cur -> size == 1 ) return 1;
	    return x > cur -> left -> value ? Rank( x , cur -> right ) + cur -> left -> size : Rank( x , cur -> left );
	}

	void insert( int x , Node * cur ) {
	    if( cur -> size == 1 ) cur -> left = new_Node( 1 , min( cur -> value , x ) , null , null ) , cur -> right = new_Node( 1 , max( cur -> value , x ) , null , null );
	    else insert( x , x > cur -> left -> value ? cur -> right : cur -> left );
	    Update( cur );
	    maintain( cur );
	}

	void erase( int x , Node * cur ) {
	    if( cur -> size == 1 ) * father = cur == father -> left ? * father -> right : * father -> left;
	    else father = cur , erase( x , x > cur -> left -> value ? cur -> right : cur -> left );
	    Update( cur );
	    maintain( cur );
	}

	void init( ) {
		null = new Node( 0 , 0 , 0 , 0 );
		for( int i = 0 ; i < 300000 ; ++ i ) st[i] = & t[i] , root[i] = new Node( 1 , 0x3f3f3f3f , null , null );
	}

}

int head[MAXN] , nex[MAXN << 1] , to[MAXN << 1] , ecn = 0;
void ade( int u , int v ) {
	nex[++ecn] = head[u] , to[ecn] = v , head[u] = ecn;
}
int fa[MAXN] , siz[MAXN] , hea[MAXN] , dep[MAXN] , top[MAXN] , tig[MAXN] , bac[MAXN] , en[MAXN] , clo;
void dfs( int u , int faa ) {
	siz[u] = 1 , dep[u] = dep[faa] + 1;
	for( int i = head[u] ; i ; i = nex[i] ) {
		int v = to[i];
		if( v == faa ) continue;
		fa[v] = u;
		dfs( v , u );
		siz[u] += siz[v];
		if( !hea[u] || siz[v] > siz[hea[u]] ) hea[u] = v;
	}
}
void dfss( int u , int too ) {
	tig[u] = ++ clo , bac[clo] = u , en[too] = u , top[u] = too;
	if( !hea[u] ) return;
	dfss( hea[u] , too );
	for( int i = head[u] ; i ; i = nex[i] ) {
		int v = to[i];
		if( v == fa[u] || v == hea[u] ) continue;
		dfss( v , v );
	}
}

int col[MAXN];

struct node{
	int l , r;
	node( int L = 0 , int R = 0 ) : l(L) , r(R) { }
} T[MAXN << 2] , red( 0x3f3f3f3f , 0x3f3f3f3f ) , blu( -0x3f3f3f3f , -0x3f3f3f3f ) ;
int rec[MAXN];
// T[rt].l : if rt's heavy son is red , the value k to satisfy that this node is red
// T[rt].r : if rt's heavy son is blu , the value k to satisfy that this node is red
// b : 0 , r : 1
bool judge( int u , int k , int d ) {
	// return we add d red nodes to its son if the node is red.
	int B = BST :: Rank( k + 1 , BST :: root[u] ) - 1;
	int R = BST :: Rank( 0x7f7f7f7f , BST :: root[u] ) - 1 - B;
	return k >= R - B - d;
}
void update( int u , int& k , int d ) {
	while( !judge( u , k , d ) ) ++ k;
	while( judge( u , k - 1 , d ) ) -- k;
}
void work( int rt , int u ) {
	if( col[u] == 0 ) {
		T[rt] = red;
	} else if( col[u] == 1 ) {
		T[rt] = blu;
	} else {
		update( u , T[rt].l , 1 );
		update( u , T[rt].r , -1 );
	}
}
node merge( node a , node b ) {
	node ret;
	ret.l = min( max( b.l , a.l ) , a.r );
	ret.r = min( max( b.r , a.l ) , a.r );
	return ret;
}
void pushup( int rt ) {
	T[rt] = merge( T[rt << 1] , T[rt << 1 | 1] );
}
node query( int rt , int l , int r , int L , int R ) {
	if( l == L && r == R ) return T[rt];
	int m = l + r >> 1;
	if( R <= m ) return query( rt << 1 , l , m , L , R );
	if( L > m ) return query( rt << 1 | 1 , m + 1 , r , L , R );
	return merge( query( rt << 1 , l , m , L , m ) , query( rt << 1 | 1 , m + 1 , r , m + 1 , R ) );
}
void build( int rt , int l , int r ) {
	if( l == r ) {
		int u = bac[l];
		work( rt , u );
		if( u == top[u] && fa[u] )
			BST :: insert( ( rec[u] = ( query( 1 , 1 , n , l , tig[en[u]] ) ).l ) , BST :: root[fa[u]] );
		return;
	}
	int mid = l + r >> 1;
	build( rt << 1 | 1 , mid + 1 , r ) , build( rt << 1 , l , mid );
	pushup( rt );
}
void mdfy( int rt , int l , int r , int p ) {
	if( l == r ) { work( rt , bac[l] ); return; }
	int m = l + r >> 1;
	if( p <= m ) mdfy( rt << 1 , l , m , p );
	else mdfy( rt << 1 | 1 , m + 1 , r , p );
	pushup( rt );
}
void modify( int x , int c ) {
	col[x] = c;
	while( x ) {
		mdfy( 1 , 1 , n , tig[x] );
		x = top[x];
		if( fa[x] != 0 ) {
			BST :: erase( rec[x] , BST :: root[fa[x]] );
			BST :: insert( rec[x] = (query( 1 , 1 , n , tig[x] , tig[en[x]] ).l ) , BST :: root[fa[x]] );
		}
		x = fa[x];
	}
}

int main() {
	BST :: init( );
	cin >> n >> k;
	for( int i = 1 , u , v ; i < n ; ++ i ) {
		scanf("%d%d",&u,&v);
		ade( u , v ) , ade( v , u );
	}
	for( int i = 1 ; i <= n ; ++ i ) scanf("%d",&col[i]);
	dfs( 1 , 1 );
	dfss( 1 , 1 );
	build( 1 , 1 , n );
	int q , opt , v , c; cin >> q;
	while( q-- ) {
		scanf("%d",&opt);
		if( opt == 1 ) {
			scanf("%d",&v);
			printf("%d\n",( query( 1 , 1 , n , tig[v] , tig[en[top[v]]] ).l ) <= -k);
		} else if( opt == 2 ) {
			scanf("%d%d",&v,&c);
			modify( v , c );
		} else {
			scanf("%d",&c);
			k = c;
		}

	}
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200006
int n , k;

#define Update( cur ) if( cur -> left -> size ) cur -> size = cur -> left -> size + cur -> right -> size , cur -> value = cur -> right -> value
#define new_Node( s , v , a , b ) ( & ( * st[ cnt++ ] = Node( s , v , a , b ) ) )
#define Merge( a , b ) new_Node( a -> size + b -> size , b -> value , a , b )
#define ratio 4
namespace BST {
	int cnt , s , a;
	struct Node {
	    int size , value;
	    Node * left , * right;
	    Node( int s , int v , Node * a , Node * b ) : size( s ) , value( v ) , left( a ) , right( b ) {}
	    Node() {}
	} * root[MAXN] , * father , * st[MAXN * 10] , t[MAXN * 10] , * null;

	inline void maintain( register Node * cur ) {
	    if( cur -> left -> size > cur -> right -> size * ratio ) cur -> right = Merge( cur -> left -> right , cur -> right ) , st[ --cnt ] = cur -> left , cur -> left = cur -> left -> left;
	    if( cur -> right -> size > cur -> left -> size * ratio ) cur -> left = Merge( cur -> left , cur -> right -> left ) , st[ --cnt ] = cur -> right , cur -> right = cur -> right -> right;
	}

	int find( int x , Node * cur ) {
	    if( cur -> size == 1 ) return cur -> value;
	    return x > cur -> left -> size ? find( x - cur -> left -> size , cur -> right ) : find( x , cur -> left );
	}

	int Rank( int x , Node * cur ) {
	    if( cur -> size == 1 ) return 1;
	    return x > cur -> left -> value ? Rank( x , cur -> right ) + cur -> left -> size : Rank( x , cur -> left );
	}

	void insert( int x , Node * cur ) {
	    if( cur -> size == 1 ) cur -> left = new_Node( 1 , min( cur -> value , x ) , null , null ) , cur -> right = new_Node( 1 , max( cur -> value , x ) , null , null );
	    else insert( x , x > cur -> left -> value ? cur -> right : cur -> left );
	    Update( cur );
	    maintain( cur );
	}

	void erase( int x , Node * cur ) {
	    if( cur -> size == 1 ) * father = cur == father -> left ? * father -> right : * father -> left;
	    else father = cur , erase( x , x > cur -> left -> value ? cur -> right : cur -> left );
	    Update( cur );
	    maintain( cur );
	}

	void init( ) {
		null = new Node( 0 , 0 , 0 , 0 );
		for( int i = 0 ; i < MAXN * 10 ; ++ i ) st[i] = & t[i] , root[i] = new Node( 1 , 0x3f3f3f3f , null , null );
	}

}

int head[MAXN] , nex[MAXN << 1] , to[MAXN << 1] , ecn = 0;
void ade( int u , int v ) {
	nex[++ecn] = head[u] , to[ecn] = v , head[u] = ecn;
}
int fa[MAXN] , siz[MAXN] , hea[MAXN] , dep[MAXN] , top[MAXN] , tig[MAXN] , bac[MAXN] , en[MAXN] , clo;
void dfs( int u , int faa ) {
	siz[u] = 1 , dep[u] = dep[faa] + 1;
	for( int i = head[u] ; i ; i = nex[i] ) {
		int v = to[i];
		if( v == faa ) continue;
		fa[v] = u;
		dfs( v , u );
		siz[u] += siz[v];
		if( !hea[u] || siz[v] > siz[hea[u]] ) hea[u] = v;
	}
}
void dfss( int u , int too ) {
	tig[u] = ++ clo , bac[clo] = u , en[too] = u , top[u] = too;
	if( !hea[u] ) return;
	dfss( hea[u] , too );
	for( int i = head[u] ; i ; i = nex[i] ) {
		int v = to[i];
		if( v == fa[u] || v == hea[u] ) continue;
		dfss( v , v );
	}
}

int col[MAXN];

struct node{
	int l , r;
	node( int L = 0 , int R = 0 ) : l(L) , r(R) { }
} T[MAXN << 2] , red( 0x3f3f3f3f , 0x3f3f3f3f ) , blu( -0x3f3f3f3f , -0x3f3f3f3f ) ;
int rec[MAXN];
// T[rt].l : if rt's heavy son is red , the value k to satisfy that this node is red
// T[rt].r : if rt's heavy son is blu , the value k to satisfy that this node is red
// b : 0 , r : 1
bool judge( int u , int k , int d ) {
	// return we add d red nodes to its son if the node is red.
	int B = BST :: Rank( k + 1 , BST :: root[u] ) - 1;
	int R = BST :: Rank( 0x7f7f7f7f , BST :: root[u] ) - 1 - B;
	return k >= R - B - d;
}
void update( int u , int& k , int d ) {
	while( !judge( u , k , d ) ) ++ k;
	while( judge( u , k - 1 , d ) ) -- k;
}
void work( int rt , int u ) {
	if( col[u] == 0 ) {
		T[rt] = red;
	} else if( col[u] == 1 ) {
		T[rt] = blu;
	} else {
		update( u , T[rt].l , 1 );
		update( u , T[rt].r , -1 );
	}
}
node merge( node a , node b ) {
	node ret;
	ret.l = min( max( b.l , a.l ) , a.r );
	ret.r = min( max( b.r , a.l ) , a.r );
	return ret;
}
void pushup( int rt ) {
	T[rt] = merge( T[rt << 1] , T[rt << 1 | 1] );
}
node query( int rt , int l , int r , int L , int R ) {
	if( l == L && r == R ) return T[rt];
	int m = l + r >> 1;
	if( R <= m ) return query( rt << 1 , l , m , L , R );
	if( L > m ) return query( rt << 1 | 1 , m + 1 , r , L , R );
	return merge( query( rt << 1 , l , m , L , m ) , query( rt << 1 | 1 , m + 1 , r , m + 1 , R ) );
}
void build( int rt , int l , int r ) {
	if( l == r ) {
		int u = bac[l];
		work( rt , u );
		if( u == top[u] && fa[u] )
			BST :: insert( ( rec[u] = ( query( 1 , 1 , n , l , tig[en[u]] ) ).l ) , BST :: root[fa[u]] );
		return;
	}
	int mid = l + r >> 1;
	build( rt << 1 | 1 , mid + 1 , r ) , build( rt << 1 , l , mid );
	pushup( rt );
}
void mdfy( int rt , int l , int r , int p ) {
	if( l == r ) { work( rt , bac[l] ); return; }
	int m = l + r >> 1;
	if( p <= m ) mdfy( rt << 1 , l , m , p );
	else mdfy( rt << 1 | 1 , m + 1 , r , p );
	pushup( rt );
}
void modify( int x , int c ) {
	col[x] = c;
	while( x ) {
		mdfy( 1 , 1 , n , tig[x] );
		x = top[x];
		if( fa[x] != 0 ) {
			BST :: erase( rec[x] , BST :: root[fa[x]] );
			BST :: insert( rec[x] = (query( 1 , 1 , n , tig[x] , tig[en[x]] ).l ) , BST :: root[fa[x]] );
		}
		x = fa[x];
	}
}

int main() {
	BST :: init( );
	cin >> n >> k;
	for( int i = 1 , u , v ; i < n ; ++ i ) {
		scanf("%d%d",&u,&v);
		ade( u , v ) , ade( v , u );
	}
	for( int i = 1 ; i <= n ; ++ i ) scanf("%d",&col[i]);
	dfs( 1 , 1 );
	dfss( 1 , 1 );
	build( 1 , 1 , n );
	int q , opt , v , c; cin >> q;
	while( q-- ) {
		scanf("%d",&opt);
		if( opt == 1 ) {
			scanf("%d",&v);
			printf("%d\n",( query( 1 , 1 , n , tig[v] , tig[en[top[v]]] ).l ) <= -k);
		} else if( opt == 2 ) {
			scanf("%d%d",&v,&c);
			modify( v , c );
		} else {
			scanf("%d",&c);
			k = c;
		}

	}
}


#include<bits/stdc++.h>
using namespace std;
constexpr int maxn = 100000;
constexpr int SB = 320;
vector<int> G[maxn + 1];
int c[maxn + 1];
int query[maxn][3];
vector<int> dfp;
int key[maxn + 1], kv[maxn + 1], kv2[maxn + 1][2];
vector<int> kidv[maxn + 1];
int par[maxn + 1];
int park[maxn + 1];
vector<int> kidk[maxn + 1];
pair<int, int> path[maxn + 1];
void DFS(int u){
    for(int v : G[u]) if(v != par[u]){
        par[v] = u;
        DFS(v);
    }
    dfp.push_back(u);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    for(int i = 1, u, v; i < n; i += 1){
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i = 1; i <= n; i += 1) cin >> c[i];
    int q;
    cin >> q;
    for(int i = 0; i < q; i += 1){
        cin >> query[i][0] >> query[i][1];
        if(query[i][0] == 2) cin >>  query[i][2];
    }
    DFS(1);
    for(int L = 0; L < q; L += SB){
        vector<int> key_node;
        int R = min(q, L + SB), root = 1;
        for(int u : dfp){
            key[u] = 0;
            kidv[u].clear();
            kidk[u].clear();
        }
        for(int j = L; j < R; j += 1)
            if(query[j][0] != 3) key[query[j][1]] = 2;
        for(int u : dfp) if(key[u] >= 2){
            key[par[u]] += 1;
            root = u;
            key_node.push_back(u);
        }
        for(int u : dfp) if(not key[u]){
            if(~c[u]) kv[u] = c[u] ? n + 1 : -n;
            else{
                int L = -n, R = n;
                while(L < R){
                    int M = (L + R - ((L + R) & 1)) / 2;
                    int b = 0, r = 0;
                    for(int x : kidv[u]) (M < x ? b : r) += 1;
                    if(b - r >= M) L = M + 1;
                    else R = M;
                }
                kv[u] = L;
            }
            kidv[par[u]].push_back(kv[u]);
        }
        for(int u : dfp) if(key[u] >= 2){
            path[u] = {-n, n + 1};
            sort(kidv[u].begin(), kidv[u].end());
            if(u == root) continue;
            int p = u;
            while(key[par[p]] < 2){
                if(par[p] == 0) cout << u << " " << p << endl;
                int L = -n, R = n;
                while(L < R){
                    int M = (L + R - ((L + R) & 1)) / 2;
                    int r = upper_bound(kidv[u].begin(), kidv[u].end(), M) - kidv[u].begin();
                    int b = kidv[u].size() - r;
                    (M < path[u].first ? b : r) += 1;
                    if(b - r >= M) L = M + 1;
                    else R = M;
                }
                path[u].first = L;
                L = -n, R = n;
                while(L < R){
                    int M = (L + R - ((L + R) & 1)) / 2;
                    int r = upper_bound(kidv[u].begin(), kidv[u].end(), M) - kidv[u].begin();
                    int b = kidv[u].size() - r;
                    (M < path[u].second ? b : r) += 1;
                    if(b - r >= M) L = M + 1;
                    else R = M;
                }
                path[u].second = L;
                p = par[p];
            }
            park[u] = par[p];
            kidk[par[p]].push_back(u);
            //cout << u << " " << park[u] << " " << path[u].first << " " << path[u].second << endl;
        }
        auto rebuild = [&](){
            for(int u : key_node)
                if(~c[u]) kv[u] = c[u] ? n + 1 : -n;
                else{
                    int L = -n, R = n;
                    while(L < R){
                        int M = (L + R - ((L + R) & 1)) / 2;
                        int r = upper_bound(kidv[u].begin(), kidv[u].end(), M) - kidv[u].begin();
                        int b = kidv[u].size() - r;
                        for(int v : kidk[u])
                            (M < (M >= kv[v] ? path[v].first : path[v].second) ? b : r) += 1;
                        if(b - r >= M) L = M + 1;
                        else R = M;
                    }
                    kv[u] = L;
                }
            if(0)for(int u : key_node)
                cout << "kv[" << u << "] = " << kv[u] << endl;
        };
        rebuild();
        for(int i = L; i < R; i += 1)
            if(query[i][0] == 3) k = query[i][1];
            else if(query[i][0] == 1)
                cout << (~c[query[i][1]] ? c[query[i][1]] : k < kv[query[i][1]]) << "\n";
            else{
                c[query[i][1]] = query[i][2];
                rebuild();
            }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ri register int
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read(){
	int ans=0;
	char ch=gc();
	bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return f?ans:-ans;
}
typedef pair<int,int> pii;
const int N=3e5+5;
int rt[N],n;
inline int rnd(){return rand()|(rand()<<15);}
namespace bst{
	#define lc (son[p][1])
	#define rc (son[p][0])
	int son[N][2],siz[N],vl[N],rd[N],sz[N];
	int stk[N],top=0,tot=0;
	inline void init(){
		tot=n;
		for(ri i=1;i<=n;++i)rt[i]=i;
	}
	inline int newidx(){return top?stk[top--]:++tot;}
	inline int newnode(int v){
		int p=newidx();
		lc=rc=0,siz[p]=sz[p]=1,vl[p]=v,rd[p]=rnd();
		return p;
	}
	inline int pushup(int p){siz[p]=siz[lc]+sz[p]+siz[rc];}
	inline int merge(int a,int b){
		if(!a||!b)return a|b;
		if(rd[a]<rd[b])return son[a][1]=merge(son[a][1],b),pushup(a),a;
		return son[b][0]=merge(a,son[b][0]),pushup(b),b;
	}
	inline pii split(int p,int k){
		if(!p)return pii(0,0);
		pii res;
		if(siz[lc]>=k)return res=split(lc,k),lc=res.se,pushup(p),pii(res.fi,p);
		return res=split(rc,k-siz[lc]-1),rc=res.fi,pushup(p),pii(p,res.se);
	}
	inline int rank(int p,int v){
		if(!p)return 0;
		if(vl[p]>v)return rank(lc,v);
		return siz[lc]+sz[p]+rank(rc,v);
	}
	inline void insert(int&rt,int v){
		int rk=rank(rt,v);
		pii x=split(rt,rk);
		rt=merge(merge(x.fi,newnode(v)),x.se);
	}
	inline void delet(int&rt,int v){
		int rk=rank(rt,v);
		pii x=split(rt,rk-1),y=split(x.se,1);
		rt=merge(x.fi,y.se),y.fi&&(stk[++top]=y.fi);
	}
	#undef lc
	#undef rc
}
struct F{
	int l,r;
	F(int l=0,int r=0):l(l),r(r){}
	friend inline F operator+(F a,F b){return F(min(max(a.l,b.l),a.r),min(max(a.l,b.r),a.r));}
};
const int inf=1e9;
int K,tg[N];
int siz[N],hson[N],dep[N],top[N],fa[N],num[N],pred[N],bot[N],col[N],tot=0;
vector<int>e[N];
void dfs1(int p){
	siz[p]=1;
	for(ri i=0,v;i<e[p].size();++i){
		if((v=e[p][i])==fa[p])continue;
		fa[v]=p,dep[v]=dep[p]+1,dfs1(v),siz[p]+=siz[v];
		if(siz[v]>siz[hson[p]])hson[p]=v;
	}
}
void dfs2(int p,int tp){
	top[p]=tp,bot[tp]=p,pred[num[p]=++tot]=p;
	if(!hson[p])return;
	dfs2(hson[p],tp);
	for(ri i=0,v;i<e[p].size();++i)if((v=e[p][i])!=fa[p]&&v!=hson[p])dfs2(v,v);
}
namespace sgt{
	#define lc (p<<1)
	#define rc (p<<1|1)
	#define mid (l+r>>1)
	F vl[N<<2];
	inline void pushup(int p){vl[p]=vl[lc]+vl[rc];}
	inline F query(int p,int l,int r,int ql,int qr){
		if(ql<=l&&r<=qr)return vl[p];
		if(qr<=mid)return query(lc,l,mid,ql,qr);
		if(ql>mid)return query(rc,mid+1,r,ql,qr);
		return query(lc,l,mid,ql,qr)+query(rc,mid+1,r,ql,qr);
	}
	inline bool check(int p,int k,int dt){
		int R=bst::rank(rt[p],k)+dt,B=bst::siz[rt[p]]+1-R;
		return B-R<k;
	}
	inline void fix(int p,int&k,int dt){
		while(check(p,k-1,dt))--k;
		while(!check(p,k,dt))++k;
	}
	inline void getval(int p,int k){
		if(col[k]==1)vl[p]=F(inf,inf);
		else if(!col[k])vl[p]=F(-inf,-inf);
		else{
			fix(k,vl[p].l,1);
			fix(k,vl[p].r,0);
		}
	}
	inline void build(int p,int l,int r){
		if(l==r){
			int k=pred[l];
			getval(p,k);
			if(k==top[k]&&fa[k]){
				if(bot[k]==k)bst::insert(rt[fa[k]],tg[k]=vl[p].l);
				else bst::insert(rt[fa[k]],tg[k]=(vl[p]+query(1,1,n,l+1,num[bot[k]])).l);
			}
			return;
		}
		build(rc,mid+1,r),build(lc,l,mid);
		pushup(p);
	}
	inline void update(int p,int l,int r,int k){
		if(l==r)return getval(p,pred[l]);
		k<=mid?update(lc,l,mid,k):update(rc,mid+1,r,k);
		pushup(p);
	}
	#undef mid
	#undef lc
	#undef rc
}
inline void change(int p){
	int tp,ftp;
	while(p){
		tp=top[p],ftp=fa[top[p]];
		sgt::update(1,1,n,num[p]);
		if(ftp){
			bst::delet(rt[ftp],tg[tp]);
			bst::insert(rt[ftp],tg[tp]=sgt::query(1,1,n,num[tp],num[bot[tp]]).l);
		}
		p=ftp;
	}
}
int main(){
	srand(time(NULL));
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read(),K=read();
	init();
	for(ri i=1,u,v;i<n;++i){
		u=read(),v=read();
		e[u].pb(v),e[v].pb(u);
	}
	for(ri i=1;i<=n;++i)col[i]=read();
	dfs1(1),dfs2(1,1);
	sgt::build(1,1,n);
	for(ri op,x,tt=read();tt;--tt){
		op=read();
		switch(op){
			case 1:{x=read(),cout<<(sgt::query(1,1,n,num[x],num[bot[top[x]]]).l>K)<<'\n';break;}
			case 2:{x=read(),col[x]=read(),change(x);break;}
			case 3:{K=read();break;}
		}
	}
	return 0;
}


#pragma comment(linker, "/STACK:16777216")

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <climits>
#include <cctype>
#include <cmath>
#include <cassert>
#include <ctime>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

using namespace std;

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }

typedef long long ll;

#define eps 1e-10
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL

#define fr(x,y,z) for(int(x)=(y);(x)<(z);(x)++)
#define cast(x,t) *({stringstream ss;static t __ret;ss<<x,ss>>__ret;&__ret;})

#define dbg(x) cout << #x << " == " << x << endl
#define print(x) cout << x << endl

// var
int a[20], b[20], c[20], n;

int ok(int num) {
	map<int,int> m;
	for(int i = 0; i < 4; i++) {
		m[num%10]++;
		num /= 10;
	}
	return m.size() == 4;
}

int eq(int a, int b) {
	int res = 0;
	for(int i = 0; i < 4; i++) {
		res += (a%10) == (b%10);
		a /= 10, b /= 10;
	}
	return res;
}

int ta[10];

int dif(int a, int b) {
	int ap[10] = { 0 }, res = 0;
	for(int i = 0; i < 4; i++) {
		ap[a%10] = 1;
		ta[i] = a%10;
		a /= 10;
	}
	for(int i = 0; i < 4; i++) {
		if(ta[i] != b%10) { res += ap[b%10]; }
		b /= 10;
	}
	return res;
}

int verif(int num) {
	for(int i = 0; i < n; i++) {
		int bull = eq(num, a[i]);
		int cows = dif(num, a[i]);
		if(bull != b[i] || cows != c[i]) {
			return 0;
		}
	}
	return 1;
}

int main() {

	scanf("%d",&n);
	fr(i,0,n) scanf("%d %d %d",a+i,b+i,c+i);

	// solve
	vector<int> res;
	for(int i = 0; i < 10000; i++) if(ok(i) && verif(i)) res.push_back(i);

	if(!res.size()) print("Incorrect data");
	else if(res.size() == 1) printf("%04d\n"res[0]);
	else print("Need more data");

	return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>

using namespace std;
int n, x[10], y[10], the[4];
string s[10];
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
#endif
	scanf ("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf ("\n");
		getline (cin, s[i]);
		scanf (" %d %d", &x[i], &y[i]);
	}
	for (int j = 123; j <= 9876; j++)
	{
		a[3] = j % 10;
		a[2] = (j / 10) % 10;
		a[1] = (j / 100) % 10;
		a[0] = (j / 1000) % 10;
		if (j < 1000) a[0] = 0;
		if (a[0] == a[1] || a[0] == a[2] || a[0] == a[3]) {used[j] = 1; continue;}
		if (a[1] == a[2] || a[1] == a[3]) {used[j] = 1; continue;}
		if (a[2] == a[3]) {used[j] = 1; continue;}
		for (int q = 0; q < n; q++)
		{
			for (int i = 0; i < 4; i++)
			{
				if (a[i] == s[q][i] - '0') bull++;
				for (int j = 0; j < 4; j++)
				{
					if (j != i && a[i] == s[q][j]) cow++;
				}
			}
			if (cow == y[q] && bull == x[q]) continue;
			else {used[j] = 1; break;}
		}
	}
	for (int j = 123; j <= 9876; j++)
	{
		if (! used[j]) ans++, ansx = j;
	}
	if (ans < 1) {printf ("Incorrect data"); exit (0);}
	if (ans > 1)
	{
		printf ("Need more data");
		exit (0);
	}
	if (ansx < 1000) printf ("0");
	printf ("%d", ansx)
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int OO = (int) 1e9+7;
//const long long OO = (long long) 1e18+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define PI acos(-1.0)
#define vec(a,b)                ((b)-(a))
#define length(a)               (hypot((a).imag(), (a).real()))
#define EPS 1e-9

#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define ff first
#define ss second
typedef vector<int> vi ;
typedef   long long ll;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

using namespace std;
ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m

struct data{
    string number ;
    int correct , position;
};
vector<data> asks;

pii reask(string mine , string tst){
    map<char,int> cnt;
    int correct = 0,position = 0;
    for(char ch: mine) ++cnt[ch];

    lp(i,0,4) if(mine[i]==tst[i]) {++correct; --cnt[ mine[i] ]; }

    for(char ch : tst) {
        if(cnt[ch]){
            ++position;
            --cnt[ch];
        }
    }
    return {correct,position};
}

int main()
{
    ios::sync_with_stdio(0);
   cin.tie(0);
  //   freopen( "output.txt" , "w" , stdout ) ;
  //  freopen( "input.txt" , "r" , stdin ) ;

    int n;
    cin >> n;
    asks.resize(n);
    lp(i,0,n) cin>>asks[i].number >> asks[i].correct >> asks[i].position;
    string ans ="";
    int cnt = 0;

    lp(i,0,10){
        lp(j,0,10){
            if(j==i) continue;
            lp(k,0,10){
                if(k==j || k == i) continue;
                lp(l,0,10){
                    if(l==k||l==j||l==i) continue;

                    string nm ="";
                    nm += '0'+i;
                    nm += '0'+j;
                    nm += '0'+k;
                    nm += '0'+l;
                    bool ok = 1;
                    lp(m,0,n){
                        pii p = reask(nm,asks[m].number);
                        if( p.ff != asks[m].correct || p.ss != asks[m].position ) ok = 0;

                    }
                    if(ok){
                        ++cnt;
                        ans = nm;
                    }

                }

            }

        }
    }

    if(!cnt){

        cout<<"Incorrect data";
    }
    else if(cnt>1){
        cout<<"Need more data";
    }
    else cout << ans;

    return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

typedef long long int int64;

int guess[20][3];

int n;
int res = 0;
bool erro;
bool used[10];

bool calcula(int x) {
	int a, b;
	int anterior[10];
	bool tem[10];
	for (int i = 0; i < n; i++) {
		a = x;
		b = guess[i][0];
		int bull = 0, cow = 0;
		int k = 0;
		memset(tem, false, sizeof(tem));
		for (int j = 0; j < 4; j++) {
			if (a % 10 == b % 10) bull++;
			else {
				anterior[k++] = a % 10;
			}
			tem[b % 10] = true;
			a = a / 10;
			b = b / 10;
		}
		for (int l = 0; l < k; l++) {
			if (tem[anterior[l]]) cow++;
		}
		if (bull != guess[i][1] || cow != guess[i][2]) return false;
	}
	return true;
}

bool rec(int x, int numero) {
	if (x == 4) {
		if (calcula(numero)) {
			if (res == 0) {
				res = numero;
				erro = false;
				return false;
			}
			else {
				erro = true;
				return true;
			}
		}
		return false;
	}
	for (int i = 0; i <= 9; i++) {
		if (!used[i]) {
			used[i] = true;
			if (rec(x+1, numero * 10 + i)) return true;
			used[i] = false;
		}
	}
	return false;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &guess[i][0], &guess[i][1], &guess[i][2]);
	}
	memset(used, 0, sizeof(used));
	erro = true;
	res = 0;
	rec(0, 0);
	if (!erro) {
		printf("%d\n", res);
	}
	else {
		if (res != 0)
			printf("Need more data\n");
		else
			printf("Incorrect data\n");
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
ll n,x,y,m;
ll cul(ll p)
{
	if(p<=0) return 0;
	return (p+1)*p/2;
}
int judge(ll p)
{
	ll a=x-1,b=y-1,c=n-x,d=n-y;
	ll ans=min(p,a)+min(p,b)+min(p,c)+min(p,d)+1;
	p--;
	ans+=cul(p)*4-2*cul(p-a)-2*cul(p-b)-2*cul(p-c)-2*cul(p-d);
	ans+=cul(p-a-b)+cul(p-b-c)+cul(p-c-d)+cul(p-d-a);
	return ans>=m;
}
int main()
{
	scanf("%lld%lld%lld%lld",&n,&x,&y,&m);
	ll l=0,r=1e9,ans=0;
	while(l<=r)
	{
		ll mid=(r+l)>>1;
		if(judge(mid))
		{
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;


#include <iostream>
#include <cstdio>

using namespace std;

int main(){
int N,x,y,c;
scanf("%d %d %d %d",&N,&y,&x,&c);
int limx0=x-1,limx1=N-x;
int limy0=y-1,limy1=N-y;
int count,i,tope;
if(c==1){
    puts("0");
    return 0;
}
for (i = 1; i < N*N; i*=2){

count = 1;int pos = 0;
    for (int j = i; j >=0; j--,pos++)
    {
        if(pos>limx1 && pos>=x){
            break;
        }
        if(pos==0){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
        }
        else {
        if(pos<=limx1){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
            count++;
        }
        if(pos<x){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
            count++;
        }
    }
    }
    if(count>=c)break;
}
if(i>N*N)i=N*N;
//debugear con salto
tope=i;
int minimo;
for (; i < N*N; i*=0,75){
count = 1;int pos = 0;
    for (int j = i; j >=0; j--,pos++){
        if(pos>limx1 && pos>=x){
            break;
        }
        if(pos==0){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
        }
        else {
        if(pos<=limx1){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
            count++;
        }
        if(pos<x){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
            count++;
        }
    }
    }
    if(count<c)break;
}
minimo=i;
for (; i < tope; i++){
count = 1;int pos = 0;
    for (int j = i; j >=0; j--,pos++){
        if(pos>limx1 && pos>=x){
            break;
        }
        if(pos==0){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
        }
        else {
        if(pos<=limx1){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
            count++;
        }
        if(pos<x){
            if(j>limy0)count+=limy0;
            else count+=j;
            if(j>limy1)count+=limy1;
            else count+=j;
            count++;
        }
    }
    }
    if(count>=c)break;
}
printf("%d",i);
puts("");
    ret


#include <stdio.h>
#include <algorithm>

typedef long long int64;
int n, x, y, happy_value;

void read() {
  scanf("%d%d%d%d", &n, &x, &y, &happy_value);
}

int64 calcTriangle(int height, int width) {
  return height * (int64)(width - height + 1) >> 1;
}

int64 calcCornerON(int row, int column, int step) {
  int dx = std::min(row, step);
  int64 S = calcTriangle(dx, step);
  if (column < step) {
    dx = std:min(dx, step - column + 1);
    S -= calcTriangle(dx, step) - dx * (int64)column;
  }
  return S;
}

int64 calcON(int step) {
  int64 ans = 0;
  int dx[2] = {x, n - x + 1};
  int dy[2] = {y, n - y + 1};
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      ans += calcCornerON(dx[i], dy[j], step);
    }
  }
  for (int i = 0; i < 2; ++i) {
    ans -= std::min(step, dx[i]);
    ans -= std::min(step, dy[i]);
  }
  ans += 1;
  return ans;
}

void go() {
  int min_step = 1, max_step = n * 2 ;
  int mid_step;
  while (min_step < max_step) {
    mid_step = (min_step >> 1) + (max_step >> 1) + (min_step & max_step & 1);
    if (calcON(mid_step) >= happy_value) [
      max_step = mid_step;
    } else {
      min_step = mid_step + 1;
    }
  }
  printf("%d\n", min_step - 1);
}

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


#include <iostream>
#include <algorithm>
using namespace std;
long long n,x,y,c;

long long getnum(long long steps)
{
    long long xn,xx,yn,yx,mnn,mnx,mxx,mxn,res=steps*(steps+1)*2+1;
    xn=max(0,steps-x+1);xx=max(0,steps-n+x);
    yn=max(0,steps-y+1);yx=max(0,steps-n+y);
    res-=max(0,xn*xn);res-=max(0,xx*xx);
    res-=max(0,yn*yn);res-=max(0,yx*yx);
    mnn=max(0,steps-x-y+1);mnx=max(0,steps-x-(n-y+1)+1);
    mxx=max(0,steps-(n-x+1)-(n-y+1)+1);mxn=max(0,steps-(n-x+1)-y+1);
    res+=max(0,mnn*(mnn+1)/2);
    res+=max(0,mnx*(mnx+1)/2);
    res+=max(0,mxx*(mxx+1)/2);
    res+=max(0,mxn*(mxn+1)/2);
    return res;
}

int main()
{
    cin>>n>>x>>y>>c;
    long long left,mid,right;
    left=0;right=n*2;
    while(left<=right){
        mid=(left+right)/2;
        if(getnum(mid)<c)left=mid+1;else right=mid-1;
    }
    cout<<left;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define MOD 1000000007

string s;

vector< vector<int> > GetMatrix(string t){
  int n = s.size();
  vector< vector<int> > A(2 * (n + 1), vector<int>(2 * (n + 1), 0));

  for(int i = 0; i < 2 * n + 2; ++i)
    A[i][i] = 1;

  for(int i = 0; i <= n; ++i){
    string x = string(s, 0, i) + t;
    int j = x.size();
    for( ; j > 0; --j){
      string y = string(s, 0, j);
      string z = string(x, x.size() - j, j);
      if(y.compare(z) == 0)
        break;
    }
    A[2 * j][2 * i] += 1;
    A[2 * j + 1][2 * i + 1] += 1;
    A[2 * j + 1][2 * i] += (j == n);
  }

  return A;
}

void MatrixMultiplication(vector< vector<int> >& A, vector< vector<int> >& B, vector< vector<int> >& C){
  for(int i = 0, n = A.size(); i < n; ++i){
    for(int j = 0; j < n; ++j){
      int val = 0;
      for(int k = 0; k < n; ++k){
        if(A[i][k] == 0 || B[k][j] == 0)
          continue;
        val = (val + 1ll * A[i][k] * B[k][j]) % MOD;
      }
      C[i][j] = val;
    }
  }
}

int main(){
  int n, k;

  cin >> n >> k >> s;
  reverse(s.begin(), s.end());

  vector< vector<int> > A = GetMatrix("0"), B = GetMatrix("1"), C(2 * (n + 1), vector<int>(2 * (n + 1), 0)), D;

  for(int i = 2; i <= k; ++i){
    if(i % 3 == 0)
      MatrixMultiplication(C, B, A);
    else if(i % 3 == 1)
      MatrixMultiplication(A, C, B);
    else
      MatrixMultiplication(B, A, C);
  }

  if(k % 3 == 0)
    D = A;
  else if(k % 3 == 1)
    D = B;
  else
    D = C;

  int ans = 0;
  for(int i = 1, m = D.size(); i < m; i += 2)
    ans = (ans + D[i][0]) % MOD;

  cout << ans << '\n';

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define MOD 1000000007

string s;

vector< vector<int> > GetMatrix(string t){
  int n = s.size();
  vector< vector<int> > A(2 * (n + 1), vector<int>(2 * (n + 1), 0));

  for(int i = 0; i < 2 * n + 2; ++i)
    A[i][i] = 1;

  for(int i = 0; i <= n; ++i){
    string x = string(s, 0, i) + t;
    int j = x.size();
    for( ; j > 0; --j){
      string y = string(s, 0, j);
      string z = string(x, x.size() - j, j);
      if(y.compare(z) == 0)
        break;
    }
    A[2 * j][2 * i] += 1;
    A[2 * j + 1][2 * i + 1] += 1;
    A[2 * j + 1][2 * i] += (j == n);
  }

  return A;
}

void MatrixMultiplication(vector< vector<int> >& A, vector< vector<int> >& B, vector< vector<int> >& C){
  for(int i = 0, n = A.size(); i < n; ++i){
    for(int j = 0; j < n; ++j){
      int val = 0;
      for(int k = 0; k < n; ++k)
        val = (val + 1ll * A[i][k] * B[k][j]) % MOD;
      C[i][j] = val;
    }
  }
}

int main(){
  int n, k;

  cin >> n >> k >> s;
  reverse(s.begin(), s.end());

  vector< vector<int> > A = GetMatrix("0"), B = GetMatrix("1"), C(2 * (n + 1), vector<int>(2 * (n + 1), 0)), D;

  for(int i = 2; i <= k; ++i){
    if(i % 3 == 0)
      MatrixMultiplication(C, B, A);
    else if(i % 3 == 1)
      MatrixMultiplication(A, C, B);
    else
      MatrixMultiplication(B, A, C);
  }

  if(k % 3 == 0)
    D = A;
  else if(k % 3 == 1)
    D = B;
  else
    D = C;

  int ans = 0;
  for(int i = 1, m = D.size(); i < m; i += 2)
    ans = (ans + D[i][0]) % MOD;

  cout << ans << '\n';

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define I insert

ll N=1e9+7;

ll power(ll a, ll b, ll mod){
	ll x = 1, y = a;
	while (b > 0){
		if (b%2){
			x = (x*y)%mod;
		}
		y = (y*y)%mod;
		b /= 2;
	}
	return x%mod;
}

map<string ,ll > M;ll fib[105];
void mpas(string s){
    ll a,b,c;string y;
    a=s.length();
    ll j=1;ll i,k;k=1;
    for(i=0;i<a;i++){
        for(j=i;j<a;j++){
            y=s.substr(i,j-i+1);
            if(M.count(y))continue;
            M[y]=k++;
        }
    }
}
ll dp[105][10005];
ll st[105][10005],en[105][10005];ll ns[105][10005];
//ll two[105];
ll nos(ll a,string s ){
	ll b,c,d,i,j,k,n,x;
    string p,q,r;
    b=M[s];if(ns[a][b]!=-1)return ns[a][b];
    d=0;d+=(nos(a-1,s)+nos(a-2,s))%N;c=s.size();
    for(i=1;i<=c-1;i++){
    	p=s.substr(0,i);q=s.substr(i,c-i);
    	d+=(nos(a-1,p)*nos(a-2,q))%N;d%=N;
    }
    return ns[a][b]=d;
}
ll sta(ll a,string s){
    ll b,c,d,i,j,k,n,x;
    string p,q,r;
    b=M[s];if(st[a][b]!=-1)return st[a][b];
    d=0;d+=(sta(a-1,s)*(power(2,fib[a-2],N)))%N;d%=N;c=s.size();d+=sta(a-2,s);d%=N;
    for(i=1;i<=c-1;i++){
    	p=s.substr(0,i);q=s.substr(i,c-i);
    	d+=(nos(a-1,p)*sta(a-2,q))%N;d%=N;
    }
    return st[a][b]=d;
}
ll end1(ll a,string s){
    ll b,c,d,i,j,k,n,x;
    string p,q,r;
    b=M[s];if(en[a][b]!=-1)return en[a][b];
    d=0;d+=(end1(a-2,s)*(power(2,fib[a-1],N)))%N;c=s.size();d%=N;d+=end1(a-1,s);d%=N;
    for(i=1;i<=c-1;i++){
    	p=s.substr(0,i);q=s.substr(i,c-i);
    	d+=(end1(a-1,p)*nos(a-2,q))%N;d%=N;
    }
    return en[a][b]=d;
}
ll fn(ll a,string s ){
   // cout<<a<<" "<<s<<"\n";
    ll b,c,d,i,j,k,n,x;
    string p,q,r;
    b=M[s];if(dp[a][b]!=-1)return dp[a][b];
    ll ans=0;ans+=((fn(a-1,s)*(power(2,fib[a-2],N)))%N+(fn(a-2,s)*(power(2,fib[a-1],N)))%N)%N;ans%=N;
    c=s.size();
    for(i=1;i<=c-1;i++){
        p=s.substr(0,i);q=s.substr(i,c-i);
        ans+=(end1(a-1,p)*sta(a-2,q))%N;ans%=N;
    }
    return dp[a][b]=ans;
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cout<<setprecision(25);
    ll a,b,c,d,i,j,k,n,x;
    string p,q,r,s;
    fib[0]=fib[1]=1;for(i=2;i<=100;i++)fib[i]=(fib[i-1]+fib[i-2])%(N-1);
    //a=1;for(i=1;i<=100;i++){a*=2;a%=M;two[i]=a;}two[0]=1;
    cin>>n>>x>>s;
    mpas(s);//map<string ,ll> :: iterator it;for(it=M.begin();it!=M.end();it++)cout<<(*it).F<<"-"<<(*it).S<<" ";
    for(i=0;i<105;i++)for(j=0;j<10005;j++)dp[i][j]=-1,st[i][j]=-1,en[i][j]=-1,ns[i][j]=-1;
    for(i=0;i<10005;i++)dp[0][i]=dp[1][i]=st[0][i]=en[1][i]=st[1][i]=en[0][i]=0,ns[0][i]=ns[1][i]=0;
    if(M.count("0"))dp[0][M["0"]]=1,st[0][M["0"]]=1,en[0][M["0"]]=1,ns[0][M["0"]]=1;if(M.count("1"))dp[1][M["1"]]=1,st[1][M["1"]]=1,en[1][M["1"]]=1,ns[1][M["1"]]=1;
//    cout<<x<<"\n";
    cout<<fn(x,s)<<"\n";
    //for(i=0;i<=4;i++){for(j=1;j<=5;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
    //cout<<end1(2,"1");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<unsigned> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<unsigned, unsigned> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef vector<string> vs;
#define pb push_back
#define ppb pop_back
#define be begin
#define all(x) (x).be(), (x).end()
#define fst first
#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
static inline 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 == 0 ? a : gcd(b, a%b);}
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;
}

#define MOD 1000000007
#define mul(a, b) (ull(a)*(b)%MOD)
#define add(a, b) ((a)+(b) >= MOD ? (a)+(b)-MOD : (a)+(b))
#define sub(a, b) ((a) < (b) ? (a)+MOD-(b) : (a)-(b))

unsigned modinv(unsigned n)
{
    unsigned y0 = 0, y1 = 1, a = MOD;
    while (n) {
        unsigned q = a/n;
        a %= n;
        swap(a, n);
        y0 = sub(y0, mul(q, y1));
        swap(y0, y1);
    }
    return y0;
}

unsigned modpow(unsigned b, unsigned e)
{
    unsigned r = 1;
    while (e) {
        if (e&1) r = mul(r, b);
        b = mul(b, b);
        e >>= 1;
    }
    return r;
}

void matmul(const unsigned a[][128], const unsigned b[][128], unsigned c[][128], int n)
{
    for (int i = 0; i < n; ++i) {
        for (int k = 0; k < n; ++k) {
            for (int j = 0; j < n; ++j) c[i][j] = add(c[i][j], mul(a[i][k], b[k][j]));
        }
    }
}

int main()
{
    canhazfast();

    static unsigned dp[101][101][101];
    static char s[128];
    int n, x;

    cin >> n >> x >> s;
    dp[0][0][0] = dp[0][n][n] = dp[1][0][0] = dp[1][n][n] = 2; /// wtf?!
    for (int i = 1; i < n; ++i) dp[0][i][i] = dp[1][i][i] = 1;
    for (int i = 0; i < n; ++i) dp[s[i]-'0'][i][i+1] = 1;
    for (int i = 2; i <= x; ++i) matmul(dp[i-1], dp[i-2], dp[i], n+1);
    cout << dp[x][0][n] << '\n';

    return 0;
}


#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
# define M_PI           3.14159265358979323846  /* pi */
// #define for(i,a,b) for(ll i=a;i<b;i++)
// #define rep(i,n) f(i,0,n)

using namespace std;
ll n,m,k; // number of nodes
vector<vector<ll>> adj(100000); // adjacency list of graph

vector<bool> visited;
vector<ll> tin, fup;
ll timer;
set<ll> bridges;
vll eulerTour;
ll first[100000];
ll end[100000], par[100000], path[100000], sum[100000];
vector<ll> height, euler, first, segtree;
vector<bool> visited;

void dfs(ll v, ll p = -1, ll h = 1) {
    visited[v] = true;
    height[v] = h;
    tin[v] = fup[v] = timer++;
    first[v] = euler.size();
    euler.push_back(v);
    for (ll to : adj[v]) {
        if (to == p) continue;
        if (visited[to]) {
            fup[v] = min(fup[v], tin[to]);
        } else {
        	par[to] = v;
            dfs(to, v, h+1);
            euler.push_back(v);
            fup[v] = min(fup[v], fup[to]);
            if (fup[to] > tin[v]){
                bridges.push_back(make_pair(v,to));

            }
        }
    }
}

void build(ll i, ll l, ll r)
{
    if (l == r) {
        segtree[i] = euler[l];
    } else {
        ll m = (l + r) >> 1;
        build(2 * i, l, m);
        build(2 * i + 1, m + 1, r);
        if (height[segtree[2 * i]] < height[segtree[2 * i + 1]])
            segtree[i] = segtree[2 * i];
        else
            segtree[i] = segtree[2 * i + 1];

    }
}

ll minimum(ll i, ll sl, ll sr, ll l, ll r)
{
    if (sl == l && sr == r)
        return segtree[i];
    ll sm = (sl + sr) >> 1;
    if (r <= sm)
        return minimum(2 * i, sl, sm, l, r);
    if (l > sm)
        return minimum(2 * i + 1, sm + 1, sr, l, r);
    ll ans1 = minimum(2 * i, sl, sm, l, sm);
    ll ans2 = minimum(2 * i + 1, sm + 1, sr, sm + 1, r);
    return height[ans1] < height[ans2] ? ans1 : ans2;
}

ll lca(ll u, ll v)
{
    ll left = first[u], right = first[v];
    if (left > right)
        swap(left, right);
    return minimum(1, 0, euler.size() - 1, left, right);
}

void preprocess(ll root)
{
	timer = 0;
    visited.assign(n, false);
    tin.assign(n, -1);
    fup.assign(n, -1);
    height.resize(n);
    first.resize(n);
    euler.reserve(n * 2);
    visited.assign(n, false);
    fill(parent, parent+n, -1);
    dfs(root);

    ll m = euler.size();
    segtree.resize(m * 4);
    build(1, 0, m - 1);
}
int main () {
	std::ios::sync_with_stdio(false);
	cin >> n >> m;

	for(ll i = 0 ; i < m ; i++){
		ll a,b;cin >> a >> b;a--;b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	preprocess(0);

	cin >> k;

	for(ll i = 0 ; i < k ; i++){
		ll a,b;cin >> a >> b;a--;b--;
		ll lc = lca(a,b);
		if(lc == a){
			path[b]+=1;
			if(a != 0)
				path[par[a]]-=1;
		}
		else if(lc == b){
			path[a]+=1;
			if(b != 0)
				path[par[b]]-=1;
		}
		else{
			if(lc != 0)
				path[par[lc]]-=2;
			path[a]+=1;
			path[b]+=1;

		}
	}

    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
#define n 1200005
long long cump[n],cumpa[n];
bool prime[n];

bool isPa(long long d)
{
    vector<long long> dig;
    if(d==0)
        dig.push_back(0);
    while(d>0)
    {
        dig.push_back(d%10);
        d/=10;
    }

    long long i=0,j=dig.size()-1;
    while(i<j)
    {
        if(dig[i++]!=dig[j--])
            return false;
    }
    return true;
}
void init()
{
    for(long long i=0;i<n;i++)
        prime[i]=true;
    prime[0]=false;
    prime[1]=false;
    for(long long i=0;i<sqrt(n)+1;i++)
        if(prime[i])
            for(long long j=i;j*i<=n;j++)
                prime[j*i]=false;
    cump[0]=0;
    for(long long i=1;i<n;i++)
        if(prime[i])
            cump[i]=cump[i-1]+1;
        else
            cump[i]=cump[i-1];

    cumpa[0]=0;
    for(long long i=1;i<n;i++)
        if(isPa(i))
            cumpa[i] = cumpa[i-1]+1;
        else cumpa[i] = cumpa[i-1];
    // for(long long i=0;i<45;i++)
    //  cout << cump[i] << " " << cumpa[i] << endl;
    // cout << endl;
}

int main()
{
    long long p,q;
    init();
    cin >> p >> q;
    long long ans=-1;
    for(long long i=1;i<n;i++)
        if(q*cump[i] <= p*cumpa[i])
        {
            ans = max(ans,i);
            //break;
        }
    if(ans>0)
        cout << ans << endl;
    else cout << "Palindromic tree is better than splay tree\n";
    //getchar();
}


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

#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i =a; i <=b ; i++)
#define all(a) a.begin(),a.end()
#define ff first
#define ss second
#define sqr(x) ((x)*(x))
#define EPS 1e-9
#define db(var) cout<<var<<" ";
#define el cout<<endl;
#define p(A,a,b)  f(i,a,b) cout<<A[i]<<" ";
#define sj  cout<<"OK"<<endl;
#define ll long long int

//functions
#define count_1(n)    __builtin_popcountll(n)
#define gcd(a,b) __gcd(a,b)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )

#define MOD 1000000007
#define PI acos(-1.0)
#define e exp(1.0)
#define EPS 1e-9
#define INF    2047483647
#define INFLL  9023372036854775807LL

using namespace std;
int prime[1000006];
int palin[1000006];
int pr[1000006];

bool ispal(string a)
{
    string b=a;
    reverse(b.begin(),b.end());
    return a==b;
}

void sieve()
{
    prime[1]=1;
    prime[2]=0;

    for(int i=2;i<=1000000;i++)
    {
        if(prime[i]==0)
        {
            for(int j=2;j*i<=1000000;j++)
            prime[j*i]=1;

        }
    }
}

void pre()
{
    f(i,1,1000000)
    {
        int val=i;
        string s=to_string(val);
        palin[i]=palin[i-1];
        pr[i]=pr[i-1];
        if(ispal(s)==true)
        {
            palin[i]++;
        }

        if(prime[val]==0)
        {
            pr[i]++;
        }
    }

}

int main()
{
    ios :: sync_with_stdio(0);

     sieve();

     pre();

     int p,q;
     cin>>p>>q;
     int ans=0;

     for(int i=1;i<=1000000;i++)
     {
        double v1=pr[i];
        double v2=(double)((double)p/(double)q)*(double)palin[i];

        if(v1<=v2)
        {
            ans=i;
        }

     }

    if(ans==0)
    cout<<"Palindromic tree is better than splay tree\n";
    else
    cout<<ans<<endl;

  return 0;
}


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

const int MX = 2e6 + 7;

int P[MX];
int L[MX];
bool oks[MX];

bool oki(int x) {
  string cionk;
  while (x > 0) {
    cionk += (char)(x % 10);
    x /= 10;
  }
  string rv = string(cionk.rbegin(), cionk.rend());
  return rv == cionk;
}

bool oki2(int k) {
  string s = to_string (k);
  while (s.back() == '0') s.pop_back();
  reverse(s.begin(), s.end());
  if (atoi(s.c_str()) == k) return true;
  return false;
}

void init() {
  L[0] = 0;
  for (int i = 1; i < MX; ++i) {
    L[i] = L[i - 1];
    if (oki(i)) ++L[i];
  }

  for (int i = 2; i < MX; ++i) oks[i] = true;
  for (int i = 2; i < MX; ++i)
    for (int j = i + i; j < MX; j += i) oks[j] = false;

  for (int i = 1; i < MX; ++i) {
    P[i] = P[i - 1];
    if (oks[i]) ++P[i];
  }
}

int main(void) {
  init();
  double p, q;
  cin >> p >> q;
  for (int i = MX - 1; i > 0; --i)
    if (P[i] <= (p / q) * (double)L[i]) {
      cout << i << endl;
      return 0;
    }

  cout << "Palindromic tree is better than splay tree\n";

  return 0;
}


#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

long long ans,d,pd,a,b,c,n,m,i,si,k,apb,bpc,cpa,dar,j;
vector <long long> g;
main()
{

  cin>>n;
   if (n%3!=0) {cout<<0<<endl; return 0;}
   n=n/3;

   for (i=2;i*i<=n;i++)
    if (n%i==0)
     {
       g.push_back(i);
       if (i*i!=n)  g.push_back(n/i);
     }

   sort (g.begin(),g.end());

    k=g.size();

// m=(a+b)(b+c)(c+a)

   for (i=0;g[i]*g[i]<n;i++)
     {
       apb=g[i];
       dar=n/apb;

       for (j=i;g[j]*g[j]<=dar;j++)
        if (dar%g[j]==0 && dar/g[j]>1)
         {
          bpc=g[j];
          cpa=dar/g[j];

            if (  (apb+bpc<cpa) || (bpc+cpa<apb) || (cpa+apb<bpc) )continue;
            if ( (apb+bpc+cpa)%2!=0) continue;
            if (apb<2 || bpc<2 || cpa<2) continue;

            if (apb==bpc && bpc==cpa) ans+=1; else
            if (apb==bpc && bpc!=cpa) ans+=2; else
            if (apb!=bpc && bpc==cpa) ans+=2; else
             ans+=6;
         }
     }
    cout<<ans<<endl;
   // system ("pause");
}


comment(linker,"/STACK:256000000")
#include <stdio.h>
#include <algorithm>

#define DID (long long)

using namespace std;

long long l,r,mid,ans,N,i,j,a,b,c,x,y,z,len;
long long pos[45000],d[45000];

main()
{
      // freopen("text.in","r",stdin); freopen("text.out","w",stdout);

      scanf("%I64d\n",&N);
      if (N%3)
      {
         printf("0\n");
         return 0;
      }
      N/=3;
      for (i=1;DID i*i<=N;i++)
          if (N%i==0)
          {
             d[len++]=i;
             if (DID i*i!=N)
             d[len++]=N/i;
          }
      sort(d,d+len);

      for (i=0;i<len;i++)
      {
          l=0;
          r=len-1;
          while (l<r)
          {
                mid=(l+r)>>1;
                if (DID d[i]*d[mid]<=N) l=mid; else r=mid-1;
                if (l+1==r)
                if (DID d[i]*d[r]<=N) l++; else r--;
          }
          pos[i]=l;
      }

      for (i=1;i<len;i++)
          for (j=1;d[j]*d[j]<=N/d[i];j++)
              if (N%(d[i]*d[j])==0)
              {
                 z=N/(d[i]*d[j]);
                 x=d[i];
                 y=d[j];
                 if ((x+y+z)%2==0 && x+y-z>1 && y+z-x>1 && x+z-y>1) ans++;
                 swap(y,z);
                 if (y==z) continue;
                 if ((x+y+z)%2==0 && x+y-z>1 && y+z-x>1 && x+z-y>1) ans++;
              }
      printf("%I64d\n",ans);

}


#pragma warning(disable:4786)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<cstdio>
#include <ctime>

using namespace std;

#define MEM(a,b) memset(a,(b),sizeof(a))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b)  ((a) < (b) ? (a) : (b))
#define istr(S) istringstream sin(S)
#define MP make_pair
#define pb push_back
#define inf 1000000000
#define maxn 1000000

//typedef  long  LL;

typedef __int64 LL;

typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;

int solve(int n)
{
	int i,j,k,ret=0;

	for(i=1;i<=n;i++) if(n%i==0)
		for(j=i;j<=n;j++) if( (n/i)%j==0)
			{
				k=n/(i*j);
				if(k<j) continue;
				int cnt = (i%2 + j%2 + k%2);
				if(cnt%2) continue;
				if(i+j-k<=0) continue;

				int a=(i+j-k)/2,b=(j+k-i)/2,c=(k+i-j)/2;

				printf("=%d %d %d\n",a,b,c);
				if(b==c)
					printf("%d %d %d\n",i,j,k);

				if(a==b && b==c)
					ret++;
				else if(a==b || b==c || c==a)
					ret+=3;
				else
					ret+=6;
			}

	return ret;
}

LL pr[60];
int fr[60],sz,ans;
LL nums[4];

void bktk(int pos,int x,LL q)
{
	int i;
	LL p=1;

	if(pos==2)
	{
		for(i=0;i<sz;i++)
			p*=pow( pr[i],fr[i]);

		nums[pos]=p;

		int odd = (nums[0]&1) + (nums[1]&1) + (nums[2]&1);

		if(odd&1) return ;

		if(nums[0]+nums[1]-nums[2]<=0 ||  nums[0]+nums[2]-nums[1]<=0 ||
		   nums[2]+nums[1]-nums[0]<=0) return;

		ans++;

		return;;

	}

	if(x==sz)
	{
		nums[pos]=q;
		bktk(pos+1,0,1);
		return;
	}

	for(i=0;i<=fr[x];i++)
	{
		fr[x]-=i;

		bktk(pos,x+1,q*p);

		fr[x]+=i;
		p*=pr[x];
	}

}

void SOLVE(LL n)
{
	int i,j,k;
	sz=0;
	ans=0;
	LL x=2;

	for(x=2;x*x<=n;x++)
	{
		int cnt=0;
		while(n%x==0) n/=x,cnt++;
		if(cnt)
			pr[sz]=x,fr[sz++]=cnt;
	}

	if(n>1)
		pr[sz]=n,fr[sz++]=1;

	//for(i=0;i<sz;i++)
	//	printf("%d %d\n",pr[i],fr[i]);

	bktk(0,0,1);
	return ;
}

int main()
{
	int i,j,k,tests,cs=0;
	LL n;

	while(1)
	{
		scanf("%I64d",&n);

		if(n%6)
		{
			puts("0");
			return 0;
		}

		SOLVE(n/3);
		printf("%d\n",ans);
		break;

	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
#define repi(i, a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)

const int lim = 100100;
const int MAXQ = 10010000;

ll N;

int ans = 0;

void check(ll p, ll q) {
	ll r = N / p / q;
	ll a = p + r - q;
	ll b = p + q - r;
	ll c = q + r - p;
	if (a > 0 && b > 0 && c > 0 && a % 2 == 0) {
		int num = 3;
		if (a == b) --num;
		if (b == c) --num;
		if (a == c) --num;
		if (num == 0) ++num;
		if (num == 1) {
			ans += 1;
		} else if (num == 2) {
			ans += 3;
		} else if (num == 3) {
			ans += 6;
		}
	}
}

int nxt[MAXQ];
int main() {
	cin >> N;
	if (N % 3) {
		cout << "0\n";
		return 0;
	}
	N /= 3;

	int prv = 0;
	for(ll q = 1; q * q <= N; ++q) {
		if (N % q == 0) {
			nxt[prv] = q;
			prv = q;
		}
	}
	nxt[prv] = N;

	for(int p = 1; p <= lim; ++p) {
		if (N % p == 0) {
			ll m = N / p;
			for (ll q = p; q * q <= m; q = nxt[q]) {
				if (m % q == 0) {
					ll r = N / p / q;
					check(p, q, r);
				}
			}
		}
	}

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


using namespace std;
char buffer[300];
int main() {
  int F,I,T,count,c;
  scanf("%d%d%d", &F,&I,&T);

for(int i=0;i<F;i++)
{
scanf("%s", &buffer[0]);
c=0;
for(int j=0;j<I;j++)
{
if (buffer[j]=='Y') c++;
}
if (c>=T) count++;
}

  printf("%d", count);
  return 0;
}


# kitten
F, L, T = map(int,input().split())
s = []
for i in range(F):
  s.append(input())
ans = 0
for i in range(L):
  cnt = 0
  for j in range(F):
    cnt += (s[j][i] == 'Y')
  ans += cnt >= T
print(ans)


#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<string> m;
    int f, z, t, i, j;
    cin >> f >> z >> t;
    for (i = 0; i < f; i++) {
        string x;
        cin >> x;
        m.push_back(x);
    }
    int ans = 0;
    for (i = 0,c; i < z; i++) {
        c = 0;
        for (j = 0; j < f; j++) {
            if (m[j][i] == 'Y') {
                c++;
            }
        }
        if (c >= t) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<string> m;
    int f, z, t, i, j, a;
    cin >> f >> z >> t;
    for (i = 0; i < f; i++) {
        string x;
        cin >> x;
        m.push_back(x);
    }
    for (i = 0; i < z; i++) {
        int c = 0;
        for (j = 0; j < f; j++) {
            if (m[j][i] == 'Y') {
                c++;
            }
        }
        if (c >= t) {
            a++;
        }
    }
    cout << a;
    return 0;


#include<bits/stdc++.h>
using namespace std;
#define maxn 105
#define maxm 200005
#define int long long
#define inf 0x3f3f3f3f3f3f3fll
#define mod 1000000007
#define local
template<typename Tp>
void read(Tp &x){
	x=0;int f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-'){f=-1;}c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;
}

struct Mat{
	int mat[105][105];
	Mat(){
		memset(mat,0,sizeof(mat));
	}
	void reset(){
		for(int i=0;i<=tmp;i++)mat[i][i]=1;
	}
};
Mat mul(Mat a,Mat b){
	Mat ret;
	for(int i=0;i<=tmp;i++){
		for(int j=0;j<=tmp;j++){
			for(int k=0;k<=tmp;k++){
				ret.mat[i][j]=(ret.mat[i][j]+a.mat[i][k]*b.mat[k][j]%mod)%mod;
			}
		}
	}
	return ret;
}
Mat Ksm(Mat b,int p){
	Mat ret;
	ret.reset();
	while(p){
		if(p&1)ret=mul(ret,b);
		b=mul(b,b);
		p>>=1;
	}
	return ret;
}

int n,m;
int a[maxn],s[maxn];
int fm;
int ksm(int b,int p){
	int ret=1;
	while(p){
		if(p&1)ret=ret*b%mod;
		b=b*b%mod;
		p>>=1;
	}
	return ret;
}
int calc(){
	int tep=n-s[n];
	Mat Base;
	Mat ans;
	ans.mat[1][tep-s[tep]]=1;
	for(int i=0;i<=tep;i++){
		if(i)Base.mat[i-1][i]=(tep-i+1)%mod*(tep-i+1)%mod;
		if(i<tep)Base.mat[i+1][i]=(i+1)%mod*(n-2*tep+i+1);
		Base.mat[i][i]+=(tep-i)%mod*i%mod;
		Base.mat[i][i]+=(tep-i)%mod*(n-2*tep+i)%mod;
		Base.mat[i][i]+=(tep*(tep-1)/2)%mod;
		Base.mat[i][i]+=((n-tep)*(n-tep-1)/2)%mod;
		Base.mat[i][i]%=mod;
	}
	ans=mul(ans,Ksm(Base,m));
	return ans.mat[1][tep];
}
signed main(){
	read(n);read(m);
	for(int i=1;i<=n;i++)read(a[i]),s[i]=s[i-1]+a[i];
	fm=n*(n-1)/2;
	fm=ksm(fm,m);
	fm=ksm(fm,mod-2);
	cout<<calc()*fm%mod<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>

using namespace std;

// #define DEBUG

namespace {
#ifdef DEBUG
    const int kDebug = true;
#else
    const int kDebuf = false;
#endif
}  // namespace

const int mod = (int)1e9 + 7;

struct Rational {
    operator int() { return x; }

    Rational() {
        this->x = 0;
#ifdef DEBUG
        this->rawValue = 0;
#endif
    }
    Rational(int x) {
        this->x = (mod + x % mod) % mod;
#ifdef DEBUG
        this->rawValue = x;
#endif
    }

    Rational operator * (int rh) {
        Rational res((this->x * 1ll * ((mod + rh % mod) % mod)) % mod);
#ifdef DEBUG
        res.rawValue = this->rawValue * rh;
#endif
        return res;
    }

    Rational operator * (Rational rh) {
        Rational res((this->x * 1ll * rh.x) % mod);
#ifdef DEBUG
        res.rawValue = this->rawValue * rh.rawValue;
#endif
        return res;
    }

    Rational operator += (Rational rh) {
        this->x = (this->x + 0ll + rh.x) % mod;
#ifdef DEBUG
        this->rawValue += rh.rawValue;
#endif
        return *this;
    }

    Rational operator = (int x) {
        this->x = (mod + x % mod) % mod;
#ifdef DEBUG
        this->rawValue = x;
#endif
        return *this;
    }

    Rational operator / (int x) {
        Rational res(this->x * 1ll * reverse(x) % mod);
#ifdef DEBUG
        res.rawValue = this->rawValue / x;
#endif
        return res;
    }

#ifdef DEBUG
    double rawValue;
#endif
private:
    int x;

    int reverse(int x) {
        x = (mod + x % mod) % mod;
        return binPow(x, mod - 2);
    }

    int binPow(int x, int p) {
        if (!p) return 1;
        if (p & 1) return binPow(x, p - 1) * 1ll * x % mod;
        x = binPow(x, p >> 1);
        return x * 1ll * x % mod;
    }
};

template <class T>
struct Matrix {
    static Matrix<T> unit(int size) {
        Matrix<T> res(size, size);
        for (int i = 0; i < size; ++i)
            res[i][i] = 1;
        return res;
    }

    int rows, cols;
    vector < vector <T> > arr;

    Matrix <T>(int rows, int cols) {
        this->rows = rows;
        this->cols = cols;
        arr.clear();
        for (int i = 0; i < rows; ++i) {
            vector <T> tmp(cols);
            arr.push_back(tmp);
        }
    }

    Matrix <T> operator * (Matrix<T> rh) {
        Matrix <T> lh = *this;
        assert(lh.cols == rh.rows);
        int commonSize = lh.cols;

        Matrix <T> res(lh.rows, rh.cols);
        for (int i = 0; i < lh.rows; ++i)
            for (int j = 0; j < rh.cols; ++j)
                for (int k = 0; k < commonSize; ++k)
                    res[i][j] += lh[i][k] * rh[k][j];

        return res;
    }

    vector <T>& operator [] (int index) {
        return arr[index];
    }
};

template <class T>
Matrix<T> binPow(Matrix<T> m, int p) {
    assert(m.rows == m.cols);
    int size = m.rows;

    if (!p) return Matrix<T>::unit(size);
    if (p & 1) return binPow(m, p - 1) * m;
    m = binPow(m, p >> 1);
    return m * m;
}

const int maxn = (int)1e2 + 10;
int a[maxn];

int main() {
    int n, k;
    cin >> n >> k;
    int cntOnes = 0, cntZeros = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i]) cntOnes++;
        else cntZeros++;
    }

    int max_ = max(cntOnes, cntZeros);
    int min_ = min(cntOnes, cntZeros);
    if (min_ == 0)
    {
        cout << 1 << endl;
        return 0;
    }

    int badZeros = 0;
    for (int i = 0; i < n; ++i) {
        if (i >= cntZeros)
            break;
        badZeros += a[i] == 1;
    }

    int size = min_ + 1;
    Matrix<Rational> initial(1, size);
    initial[0][badZeros] = 1;

    Matrix<Rational> step(size, size);
    for (int i = 0; i <= min_; ++i) {
        if (i < min_)
            step[i + 1][i] = (i + 1) * (i + 1);
        if (i > 0)
            step[i - 1][i] = (max_ - i + 1) * (min_ - i + 1);
        step[i][i] =
            (i * (min_ - i) + i * (max_ - i) + min_ * (min_ - 1) / 2 + max_ * (max_ - 1) / 2);
    }

#ifdef DEBUG
    cout << (Rational(2) * 1 * 1 / n).rawValue << endl;
    for (int i = 0; i <= min_; ++i)
        for (int j = 0; j <= min_; ++j) {
            cout << "step[" << i << "][" << j << "]=";
            printf("%.7lf\n", step[i][j].rawValue);
            cout << endl;
        }
#endif
    step = binPow<Rational>(step, k);
#ifdef DEBUG
    for (int i = 0; i <= min_; ++i)
        for (int j = 0; j <= min_; ++j)
            cout << "step[" << i << "][" << j << "]=" << step[i][j].rawValue << endl;
#endif

    Matrix<Rational> answer = initial * step;
    Rational sum = 0;
    for (int i = 0; i <= min_; ++i)
        sum += answer[0][i];
#ifdef DEBUG
    cout << answer[0][0].rawValue << endl;
    cout << sum << endl;
#endif
    cout << answer[0][0] / sum << endl;
    return 0;
}

// CodeForces


#include <bits/stdc++.h>
using namespace std;
inline ll read() {
    ll f=1,x=0;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
const int MOD=1e9+7;
const int N=100;
const int MAXN=N+5;
int pow_mod(int x,int i) {
    int res=1;
    while(i) {
        if(i&1) res=(ll)res*x%MOD;
        x=(ll)x*x%MOD;
        i>>=1;
    }
    return res;
}
int n,k,a[MAXN],c,e,t;
struct Matrix {
    int a[MAXN][MAXN];
    Matrix(){memset(a,0,sizeof(a));}
}B;
Matrix operator * (Matrix X,Matrix Y) {
    Matrix Z;
    for(int i=0;i<=N;++i)
        for(int j=0;j<=N;++j)
            for(int k=0;k<=N;++k)
                Z.a[i][j]=((ll)Z.a[i][j]+(ll)X.a[i][k]*Y.a[k][j]%MOD)%MOD;

    return Z;
}
Matrix matrix_pow(Matrix X,int i) {
    Matrix Y;
    for(int i=0;i<=N;++i) Y.a[i][i]=1;
    while(i) {if(i&1) Y=Y*X;X=X*X;i>>=1;}
    return Y;
}
int main() {
    n=read();k=read();
    for(int i=1;i<=n;++i) a[i]=read(),c+=(a[i]==0);
    for(int i=1;i<=c;++i) t+=(a[i]==0);
    for(int i=0;i<=c;++i) {
        if(i!=0) B.a[i-1][i]=1LL*(c-(i-1))*(c-(i-1))%MOD;
        B.a[i][i]=1LL*(1LL*i*(c-i)%MOD+1LL*(c-i)*(n-c-c+i))%MOD;
        B.a[i][i]=(B.a[i][i]+1LL*c*(c-1)/2%MOD)%MOD;
        B.a[i][i]=(B.a[i][i]+1LL*(n-c)*(n-c-1)/2%MOD)%MOD;
        if(i!=c) B.a[i+1][i]=1LL*(i+1)*(n-c-c+i+1)%MOD;
    }
    B=matrix_pow(B,k);
    int ans=B.a[t][c];
    for(int i=0;i<=c;++i)e=((ll)e+B.a[t][i])%MOD;
    ans=((ll)ans*pow_mod(e,MOD-2))%MOD;
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cassert>
#include <vector>
#include <map>
#include <set>

using namespace std;
typedef long long LL;
typedef long double LD;
const int inf = 2*(1e9) + 10;
const long long infl = 2*(1e18) + 10;
const long long MOD = 1000000007;
const long NMAX = 300005;

class modMatrix{
    public:
    LL mat[55][55];
    int n;

    modMatrix(int _n)
        : n(_n)
    {
        memset(mat, 0, sizeof(mat));
    }

    modMatrix operator*(const modMatrix& b){
        modMatrix c(n);
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=n; ++j){
                for(int k=1; k<=n; ++k){
                    c.mat[i][j] = (c.mat[i][j] + mat[i][k]*b.mat[k][j])%MOD;
                }
            }
        }
        return c;
    }

    modMatrix& operator%(int p){
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=n; ++j){
                mat[i][j] = (mat[i][j]) % p;
            }
        }
        return *this;
    }
};

int A[105];

template <class T>
T binExp(T n, int k){
    T x = n;
    k--;
    while(k){
        if(k & 1)
            x = (x*n)%MOD;
        k = k/2;
        n = (n*n)%MOD;
    }
    return x;
}

LL modInv(LL n){
    return binExp(n, MOD - 2);
}

int main(){

    LL n, k;
    cin >> n >> k;

    LL n1, n0;

    n1 = 0;
    for(int i=1; i<=n; ++i){
        cin>>A[i];
        n1 += A[i];
    }
    n0 = n - n1;

    LL state0 = 0;
    // 1 invades the 0 subsegment
    for(int i=1; i<=n0; ++i){
        state0 += (A[i] == 1);
    }

    modMatrix gen = modMatrix(min(n0, n1) + 1);

    LL n0n1 = ((n0 * (((n0 - 1) * modInv(2))%MOD))%MOD +
                (n1 * (((n1 - 1) * modInv(2))%MOD))%MOD)%MOD;
    for(LL i=1; i<=min(n0, n1) + 1; ++i){
        gen.mat[i][i] = (n0n1 + ((i-1)*(n - 2*i + 2))%MOD)%MOD;
        if(i > 1)
            gen.mat[i][i-1] = ((n0 - i + 2)*(n1 - i + 2))%MOD;
        if(i < min(n0, n1) + 1)
            gen.mat[i][i+1] = (i * i)%MOD;
    }

    gen = binExp(gen, k);

    LL ans = 0;
    ans = (gen.mat[1][state0+1] + ans) % MOD;

    cout << (1LL * ans * modInv(binExp( (((n*(n-1))%MOD)*modInv(2))%MOD , k)))%MOD << "\n";

    return 0;
}


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

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;

// pairs
#define mp make_pair
#define f first
#define s second

// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const int IINF = 1e9;
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// helper funcs
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

tcT> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

#define tcTU tcT, class U
tcTU> T fstTrue(T lo, T hi, U f) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	lo --; assert(lo <= hi); // assuming f is decreasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	}
	return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
	auto it = t.find(u); assert(it != end(t));
	t.erase(u); } // element that doesn't exist from (multi)set

// INPUT
#define tcTUU tcT, class ...U
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(vector<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);

tcT> void re(T& x) { cin >> x; }
void re(db& d) { str t; re(t); d = stod(t); }
void re(ld& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }

tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(vector<T>& x) { trav(a,x) re(a); }
tcT, size_t SZ> void re(AR<T,SZ>& x) { trav(a,x) re(a); }

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) {
	#ifdef LOCAL
		return b ? "true" : "false";
	#else
		return ts((int)b);
	#endif
}
tcT> str ts(complex<T> c) {
	stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
	str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
	str res = ""; F0R(i,SZ) res += char('0'+b[i]);
	return res; }
tcTU> str ts(pair<T,U> p);
tcT> str ts(T v) { // containers with begin(), end()
	#ifdef LOCAL
		bool fst = 1; str res = "{";
		for (const auto& x: v) {
			if (!fst) res += ", ";
			fst = 0; res += ts(x);
		}
		res += "}"; return res;
	#else
		bool fst = 1; str res = "";
		for (const auto& x: v) {
			if (!fst) res += " ";
			fst = 0; res += ts(x);
		}
		return res;

	#endif
}
tcTU> str ts(pair<T,U> p) {
	#ifdef LOCAL
		return "("+ts(p.f)+", "+ts(p.s)+")";
	#else
		return ts(p.f)+" "+ts(p.s);
	#endif
}

// OUTPUT
tcT> void pr(T x) { cout << ts(x); }
tcTUU> void pr(const T& t, const U&... u) {
	pr(t); pr(u...); }
void ps() { pr("\n"); } // print w/ spaces
tcTUU> void ps(const T& t, const U&... u) {
	pr(t); if (sizeof...(u)) pr(" "); ps(u...); }

// DEBUG
void DBG() { cerr << "]" << endl; }
tcTUU> void DBG(const T& t, const U&... u) {
	cerr << ts(t); if (sizeof...(u)) cerr << ", ";
	DBG(u...); }
#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert
	#define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
	#define chk(...) if (!(__VA_ARGS__)) cerr << "Line(" << __LINE__ << ") -> function(" \
		 << __FUNCTION__  << ") -> CHK FAILED: (" << #__VA_ARGS__ << ")" << "\n", exit(0);
#else
	#define dbg(...) 0
	#define chk(...) 0
#endif

// FILE I/O
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIO(str s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit);
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

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);
    }
};

template<int SZ> struct Sieve {
	vi pr;
	int sp[SZ]; // smallest prime that divides
	Sieve() { // above is faster
		memset(sp,0,sizeof sp);
		FOR(i,2,SZ) {
			if (sp[i] == 0) sp[i] = i, pr.pb(i);
			trav(p,pr) {
				if (p > sp[i] || i*p >= SZ) break;
				sp[i*p] = p;
			}
		}
	}
};
Sieve<2000010> S;

ll exp(ll a, int b){
	if(b == 0)
		return 1;
	ll p = exp(a, b / 2);
	p = (p * p) % MOD;
	if(b & 1)
		p = (p * a) % MOD;
	return p;
}

int main(){
	setIO();
	int n;
	cin >> n;
	vector<bool> asp(n);
	map<int, pi> m;
	vi p(n);
	F0R(a, n)
		cin >> p[a];
	sort(all(p), [](const int& a, const int& b){return a > b;});
	F0R(a, n){
		if(m[p[a]] == mp(0, 0))
			m[p[a]] = {1, 1}, asp[a] = true;
		else{
		int q = p[a] - 1;
		map<int, int> M;
		while(q != 1){
			M[S.sp[q]]++;
			q /= S.sp[q];
		}
		trav(b, M){
			auto temp = m[b.f];
			if(temp.f == b.s)
				m[b.f] = {temp.f, temp.s + 1};
			else if(temp.f < b.s)
				m[b.f] = {b.s, 1};
		}}
	}
	bool add = false;
	F0R(a, n){
		if(asp[a]){
			if(m[p[a]].f > 1 || m[p[a]].s > 1)
				add = true;
		}
		else{
			bool good = true;
			int q = p[a] - 1;
			else{
			map<int, int> M;
			while(q != 1){
				M[S.sp[q]]++;
				q /= S.sp[q];
			}
			trav(b, M){
				auto temp = m[b.f];
				if(!(temp.f > b.s || temp.s > 1))
					good = false;
			}
			if(good)
				add = true;
			}
		}
	}
	ll lcm = 1;
	trav(a, m)
		lcm = (lcm * exp(a.f, a.s.f)) % MOD;
	cout << (lcm + add) % MOD << endl;
	// you should actually read the stuff at the bottom
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/


#include<bits/stdc++.h>
#define N 2000005
typedef long long ll;
const ll M=1e9+7;
using namespace std;

ll ans=1;
long pr[N],primeid[N],cnt[N],nump=0,n,x,i,j,k,tmp,listp[N],id[N];
vector<long> maxid[N],num[N];
bool f[N],fl[N],vis[N],isp[N],plus1s;

bool cmp(vector<long> a,vector<long> b) {return a.size()>b.size();}
int main()
{
	for (i=2; i<=N-5; i++)
	{
		if (!f[i]) pr[++nump]=i,primeid[i]=nump;
		for (j=1; j<=nump&&i*pr[j]<=N-5; j++)
		{
			f[i*pr[j]]=1;
			if (i%pr[j]==0) break;
		}
	}

	cin>>n;
	for (i=1; i<=n; i++)
	{
		cin>>x;
		if (cnt[x]==0) cnt[x]=1,fl[x]=1,id[x]=i,maxid[x].push_back(i);
		else {
			long p=0,q=1;
			listp[1]=x-1;
			while (p<q)
			{
				p++;
				tmp=listp[p];
				for (j=1; j<=nump&&tmp>=pr[j]; j++)
				{
					long s=0;
					while (tmp%pr[j]==0) s++,tmp/=pr[j];
					if (s>0&&fl[pr[j]]) q++,listp[q]=pr[j]-1,fl[pr[j]]=0,maxid[pr[j]].clear();
					if (s>cnt[pr[j]]) {cnt[pr[j]]=s,maxid[pr[j]].clear(); maxid[pr[j]].push_back(p==1?i:id[listp[p]+1]);}
						else if (s==cnt[pr[j]]&&s!=0) maxid[pr[j]].push_back(p==1?i:id[listp[p]+1]);
					if (!f[tmp]) j=primeid[tmp]-1;// black technology
				}
			}
		}
//		for (k=1; k<=14; k++) {cout<<pr[k]<<':';for (j=0; j<maxid[pr[k]].size(); j++) cout<<maxid[pr[k]][j]<<' ';cout<<endl;}system("pause");
	}

	for (i=1; i<=nump; i++)
		for (j=0; j<maxid[pr[i]].size(); j++)
			num[maxid[pr[i]][j]].push_back(pr[i]);
//	for (i=1; i<=n; i++) {for (j=0; j<num[i].size(); j++) cout<<num[i][j]<<' ';cout<<endl;}system("pause");
	sort(num+1,num+n+1,cmp);
	for (i=1; i<=n; i++)
	{
		//if (isp[i]) continue;
		bool pp=0;
		for (j=0; j<num[i].size(); j++)
			if (!vis[num[i][j]]) vis[num[i][j]]=1,pp=1;
		if (!pp) {plus1s=1; break;}
	}

	for (i=2; i<N; i++)
		for (j=1; j<=cnt[i]; j++)
			ans=ans*i%M;
	if (plus1s) ans=(ans+1)%M;
	cout<<ans;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

const int mod = 1e9 + 7;
const int mxsz = 1e5 + 5;
const int MX = 2e6;

LL fpow(LL b, LL e){
	LL ret = 1;
	for (; e > 0; e >>= 1){
		if (e&1) (ret *= b) %= mod;
		(b *= b) %= mod;
	}
	return ret;
}

int n;
int p[mxsz];
int sml[MX + 5];
vector<pii> fac[MX + 5];

int Exp[MX + 5], occ[MX + 5];
void prec(){
	for (int i = 1; i <= MX; i++) sml[i] = i;
	for (int i = 2; i <= MX; i++){
		if (sml[i] < i) continue;
		for (LL j = 1LL * i * i; j <= MX; j += i)
			sml[j] = min(sml[j], i);
	}
	for (int i = 2; i <= MX; i++){
		int u = i;
		while (u > 1){
			int f = sml[u];
			fac[i].eb(f,0);
			while (u % f == 0){
				u /= f; fac[i].back().se++;
			}
		}
	}
}
int main(){
	prec();
	n = re<int>();
	for (int i = 1; i <= n; i++) p[i] = re<int>();
	sort(p+1,p+n+1, greater<int>());
	for (int i = 1; i <= n; i++){
		if (!Exp[p[i]]){ // prime first occurence
			Exp[p[i]] = 1; occ[p[i]] = 1;
		} else {
			p[i]--;
			for (pii P : fac[p[i]]){
				if (Exp[P.fi] < P.se){
					Exp[P.fi] = P.se;
					occ[P.fi] = 1;
				} else if (Exp[P.fi] == P.se) occ[P.fi]++;
			}
		}
	}
	LL ext = 0, lcm = 1;
	for (int i = 1; i <= n; i++){
		bool ad = 0;
		for (pii P : fac[p[i]]){
			ad |= (Exp[P.fi] == P.se && occ[P.fi] == 1);
		}
		if (!ad) ext = 1;
	}
	for (int i = 2; i <= MX; i++){
		(lcm *= fpow(i, Exp[i])) %= mod;
	}
	printf("%lld\n", (lcm + ext) % mod);
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx")
#pragma GCC target ("avx2,fma")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define rank fewfewf
#define double long double

using namespace std;
using namespace __gnu_pbds;
//using namespace atcoder;

typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1100105;
const int K = 90;
const int mod = 1e9 + 7;
int p[N], a[N], have[N], b[N], taken[N];
vector<pair<int,int>> d[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for (int i = 2; i < N; i++){
        if (p[i] == 0){
            for (int j = i; j < N; j++){
                p[j] = i;
            }
        }
    }
    for (int i = 0; i < n; i++) cin >> a[i];
    reverse(a, a + n);
    for (int i = 0; i < n; i++){
        if (taken[a[i]]){
            b[i] = a[i] - 1;
            int y = b[i];
            while(y != 1){
                int x = p[y];
                int k = 0;
                while(y % x == 0){
                    y /= x;
                    k++;
                }
                d[i].pb({x, k});
            }
            for (auto x: d[i]){
                taken[x.F] = 1;
            }
        } else{
            b[i] = a[i];
            taken[a[i]] = 1;
            d[i].pb({a[i], 1});
        }
    }
    int z = 0;
    for (int i = 0; i < n; i++){
        int ok = 0;
        for (auto x: d[i]){
            if (have[x.F] < x.S) ok = 1;
            have[x.F] = max(x.S, have[x.F]);
        }
        if (!ok) z = 1;
    }
    int res = 1;
    for (int i = 1; i < N; i++){
        for (int j = 0; j < have[i]; j++){
            res = res * i % mod;
        }
    }
    cout << (z + res) % mod;
}


#include <cstdio>
typedef long long ll;

int main(){

    const ll MOD = 1000000007;
    const ll N = 2007;

    std::vector<std::vector<ll> > f(N, std::vector<ll>(N, 0));
    for(int p = 0; p < N; p++){
        f[p][0] = 1;
        for(int q = 1; q <= p; q++){f[p][q] = (f[p - 1][q - 1] + f[p - 1][q]) % MOD;}
    }

    ll n, m, k; scanf("%lld %lld %lld", &n, &m, &k);
    printf("%lld\n", f[n - 1][2 * k] * f[m - 1][2 * k] % MOD);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll ncr[1005][1005];

int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif

    for(ll i=0;i<1005;i++)
        ncr[i][0]=1;
    for(ll i=1;i<1005;i++)
        for(ll j=1;j<=i;j++)
            ncr[i][j]=(ncr[i-1][j-1]+ncr[i-1][j])%mod;

    ll n,m,k;cin>>n>>m>>k;
    if(2*k>n || 2*k>m) return cout<<0;
    ll a1=ncr[n-1][2*k];
    ll a2=ncr[m-1][2*k];
    cout<<(a1*a2)%mod;

    #ifdef APNA_IO
        end_routine();
    #endif
}


#include<iostream>
using namespace std;
const long long unsigned kachal=1000*1000*1000+7;
long long unsigned pa[2001][2001];
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    int s=max(n,m);
    pa[0][0]=1;
    for(int i=1;i<=s;i++)
        for(int j=1;j<=2*k;j++){
            if(j==i)
                pa[i][j]=1;
            pa[i][j]=(pa[i-1][j-1]+pa[i-1][j])%kachal;
        }
    cout << ((pa[n-1][2*k]%kachal)*(pa[m-1][2*k]%kachal))%kachal << endl;
    system("pause");
    return 0;
}


#include <cstdio>
#include <vector>
using namespace std;

int main(){
    const long long MOD = 1000000007;
    const long long N = 2007;
	vector<vector<long long> > f(N, vector<long long>(N, 0));
    for(int p = 0; p < N; p++){
        f[p][0] = 1;
        for(int q = 1; q <= p; q++){f[p][q] = (f[p - 1][q - 1] + f[p - 1][q]) % MOD;}
    }
    scanf("%ld %ld %ld", &n, &m, &k);
    printf("%ld\n", f[n - 1][2 * k] * f[m - 1][2 * k] % MOD);

    return 0;
}