//计算几何题
//二维平面上两个点集，判断是否能通过平移和绕原点旋转整个点集使得两个点集完全相同，
//先考虑将所有点进行平移，使得接下来只要进行旋转就能使得两点集完全相同
//重心
//绕原点旋转
//actan2
//遍历
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f
// #define swap(a, b) (a ^= b ^= a ^= b)
// #define max(x,y) ((x)>(y)?(x):(y))
// #define min(x,y) ((x)<(y)?(x):(y))
#define endl '\n'
const int maxn = 1e2 + 5;
inline int pow(int a, int b, int mod) { int ans = 1;while (b) { if (b & 1)        ans = ans * a % mod;    a = a * a % mod;    b >>= 1; }    return ans % mod; }
inline void print(double x, int d) { cout << fixed << setprecision(d) << x; }
inline int read() { int x = 0, s = 1;   char c = cin.get();   while (c < 48 || c > 57) { if (c == '-')            s = -1;        c = cin.get(); }   while (c <= 57 && c >= 48) { x = (x << 1) + (x << 3) + c - '0';       c = cin.get(); }    return x * s; }

pair<double, double> p1[maxn];
pair<double, double> p2[maxn];
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;cin >> n;

    double sumx = 0, sumy = 0;
    for (int i = 0;i < n;i++) {
        cin >> p1[i].first >> p1[i].second;
        sumx += p1[i].first, sumy += p1[i].second;
    }
    sumx /= n, sumy /= n;
    for (int i = 0;i < n;i++) {
        p1[i].first -= sumx, p1[i].second -= sumy;

    }

    sumx = sumy = 0;
    for (int i = 0;i < n;i++) {
        cin >> p2[i].first >> p2[i].second;
        sumx += p2[i].first, sumy += p2[i].second;
    }
    sumx /= n, sumy /= n;
    for (int i = 0;i < n;i++) {
        p2[i].first -= sumx, p2[i].second -= sumy;
        // cout << p2[i].first << ' ' << p2[i].second << "    ";
    }
    // cout << endl;

    for (int i = 1;i < n;i++) {
        if (p2[0].first == 0 && p2[0].second == 0)
            swap(p2[i], p2[0]);
        else break;
    }

    bool flag = 0;
    double dif = 1e-6;
    for (int i = 0;i < n;i++) {
        double angle = -atan2(p2[0].first, p2[0].second) + atan2(p1[i].first, p1[i].second);
        // cout << angle << endl;
        for (int i = 0;i < n;i++) {
            double x = p1[i].first * cos(angle) - p1[i].second * sin(angle);
            double y = p1[i].first * sin(angle) + p1[i].second * cos(angle);
            // cout << x << ' ' << y << endl;
            bool flag2 = 0;
            for (int i = 0;i < n;i++) {
                if (abs(x - p2[i].first) < dif && abs(y - p2[i].second) < dif) {
                    flag2 = 1;break;
                }
            }
            if (!flag2)break;
            if (i == n - 1)flag = 1;
        }
    }

    if (flag)cout << "Yes";
    else cout << "No";
}

#define _DEBUG
#include "bits/stdc++.h"
//#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug_6(x1,x2,x3,x4,x5,x6) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<", "#x6<<": "<<x6<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_6,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define prind(argument) cout<<std::fixed<<setprecision(13)<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define PI acosl(-1)
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define puba emplace_back
#define pubamp(a,b) emplace_back(mp(a,b))
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int x1[101],y1[101],x2[101],y2[101];
	scan(N);
	rep(i,N){
		scan(x1[i]>>y1[i]);
	}
	rep(i,N){
		scan(x2[i]>>y2[i]);
	}
	if(N==1){
		prin("Yes");
		return 0;
	}
	int a01x=x1[1]-x1[0],a01y=y1[1]-y1[0];
	map<pint,int> acount;
	rep(i,N){
		int atox=x1[i]-x1[0],atoy=y1[i]-y1[0];
		int naiseki=a01x*atox+a01y*atoy;
		int gaiseki=a01x*atoy-atox*a01y;
		acount[mp(naiseki,gaiseki)]++;
	}
	rep(ii,N){
		rep(jj,N){
			if(ii==jj) continue;
			int b01x=x2[ii]-x2[jj],b01y=y2[ii]-y2[jj];
			map<pint,int> bcount;
			rep(i,N){
				int btox=x2[i]-x2[jj],btoy=y2[i]-y2[jj];
				int naiseki=b01x*btox+b01y*btoy;
				int gaiseki=b01x*btoy-btox*b01y;
				bcount[mp(naiseki,gaiseki)]++;
			}
			bool ok=1;
			for(const auto& fs:acount){
				if(bcount[fs.first]!=fs.second){
					ok=0;
				}
			}
			if(ok){
				prin("Yes");
				return 0;
			}
		}
	}
	prin("No");
	return 0;
}


#include <bits/stdc++.h>
#define MOD 998244353LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w;
int fie[501][501];
int flag[1001];

int main(void){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		string s;
		cin >> s;
		for(int j=0;j<w;j++){
			if(s[j]=='R'){
				fie[i][j]=1;
			}else if(s[j]=='B'){
				fie[i][j]=2;
			}else{
				fie[i][j]=0;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			flag[i+j]|=(1<<fie[i][j]);
		}
	}
	ll ans=1;
	for(int i=0;i<h+w-1;i++){
		if(flag[i]&2 && flag[i]&4){
			ans=0;
		}else{
			if(flag[i]&1){
				if((flag[i]&2)==0 && (flag[i]&4)==0){
					ans=ans*2%MOD;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define bits(x,i) (((x) >> (i)) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 1005;
int a[N], n;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    up(i,1,n) cin >> a[i];
    int ans = 0;
    up(i,1,n) ans += a[i] - min(a[i], 10);
    cout << ans;
}


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

const long long MOD = 1e9+7;
char cAA, cAB, cBA, cBB;

long long f[1005];

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

    scanf(" %c %c %c %c", &cAA, &cAB, &cBA, &cBB);

    if(cAA == 'A' && cAB == 'A'){
        printf("1");
        return 0;
    }else if(cBB == 'B' && cAB == 'B'){
        printf("1");
        return 0;
    }else if(N <= 3){
        printf("1");
        return 0;
    }else if( (cAA != cBB && cAB == cBA) || (cAA == 'A' && cAB == 'B' && cBA == 'B' && cBB == 'A') ||(cAA == 'B' && cAB == 'A' && cBA == 'A' && cBB == 'B') ){
        f[2] = 1;
        f[3] = 1;
        for(int i = 4; i <= N; i ++){
            f[i] = (f[i-1] + f[i-2])%MOD;
        }
        printf("%lld\n", f[N]);
        return 0;
    }else if((cAA == cBA && cBA == cBB && cAB != cBA) || (cAA == 'B' && cAB == 'A' && cBA == 'B' && cBB == 'A') || (cAA == 'B' && cAB == 'B' && cBA == 'A' && cBB == 'A')){
        f[2] = 1;
        f[3] = 1;
        for(int i = 4; i <= N; i ++){
            f[i] = (f[i-1] + f[i-1])%MOD;
        }
        printf("%lld\n", f[N]);
        return 0;
    }
    throw;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T>bool chmin(T&x,const T&y) {if(x>y){x=y;return true;} else return false;}
template<typename T>bool chmax(T&x,const T&y) {if(x<y){x=y;return true;} else return false;}

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

    // for prime MOD
    ll val() const { return x;}
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k];
    }
}; //comb(10000007); // ←MOD-1が上限
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)
int N;
set<string> st;
map<string, char> mp;
void dfs(string s) {
    int l = sz(s);
    if (l == N) {
        st.insert(s);
        return;
    }
    for (int i = 0; i < l-1; i++) {
        // iとi+1の間にいれる
        string target = s.substr(i, 2);
        string t = s.substr(0, i+1) + mp[target] + s.substr(i+1);
        // cout << s << '\n';
        // cout << target << ' ' << t << '\n';
        // cout << "--------" << '\n';
        dfs(t);
    }
}

int main() {
    // フラクタル？、逆から考えて実現可能か、dp[i][j] iは長さjはAの数、bit
    // どこかで分割
    int M;
    cin >> M;
    cin >> mp["AA"] >> mp["AB"] >> mp["BA"] >> mp["BB"];
    vector<mint> ans(1e3 + 10);
    for (int i = 2; i <= 10; i++) {
        st.clear();
        N = i;
        dfs("AB");
        ans[i] = sz(st);
    }
    if (M < 10) {
        cout << ans[M] << '\n';
        return 0;
    }
    if (ans[8].val() == 1) {
        cout << 1 << '\n';
        return 0;
    }
    // rep(i, 10) cout << ans[i].val() << '\n';
    if (ans[8].val() == ans[7].val() + ans[6].val()) {
        for (int i = 11; i <= M; i++) {
            ans[i] = ans[i-1] + ans[i-2];
        }
    } else if (ans[8].val() == ans[7].val() * 2) {
        for (int i = 11; i <= M; i++) {
            ans[i] = ans[i-1] * 2;
        }
    }
    cout << ans[M] << '\n';
    return 0;
    // 言い換え、重複, 境界, 条件, ll (1e5のnC2), 0, -, 1i, for s&g, debug
}

// 49


#include <cstdio>
#include <algorithm>
#define N 1010
#define ll long long
#define fo(x, a, b) for (int x = (a); x <= (b); x++)
#define fd(x, a, b) for (int x = (a); x >= (b); x--)
using namespace std;
int n, m, zf = 0, a[N << 1];

inline int calc(int l, int r) {
	return (l + r) * (r - l + 1) / 2;
}

int main() {
	scanf("%d%d", &n, &m);
	if (n < m) swap(n, m), zf = -1; else zf = 1;
	fo(i, 1, n) a[i] = i;
	int ec = n / m, st = 1;
	fo(i, 1, m) {
		if (i == m) a[n + i] = calc(st, n), st = n + 1;
		else a[n + i] = calc(st, st + ec - 1), st = st + ec;
	}
	fo(i, 1, n) printf("%d ", a[i] * zf);
	fo(i, n + 1, n + m) printf("%d ", -a[i] * zf);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int h,w,x[2010][2010],y[2010][2010];

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod;
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

signed main(){
	int cnt = 0;
	string s[2010];
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		cin >> s[i];
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(s[i][j] == '.') cnt++;
		}
	}
	for(int i = 0;i < h;i++){
		x[i][0] = (s[i][0] == '.');
		for(int j = 1;j < w;j++){
			if(s[i][j] == '.') x[i][j] = x[i][j - 1] + 1;
			else x[i][j] = 0;
		}
		for(int j = w - 2;j >= 0;j--){
			if(x[i][j + 1] && x[i][j]) x[i][j] = x[i][j + 1];
		}
	}

	for(int i = 0;i < w;i++){
		y[0][i] = (s[0][i] == '.');
		for(int j = 1;j < h;j++){
			if(s[j][i] == '.') y[j][i] = y[j - 1][i] + 1;
			else y[j][i] = 0;
		}
		for(int j = h - 2;j >= 0;j--){
			if(y[j + 1][i] && y[j][i]) y[j][i] = y[j + 1][i];
		}
	}
	modint<> ans;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(s[i][j] == '#') continue;
			int r = x[i][j] + y[i][j] - 1;
			ans += (modint<>(2).pow(r) - modint<>(1)) * modint<>(2).pow(cnt - r);
		}
	}
	cout << ans << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m;if(n<0)n+=m;return n; }

const int MAXN = 2e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

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

    const int SZ = 1<<5;
    int n; cin>>n;

    vector<vector<int>> v(n, vector<int>(5));

    for(int i=0; i<n; i++)
    {
        for(int j=0; j<5; j++)
            cin>>v[i][j];
    }

    ll lo = 0, hi = 1e10, mid, ans = 0;

    while(lo <= hi)
    {
        mid = lo + (hi-lo)/2;
        vector<int> have(SZ,0);

        for(int i=0; i<n; i++)
        {
            int mask = 0;
            for(int j=0; j<5; j++)
            {
                if(v[i][j] >= mid)
                    mask |= (1<<j);
            }
            // cout<<i<<" "<<mask,nl;
            have[mask]++;
        }
        vector<int> options;

        for(int i=0; i<SZ; i++)
        {
            for(int j=0; j<min(3, have[i]); j++)
                options.pb(i);
        }

        int len = options.size();
        bool ok = 0;

        for(int i=0; i<len; i++)
        {
            for(int j=i+1; j<len; j++)
            {
                for(int k=j+1; k<len; k++)
                {
                    int total_mask = options[i] | options[j] | options[k];
                    if(total_mask == (SZ-1))
                    {
                        ok = 1;
                        break;
                    }
                }
                if(ok) break;
            }
            if(ok) break;
        }

        if(ok)
        {
            ans = mid;
            lo = mid+1;
        }
        else
            hi = mid-1;

    }

    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define IT iterator
#define V vector
#define TP template <class o>
#define TPP template <typename t1, typename t2>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = b; i >= a; i--)
#define FOR(i, n) rep(i, 1, n)
#define debug(x) cerr << #x << ' ' << '=' << ' ' << x << endl
using namespace std;
typedef double db;
typedef unsigned ui;
typedef long long ll;
typedef long double ld;

// char buf[1 << 20],*p1=buf,*p2=buf;
TP void qr(o& x) {
    char c = gc;
    x = 0;
    int f = 1;
    while (!isdigit(c)) {
        if (c == '-')
            f = -1;
        c = gc;
    }
    while (isdigit(c))
        x = x * 10 + c - '0', c = gc;
    x *= f;
}
template <class o, class... O> void qr(o& x, O&... y) { qr(x), qr(y...); }
TP void qw(o x) {
    if (x < 0)
        putchar('-'), x = -x;
    if (x / 10)
        qw(x / 10);
    putchar(x % 10 + '0');
}
TP void pr1(o x) { qw(x), putchar(' '); }
template <class o, class... O> void pr1(o x, O... y) { pr1(x), pr1(y...); }
TP void pr2(o x) { qw(x), putchar(10); }
template <class o, class... O> void pr2(o x, O... y) { pr2(x), pr2(y...); }
TP bool cmax(o& x, o y) { return (x < y ? x = y, 1 : 0); }
TP bool cmin(o& x, o y) { return (x > y ? x = y, 1 : 0); }

const int mod = (int)1e9 + 7;
TPP void ad(t1& x, t2 y) { (x += y) >= mod && (x -= mod); }
TPP void dl(t1& x, t2 y) { (x -= y) < 0 && (x += mod); }

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll power(ll a, ll b = mod - 2, ll p = mod) {
    ll c = 1;
    while (b) {
        if (b & 1)
            c = c * a % p;
        b /= 2;
        a = a * a % p;
    }
    return c;
}
ll exgcd(ll a, ll b, ll& x, ll& y) {
    if (!a) {
        x = 0;
        y = 1;
        return b;
    }
    ll d = exgcd(b % a, a, y, x);
    x -= b / a * y;
    return d;
}
ll INV(ll n, ll p = mod) {
    ll x, y;
    exgcd(n, p, x, y);
    return (x % p + p) % p;
}

const int N = 110;
const ll INF = 1e15;
int n, m, k, val[N];

struct rec {
    int a[N][N];
    rec() { memset(a, 0, sizeof a); }
    rec operator*(rec b) const {
        rec c;
        FOR(i, n) FOR(j, n) FOR(k, n) ad(c.a[i][k], 1ll * a[i][j] * b.a[j][k] % mod);
        return c;
    }
} a, c;

void solve() {
    qr(n, m, k);
    FOR(i, n) a.a[i][i] = c.a[i][i] = 1, qr(val[i]);
    ll inv = power(2 * m);
    while (m--) {
        int x, y;
        qr(x, y);
        dl(a.a[x][x], inv);
        ad(a.a[x][y], inv);
        dl(a.a[y][y], inv);
        ad(a.a[y][x], inv);
    }
    while (k) {
        if (k & 1)
            c = c * a;
        k /= 2;
        a = a * a;
    }
    FOR(i, n) {
        ll ans = 0;
        FOR(j, n) ad(ans, 1ll * c.a[j][i] * val[j] % mod);
        pr2(ans);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    clock_t start_time = clock();
#endif
    int T = 1;
    // qr(T);
    while (T--)
        solve();
#ifndef ONLINE_JUDGE
    cerr << 1.0 * (clock() - start_time) / CLOCKS_PER_SEC << ' ' << 's' << endl;
#endif
    return 0;
}


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

#define ll long long
#define M1 1000000007
#define M2 998244353

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  /////////////////////////////
  int maxn = 62;
  int a,b;
  ll k;
  cin>>a>>b>>k;
  // Pre-Compute nCr values;
  vector<vector<ll>>nCr(maxn,vector<ll>(maxn));
  nCr[0][0] = 1;
  for(int i=1;i<maxn;i++){
    nCr[i][0] = 1;
  }
  for(int n=1;n<maxn;n++){
    for(int r =1;r<=n;r++){
        nCr[n][r] = nCr[n-1][r] + nCr[n-1][r-1];
    }
  }
  ll req =k;
  int n = a+b;
  for(int i=0;i<n;i++){
   ll cnt = nCr[a+b-1][b];
   if(cnt>=k){
    cout<<"a";
    a--;
   }
   else{
    cout<<"b";
    b--;
    k-=cnt;
   }

  }
  return 0;
}

//
//
// File Creation Date:
// Author: Gourav(https://github.com/GouravKhunger)

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef set<int> si;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int>> pqs;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i, a, b) for (int i=a; i<=b; i++)
#define FORn(i, a, b) for (int i=a; i>=b; i--)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define rng_init mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const int MOD = 1e9+7;
const ll INF = 1e15;

int main() {
	FIO;

    //start here

ll a, b, c;
cin>>a>>b>>c;

if(a*a+b*b<c*c) cout<<"Yes";
else cout<<"No";

    //end here

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'

#ifndef ONLINE_JUDGE
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); }
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#endif

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

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

    #ifndef ONLINE_JUDGE
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    while(t--){
    	int n, k;cin >> n >> k;
    	vi ct(n + 1, 0);
    	vl a(n);
		forn(i,n){
			cin >> a[i];
			ct[a[i]] = min(ct[a[i]] + 1, k);
		}
		vi pre(n+1,0);
		int cur = 1e6;
		for(int i = 0; i <= n; i++){
			cur = min(cur, ct[i]);
			pre[1]++;
			pre[cur+1]--;
		}
		int ans = 0;
		for(int i = 1 ;i <= n; i++){
			pre[i] += pre[i-1];
			ans += pre[i];
		}
		cout << ans;
    }
}

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007//998244353//1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef  long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef ll ValType;
template<typename  T> void maxtt(T& t1, T t2) {
    t1=max(t1,t2);
}
template<typename  T> void mintt(T& t1, T t2) {
    t1=min(t1,t2);
}
#define MAX (135)

bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
const ll MOD2 = (ll)MOD * (ll)MOD;
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD){
    x+=y; if (x>=mod) x-=mod;
    if(x<0) x+=mod;
    assert(x>=0 && x<mod);
}
void et(int x=-1) {
    printf("%d\n", x); exit(0);
}
ll fastPow(ll x, ll y, int mod=MOD) {
    ll ans = 1;
    while(y>0) {
        if(y&1) ans = (x * ans)%mod;
        x = x*x%mod;
        y>>=1;
    }
    return ans;
}
ll gcd1(ll x, ll y) {
    return y?gcd1(y,x%y):x;
}

char s[MAX][MAX];
void fmain(int tid) {
    scanf("%d", &n);
    REQ(i,n) scanf("%s", s[i]+1);
    vector<vector<bool>> dp(n+1, vector<bool>(n+1,0));
    REQ(i,n) REQ(j,n) if(s[i][j]=='1') dp[i][j]=1;
    REQ(i,n) dp[i][i]=1;
    REQ(k,n)REQ(i,n)REQ(j,n) if(dp[i][k]&&dp[k][j]) dp[i][j]=1;
    ld ans=0;
    REQ(i,n) {
        int cc=0;
        REQ(j,n) if(dp[j][i]) cc++;
       ans+= (ld)1/cc;
    }
    printf("%.10Lf\n", ans);
}
int main() {
    int t=1;
//    init();
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(10);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
#define delif(c,pred) (c).erase(remove_if(all(c),(pred)), end(c))
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cerr << #a << ": " << (a) << endl;
#define dbgs(s) cerr << #s << endl;
#define dbg1(a,n) cerr<<#a<<": "; rep(i,n) cerr<<(a)[i]<<" "; cerr<<endl;
#define dbg2(m,h,w) cerr<<#m<<":"<<endl; rep(i,(h)){ rep(j,(w))cerr<<(m)[i][j]<<" "; cerr<<endl; }
template <class T, class U> ostream& operator << (ostream& os, pair<T,U> v) {os<<v.first<<","<<v.second;return os;}
template <class T> struct vec;
template <class T> ostream& operator << (ostream& os, vec<T> v) {os<<v[0]<<","<<v[1];return os;}
template <class T, size_t N> ostream& operator << (ostream& os, array<T,N> v) {rep(i,N)os<<v[i]<<(i+1<(ll)N?" ":"");return os;}
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }
inline constexpr int offset[] = {1,0,-1,0,1};

template <class T>
struct vec {
    T x{},y{};
    vec(){}
    vec(T x, T y) : x(x),y(y) {}
    vec rotate(vec a) {
        return vec{x*a.x-y*a.y, x*a.y+y*a.x};
    }
    friend vec operator + (vec a, vec b) {
        return vec{a.x + b.x, a.y + b.y};
    }
    friend vec operator - (vec a, vec b) {
        return vec{a.x - b.x, a.y - b.y};
    }
    friend vec operator * (vec a, T m) {
        return vec{a.x*m, a.y*m};
    }
    T& operator [](int i) { return i==0 ? x : y; }
    T norm2() const { return x*x + y*y; }
    double norm() const { return sqrt(norm2()); }
    double angle(vec a) const {
        double c = (x*a.x + y*a.y)/(norm()*a.norm());
        if (cross(a) < 0) return 2*M_PI-acos(c);
        return acos(c);
    }
    T dot(vec a) const { return x*a.x + y*a.y; }
    T cross(vec a) const { return x*a.y-y*a.x; }
    bool operator < (vec a) const {
        int p = quadrant();
        int q = a.quadrant();
        if (p != q) return p < q;
        T c = cross(a);
        if (c == 0) return norm2() < a.norm2();
        return c > 0;
    }
    int quadrant() const {
        if (y == 0 && x == 0) return 0;
        if (y >= 0) return x > 0 ? 1 : 2;
        else return x < 0 ? 3 : 4;
    }
    bool operator == (vec a) const { return x == a.x && y == a.y; }
};

int main() {
    fastio;
    ll ans{};
    ll N;
    cin >> N;
    if (N == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    vector<vec<int>> s(N),t(N);
    rep(i,N) rep(j,2) cin >> s[i][j];
    rep(i,N) rep(j,2) cin >> t[i][j];

    rep(j,N) {
        rep(q,N) {
            if (q == j) continue;
            if ((t[q] - t[j]).norm2() != (s[1]-s[0]).norm2()) continue;
            vector<vec<int>> v(N);
            rep(k,N) v[k] = s[k] - s[0];

            vector<vec<int>> u(N);
            rep(k,N) u[k] = t[k] - t[j];
            rep(m,N) {
                u[m] = u[m].rotate(s[1] - s[0]);
                v[m] = v[m].rotate(t[q] - t[j]);
            }
            sort(all(u));
            sort(all(v));
            if (u == v) {
                ans = 1;
                break;
            }
        }
    }
    cout << YN(ans) << endl;
}

#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using lli = long long;
using vi = vc<int>;
using ii = pair<int,int>;

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}
lli lcm(lli a, lli b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
int popcount(lli x) { return __builtin_popcountll(x); }
lli poww(lli a, lli b){
	lli res = 1;
	while(b){ if(b&1) res = res*a; a=a*a; b/=2;}
	return res;
}

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

template<class t,class u>bool mmax(t&a,u b){if(a<b)a=b;return a<b;}
template<class t,class u>bool mmin(t&a,u b){if(b<a)a=b;return b<a;}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
// ---- しゃけ ツナマヨ ('-')7

void solve(){
	lli k; cin>>k;
	string a,b; cin>>a>>b;
	vi x(10,0),y(10,0);
	fore(i,0,4)x[a[i]-'0']++;
	fore(i,0,4)y[b[i]-'0']++;
	long double w=0,tot=0;
	vv(lli,num,10,10,0);
	fore(i,1,10)fore(j,1,10){
		lli aa = k-x[i]-y[i];
		lli bb = k-x[j]-y[j];
		if(aa==0 or bb==0)continue;
		if(i!=j)num[i][j]=(aa*bb);
		else num[i][j]=(aa*(aa-1));
		tot+=num[i][j];
	}
	fore(i,1,10){
		if(k-x[i]-y[i]==0)continue;
		lli sc = 0;
		fore(ii,1,10)sc+=poww(10,x[ii]+(i==ii))*ii;
		fore(j,1,10){
				if(k-x[j]-y[j]-(j==i)==0)continue;
				lli ss=0;
				fore(ii,1,10)ss+=poww(10,y[ii]+(j==ii))*ii;
				w+=(sc>ss)*num[i][j];
		}
	}
	long double res = w/tot;
	//cout<<w<<" "<<tot<<ENDL;
	cout<<fixed<<setprecision(7)<<res<<ENDL;

}

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


#include<bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

struct UnionFind{
  vector<int> data;

  UnionFind(int N){
    data.assign(N,-1);
  }

 bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  UnionFind uf1=UnionFind(50),uf2=UnionFind(50);//1=tate,2=yoko;
  int mp[n][n];
  rep(i,n){
    rep(j,n){
      cin>>mp[i][j];
    }
  }
  rep(i,n){
    repi(j,i+1,n){
      bool flag=true;
      rep(l,n){
	if(mp[i][l]+mp[j][l]>k) flag=false;
      }
      if(flag){
	uf1.unite(i,j);
      }
    }
  }
  rep(i,n){
    repi(j,i+1,n){
      bool flag=true;
      rep(l,n){
	if(mp[l][i]+mp[l][j]>k) flag=false;
      }
      if(flag){
	uf2.unite(i,j);
      }
    }
  }
  int flag1[50]={},flag2[50]={};
  int cnt1=1,cnt2=1;
  rep(i,50){
    if(flag1[uf1.find(i)]==0){
      flag1[uf1.find(i)]++;
      for(int j=0;j<uf1.size(i);j++){
	cnt1*=(j+1);
	cnt1%=MOD;
      }
    }
     if(flag2[uf2.find(i)]==0){
      flag2[uf2.find(i)]++;
      for(int j=0;j<uf2.size(i);j++){
	cnt2*=(j+1);
	cnt2%=MOD;
      }
    }
  }
  cout<<(cnt1*cnt2)%MOD<<endl;
  return 0;
}

// Hail god Yato

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

#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e18;
const ll MAX = 52;
//
//
ll frac[52];
void dfs(int idx, vector<int> &vis, vector<vector<int>> &g, int &cnt){
    if(vis[idx])
        return ;
    vis[idx] = 1;
    ++cnt;
    for(int e : g[idx])
        dfs(e, vis, g, cnt);
}
void solve(){
    int n, k;
    cin>>n>>k;
    frac[0] = 1;
    for(int i = 1; i < 52; i++)
        frac[i] = (frac[i-1]*i)%MOD;
    vector<vector<int>> vec(n, vector<int>(n));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin>>vec[i][j];

    vector<vector<int>> g(52, vector<int>());
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n; j++){
            bool flag = true;
            for(int t = 0; t < n; t++){
                if(vec[i][t] + vec[j][t] > k){
                    flag = false;
                    break;
                }
            }
            if(flag){
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
    ll ans = 1;
    vector<int> vis(52, 0);
    for(int i = 0; i < n; i++){
        int cnt = 0;
        dfs(i, vis, g, cnt);
        ans *= frac[cnt];
        ans %= MOD;
    }

    for(int i = 0; i < 52; i++){
        g[i].clear();
        vis[i] = 0;
    }
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n; j++){
            bool flag = true;
            for(int t = 0; t < n; t++){
                if(vec[t][i] + vec[t][j] > k){
                    flag = false;
                    break;
                }
            }
            if(flag){
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
        ll ans2 = 1;
    for(int i = 0; i < n; i++){
        int cnt = 0;
        dfs(i, vis, g, cnt);
        ans2 *= frac[cnt];
        ans2 %= MOD;
    }
    ans *= ans2;
    ans %= MOD;
    cout<<ans;
}
int main(){
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define sorts(s) sort(s.begin(), s.end())
#define sortu(s) sort(s.begin(), s.end(), greater<>())
typedef long long int ll;
using Graph = vector<vector<int>>;

int main(void) {
    //int i = 0, j = 0, k = 0;
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; ++i) {
        if (N*2/i <= i) break;
        if (i % 2 == 1) {
            if (N % i == 0) ans++;
        } else {
            if (N % i != 0 && (N*2) % i == 0) ans++;
        }
    }
    ans *= 2;
    cout << ans << endl;
    //cout << fixed << setprecision(20) << ans << endl;
    return 0;
}

#include <algorithm>
#include <iostream>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

struct Event {
  int time, index;
  bool start;
  inline bool operator<(const Event& other) const {
    return make_tuple(time, start, index) \
      < make_tuple(other.time, other.start, other.index);
  }
};

template <typename T = int>
std::vector<T> ReadArray(int size = 0, std::istream& in_stream = std::cin);

template <typename T>
void PrintArray(const std::vector<T>& array, std::ostream& out_stream = std::cout,
                bool size = false, char element_separator = ' ', char end = '\n');

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

  int64_t n;
  cin >> n;
  n <<= 1;

  int64_t answer = 0;

  for (int64_t s = 1; s * s <= n; ++s) {
    if (n % s == 0) {
      int64_t d = n / s - 1;
      if ((d & 1) == (s & 1)) {
        ++answer;
      }
    }
  }

  for (int64_t t = 1; t * t < n; ++t) {
    if (n % t == 0) {
      int64_t s = n / t;
      int64_t d = n / s - 1;
      if ((d & 1) == (s & 1)) {
        ++answer;
      }
    }
  }

  cout << answer << "\n";

  return 0;
}

template <typename T>
std::vector<T> ReadArray(int size, std::istream& in_stream) {
  if (!size) {
    in_stream >> size;
  }
  std::vector<T> array(size);
  for (auto& element : array) {
    in_stream >> element;
  }
  return array;
}

template <typename T>
void PrintArray(const std::vector<T>& array, std::ostream& out_stream,
                bool size, char element_separator, char end) {
  if (size) {
    out_stream << array.size() << end;
  }
  for (const auto& element : array) {
    out_stream << element << element_separator;
  }
  out_stream << end;
}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///

void _case()
{
    ll n,i,c=0,d=0,ans=0;
    cin>>n;
    ll a[n];
    forn(i,n) cin>>a[i];
    for(i=2;i<=1000;i++){
        c=0;
        for(auto j:a){
            if(j%i==0) c++;
        }
        if(c>d) ans=i,d=c;
    }
    cout<<ans el;
}

main()
{
    fastio();
    _case();

}

///Thank you.

///Brainless_Loco Terminates Here!

#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    int max_count=0,ans=0,tmp=0;
    for (int i=2;i<=1000;i++) {
        int count=0;
        for (int j=0;j<n;j++) {
            if (deq[j]%i==0) {
                count++;
                tmp=i;
            }
        }
        if (count>=max_count) {
            max_count=count;
            ans=tmp;
        }
    }
    cout<<ans<<endl;
}


#include <iostream>

using namespace std;
typedef long long ll;
int main(void) {
  ll N;
  cin >> N;
  ll sum = 0;

  for (int i = 0; i < N; i++) {
    ll A, B;
    cin >> A >> B;
    sum += (B * (B + 1) / 2) - ((A - 1) * A / 2);
  }
  cout << sum << endl;
  return 0;
}

#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  ll r=0;
  rep(i, n){
    ll a,b;cin>>a>>b;
    b = b*(b+1)/2;
    a--;
    a = a*(a+1)/2;
    r += b-a;
  }

  cout<<r<<endl;

  return 0;
}


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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)

const int inf=0x3f3f3f3f3f3f3f3f;
int dx[]={0,1,1,1,0,-1,-1,-1};
int dy[]={1,1,0,-1,-1,-1,0,1};

// <--------------------Code Begins Here-------------------->

int32_t main() {
    SPEED;
    int t = 1;
    // cin>>t;
    while(t--) {
    	int n;
    	cin>>n;
    	int LG = log2(n);
    	// cout<<LG<<endl;
    	int ans = 1e18;
    	for(int i = 0; i <= LG; ++i) {
    		int k = (1ll << i);
    		int c = n % k, a = n / k;
    		ans = min(ans, a + i + c);
    	}
    	cout<<ans;
    }
    return 0;
}

#include <bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll exp = 1,p = 0,a = 1000000000000000000;
  while(exp <= n){
    a = min(a,p+n/exp+n%exp);
    exp *= 2;
    p++;
  }
  cout << a << endl;
}


#include<iostream>
#include<set>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int find(int a,vector<int>& uf){
  if(uf[a]<0) return a;
  return uf[a]=find(uf[a],uf);
}

void unite(int a,int b,vector<int>& uf){
  a=find(a,uf),b=find(b,uf);
  if(a==b)return ;
  if(uf[a]>uf[b]) swap(a,b);
  uf[a]+=uf[b];
  uf[b]=a;
}

int main(){
  int h,w; cin >>h >>w;
  vector<string> mp(h); rep(i,h) cin >>mp[i];
  vector<vector<int>> adj(h+w);
  int n=h+w;
  vector<int> uf(n,-1);
  unite(0,h,uf);
  unite(h-1,h,uf);
  unite(h-1,h+w-1,uf);
  unite(0,h+w-1,uf);
  rep(i,h) rep(j,w){
    if(mp[i][j]=='#'){
      unite(i,h+j,uf);
    }
  }

  set<int> tate,yoko;
  rep(i,h){
    tate.insert(find(i,uf));
  }
  rep(j,w){
    yoko.insert(find(h+j,uf));
  }
  print(min(tate.size(),yoko.size())-1);
}

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

int Solve(vector<string>s) {
	H = s.size();
	W = s[0].size();
	UnionFind uf(H);
	uf.Unite(0, H - 1);
	vector<vector<int>>w(W);
	w[0].push_back(0);
	w[0].push_back(H - 1);
	w[W - 1].push_back(0);
	w[W - 1].push_back(H - 1);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') {
				w[j].push_back(i);
			}
		}
	}
	int ret = H - 2;
	for (int i = 0; i < W; i++) {
		for (int j = 1; j < w[i].size(); j++) {
			if (uf.Check_Same(w[i][j], w[i][0]))continue;
			ret--;
			uf.Unite(w[i][j], w[i][0]);
		}
	}
	return ret;
}

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

	cin >> H >> W;
	vector<string>s(H);
	for (auto &i : s) cin >> i;
	int ans = MOD;
	ans = min(ans, Solve(s));
	vector<string>t(s[0].size());
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			t[j].push_back(s[i][j]);
		}
	}
	cout << min(ans, Solve(t)) << endl;
}


#include <bits/stdc++.h>

#pragma region my_template

struct Rep {
  struct I {
    int i;
    void operator++() { ++i; }
    int operator*() const { return i; }
    bool operator!=(I o) const { return i < *o; }
  };
  const int l_, r_;
  Rep(int l, int r) : l_(l), r_(r) {}
  Rep(int n) : Rep(0, n) {}
  I begin() const { return {l_}; }
  I end() const { return {r_}; }
};
struct Per {
  struct I {
    int i;
    void operator++() { --i; }
    int operator*() const { return i; }
    bool operator!=(I o) const { return i > *o; }
  };
  const int l_, r_;
  Per(int l, int r) : l_(l), r_(r) {}
  Per(int n) : Per(0, n) {}
  I begin() const { return {r_ - 1}; }
  I end() const { return {l_ - 1}; }
};

template <class F>
struct Fix : private F {
  Fix(F f) : F(f) {}
  template <class... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class T = int>
T scan() {
  T res;
  std::cin >> res;
  return res;
}

template <class T, class U = T>
bool chmin(T& a, U&& b) {
  return b < a ? a = std::forward<U>(b), true : false;
}
template <class T, class U = T>
bool chmax(T& a, U&& b) {
  return a < b ? a = std::forward<U>(b), true : false;
}

#ifndef LOCAL
#define DUMP(...) void(0)
template <int OnlineJudge, int Local>
constexpr int OjLocal = OnlineJudge;
#endif

using namespace std;

#define ALL(c) begin(c), end(c)

#pragma endregion

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n = scan();
  auto s = scan<string>();
  auto x = scan<string>();
  int base = 1;
  bitset<7> bs;
  bs[0] = 1;
  for (int i : Per(n)) {
    int r = (s[i] - '0') * base % 7;
    bitset<7> nbs;
    if (x[i] == 'A') {
      for (int z : Rep(7)) nbs[z] = bs[z] and bs[(z + 7 - r) % 7];
    } else {
      for (int z : Rep(7)) nbs[z] = bs[z] or bs[(z + 7 - r) % 7];
    }
    bs = nbs;
    base *= 10;
    base %= 7;
  }
  cout << (bs[0] ? "Takahashi\n" : "Aoki\n");
}

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

template <typename T>
T mypow(T x, T n, const T &p = -1)
{ //x^nをmodで割った余り

	if(p!=-1){
		x%=p;
	}
	T ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;

void solve()
{
	int n;
	cin>>n;
	string s,x;
	cin>>s>>x;
	vector<vector<int>>dp(n+1,vector<int>(7,-1));

	auto rec=[&](auto self,int id,int num)->int{//true:T-win,false-A-win

		if(dp[id][num]>-1)return dp[id][num];
		if(id==n){
			if(num==0)return true;
			else return false;
		}
		int res;
		if(x[id]=='T'){
			if(self(self,id+1,num*10%7)||self(self,id+1,(num*10+s[id]-'0')%7))res=true;
			else res=false;
		}else{
			if(self(self,id+1,num*10%7)&&self(self,id+1,(num*10+s[id]-'0')%7))res=true;
			else res=false;
		}
		return dp[id][num]=res;
	};

	if(rec(rec,0,0))cout<<"Takahashi\n";
	else{
		cout<<"Aoki\n";
	}
}

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


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug true
#define debug2 false

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

void solve(){

    ll X,Y,P,Q;
    cin >> X >> Y >> P >> Q;

    ll x,y,g;
    g = extGCD(2*X+2*Y,P+Q,x,y);
    //これでx,yは(2X+2Y)x+(P+Q)y=gを満たす

    x%=(P+Q);
    x+=(P+Q);
    x%=(P+Q);
    //0<=x<P+Qにしたい　残りはyに押し付ける

    ll Ans = INF;
    REP(j,Y){
        REP(k,Q){
            //欲しいのは(2X+2Y)a+X+j = (P+Q)b+P+kをみたすa
            //(2X+2Y)a-(P+Q)b = P+k-X-jになる
            //(2X+2Y)a = P+k-X-j (mod P+Q)を満たすaが欲しい
            //さっき(2X+2Y)x=g (mod P+Q)を満たすxを求めた
            ll q = P-X-j+k;
            q%=(P+Q);
            q+=(P+Q);
            q%=(P+Q);

            if(q%g!=0)continue;
            ll r = q/g;
            //cout << "! " << q << " " << g << endl;
            ll a=(x*r)%((P+Q)/g);
            /*if(Q==8){
                cout << "! " << X+j MM P+k  MM q MM r MM a MM a*(2*X+2*Y)+X+j << endl;
            }*/
            Ans = min(Ans,a*(2*X+2*Y)+X+j);

        }
    }

    if(Ans==INF){
        cout << "infinity" << endl;
    }else{
        cout << Ans << endl;
    }

}

int main(void){

    ll T;
    cin >> T;
    REP(_,T){
        solve();
    }

    return 0;
}

// 2020-11-21 21:45:27
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
const int MX = 100010;
int n, m;
int visited[MX], color[MX];
vector<P> G[MX];  // v c
void dfs(int u) {
  for (auto [v, c] : G[u]) {
    if (visited[v]) continue;
    visited[v] = 1;
    int nc = 0;
    if (color[u] == c)
      nc = (c + 1) % n;
    else
      nc = c;
    color[v] = nc;
    dfs(v);
  }
}
void answer() {
  cin >> n >> m;
  rep(i, m) {
    int u, v, c;
    cin >> u >> v >> c;
    u--;
    v--;
    c--;
    G[u].emplace_back(v, c);
    G[v].emplace_back(u, c);
  }
  memset(color, -1, sizeof color);
  memset(visited, 0, sizeof visited);
  visited[0] = 1;
  color[0] = 0;
  dfs(0);
  rep(i, n) cout << color[i] + 1 << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}


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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

ll n,m,k,x,y,p=1e9+7,invm;

void mult(vector<vector<ll>>& a, vector<vector<ll>>& b){
	vector<vector<ll>> c(n,vector<ll>(n));
	forn(i,0,n)
		forn(j,0,n)
			forn(k,0,n)
				c[i][j]+=a[i][k]*b[k][j], c[i][j]%=p;
	swap(a,c);
}

vector<vector<ll>> power(vector<vector<ll>>& F, int N){
	vector<vector<ll>> res(n,vector<ll>(n));
	forn(i,0,n)
		res[i][i]=1;
	while(N){
		if(N%2)
			mult(res,F);
		mult(F,F);
		N/=2;
	}
	return res;
}

int inv(ll m){
	ll res=1, n=p-2;
	while(n){
		if(n%2)
			res*=m, res%=p;
		m*=m, m%=p;
		n/=2;
	}
	return res;
}

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

    cin>>n>>m>>k;
    invm = inv(2ll*m);
    vector<vector<ll>> adj(n,vector<ll>(n)), a(n,vector<ll>(1));
    vector<int> deg(n);
    forn(i,0,n)
    	cin>>a[i][0];
    forn(_,0,m){
    	cin>>x>>y, x--, y--;
    	adj[x][y]=adj[y][x]=invm, deg[x]++, deg[y]++;
    }
    forn(i,0,n)
    	adj[i][i]=(p*p+1-deg[i]*invm)%p;
    adj = power(adj,k);
    mult(adj,a);
    forn(i,0,n)
    	cout<<adj[i][0]<<'\n';

    return 0;
}

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

#define INF 1234567890
#define ll long long
#define MOD 1000000007

ll pw(ll a, ll n)
{
	ll ret = 1;
	while(n)
	{
		if (n&1) ret=ret*a%MOD;
		a=a*a%MOD;
		n>>=1;
	}
	return ret;
}

ll inv(ll a)
{
	return pw(a, MOD-2);
}

int N, M, K;
vector<vector<ll> > V, A, g;
ll deg[101];

ll tmp[101][101];
void mul(int n, int m, int p, vector<vector<ll> > &ret, vector<vector<ll> > &A, vector<vector<ll> > &B)
{
	for(int i=0; i<n; i++)
		for(int j=0; j<p; j++)
			tmp[i][j] = 0;
	for(int i=0; i<n; i++)
		for(int k=0; k<m; k++)
			for(int j=0; j<p; j++)
			{
				tmp[i][j] += A[i][k] * B[k][j];
				tmp[i][j] %= MOD;
			}
	for(int i=0; i<n; i++)
		for(int j=0; j<p; j++)
			ret[i][j] = tmp[i][j];
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	cin >> N >> M >> K;
	vector<vector<ll> > V(N, vector<ll>(1));
	vector<vector<ll> > A(N, vector<ll>(N));
	vector<vector<ll> > g(N, vector<ll>(N));

	for(int i=0; i<N; i++)
		cin >> V[i][0];
	for(int i=0; i<M; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a][b] = g[b][a] = inv(2*M);
		deg[a]++; deg[b]++;
	}
	for(int i=0; i<N; i++)
		g[i][i] = (2*M-deg[i]) * inv(2*M) % MOD;

	for(int i=0; i<N; i++)
		A[i][i] = 1;
	while(K)
	{
		if (K & 1) mul(N, N, N, A, A, g);
		mul(N, N, N, g, g, g);
		K >>= 1;
	}
	mul(N, N, 1, V, A, V);
	for(int i=0; i<N; i++)
	{
		ll res = V[i][0];
		res %= MOD; res += MOD; res %= MOD;
		cout << res << "\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define ld long double
#define MOD 1000000007
#define vec vector<int>
#define vecll vector<ll>
#define pb push_back
#define f(i,l,n) for(int i=l;i<n;i++)
#define fll(i,l,n) for(ll i=l;i<n;i++)
#define regstuff                \
    int n;                      \
    cin >> n;                   \
    vec A(n);                   \
    for (int i = 0; i < n; i++) \
        cin >> A[i];
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
vec noprimes(1000001);

void seive(vec &primes, int n)
{
   //gives a prifix array of number of primes as well
    vector<bool> ntprimes(n + 1, false);
    ntprimes[0] = ntprimes[1] = true;
    for (int i = 2; i * i <= n; i++)
    {
        if (!ntprimes[i])
        {
            for (int j = i * i; j <= n; j += i)
            {
                ntprimes[j] = true;
            }
        }
    }
    int x = 0;
    for (int i = 2; i <= n; i++)
    {
        if (!ntprimes[i])
        {
            primes.pb(i);
            x++;
            noprimes[i] = x;
        }
        else
            noprimes[i] = x;
    }
}

ll pow(ll x, ll n)
{
    ll res = 1;
    while (n)
    {
        if (n % 2 == 0)
        {
            n = n / 2;
            x = x * x;
        }
        else
        {
            res *= x;
            n--;
        }
    }
    return res;
}

int main()
{
    fast
    int a,b,c;
    cin>>a>>b>>c;
    if((a*a+b*b)<c*c)
    {
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
    #include "dbg.cpp"
#else
    #define out(...) 42
#endif

void solve () {
    int64_t a, b, c;
    cin >> a >> b>> c;
    a *= a;
    b *= b;
    c *= c;
    if (a + b < c) cout <<"Yes\n";
    else            cout<<"No\n";
}

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

    int tc = 1;
    // cin >> tc;

    for (int i = 1; i <= tc; ++i)
        solve ();
}


#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int k;
  while (~scanf("%d", &k))
  {
    lli ans = 0;
    for (lli a = 1; a <= k; a++)
      for (lli b = 1; a*b <= k; b++)
        for (lli c = 1, hehe = a*b; hehe*c <= k; c++)
          ans++;
    printf("%lld\n", ans);
  }
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x, ll y) {
  ll g = __gcd(x, y);
  x /= g;
  return x * y;
}

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

  int n;
  cin >> n;
  ll p = 1;
  for (int i = 1; i <= n; i++) p = f(p, i);
  cout << p + 1 << "\n";
}


#include <algorithm>
#include <bitset>
//#include <cmath>
//#include <complex>
#include <cctype>
#include <cstdio>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

int64_t INF = LLONG_MAX;

int check(vector<vector<char>> &grid, int i, int j, string &current, int mode){
    int cost = 0;

    if(mode == 0){
        //横の探索
        for(int k = 0; k < current.size(); k++){
            if(grid.at(i).at((j+k)%20) == '.'){
                cost++;
            }else if(grid.at(i).at((j+k)%20) == current.at(k)){
                continue;
            }else{
                return -1;
            }
        }
    }else{
        //縦の探索
        for(int k = 0; k < current.size(); k++){
            if(grid.at((i+k)%20).at(j) == '.'){
                cost++;
            }else if(grid.at((i+k)%20).at(j) == current.at(k)){
                continue;
            }else{
                return -1;
            }
        }
    }

    return cost;
}

void update(vector<vector<char>> &grid, int i, int j, string &current, int mode){
    if(mode == 0){
        //横の探索
        for(int k = 0; k < current.size(); k++){
            if(grid.at(i).at((j+k)%20) == '.'){
                grid.at(i).at((j+k)%20) = current.at(k);
            }
        }
    }else{
        //縦の探索
        for(int k = 0; k < current.size(); k++){
            if(grid.at((i+k)%20).at(j) == '.'){
                grid.at((i+k)%20).at(j) = current.at(k);
            }
        }
    }
}

void run(vector<vector<char>> &grid, vector<string> &s){
    for(string current : s){
        int mini, minj, mode, cost;
        mini = minj = mode = -1;
        cost = 100;
        for(int i = 0; i < 20; i++){
            for(int j = 0; j < 20; j++){
                int tmpcost;
                tmpcost = check(grid, i, j, current, 0);
                if(tmpcost != -1){
                    if(cost > tmpcost){
                        mini = i;
                        minj = j;
                        mode = 0;
                        cost = tmpcost;
                    }
                }

                tmpcost = check(grid, i, j, current, 1);
                if(tmpcost != -1){
                    if(cost > tmpcost){
                        mini = i;
                        minj = j;
                        mode = 1;
                        cost = tmpcost;
                    }
                }
            }
        }

        if(cost == 100){
            continue;
        }

        update(grid, mini, minj, current, mode);
    }
}

void output(vector<vector<char>> &grid){
    for(int i = 0; i < 20; i++){
        for(int j = 0; j < 20; j++){
            cout << grid.at(i).at(j);
        }
        cout << endl;
    }
}

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

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

    vector<vector<char>> grid(N, vector<char>(N, '.'));

    vector<string> s(M);
    for(int i = 0; i < M; i++){
        cin >> s.at(i);
    }

    sort(s.begin(), s.end(), [](auto a, auto b){
        return a.size() > b.size();
    });

    run(grid, s);
    output(grid);

    return 0;
}

// #define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 5e6 + 10;
int fact[N], ifact[N], inv[N];

struct comb_init {
  comb_init() {
    inv[1] = 1;
    for (int i = 2; i < N; ++i) {
      inv[i] = (MOD - MOD / i) * (int64)inv[MOD % i] % MOD;
    }
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < N; ++i) {
      fact[i] = (int64)fact[i - 1] * i % MOD;
      ifact[i] = (int64)ifact[i - 1] * inv[i] % MOD;
    }
  }
} comb_init_;

int64 comb(int n, int m) {
  if (n < m || m < 0) return 0;
  return (int64)fact[n] * ifact[m] % MOD * ifact[n - m] % MOD;
}

int main() {
  int n, m;
  cin >> n >> m;
  m += n;
  vector<int> a(n);
  int sum = n;
  for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
  int ret = 1;
  trace(m, sum);
  for (int i = 0; i < sum; ++i) ret = 1LL * ret * (m - i) % MOD;
  ret = 1LL * ret * ifact[sum] % MOD;
  cout << ret << '\n';
  return 0;
}


#include<iostream>
#define ll long long
using namespace std;
ll n,a,b,c;
const ll inf=1e18;
ll ksm(ll x,ll n){
	ll res=1;
	while(n){
		if(n&1)res=res*x;
		x=x*x;
		n/=2;
	}
	return res;
}
int main(){
	scanf("%lld",&n);
	ll mi=inf;
	for(int i=0;i<63;i++){
		ll now=ksm(2,i);
		if(now>n)continue;
		a=n/now;
		c=n%now;
		mi=min(a+i+c,mi);
	}
	printf("%lld\n",mi);
}

#include<bits/stdc++.h> // 54 68 "Baklol, Take it easy"
using namespace std;
using ll = long long int;
using ld = long double;

#define rep(x, k, n)        for(int x = (k); x <= (n); ++x)
#define rept(x, k, n)       for(int x = (k); x < (n); ++x)
#define repr(x, k, n)       for(int x = (k); x >= (n); --x)
#define pb                  push_back
#define siz(x)              ((int)(x).size())
#define o2(x)               ((x) * (x))
#define all(x)              (x).begin(), (x).end()
#define clr(x, k)           memset(x, k, sizeof(x)) // 0, -1
#define printv(v, k, n)     rep(i, k, n) cout << v[i] << " \n"[i==n];
#define print2dv(V,k,n,m)   rep(j, k, n) printv(V[j], k, m);
#define report(x)           cout << ((x) ? "Yes" : "No") << '\n'
#define setbits(x)          __builtin_popcountll(x)
#define inf                 INT_MAX
#define ninf                INT_MIN
#define int                 long long // "be carefull"

typedef vector<int>         vi;
typedef pair<int, int>      pii;

template <typename Arg1>
void debug_out(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1  << " ]" << "\n";
}

template <typename Arg1, typename... Args>
void debug_out(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << ",";
    debug_out(comma+1, args...);
}

#ifdef LOCAL
#define deb(...) cerr << "[ ", debug_out(#__VA_ARGS__, __VA_ARGS__)
#define debv(v, k, n)       rep(i, k, n) cerr << v[i] << " \n"[i==n];
#define deb2dv(V, k, n, m)  rep(j, k, n) debv(V[j], k, m);
#define line                rep(i, 0, 50){ cerr << '-'; } cerr << '\n'
#else
#define deb(...)
#define debv(v, k, n)
#define deb2dv(V, k, n, m)
#define line
#endif

const int mod = 1e9 + 7; // 998244353;
const int N = 3e5 + 5, M = 2e5 + 5;

template<class T>
T npow(T base, T exp){
    /* O(logn) */
    T result = 1;
    while (exp > 0) {
        if (exp & 1) result = (result * base);
        base = (base * base);
        exp >>= 1;
    }
    return result;
}

/*/------------------------------ CODE BEGINS ------------------------------/*/

int n;

void Solve_main() {

    cin >> n;
    int cnt = 0;
    set<int> st;
    for(int i = 2; i * i <= n; i++){
        for(int j = i*i; j <= n; j*=i){
            st.insert(j);
        }
    }
    cout << n - siz(st) << '\n';
}

/*/------------------------------- CODE ENDS -------------------------------/*/

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);

    // cout << setprecision(12) << fixed;
    int tc = 1;
    // cin >> tc;
    for(int i = 1; i <= tc; i++) {
        Solve_main();
#ifdef LOCAL
        // BRUTE_FORCE();
#endif
    }

    cerr << "[time:" << 1.0*clock()/CLOCKS_PER_SEC << "s] ";
    return 0;
}

/*
-> edge cases, n = 1 ?
-> Submit - right file.
-> Move on - if completely_stuck > 30 minute.
-> entire input - multiple testcases.
-> time complexity - 1 sec : 4e8 will work but risky.
-> space complexity - 256 mb : 6e7(int), 3e7(ll), 2e8(bool, char), will work.
-> mod : sort ?, mint, remove #define int.
-> builtin fuction - add ll.
-> Iterative > Recursive.
-> clear - global variables.
*/


#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
vc<ll> odd,even;
vc<ll> sto,ste;
int sz;
int ans=0;
void dfs(int u,ll st)
{
    if(u==sz)
    {
        ans++;
        for(int j=0;j<even.size();j++)
        {
            if(ste[j]&st);
            else ans++;
        }
        return;
    }
    if(sto[u]&st);
    else dfs(u+1,st|(1LL<<u));
    dfs(u+1,st);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A,B;
    cin>>A>>B;
    for(ll i=A;i<=B;i++)
    {
        if(i&1) odd.push_back(i);
        else even.push_back(i);
    }
    sz=odd.size();
    for(int i=0;i<odd.size();i++)
    {
        ll st=0;
        for(int j=0;j<odd.size();j++)
        {
            if(i==j) continue;
            if(__gcd(odd[i],odd[j])!=1)
                st|=1LL<<j;
        }
        sto.push_back(st);
    }
    for(int i=0;i<even.size();i++)
    {
        ll st=0;
        for(int j=0;j<odd.size();j++)
        {
            if(__gcd(even[i],odd[j])!=1)
                st|=1LL<<j;
        }
        ste.push_back(st);
    }
    dfs(0,0);
    print(ans);
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);
#define totori signed
#define nyaa main

int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};

totori nyaa(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);

	ll a,b;
	cin>>a>>b;
	int m = 20;
	ll dp[(1<<m)]={};
	vector<int> v;
	for(ll i=a;i<=b;i++){
		ll bit = 0;
		for(int j=0;j<m;j++){
			if(i%primes[j] == 0)bit += (1<<j);
		}
		v.push_back(bit);
	}
	dp[0] = 1;
	ll ans = 0;
	for(auto i:v){
		for(int bit=0;bit<(1<<m);bit++){
			if((i&bit) == 0){
				dp[bit|i] += dp[bit];
			}
		}
	}
	for(int i=0;i<(1<<m);i++){
		ans += dp[i];
		// if(dp[i])cerr << i << " " << dp[i] << endl;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
using i64 = long long;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n;
    std::set<std::tuple<int, int, int>> s;
    std::vector<std::pair<int, int>> a(n);
    for (auto &[x, y] : a) {
        std::cin >> x >> y;
    }
    sort(a.begin(), a.end());
    s.emplace(std::max(abs(a[n - 1].first - a[0].first), abs(a[n - 1].second - a[0].second)), 0, n - 1);
    s.emplace(std::max(abs(a[n - 2].first - a[0].first), abs(a[n - 2].second - a[0].second)), 0, n - 2);
    s.emplace(std::max(abs(a[n - 1].first - a[1].first), abs(a[n - 1].second - a[1].second)), 1, n - 1);
    std::vector<int> id(n);
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), [&](int i, int j){
        if (a[i].second == a[j].second) return a[i].first < a[j].first;
        return a[i].second < a[j].second;
    });
    s.emplace(std::max(abs(a[id[n - 1]].first - a[id[0]].first), abs(a[id[n - 1]].second - a[id[0]].second)), id[0], id[n - 1]);
    s.emplace(std::max(abs(a[id[n - 2]].first - a[id[0]].first), abs(a[id[n - 2]].second - a[id[0]].second)), id[0], id[n - 2]);
    s.emplace(std::max(abs(a[id[n - 1]].first - a[id[1]].first), abs(a[id[n - 1]].second - a[id[1]].second)), id[1], id[n - 1]);
    auto x = s.end();
    x--;
    x--;
    std::cout << std::get<0>(*x) << "\n";
    return 0;
}

#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(M);
	for (int &a: A) cin >> a;
	for (int &b: B) cin >> b;

	vector<vector<int>> dp(N + 1, vector<int> (M + 1, 0));
	for (int i = 0; i <= N; i++) dp[i][0] = -i;
	for (int i = 0; i <= M; i++) dp[0][i] = -i;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			dp[i][j] = max(dp[i - 1][j - 1] - 1  + (A[i - 1] == B[j - 1]), max(dp[i - 1][j] - 1, dp[i][j - 1] - 1));
		}
	}
	cout << abs(dp[N][M]) << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(998244353);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int multipf(vector<string>& s){
    if(s.size() == 0)return 0;
    cout << s[0];
    rep1(i, s.size() - 1)cout << " " << s[i];
    cout << endl;
    return 0;
}

int multipf(vector<ll>& n){
    cout << n[0];
    rep1(i, n.size() - 1)cout << " " << n[i];
    cout << endl;
    return 0;
}

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b, ll m){
    ll ans = 1;
    while(b) {
        if(b & 1LL) ans = ans * a % m;
        ans %= m;
        a = a * a;
        a %= m;
        b >>= 1;
    }
    return ans % m;
}

int main() {
    string s;
    cin >> s;
    bool f = true;
    rep0(i, s.size()){
        if(i % 2 == 1 && 'a' <= s[i] && s[i] <= 'z')f = false;
        else if(i % 2 == 0 && 'A' <= s[i] && s[i] <= 'Z')f = false;
    }
    if(f)yes;
    else no;
    return 0;
}

#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<unordered_set>
#include<queue>
#include<unordered_map>
#include<algorithm>

using namespace std;

#define endl                   '\n'
#define gap                    ' '
#define Max                    LLONG_MAX
#define Min                    LLONG_MIN
#define Mod                    1000000007
#define remax(a, b)            a = max(a, b)
#define remin(a, b)            a = min(a, b)
#define PI                     3.1415926535897932384626433832795
#define nps                    string::npos
#define int                    int64_t
#define double                 long double
#define cont(it, s)            for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i, s, n)           for(int i = s; i < n; ++i)
#define repe(i, s, n)          for(int i = s; i <= n; ++i)
#define repr(i, n, s)          for(int i = n; i >= s; --i)
#define read(a)                for(auto& xy : a) cin >> xy
#define speak(a)               for(auto xy : a) cout << xy << ' '; cout << endl
#define work(xy, a)            for(auto& xy : a)
#define dbg(x)                 cerr << (#x) << " is " << (x) << endl
#define all(xy)                (xy).begin(),(xy).end()
#define rall(xy)               (xy).rbegin(),(xy).rend()

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

    int n;
    cin >> n;
    set<int> s;

    for(int i = 1; i*i <= n; ++i) {
    	if(n%i==0) s.insert(i), s.insert(n/i);
    }
    work(x,s) cout<<x<<endl;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define amax(a, b) a = max(a, b)
#define amin(a, b) a = min(a, b)

using ll = long long;

using P = std::pair<int, bool>;
#define fi first
#define se second

struct floor {
    int id;
    bool used;
    bool in;
    bool has_tui;
};

int main() {
    int n;
    std::cin >> n;
    std::vector<floor> status(2*n, floor{-1, false, false, false});
    for (int i=0, ai, bi; i<n; i++) {
        std::cin >> ai >> bi;
        if (ai >= bi && bi > 0) {
            std::cout << "No" << '\n';
            return 0;
        }
        if (ai > 0) {
            if (status[ai-1].used) {
                std::cout << "No" << '\n';
                return 0;
            }
            status[ai-1] = floor{i, true, true, bi > 0};
        }
        if (bi > 0) {
            if (status[bi-1].used) {
                std::cout << "No" << '\n';
                return 0;
            }
            status[bi-1] = floor{i, true, false, ai > 0};
        }
    }
    std::vector<bool> dp(n+1, false);
    dp[0] = true;
    for (int i=1; i<=n; i++) {
        for (int j=0; j<i; j++) {
            if (!dp[j]) continue;
            int w = i - j;
            dp[i] = true;
            for (int k=0; k<w; k++) {
                if ((status[j*2+k].used && status[j*2+w+k].used && status[j*2+k].id == status[j*2+w+k].id)
                        || ( status[j*2+k].used && !status[j*2+w+k].used && !status[j*2+k].has_tui)
                        || (!status[j*2+k].used &&  status[j*2+w+k].used && !status[j*2+w+k].has_tui)
                        || (!status[j*2+k].used && !status[j*2+w+k].used)) {
                    continue;
                }
                dp[i] = false;
                break;
            }
            if (dp[i]) break;
        }
    }
    std::cout << (dp[n] ? "Yes" : "No") << '\n';
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y))
#define chmax(x,y) x = max((x),(y))
#define popcount(x) __builtin_popcount(x)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> tree(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    auto longest = [&](auto&& longest,int i,int p) -> P {
        P res = {i,0};
        for(int j:tree[i]){
            if(j == p) continue;
            P tmp = longest(longest,j,i);
            tmp.second ++;
            if(tmp.second > res.second){
                res = tmp;
            }
        }
        return res;
    };
    auto s = longest(longest,0,-1);
    auto t = longest(longest,s.first,-1);

    vector<ll> e(n);
    int c = 1;
    vector<int> to_s(n,-1);
    auto tos = [&](auto&& tos,int i,int p) -> bool {
        if(to_s[i] != -1) return to_s[i] == 1;
        to_s[i] = (i == s.first ? 1 : 0); // false
        for(int j:tree[i]){
            if(j == p) continue;
            if(tos(tos,j,i)) to_s[i] = 1; // true
        }
        return to_s[i] == 1;
    };
    auto dfs = [&](auto&& dfs,int i,int p) -> void {
        e[i] = c;
        c++;
        int ind = -1;
        for(int j:tree[i]){
            if(j == p) continue;
            if(tos(tos,j,i)){
                ind = j;
                continue;
            }
            dfs(dfs,j,i);
            c++;
        }
        if(ind >= 0){
            dfs(dfs,ind,i);
            c++;
        }
        return;
    };
    dfs(dfs,t.first,-1);
    rep(i,n) cout << e[i] << " ";
    cout <<  endl;
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{   if(k>n)
        return 0;
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n,m;
        cin>>n>>m;
        set<lld>s;
        s.insert(0);
        s.insert(n+1);
        for(i=0;i<m;i++)
        {
            lld a;
            cin>>a;
            s.insert(a);
        }
        if(m==0)
        {
            cout<<1<<endl;
            return 0;
        }
        if(m==n)
        {
            cout<<0<<endl;
            return 0;
        }
        vector<lld>v;
        for(lld x:s)
            v.push_back(x);
        cout<<endl;
        lld ma=LLONG_MAX;
        for(i=1;i<v.size();i++)
        {
            if(v[i]-v[i-1]-1!=0)
                ma=min(ma,v[i]-v[i-1]-1);
        }
        lld ans=0;
        for(i=1;i<v.size();i++)
            {
                ans+=(v[i]-v[i-1]-1)/ma;
                if((v[i]-v[i-1]-1)%ma!=0)
                    ans++;
            }
        cout<<ans<<endl;
    }
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)

int main() {

    string S;
    cin >> S;

    if(S.size()<=3){
        sort(S.begin(), S.end());
        do{
            int n = stoi(S);
            if(n%8 == 0){
                cout << "Yes" << endl;
                return 0;
            }
        }while(next_permutation(S.begin(), S.end()));
        cout << "No" << endl;
        return 0;
    }

    vector<int> nums(10, 0);

    for(auto s:S){
        if(nums.at(s-'0')<3){
            ++nums.at(s-'0');
        }
    }

    string V = "";
    for(int i=1; i<10; ++i){
        rep(j, nums.at(i)) V += (to_string(i));
    }

    do{

        int n = stoi(V.substr(V.size()-3));
        if(n%8 == 0){
            cout << "Yes" << endl;
            return 0;
        }

    }while(next_permutation(V.begin(), V.end()));
    cout << "No" << endl;
}


#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define f(i,x,n) for(ll i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define debug(x) cout<<x<<"\n";
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define MOD 1000000007
ll n,a,b,c,k,d,m,x,y;
string s;

int  main()
{

   int  t;
    t=1;
    //cin>>t;
    while(t--){
   cin>>a>>b>>c>>d;
   float ans=0;
   ans=float(a*d+b*c)/float(b+d);
   std::cout << std::setprecision(12) << ans << '\n';

}

 }

/* Priyansh Agarwal*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<algorithm>
#include<string.h>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
#include<chrono>

using namespace std;
using namespace __gnu_pbds;
using namespace chrono;

#define debug(x) cout << #x << " " << x <<endl;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define pb push_back
#define ppb pop_back;
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcount
#define sz(x) (int)(x.size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size1 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll *fact, ll *ifact) {ll val1 = fact[n]; ll val2 = ifact[n - r]; ll val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}  //only for prime m
ll phin(ll n) {ll number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0)n /= 2;} for (ll i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))
/*--------------------------------------------------------------------------------------------------------------------------*/

void solve() {
	lld a, b, c, d;
	cin >> a >> c >> b >> d;
	cout << setprecision(10) << fixed;
	cout << (c * b + a * d) / (d + c) << nline;
}
int main() {
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	auto start1 = high_resolution_clock::now();
	solve();
	auto stop1 = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop1 - start1);
#ifndef ONLINE_JUDGE
	cerr << "Time: " << duration.count() / 1000 << endl;
#endif
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

void print(vector<bool> x){
    for (bool b: x){
        cout << b << " ";
    }
    cout << endl;
}

void flip(string& s){
    string t;
    for (char l: s){
        t = l + t;
    }
    s = t;
    return;
}

int main(){
    int n;
    cin >> n;
    string s,x;
    cin >> s >> x;
    string s7;
    int mod107 = 1;
    for (int i = 0; i < n; i++){
        int num = (*(s.end()-1) -'0') * mod107 % 7;
        s.pop_back();
        mod107 = mod107 * 10 % 7;
        s7 = char(num + '0') + s7;
    }
    //s7,x を反転
    flip(s7);
    flip(x);
    vector<bool> t_win = {true, false, false, false, false, false, false};
    for (int i = 0; i < n; i++){
        char xi = x[i];
        //print(t_win);
        if (xi == 'T'){//高橋のターン
            vector<bool> t_win_t = {false, false, false, false, false, false, false};
            for (int t = 0; t < 7; t++){
                if (t_win[t] == true || t_win[(t + (s7[i] - '0'))%7] == true) t_win_t[t] = true;
            }
            t_win = t_win_t;
        } else {//青木のターン
            vector<bool> t_win_t = t_win;
            for (int t = 0; t < 7; t++){
                if (t_win_t[t] == true && t_win_t[(t + s7[i] - '0') % 7] == true){
                    t_win[t] = true;
                } else {
                    t_win[t] = false;
                }
            }
        }
    }

    if (t_win[0] == true){
        cout << "Takahashi" << endl;
    } else {
        cout << "Aoki" << endl;
    }
}

#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}
vector<int> digit;
int n;
vector2d(int,dp,100001,7,-1);
string s,t;
int rec(int i,int sum){
    if(i==n)return (sum%7==0);
    if(dp[i][sum]!=-1)return dp[i][sum];
    int ret=0;
    if(t[i]=='A'){
        //0のほうを選ぶ
        if(!rec(i+1,(sum+digit[i]*(s[i]-'0'))%7))ret=0;
        else ret=rec(i+1,sum);
    }else{
        //1のほうを選ぶ
        if(rec(i+1,(sum+digit[i]*(s[i]-'0'))%7))ret=1;
        else ret=rec(i+1,sum);
    }
    return dp[i][sum]=ret;
}

int main(){
    in(n);
    cin>>s>>t;
    digit.resize(n);
    ll d=1;
    rep(i,n){
        digit[i]=d;
        (d*=10)%=7;
    }
    reverse(all(digit));
    out(rec(0,0)==1?"Takahashi":"Aoki");
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int x = 1e9;
	for (int i = 1; i <= x; ++i) {
		int sum = (i * (i + 1)) / 2;
		if (sum >= n) {
			cout << i;
			break;
		}
	}
	return 0;
}

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

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