#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
int dp[3][100][100];
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, K;
	cin >> N >> M >> K;
	int A[100];
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) dp[0][i][i] = 1;
	rep(i, N) dp[1][i][i] = 1;
	int are = modpow(2 * M, mod - 2);

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		(dp[0][x][x] += mod - are) %= mod;
		(dp[0][x][y] += are) %= mod;
		(dp[0][y][x] += are) %= mod;
		(dp[0][y][y] += mod - are) %= mod;
	}

	auto mae = dp[1], ato = dp[2];
	rep(i, 30) {
		rep(x, N) rep(y, N) {
			ll tmp = 0;
			rep(z, N) {
				tmp += mae[x][z] * (ll)mae[z][y] % mod;
			}
			ato[x][y] = tmp % mod;
		}
		swap(mae, ato);

		if (K >> 29 - i & 1) {
			rep(x, N) rep(y, N) {
				ll tmp = 0;
				rep(z, N) {
					tmp += mae[x][z] * (ll)dp[0][z][y] % mod;
				}
				ato[x][y] = tmp % mod;
			}
			swap(mae, ato);
		}
	}

	rep(i, N) {
		ll kotae = 0;
		rep(j, N) kotae += (ll)mae[i][j] * A[j] % mod;
		co(kotae % mod);
	}

	Would you please return 0;
}

/*
 * @date:2021-04-24 20:37:33
 * @source:
*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100 + 5;
const int MOD = 1e9 + 7;

int N, M, K;
long long A[MAXN];
int Num[MAXN];

struct Matrix {
    long long A[MAXN][MAXN];
    Matrix() {
        memset(A, 0, sizeof A);
    }
} a, c;

Matrix mul(const Matrix &x, const Matrix &y) {
    memset(c.A, 0, sizeof c.A);
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            for (int k = 1; k <= N; ++k) {
                c.A[i][j] = (c.A[i][j] + x.A[i][k] * y.A[k][j] % MOD) % MOD;
            }
        }
    }
    return c;
}

long long poww(long long x, int t) {
    long long res = 1;
    for (; t; t >>= 1) {
        if (t & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

Matrix poww(Matrix &x, int t) {
    Matrix res = x;
    for (--t; t; t >>= 1) {
        if (t & 1) res = mul(res, x);
        x = mul(x, x);
    }
    return res;
}

int main() {
    scanf("%d%d%d", &N, &M, &K);
    for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
    if (!K) {
        for (int i = 1; i <= N; ++i) {
            printf("%lld\n", A[i]);
        }
        return 0;
    }
    long long p = poww(M, MOD - 2), two = poww(2, MOD - 2);
    for (int i = 1, u, v; i <= M; ++i) {
        scanf("%d%d", &u, &v);
        ++Num[u], ++Num[v];
        a.A[u][v] = a.A[v][u] = p * two % MOD;
    }
    for (int i = 1; i <= N; ++i) {
        a.A[i][i] = p * (M - Num[i] + two * Num[i]) % MOD;
    }
    a = poww(a, K);
    for (int i = 1; i <= N; ++i) {
        long long x = 0;
        for (int j = 1; j <= N; ++j) {
            x = (x + A[j] * a.A[i][j]) % MOD;
        }
        printf("%lld\n", x);
    }
    return 0;
}


/*
                    author         : TAPAN SAVANI
                    codeforces     : savanitapan2001
                    codechef       : savanitapan17
*/

/*
------------------------------------------------------------------------

░██╗░░░░░░░██╗░█████╗░██████╗░██╗░░██╗  ██╗░░██╗░█████╗░██████╗░██████╗░
░██║░░██╗░░██║██╔══██╗██╔══██╗██║░██╔╝  ██║░░██║██╔══██╗██╔══██╗██╔══██╗
░╚██╗████╗██╔╝██║░░██║██████╔╝█████═╝░  ███████║███████║██████╔╝██║░░██║
░░████╔═████║░██║░░██║██╔══██╗██╔═██╗░  ██╔══██║██╔══██║██╔══██╗██║░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝██║░░██║██║░╚██╗  ██║░░██║██║░░██║██║░░██║██████╔╝
░░░╚═╝░░░╚═╝░░░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝  ╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░

------------------------------------------------------------------------
*/

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

#define HAPPY_CODING              \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())
#define mod 1000000007
#define pi 3.141592653589793238
#define ll long long int
#define ull unsigned long long
#define be begin()
#define en end()
#define FOR(i, a, b) for (long long int i = a; i < b; i++)
#define FORI(i, a, b) for (int i = a; i >= b; i--)

typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef vector<PI> VPI;

int main()
{
    HAPPY_CODING;

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

    if (n == 0 || k == 0)
    {
        cout << n << "\n";
        return 0;
    }

    VI x;

    int temp = n, ans = 0;
    while (temp)
    {
        x.pb(temp % 10);
        temp /= 10;
    }

    while (k--)
    {
        int first = 0;

        SORT(x);
        FOR(i, 0, x.size())
        {
            first *= 10;
            first += x[i];
        }

        int second = 0;
        SORTR(x);
        FOR(i, 0, x.size())
        {
            second *= 10;
            second += x[i];
        }

        ans = second - first;

        int temp = ans;
        x.clear();
        while (temp)
        {
            x.pb(temp % 10);
            temp /= 10;
        }

        if (ans == 0)
            break;
    }

    cout << ans << "\n";

    return 0;
}

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

int g1(int x) {
  priority_queue<int> q;
  int ans = 0;
  while (x > 0) {
    q.push(x % 10);
    x /= 10;
  }
  while (!q.empty()) {
    ans *= 10;
    ans += q.top();
    q.pop();
  }
  return ans;
}

int g2(int x) {
  priority_queue<int, vector<int>, greater<int>> q;
  int ans = 0;
  while (x > 0) {
    q.push(x % 10);
    x /= 10;
  }
  while (!q.empty()) {
    ans *= 10;
    ans += q.top();
    q.pop();
  }
  return ans;
}

int f(int x) { return g1(x) - g2(x); }

int main(void) {
  int N, K;
  cin >> N >> K;
  int a = N;
  for (int i = 0; i < K; ++i) {
    a = f(a);
  }
  printf("%d\n", a);

  return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

long long N, K;
long long calc(long long x) {
  if (x<2) return 0;
  if (x > 2*N) return 0;
  return min(x-1, N*2-x+1);
}

int main(void) {
  cin >> N >> K;

  unsigned long long ans = 0;
  for (long long ab = 2; ab <= 2*N; ab++) {
    long long cd = ab-K;
    unsigned long long abptn = calc(ab);
//    unsigned long long cdptn = min(cd-1, N*2-cd+1);
    unsigned long long cdptn = calc(cd);

    ans += abptn*cdptn;
  }
  cout << ans << endl;
  return 0;
}

#pragma GCC         optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define E(x,y)      cerr<< __LINE__ <<": "<< #x << " = "<<(x)<<' '<< #y << " = "<<(y) <<'\n';
#define endl        '\n'
///Input-Output
#define si(x)       scanf("%d",&x)
#define sii(x,y)     scanf("%d%d",&x,&y)
#define sl(x)       scanf("%lld",&x)
#define sll(x,y)     scanf("%lld%lld",&x,&y)
///
using namespace std;
using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

template <typename T>  using orderedSet =
    tree<T, null_type, less<T>,
    rb_tree_tag, tree_order_statistics_node_update>;
/*order_of_key(k) - number of element strictly less than k.
 find_by_order(k) - k'th element in set.(0 indexed)(iterator)*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
//template<typename T>inline T gcd(T a, T b){T c;while (b){c = b;b = a % b;a = c;}return a;}
//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;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1.0);
const double eps = 1e-8;
const int mod    =998244353;
const int mx     = 2e5+5;
const int lg     = 26;
/*--------------------------------------------------------------*/
int main()
{
    ll n,k;
    sll(n,k);
    ll ans = 0;
    for(ll i=1;i<=n*2;i++)
    {
        ll x = i;
        ll y = x-k;
        if(x<=0 || y<=0 || x>n*2 || y>n*2) continue;
        if(x>n)x=x-(x-n-1)*2;
        if(y>n) y=y-(y-n-1)*2;
        ans+=(x-1)*(y-1);
        //E(x,y);
      // D(ans);
    }
    cout<<ans<<endl;
}


#include <iostream>

#define int long long

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

  int a, b, c;
  std::cin >> a >> b >> c;

  std::cout << (a + b + c) - std::min(a, std::min(b, c)) << std::endl;

  return 0;
}

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

using namespace __gnu_pbds;
using namespace std;
/* Written by Nishant Mittal aka nishantwrp */
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
/* Long Long Int */
#define int long long int
#define modnum 1000000007
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define rep(n) for(int i = 0;i<n;i++)
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define all(data) data.begin(), data.end()
#define endl '\n'
#define last(a) a[sz(a)-1]
#define INF 1000000000000000000

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

typedef tree <int, null_type, greater <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values greater than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

// NOTE: For reverse ordered set (that does same things for lower than)
// typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

//primes for hashing 937,991,1013,1409,1741

//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define ub(data,key) upper_bound(all(data),key) - data.begin();

// Random Number Generator
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

void nishantwrp(int cas) {
    vector <int> data;
    invect(data,3,)
    sort(data.begin(),data.end());
    cout<<data[2] + data[1];
}

signed main()
{
    FAST
    int t = 1;
    // cin>>t;
    int cas = 1;
    while(cas <= t) {
        nishantwrp(cas);
        cas++;
    }
    return 0;
}


#include <bits/stdc++.h>
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
#define logn long
#define lnog long
#define itn int
using namespace std;
int main() {
	long long N; cin >> N;
	string T; cin >> T;
	for (long long i = 1; i < N; i++) {
		if (T.at(i - 1) == '0' && T.at(i) == '0') {
			cout << 0 << endl;
			return 0;
		}
	}
	for (long long i = 1; i < N - 1; i++) {
		if (T.at(i - 1) == '0' && T.at(i) == '1' && T.at(i + 1) == '0') {
			cout << 0 << endl;
			return 0;
		}
		else if (T.at(i - 1) == '1' && T.at(i) == '1' && T.at(i + 1) == '1') {
			cout << 0 << endl;
			return 0;
		}
	}
	long long num = 0;
	for (long long i = 0; i < N; i++) {
		num += (T.at(i) == '0');
	}
	if (T == "1") {
		cout << 2 * 10000000000 << endl;
	}
	else if (T == "11") {
		cout << 10000000000 << endl;
	}
	else {
		cout << 10000000000 - num + (T.at(N - 1) == '0') << endl;
	}
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

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

  int64 N;
  cin >> N;
  string T;
  string S = "110";
  cin >> T;

  int64 res = 0;
  REP(s, 3) {
    bool ok = 1;
    REP(i, N) {
      if (S[(s + i)%3] != T[i]) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      int64 x = (N + s) % 3;
      int64 y = (30000000000LL - (3-x)%3 - N + 1);
      res += (y + 2) / 3;
    }
  }
  cout << res << endl;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;

static const LL INF = 1LL << 60;
static const long long MOD = 998244353;
static const size_t MAX_N = 1000001;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r]) * inv[n - r];
}

LL solve(long long H, long long W, std::vector<std::string> &S) {
	modll ans = 1;
	for (int i = 0; i < H + W; ++i) {
		int ac = 0, rc = 0, bc = 0;
		for (int c = 0; c < W; ++c) {
			int r = i - c;
			if (r >= 0 && r < H) {
				++ac;
				if (S[r][c] == 'R') ++rc;
				if (S[r][c] == 'B') ++bc;
			}
		}
		if (ac) {
			if (rc && bc) {
				return 0;
			}
			if (rc == 0 && bc == 0) {
				ans *= 2;
			}
		}
	}
	return ans;
}

int main() {
    long long H, W;
	std::cin >> H >> W;
	std::vector<std::string> S(H);
	for (int i = 0; i < H; i++) {
		std::cin >> S[i];
	}
	cout << solve(H, W, S) << endl;
	return 0;
}

#line 1 "main.cpp"

/**
 * @title Template
 */

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <cassert>
#include <map>

#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/chmin_chmax.cpp"

template <class T, class U>
constexpr bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
constexpr bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

/**
 * @title Chmin/Chmax
 */
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

class range {
  struct iter {
    std::size_t itr;
    constexpr iter(std::size_t pos) noexcept: itr(pos) { }
    constexpr void operator ++ () noexcept { ++itr; }
    constexpr bool operator != (iter other) const noexcept { return itr != other.itr; }
    constexpr std::size_t operator * () const noexcept { return itr; }
  };

  struct reviter {
    std::size_t itr;
    constexpr reviter(std::size_t pos) noexcept: itr(pos) { }
    constexpr void operator ++ () noexcept { --itr; }
    constexpr bool operator != (reviter other) const noexcept { return itr != other.itr; }
    constexpr std::size_t operator * () const noexcept { return itr; }
  };

  const iter first, last;

public:
  constexpr range(std::size_t first, std::size_t last) noexcept: first(first), last(std::max(first, last)) { }
  constexpr iter begin() const noexcept { return first; }
  constexpr iter end() const noexcept { return last; }
  constexpr reviter rbegin() const noexcept { return reviter(*last - 1); }
  constexpr reviter rend() const noexcept { return reviter(*first - 1); }
};

/**
 * @title Range
 */
#line 17 "main.cpp"

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

usize find(std::vector<usize> &vec, usize x) {
  if (vec[x] == x) {
    return x;
  }
  return vec[x] = find(vec, vec[x]);
}

int main() {
  usize N, Q;
  std::cin >> N >> Q;
  std::vector<std::map<usize, usize>> map(N);
  for (auto i: range(0, N)) {
    usize c;
    std::cin >> c;
    c -= 1;
    map[i][c] += 1;
  }
  std::vector<usize> par(N);
  for (auto i: range(0, N)) {
    par[i] = i;
  }
  while (Q--) {
    usize t;
    std::cin >> t;
    if (t == 1) {
      usize a, b;
      std::cin >> a >> b;
      a -= 1;
      b -= 1;
      a = find(par, a);
      b = find(par, b);
      if (a != b) {
        if (map[a].size() < map[b].size()) {
          std::swap(a, b);
        }
        for (auto [x, y]: std::move(map[b])) {
          map[a][x] += y;
        }
        par[b] = a;
      }
    }
    else {
      usize a, b;
      std::cin >> a >> b;
      a -= 1;
      b -= 1;
      a = find(par, a);
      auto itr = map[a].find(b);
      if (itr != map[a].end()) {
        std::cout << itr -> second << '\n';
      }
      else {
        std::cout << "0\n";
      }
    }
  }
  return 0;
}


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

int main()
{
char a , b ,c ;
cin >>a >> b >>c;
cout<< b << c << a;

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <utility>
using ll=long long;
using namespace std;

int main(){
    string S;
    cin>>S;
    int slen=S.size();
    int big;
    int ans=1;
    for(int i=0;i<slen;i++){
        if(S[i] >= 'a'){
            big=0;
        }else{
            big=1;
        }
        if(i%2 != big){
            ans=0;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 10005
bitset<N>p[5],f[3];
int n,i,l,r,cnt,mid,a[N][10],c[10],fl,b[5][5],e[10];
bool check(){
	int i;
	for(i=1;i<=n;++i)f[0][i]=f[1][i]=f[2][i]=1;
	for(i=0;i<5;++i){
		f[e[i]]&=p[i];
	}
	if(f[0].count()&&f[1].count()&&f[2].count())return 1;
	return 0;
}
void dfs(int now){
	if(now==5){fl|=check();return ;}
	e[now]=0;dfs(now+1);e[now]=1;dfs(now+1);e[now]=2;dfs(now+1);
}
int check(int x){
	for(int i=0;i<5;++i){
		for(int j=1;j<=n;++j){
			if(a[j][i]>=x)p[i][j]=1;else p[i][j]=0;
		}
	}
	fl=0;dfs(1);if(fl)return 1;return 0;
}
int main(){
	cin>>n;
	for(i=1;i<=n;++i)cin>>a[i][0]>>a[i][1]>>a[i][2]>>a[i][3]>>a[i][4];
	l=0;r=1e9;
	while(l<r){
		mid=r-(r-l>>1);
		if(check(mid))l=mid;
		else r=mid-1;
	} cout<<l;
}

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib>
#include <math.h>
#include<cstdio>
#include<cstring>
#include <math.h>
#define vi v(n) vector<ll> v(n);
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    IOS
    ll n;
    cin>>n;
    ll dp[n+1][3][35];
    fo(i,n+1){
        fo(j,3){
            fo(k,35){
                dp[i][j][k]=0;
            }
        }
    }
    ll a,b,c,d,e;
    FOR(i,1,n){
        cin>>a>>b>>c>>d>>e;
        vector<ll> myVals{a,b,c,d,e};
        fo(j,3){
            fo(k,32){
                ll val=dp[i-1][j][k];
                fo(l,32){
                    if(k|l==k){
                        if(j==0){
                            if(l!=k) continue;
                            ll my=10000000000000;
                            fo(m,5){
                                if(l&(1<<m)){
                                    my=min(my,myVals[m]);
                                }
                            }
                            if(my==10000000000000) my=0;
                            val=max(val,my);

                        }
                        else if(i>=j+1){

                            ll my=10000000000000;
                            fo(m,5){
                                if(l&(1<<m)){
                                    my=min(my,myVals[m]);
                                }
                            }
                            if(my==10000000000000) my=0;
                            my=min(my,dp[i-1][j-1][l^k]);
                            val=max(val,my);
                        }
                    }
                }
                dp[i][j][k]=val;
            }
        }
    }
   // dbg(dp[1][0][1]);
    cout<<dp[n][2][31]<<endl;

}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) ll((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=998244353;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	ll n, m, mi=10000000;
	cin>>n>>m;
	vll a(n*m);
	fo(i, n*m){
		cin>>a[i];
		mi=min(mi, a[i]);
	}
	ll ans=0;
	fo(i, n*m){
		ans+=a[i]-mi;
	}
	on(ans);
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
template <class T = int>
using V = vector<T>;
template <class T = int>
using VV = V<V<T>>;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<ld,ld>;

struct edge{
    int to, c;
    edge(int to, int c): to(to), c(c) {}
};

const int INF = 1<<30;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    VV<edge> g(n);
    rep(i,m){
        int a, b; char c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].eb(b,c-'a');
        g[b].eb(a,c-'a');
    }
    VV<int> dp(n, V<int>(n, INF));
    queue<pii> que;
    auto push = [&](int a, int b, int x){
        if(dp[a][b] != INF) return;
        dp[a][b] = x;
        que.emplace(a,b);
    };
    push(0,n-1,0);
    while(!que.empty()){
        int a = que.front().first, b = que.front().second;
        que.pop();
        for(auto ea : g[a]) for(auto eb : g[b]){
            if(ea.c != eb.c) continue;
            push(ea.to, eb.to, dp[a][b] + 1);
        }
    }
    int ans = dp[n-1][0];
    if(ans == INF) ans = -1;
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define per(i,n) for(ll (i)=(n)-1;(i)>=0;--(i))
#ifdef LOCAL
#define debug(x) cerr<<__LINE__<<": "<<#x<<"="<<x<<endl;
#define debugALL(x) cerr<<__LINE__<<": "<<#x<<"=";for(auto i=(x).begin();i!=--(x).end();i++)cerr<<*i<<" ";cerr<<*--(x).end()<<endl;
#else
#define debug(x) true
#define debugALL(x) true
#endif
using namespace std;

int main(){
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    V a,b;
    rep(i,n){
        if(s[i]=='0')a.emplace_back(i);
        if(t[i]=='0')b.emplace_back(i);
    }
    if(a.size()!=b.size()){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0;
    rep(i,a.size())if(a[i]!=b[i])ans++;
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,string>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;
const LL sc = (int)1e8;
const double TL = 2.85;
const int Max_N = 20;
const int Max_K = 8;
const int Max_length = 12;
const double blank_poss = 1.00;

int N, M;
vector<P> s;
vector<vector<char>> mat;
map<string,int> mp;
LL score(){
	int blank = 0, hit = 0;
	rep(i,N){
		rep(j,N) if(mat[i][j] == '.') blank++;
	}
	rep(i,M) if(mp[s[i].second] > 0) hit++;
	LL res = sc;
	if(hit < M){
		res *= hit;
		res /= M;
	}
	else{
		res *= N * N * 2;
		res /= (N * N * 2 - blank);
	}
	return res;
}
void del(int h, int w){
	for(int l = 2; l <= Max_length; l++){
		rep(i,l){
			string t1, t2;
			int st = h - i;
			if(st < 0) st += N;
			rep(j,l) t1 += mat[(st+j)%N][w];
			st = w - i;
			if(st < 0) st += N;
			rep(j,l) t2 += mat[h][(st+j)%N];
			mp[t1]--;
			mp[t2]--;
		}
	}
}
void add(int h, int w, char c){
	mat[h][w] = c;
	for(int l = 2; l <= Max_length; l++){
		rep(i,l){
			string t1, t2;
			int st = h - i;
			if(st < 0) st += N;
			rep(j,l) t1 += mat[(st+j)%N][w];
			st = w - i;
			if(st < 0) st += N;
			rep(j,l) t2 += mat[h][(st+j)%N];
			mp[t1]++;
			mp[t2]++;
		}
	}
}

int main(){
	//FILE *outputfile;
	//outputfile = freopen("test.txt", "w", stdout);

	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> pos(0, Max_N - 1);
	uniform_int_distribution<> code(0, Max_K - 1);
	uniform_real_distribution<> R(0.0, 1.0);
	cin >> N >> M;
	s.resize(M);
	rep(i,M){
		string t;
		cin >> t;
		s[i] = P((int)t.size(), t);
	}
	sort(s.begin(), s.end());
	mat.resize(N);
	rep(i,N){
		rep(j,N){
			int k = code(mt);
			char c = 'A' + k;
			double r = R(mt);
			if(r < blank_poss) mat[i].push_back('.');
			else mat[i].push_back(c);
		}
	}
	int now_h = 0, now_w = 0;
	rep(i,M){
		string t = s[i].second;
		int siz = t.size();
		if(now_w + siz > N){
			if(now_h == N - 1) break;
			else{
				now_h++;
				now_w = 0;
			}
		}
		rep(j,siz) add(now_h, now_w + j, t[j]);
		now_w += siz;
	}
	double T0 = 1e5, T1 = 5e2;
	while(1.0 * clock() / CLOCKS_PER_SEC < TL){
		double t = 1.0 * clock() / CLOCKS_PER_SEC / TL;
		double temp = pow(T0, 1.0 - t) * pow(T1, t);
		LL now_score = score();
		int h = pos(mt), w = pos(mt);
		int k = code(mt);
		char new_c = 'A' + k;
		char old_c = mat[h][w];
		del(h, w);
		add(h, w, new_c);
		LL new_score = score();
		LL dif = new_score - now_score;
		if(dif < 0){
			double change_poss = exp(dif / temp);
			if(change_poss < R(mt)){
				del(h, w);
				add(h, w, old_c);
			}
		}
	}
	vector<string> ans(N);
	rep(i,N){
		rep(j,N) ans[i].push_back(mat[i][j]);
	}
	rep(i,N) cout << ans[i] << endl;
	//LL fin = score();
	//cout << fin << endl;

	return 0;
}

//GIVE ME AC!!!!!!!!!!!!!!!!!
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define floatset() fixed<<setprecision(15)
#define all(n) n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
#define rep(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define pb push_back
#define eb emplace_back
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
using namespace std;
using vl=vector<ll>;
using vi=vector<int>;
using vs=vector<string>;
using vc=vector<char>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using vvc=vector<vc>;
using vd=vector<double>;
using vp=vector<P>;
using vb=vector<bool>;
using P=pair<ll,ll>;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const ll inf =1e18;
const ll MOD=1000000007;
const ll mod=998244353;
const double pi=acos(-1);
template<typename T1,typename T2 >
ostream &operator<<(ostream&os,const pair<T1,T2>&p) {
  os<<p.first<<" "<<p.second;
  return os;
}
template<typename T1,typename T2>
istream &operator>>(istream&is,pair<T1,T2>&p) {
  is>>p.first>>p.second;
  return is;
}
template<typename T>
ostream &operator<<(ostream&os,const vector<T>&v) {
  for(int i=0;i<(int)v.size();i++) {
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}
template<typename T>
istream &operator>>(istream&is,vector<T>&v) {
  for(T &in:v)is>>in;
  return is;
}
void scan(){}
template<class Head,class... Tail>
void scan(Head&head,Tail&... tail) {
  cin>>head;
  scan(tail...);
}
template<class T>
void print(const T &t) { cout << t << '\n'; }
template<class Head, class... Tail>
void print(const Head &head, const Tail &... tail) {
  cout << head << ' ';
  print(tail...);
}
template<class... T>
void fin(const T &... a) {
  print(a...);
  exit(0);
}
template<typename T1,typename T2>
inline bool chmax(T1&a,T2 b){return a<b&&(a=b,true);}
template<typename T1,typename T2>
inline bool chmin(T1&a,T2 b){return a>b&&(a=b,true);}
random_device seed_gen;
mt19937 engine(seed_gen());
int main(){
  LL(n,m);
  vs a(m);
  cin>>a;
 rep(i,0,100){
  shuffle(all(a),engine);
 }
  ll now=0;
  rep(i,0,n){
    ll cnt=0;
    string ans="";
    while(cnt+(ll)(a[now].size())<=n){
      cnt+=a[now].size();
      ans+=a[now];
      now++;
    }
    rep(i,0,n-cnt){
      ll x=engine();
      x%=8;
      cout<<(char)('A'+x);
    }
    cout<<ans<<endl;
  }
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
using namespace std;
const int INF = (int) 1e9;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
vector<int> bit[30];
int n,q;
int arr[MAXN];
void upd(int pos,int val,int b){
    for(;pos<n;pos+=pos&-pos){
        bit[b][pos]+=val;
    }
}
int sum(int pos,int b){
    int ret = 0;
    for(;pos>0;pos-=pos&-pos){
        ret += bit[b][pos];
    }
    return ret;
}
void solve(){
    cin >> n >> q;
    n++;
    for(int i=0;i<30;i++){
        bit[i].assign(n,0);
    }
    for(int i=1;i<n;i++){
        cin >> arr[i];
        for(int b=0;b<30;b++){
            if((1<<b)&arr[i]){
                //cout << arr[i] << " "<< b << " ";
                upd(i,1,b);
            }
        }
        //cout << endl;
    }
    while(q--){
        int t,x,y;
        cin >> t >> x >> y;
        if(t == 1){
            int val = arr[x] ^y;
            for(int i=0;i<30;i++){
                if((1<<i) & val && !((1<<i) & arr[x])){
                    upd(x,-1,i);
                }
                if(!((1<<i) & val) && (1<<i) & arr[x]){
                    upd(x,1,i);
                }
            }
            arr[x] = val;
        }
        if(t == 2){
            int ans = 0;
            for(int i=0;i<30;i++){
                if((sum(y,i)-sum(x-1,i))%2){
                    ans+=(1<<i);
                }
            }
            cout << ans << endl;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007;
ll bit[300005];
ll update(ll idx,ll val,ll n=300005){
    idx++;
    while(idx<n){
        bit[idx]^=val;
        idx+=idx&-idx;
    }
    return 0;
}
ll getsum(ll idx){
    ll sum=0;
    if(idx<=0)
    return 0;
    while(idx>0){
        sum^=bit[idx];
        idx-=idx&-idx;
    }
    return sum;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll n,q;cin>>n>>q;
    ll arr[n];
    for(ll i=0;i<n;i++)cin>>arr[i];
    for(ll i=1;i<n;i++)arr[i]^=arr[i-1];
    ll a,b,rig,lef;
    while(q--){
        cin>>a;
        if(a==1){
            cin>>a>>b;
            update(a-1,b);
        }
        else
        {
            cin>>a>>b;
            rig=arr[b-1]^getsum(b);
            if(a-2>=0)
            lef=arr[a-2]^getsum(a-1);
            else
            lef=0;
            cout<<(rig^lef)<<endl;
        }

    }

}


#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <math.h>
using namespace std;
#define MOD 1000000007LL
#define LL long long

int n, L;

vector<int> convert(vector<int> N) {
    vector<int> R;
    int lx = 0;
    for (const auto &x : N) {
        R.push_back(x - lx - 1);
        lx = x;
    }
    R.push_back(L - lx);
    return R;
}

LL solve() {
    cin >> n >> L;
    vector<int> A(n);
    vector<int> B(n);
    for (int i = 0 ; i < n; i++) cin >> A[i];
    for (int i = 0 ; i < n; i++) cin >> B[i];
    A = convert(A);
    B = convert(B);

    int j = 0;
    LL sol = 0;
    for (int i = 0 ; i < B.size(); i++) {
        int sa = 0;
        int m1 = i;
        int m2 = i;
        while (sa < B[i] && j < A.size()) {
            sa += A[j];
            if (A[j] > 0) {
                m1 = min(m1, j);
                m2 = max(m2, j);
            }
            j++;
        }
        sol += m2 - m1;
        if (B[i] != sa) return -1;
    }
    return sol;
}

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

    int test = 1; //cin >> test;
    while(test--) {
        cout << solve() << endl;
    }

    return 0;
}

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <list>
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 100000 + 2;

int n, len;
int a[MAXN];
int b[MAXN];

map<int, pair<int, int>> awho;

int target[MAXN];

ll solve() {
	//printf("a':"); REP(i, n) printf(" %d", a[i] - i); puts("");
	//printf("b':"); REP(i, n) printf(" %d", b[i] - i); puts("");
	REP(i, n) {
		int x = a[i] - i;
		if (!awho.count(x)) { awho[x] = MP(i, i); continue; }
		assert(awho[x].second == i - 1);
		++awho[x].second;
	}
	REP(i, n) {
		if (!awho.count(b[i] - i)) return -1;
		pair<int, int> cur = awho[b[i] - i];
		if (i < cur.first) target[i] = cur.first; else if (i > cur.second) target[i] = cur.second; else target[i] = i;
	}

	ll ret = 0;
	{
		int at = 0;
		while (at < n) {
			if (target[at] <= at) { ++at; continue; }
			ret += target[at] - at;
			int to = at; while (to < n && target[to] == target[at]) ++to;
			at = to;
		}
	}
	{
		int at = n - 1;
		while (at >= 0) {
			if (target[at] >= at) { --at; continue; }
			ret += at - target[at];
			int to = at; while (to >= 0 && target[to] == target[at]) --to;
			at = to;
		}
	}

	return ret;
}

void run() {
	scanf("%d%d", &n, &len);
	n += 2;
	a[0] = b[0] = 0, a[n - 1] = b[n - 1] = len + 1;
	FOR(i, 1, n - 1) scanf("%d", &a[i]);
	FOR(i, 1, n - 1) scanf("%d", &b[i]);
	printf("%lld\n", solve());
}

int main() {
	run();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
// 型
#define ll int64_t                  // ll -> int64_t
using graph = vector<vector<int>>;  // グラフ型
// for文
#define lp(i,n) for(int i=0;i<n;i++)      // 変数 i をおいて n 回繰り返し
#define lp_(i,n) for(int i=0;i<=n;i++)    // 条件に＝つき
#define lpp(i,n,m) for(int i=n;i<m;i++)   // 開始と終了を指定して繰り返し
#define lpp_(i,n,m) for(int i=n;i<=m;i++) // 開始と終了を指定，条件に＝つき
// vector定義
#define _GLIBCXX_DEBUG
#define vec(v,n) vector<int> v(n)       // int
#define vec_(v,n,m) vector<int> v(n,m)  // int 初期条件あり
#define vec64(v,n) vector<ll> v(n)      // int64_t
#define vec64_(v,n,m) vector<ll> v(n,m) // int64_t 初期条件あり
#define vecc(v,n) vector<char> v(n)     // char
#define vecs(v,n) vector<string> v(n)   // string
#define vece(v) vector<int> v;          // int 空
#define vecec(v) vector<char> v;        // char 空
#define vec2i(v,h,w) vector<vector<int>> v(h,vector<int>(w))    // 二次元配列 int
#define vec2c(v,h,w) vector<vector<char>> v(h,vector<char>(w))  // 二次元配列 char
// vector,string操作
#define all(v) v.begin(),v.end()
#define back(v) v.back()                         // 最後の要素
#define sum(v) accumulate(all(v),0)              // 総和
#define sort(v) sort(all(v))                     // ソート
#define reverse(v) reverse(all(v))               // 反転
#define lower(v,x) lower_bound(all(v),x)         // x<=a[i]となる最小のi / a[i]<xとなるiの個数
#define cou(v,n) count(all(v),n)                 // n の出現回数を数える
#define pb(v,n) v.push_back(n)                   // 最後尾に n を追加
#define ins(v,i,n) v.insert(v.begin()+i,n)       // 場所を指定してv[i]に n を追加
#define del(v) v.pop_back()                      // 最後尾を削除
#define del0(v) v.erase(v.begin())               // 最初の要素v[0]を削除
#define del_(v,i) v.erase(v.begin()+i)           // 場所を指定してv[i]を削除
#define del__(v,i,j) v.erase(v.begin()+i,v.begin()+j+1)  // 範囲を指定してv[i]~v[j]を削除
#define sub(s,i,j) s.substr(i,j-i+1)             // 範囲を指定してs[i]~s[j]を取得【stringのみ】
// others
const ll MOD=1000000007;
const ll INF=(1LL<<60);
#define under(n) cout<<fixed<<setprecision(n) // 小数点以下の桁数を指定
#define cout(n) cout<<n<<endl

int main()
{
  ll n,m,even=0,odd=0;
  cin>>n>>m;
  lp(i,n)
  {
    bitset<25> b;
    cin>>b;
    if(b.count()%2==0)
      even++;
    else
      odd++;
  }
  ll ans=even*odd;
  cout(ans);
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
#define rep2(i, n, m) for(int i=(int)n; i<=(int)m; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll inf=1LL<<60;

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

  ll s, p;
  cin >> s >> p;
  string ans="No";
  for(ll i=1; i*i<=p; i++){
    if(p%i!=0)continue;
    if(i+p/i==s){
      ans="Yes";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
int A[55];
int P[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int B[55];
int ans = -1;
int n;
void dfs(int x){
    if(x == 15){
        int y = 1;
        for(int i = 0; i < 15; i++){
            if(B[i]){
                y *= P[i];
            }
        }
        bool flag = true;
        for(int i = 0; i < n; i++){
            if(__gcd(A[i],y) == 1){
                flag = false;break;
            }
        }
        if(flag&& (y < ans|| ans == -1))ans = y;
        return;
    }
   B[x] = 0;
   dfs(x+1);
   B[x] = 1;
   dfs(x+1);
}
signed main()
{

    sc(n)
    for(int i = 0; i < n; i++)
    {
        sc(A[i])

    }
    dfs(0);
    cout << ans <<'\n';
}


#include <stdio.h>
#include <string.h>

int ans[110][10010];
int a;
char x[110];
int y[110];

void func(int k)
{
	printf("%d\n",k);
	for(int i=0;i<=a;i++)
	{
		int s = y[i]/k;
		int t = y[i]%k;
		for(int j=1;j<=t;j++) ans[i][j] = s+1;
		for(int j=t+1;j<=k;j++) ans[i][j] = s;
	}

	for(int j=1;j<=k;j++)
	{
		for(int i=0;i<=a;i++) printf("%d ",ans[i][j]);
		printf("\n");
	}
}

int main()
{
	scanf("%d",&a);
	scanf("%s",x+1);
	for(int i=0;i<=a;i++) scanf("%d",&y[i]);

	int limit = 10000;
	for(int i=limit;i>=1;i--)
	{
		int s = y[0]/i;
		int t = y[0]%i;
		for(int j=1;j<=a;j++)
		{
			int s2 = y[j]/i;
			int t2 = y[j]%i;
			if(x[j]=='<')
			{
				if(t<t2)
				{
					if(s+1 < s2+1 && s < s2+1 && s<s2);
					else goto u;
				}
				else if(t>t2)
				{
					if(s+1 < s2+1 && s+1 < s2 && s<s2);
					else goto u;
				}
				else
				{
					if(s+1 < s2+1 && s<s2);
					else goto u;
				}
			}
			else
			{
				if(t<t2)
				{
					if(s+1 > s2+1 && s > s2+1 && s>s2);
					else goto u;
				}
				else if(t>t2)
				{
					if(s+1 > s2+1 && s+1 > s2 && s>s2);
					else goto u;
				}
				else
				{
					if(s+1 > s2+1 && s>s2);
					else goto u;
				}
			}
			s = s2;
			t = t2;
		}

		func(i);
		return 0;
		u:;
	}
}

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

int n;
int cnt1[500][500];
int cnt2[500][500];
int team[500][500];
int tgt=0;
bool deta=false;
int col[500][500];

int main(void){
	scanf("%d",&n);
	if(n==1){
		printf("1\n");
		printf("AB\n");
		return 0;
	}
	if(n==2){
		printf("3\n");
		printf("AABB\n");
		printf("ABAB\n");
		printf("ABBA\n");
		return 0;
	}
	col[0][2]=1;
	col[0][3]=1;
	col[1][1]=1;
	col[1][3]=1;
	col[2][1]=1;
	col[2][2]=1;
	int m=(1<<n);
	int s=2;
	int sz=3;
	int len=4;
	for(int i=2;i<n;i++){
		for(int j=0;j<sz;j++){
			for(int k=0;k<len;k++){
				col[j+sz][k]=col[j][k];
			}
		}
		for(int j=0;j<sz;j++){
			for(int k=0;k<len;k++){
				col[j][k+len]=col[j][k];
				col[j+sz][k+len]=1-col[j+sz][k];
			}
		}
		for(int j=0;j<len;j++){
			col[sz*2][j+len]=1;
		}
		sz=sz*2+1;
		len=len*2;
	}
	printf("%d\n",m-1);
	for(int i=0;i<m-1;i++){
		for(int j=0;j<m;j++){
			printf("%c",col[i][j]==0?'A':'B');
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;

#define LL long long
#define mem(s, v) memset(s, v, sizeof s)
#define FILEIN(s) freopen(s".in", "r", stdin)
#define FILEOUT(s) freopen(s".out", "w", stdout)

inline LL read(void) {
	LL x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return f * x;
}

const int maxn = 4e5 + 5;

int n;
long long a[maxn], b[maxn];
int c[maxn], d[maxn];

vector<int>vec[maxn];

bool lsh(void) {
	int tot = 0;
	for (int i = 1; i <= n; ++ i) {
		c[i] = a[i] + i;
		d[i] = b[i] + i;
	}
	sort(c + 1, c + n + 1); sort(d + 1, d + n + 1);
	for (int i = 1; i <= n; ++ i) if (c[i] != d[i]) return false;
	tot = 0;
	for (int i = 1; i <= n; ++ i) c[++ tot] = a[i] + i;
	for (int i = 1; i <= n; ++ i) c[++ tot] = b[i] + i;
	sort(c + 1, c + tot + 1);
	tot = unique(c + 1, c + tot + 1) - c - 1;
	for (int i = n; i >= 1; -- i) {
		a[i] = lower_bound(c + 1, c + tot + 1, a[i] + i) - c;
		vec[a[i]].push_back(i);
		b[i] = lower_bound(c + 1, c + tot + 1, b[i] + i) - c;
	}
	return true;
}

int tr[maxn];

inline int lowbit(int x) { return x & (-x); }

inline void add(int p, int v) {
	for (; p <= n; p += lowbit(p)) tr[p] += v;
}

inline int query(int p) {
	int res = 0;
	for (; p; p -= lowbit(p)) res += tr[p];
	return res;
}

int main() {
	n = read();
	for (int i = 1; i <= n; ++ i) {
		a[i] = read();
	}
	for (int i = 1; i <= n; ++ i) {
		b[i] = read();
	}
	if (!lsh()) {
		puts("-1"); return 0;
	}

	long long ans = 0;
	for (int i = 1; i <= n; ++ i) {
		int tmp = vec[b[i]].back(); vec[b[i]].pop_back();
		ans += tmp + query(tmp) - i;
		add(1, 1);
		add(tmp + 1, -1);
	}
	printf("%lld\n", ans);
	return 0;
}

#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=1;i<=(n);++i)
#define rep3(i,i0,n) for(ll i=i0;i<(n);++i)
#define rrep(i,n) for(ll i=((n)-1); i>=0; --i)
#define rrep2(i,n) for(ll i=(n); i>0; --i)
#define pb push_back
#define mod 1000000007
#define fi first
#define se second
#define len(x) ((ll)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
using Pi = pair< ll, ll >;
using vl = vector<ll>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<Pi>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

const ll INF = 1LL << 60;
const ld PI = 3.1415926535897932385;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
void printb(ll N,ll d=16){
    rep(i,d){
        cout<<(N/(1<<(d-i-1)))%2;
    }
    cout<<endl;

}
void printv(vector<ll>a){
    rep(i,a.size()){
        if(i==a.size()-1){
            cout<<a[i]<<endl;
        }else{
            cout<<a[i]<<" ";
        }
    }
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;

    }else{
        return a.second < b.second;
    }
}

//const vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1};
//const vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<mod>;
using vm = vector<mint>;
using vvm = vector<vector<mint>>;
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll N,P;
    cin>>N>>P;
    mint ans=modpow(P-2,N-1);
    ans*=(P-1);

    cout<<ans.a<<endl;

    return 0;

}


# include<bits/stdc++.h>
using namespace std;
int main()
{
  int m,n,i,j;
  cin>>m>>n;
  int a[m][n];
  int min=99999999;
  int res=0;
  for (i=0;i<m;i++)
  {
    for (j=0;j<n;j++)
    {
      cin>>a[i][j];
      if (a[i][j]<min){min=a[i][j];}
    }
  }
  for (i=0;i<m;i++)
  {
    for (j=0;j<n;j++)
    {
      res+=(a[i][j]-min);
    }
  }
  cout<<res;
  return 0;
}

#include <bits/stdc++.h>
#define task "triangles"
#define pb push_back
#define pll pair<ll, ll>
#define pii pair< ll, pll>
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;

const int N = 555;
const ll mod = 1e15+7;
const ll ex = 1e5;

ll n, m, t, k, tong, a[N][N], b[N][N], T, ans, c[N][N], d[32][3], h[N], lo;
vector<ll> adj[N], kq;
string s, res;

void sol()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j < m; j ++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 1; i < n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            cin >> b[i][j];

        }
    }
    for(int i = 1; i <= n; i ++)for(int j = 1; j <= m; j ++)c[i][j] = mod;
    priority_queue< pii, vector<pii>, greater<pii> > pq;
    pii x;
    x.fi = 0;
    x.se.fi = 1;
    x.se.se = 1;
    pq.push(x);
    c[1][1] = 0;
    while(!pq.empty())
    {
        pii u = pq.top();
        pq.pop();
        if(u.fi != c[u.se.fi][u.se.se])continue;
        //cout << u.se.fi <<" " << u.se.se<<'\n';
        if(u.se.fi == n && u.se.se == m)
        {
            cout << u.fi;
            return;
        }
        if(u.se.se < m && c[u.se.fi][u.se.se + 1] > u.fi + a[u.se.fi][u.se.se])
        {
            c[u.se.fi][u.se.se + 1] = u.fi + a[u.se.fi][u.se.se];
            pii v;
            v.fi = u.fi + a[u.se.fi][u.se.se];
            v.se.fi = u.se.fi;
            v.se.se = u.se.se+1;
            pq.push(v);
        }
        if(u.se.se > 1 && c[u.se.fi][u.se.se - 1] > u.fi + a[u.se.fi][u.se.se-1])
        {
            c[u.se.fi][u.se.se - 1] = u.fi + a[u.se.fi][u.se.se-1];
            pii v;
            v.fi = u.fi + a[u.se.fi][u.se.se-1];
            v.se.fi = u.se.fi;
            v.se.se = u.se.se-1;
            pq.push(v);
        }
        if(u.se.fi < n && c[u.se.fi+1][u.se.se] > u.fi + b[u.se.fi][u.se.se])
        {
            c[u.se.fi+1][u.se.se] = u.fi + b[u.se.fi][u.se.se];
            pii v;
            v.fi = u.fi + b[u.se.fi][u.se.se];
            v.se.fi = u.se.fi+1;
            v.se.se = u.se.se;
            pq.push(v);
        }
        for(int i = 1;i < u.se.fi; i ++)
        {
            if(c[u.se.fi-i][u.se.se] > u.fi + i + 1)
            {
                c[u.se.fi-i][u.se.se] = u.fi + i + 1;
                pii v;
                v.fi = u.fi + i + 1;
                v.se.fi = u.se.fi - i;
                v.se.se = u.se.se;
                pq.push(v);
            }
        }
    }

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

    if (fopen(task".in", "r"))
        freopen(task".in", "r", stdin),
            freopen(task".out", "w", stdout);

    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}
/*
3 4
1 (
3 )
2 )
3 )

-1 0 1 0 -1
*/


#include <bits/stdc++.h>

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 505;
int n, a[MX][MX];

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

	cin >> n;
	forn (i, n)
		forn (j, n) {
			cin >> a[i][j];

			if (i && j)
				if (a[i][j] - a[i][j - 1] != a[i - 1][j] - a[i - 1][j - 1]) {
					cout << "No" << endl;
					return 0;
				}
		}

	int ind = 0;
	forn (i, n)
		if (a[i][0] < a[ind][0])
			ind = i;

	cout << "Yes" << endl;

	forn (i, n)
		cout << a[i][0] - a[ind][0] << " ";
	cout << endl;

	forn (i, n)
		cout << a[ind][i] << " ";
	cout << endl;

	return 0;
}

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <complex>
using namespace std;
#define all(v) v.begin(),v.end()
#define GS std::greater<int>()
#define FOR(i,l,r) for(Int i=(l);i<(r);i++)
#define DCOUT cout<<fixed<<setprecision(15) //DCOUT<<d<<endl;
#define ROUNDUP(a,b) ((a)+((b)-1))/(b)
#define TDVEC(name,type,h,w) vector<vector<type>>name((h),vector<type>(w))
#define P pair<Int,Int>
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define PI 3.1415926535897932384626433832795028
#define itn int
#define space ' '
typedef long long Int;
typedef unsigned long long uInt;
typedef long double ld;
Int gcd(Int a,Int b){return b?gcd(b,a%b):a;}
Int lcm(Int a,Int b){return a/gcd(a,b)*b;}

int main(){
	Int r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2;
	if(r1==r2&&c1==c2){cout<<0<<endl;return 0;}
	if(abs(r1-r2)+abs(c1-c2)<=3||(r1+c1==r2+c2)||(r1-c1==r2-c2)){cout<<1<<endl;return 0;}
	if((r1+c1)%2==(r2+c2)%2||abs(abs(r1-r2)-abs(c1-c2))<=3||abs(r1-r2)+abs(c1-c2)<=6){cout<<2<<endl;return 0;}
	cout<<3<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 1000 + 5;
char grid[MAX][MAX], grid_cpy[MAX][MAX];
bool line_unblocked[MAX], column_unblocked[MAX];
int n, m;

void unblock(int x, int y);

void unblock_line(int x) {
    if (line_unblocked[x]) return;
    line_unblocked[x] = true;
    fori (i, 1, m + 1) {
        if (grid[x][i] == '#') unblock(x, i);
    }
}

void unblock_column(int y) {
    if (column_unblocked[y]) return;
    column_unblocked[y] = true;
    fori (i, 1, n + 1) {
        if (grid[i][y] == '#') unblock(i, y);
    }
}

void unblock(int x, int y) {
    unblock_line(x);
    unblock_column(y);
}

void solve() {
    cin >> n >> m;
    fori (i, 1, n + 1) fori (j, 1, m + 1) cin >> grid[i][j];

    grid[1][1] = grid[1][m] = grid[n][1] = grid[n][m] = '#';
    memcpy(grid_cpy, grid, sizeof(char) * MAX * MAX);

    int line_cost = 0;
    unblock(1, 1);
    fori (i, 1, n + 1) {
        if (!line_unblocked[i]) {
            grid[i][1] = '#';
            line_cost++;
            unblock(i, 1);
        }
    }

    memcpy(grid, grid_cpy, sizeof(char) * MAX * MAX);
    memset(line_unblocked, false, sizeof line_unblocked);
    memset(column_unblocked, false, sizeof column_unblocked);

    int column_cost = 0;
    unblock(1, 1);
    fori (i, 1, m + 1) {
        if (!column_unblocked[i]) {
            grid[1][i] = '#';
            column_cost++;
            unblock(1, i);
        }
    }

    cout << min(line_cost, column_cost) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}

#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> Alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  cout << fixed << setprecision(10);
  ll a,b;
  cin >> a >> b;
  if(abs(a-b)<3) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int> n
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = (sizeof(int) == 4 ? 1e9 : 2e18) + 1e5;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

string print(__int128_t x) {
  if (x == 0)
    return "0";
  bool neg = false;
  if (x < 0) {
    neg = true;
    x *= -1;
  }
  string ans;
  while (x) {
    ans += char(x % 10 + '0');
    x /= 10;
  }

  if (neg)
    ans += "-";
  reverse(all(ans));
  return ans;
}

// #define MULTIPLE_TEST_CASES
void solve() {
  int x, y, a, b;
  cin >> x >> y >> a >> b;

  auto check = [&](__int128_t mid) {
    __int128_t maxx = 0;
    for (__int128_t xo = x, exp = 0; xo < y; xo *= a, ++exp) {
      __int128_t expo = exp;
      expo += (y - 1 - xo) / b;
      maxx = max(maxx, expo);
    }
    return maxx;
  };

  cout << print(check(x)) << endl;
}

signed main() {
  // const string FILE_NAME = "";
  // freopen((FILE_NAME + string(".in")).c_str(), "r", stdin);
  // freopen((FILE_NAME + string(".out")).c_str(), "w", stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll x,y,a,b;cin >> x >> y >> a >> b;
    ll ans=0;
    if(x>=y/a)cout << ans+(y-1-x)/b <<endl,exit(0);
    while(true){
        if(x>=y/a)cout << ans+(y-1-x)/b <<endl,exit(0);
        if(x>=(x+b)/a)cout << ans+(y-1-x)/b <<endl,exit(0);
        else {
            ans++;
            x=x*a;
        }
    }
}


#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pld> vpld;
typedef unordered_map<int, int> mpii;

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

	cout << fixed;
	cout.precision(17);

	ll k; cin >> k;
	cin.ignore();
	string s; getline(cin, s);
	string t; getline(cin, t);

	vl vec(10, k);
	unordered_map<int, int> S, T;
	for (const auto &a : s) S[a - '0']++, vec[a - '0']--;
	for (const auto &a : t) T[a - '0']++, vec[a - '0']--;

	auto calc = [](auto &cnt) {
		ll ret = 0;
		for (int i = 1; i <= 9; i++) ret += i * powl(10, cnt[i]);
		return ret;
	};

	ll ans = 0;
	for (int i = 1; i <= 10; i++) {
		if (!vec[i]) continue;
		--vec[i];
		for (int j = 1; j <= 10; j++) {
			if (!vec[j]) continue;
			S[i]++;
			T[j]++;
			if (calc(S) > calc(T)) { //ok win
				if (i == j) ans += vec[i] * (vec[i] + 1);
				else ans += (vec[i] + 1) * vec[j];
				//cout << i << " " << j << "\n";
			}
			S[i]--;
			T[j]--;
		}
		++vec[i];
	}

	ld cnt = 9 * k - 8;
	cout << ans / (cnt * (cnt - 1));
}

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

int main(){
  ll n;
  cin >> n;
  set<ll> s;

  for(ll a=2 ; a*a <= n; ++a){
    ll x = a*a;
    while(x <= n){
      s.insert(x);
      x *= a;
    }
  }
  ll ans = n-s.size();
  cout << ans << endl;
  return 0;
}


#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstring>
#include <regex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <unordered_set>
#include <queue>
#include <unordered_map>
#include <set>
#include <cassert>
#include <climits>
#include <bitset>
#include <numeric>

#pragma GCC optimize("O3")

using namespace std;
using ll = long long;
using ull = unsigned long long;
template<typename Key, typename Value>
using umap = std::unordered_map<Key, Value>;
template<typename Key>
using uset = std::unordered_set<Key>;

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repd(i, n) for(ll i = (n) - 1ll; i >= 0; --i)
#define rep1(i, n) for(ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define repd1(i, n) for(ll i = (n); i > 0; --i)
#define FOR(i, a, b) for(ll i = a; i < ll(b); ++i)
#define FORD(i, a, b) for(ll i = a; i > ll(b); --i)
#define foreach(i, itr) for(auto& i : (itr))
// 小さい順
#define asort(arr, size) std::sort((arr), (arr) + (size))
// 大きい順
#define dsort(arr, size) std::sort((arr), (arr) + (size), [](auto a, auto b) { return a > b; })
#define vsort(vec) std::sort((vec).begin(), (vec).end());
#define rsort(vec) std::sort((vec).begin(), (vec).end(), [](auto a, auto b) { return a > b; });
#define bit(n) (1LL << (n))

// 行数多く出力するとき用

inline void println(int n) {
    printf("%d\n", n);
}
inline void println(ll n) {
    printf("%lld\n", n);
}
inline void println(ull n) {
    printf("%llu\n", n);
}

inline void println(int* n, size_t size) {
    FOR(i, 0, size - 1) {
        printf("%d ", n[i]);
    }
    printf("%d\n", n[size - 1]);
}
inline void println(ll* n, size_t size) {
    FOR(i, 0, size - 1) {
        printf("%lld ", n[i]);
    }
    printf("%lld\n", n[size - 1]);
}
inline void println(ull* n, size_t size) {
    FOR(i, 0, size - 1) {
        printf("%llu ", n[i]);
    }
    printf("%llu\n", n[size - 1]);
}

////////////////////////////////////
////////////////////////////////////

int main() {
    ll N;
    cin >> N;
    ll n = 1;
    ll i = 1;
    while (n < N) {
        ++i;
        n += i;
    }

    cout << i << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;
const int MAX32 = 2147483647;
const long long MAX64 = 9223372036854775807;
const double PI = 3.14159265358979323846;

int main() {
  long long n, i = 0;
  cin >> n;
  while (n > 0) {
    n -= ++i;
  }
  cout << i << endl;
}


#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define PI 3.14159265359
#define fi fixed
#define se setprecision(10)
using namespace std;

int main() {
  int N;cin >> N;
  N = N % 100;
  cout << 100 - N << endl;
}

#include <iostream>
using namespace std;

int main() {
  long X;
  cin >> X;
  long Y = 100 - (X % 100);
  cout << Y << endl;
}


/**
*    author: zakhio (mttk1528)
*    created: 31.01.2021 15:25:52
**/
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;

#define dump(x) cout << #x << " = " << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define len(x) (int)(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pcnt __builtin_popcount
#define rup(x, y) ((x + y - 1) / (y))

using str = string;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pldld = pair<ld,ld>;
// using bint = boost::multiprecision::cpp_int;

constexpr ld PI = M_PI;
constexpr ld EPS = 1e-10;
constexpr ll LINF = 1e18;
constexpr int INF = 1e9;
constexpr int MAX = 2000020;
constexpr int MOD1 = 1000000007;
constexpr int MOD2 = 998244353;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};
const int di2[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj2[8] = {1, 0, -1, 0, 1, -1, 1, -1};

constexpr ld radian_to_degree(ld r) { return (r * 180.0 / PI); }
constexpr ld degree_to_radian(ld d) { return (d * PI / 180.0); }
inline bool eq(ld lhs, ld rhs) { return std::fabs(lhs - rhs) < EPS; }
inline void print() { cout << endl; return; }

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail)) cout << " "; print(forward<Tail>(tail)...); }
template <typename T, typename U> inline bool chmax(T &lhs, U rhs) { if (lhs < rhs) { lhs = rhs; return true; } return false; }
template <typename T, typename U> inline bool chmin(T &lhs, U rhs) { if (lhs > rhs) { lhs = rhs; return true; } return false; }
template <typename T> inline T gcd_all(vector<T> &v) { return reduce(all(v), v[0], [] (T x, T y) { return gcd(x, y); }); }
template <typename T> inline T lcm_all(vector<T> &v) { return reduce(all(v), v[0], [] (T x, T y) { return lcm(x, y); }); }
template <typename T> inline T bpow(T a, int n) { T r(1); while (n) { if (n & 1) r *= a; a *= a; n >>= 1; } return r; }
template <typename T> inline auto comp(vector<T> v) { sort(all(v)); v.erase(unique(all(v)), v.end()); return v; }
template <typename T> inline string join(string s, vector<T> v) { string t = ""; rep(i, len(v)) { if (i) t += s; t += to_string(v[i]); } return t; }
template <typename T> inline ld eucdist(pair<T,T> x, pair<T,T> y) { return hypotl(x.first - y.first, x.second - y.second); }

template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T,U> &p) { return os << p.first << " " << p.second;}
template <typename T, typename U> istream &operator>>(istream &is, pair<T,U> &p) { return is >> p.first >> p.second; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, len(v)) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &st) { int c(0); for (auto &x : st) { if (c) os << " "; os << x; c++; } return os;}

void solve() {

    int n; cin >> n;
    ll tnum = 1, fnum = 1;
    rep(i, n) {
        string s; cin >> s;
        if (s == "OR") {
            tnum += tnum + fnum;
        }
        else {
            fnum += tnum + fnum;
        }
    }
    print(tnum);

    return;
}

int main() {

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);

    solve();

    return 0;
}

#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////
#include <iostream>
using namespace std;
#define dp(arg) do { cout << #arg << ":"; dprint(arg); } while(0)

template <typename T> void dprint(T arg) { cout << arg << "\n"; }
template <typename T> void dprint(const vector<T>& arg) { for_each(begin(arg), end(arg), [](T value){ cout << value << " "; }   ); cout << "\n";  }
template <typename T> void dprint(const vector<vector<T>>& arg) { for_each(begin(arg), end(arg), [=](vector<T> arg2){ dprint(arg2); cout << "\n";} );  }

//////////////////////////////////////
#define ll long long int

// sigma 1 to n
ll sigma1(ll n){
    return n*(n+1)/2;
}

int main(int argc, char *argv[]) {
    int h,w, n, m;
    cin >> h>>w >> n>> m;
    int maze[h][w];
    int visited[h][w][4];
    REP(hh,h){
        REP(ww, w){
            maze[hh][ww] = 0;
            visited[hh][ww][0] = 0;
            visited[hh][ww][1] = 0;
            visited[hh][ww][2] = 0;
            visited[hh][ww][3] = 0;
        }
    }
    vector<int> data;
    vector<int> datb;
    vector<int> datc;
    vector<int> datd;
    int a,b,c,d;
    REP(i, n){ cin >>a>>b; --a;--b; data.push_back(a); datb.push_back(b); }
    REP(i, m){ cin >>c>>d; --c;--d; maze[c][d] = 1; }
    int dh[4] = {-1, 0, 1,0};
    int dw[4] = {0, 1, 0, -1};
    int oa, ob, nh, nw;
    int flag;
    REP(iii, n){
        oa = data[iii];
        ob = datb[iii];
        a = oa;
        b = ob;
        maze[a][b] = 2;
        REP(dir, 4){
            a = oa;
            b = ob;
            //cout << "cnt" << a << b << dir<< endl;
            flag = 1;
            while(flag) {
                //cout << "gogo" << a << b << dir<< endl;
                maze[a][b] = 2;
                if(visited[a][b][dir] == 1) break;
                visited[a][b][dir] = 1;
                nh = a + dh[dir];
                nw = b + dw[dir];
                if (nh < 0 || (h - 1) < nh)  break;
                if (nw < 0 || (w - 1) < nw)  break;
                if (maze[nh][nw] != 1 && visited[nh][nw][dir] == 0){
                    a = nh;
                    b = nw;
                } else break;
            }

        }
    }
    int res = 0;
    REP(hh,h){
        REP(ww, w){
            if(maze[hh][ww] == 2){
                res++;
            }
        }
    }
    cout << res;

}


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

void cout_line(vector<int> &a){
    for(int i=0;i<a.size();i++){
        if(i<a.size()-1){
            cout<<a.at(i)<<" ";
        }else{
            cout<<a.at(i)<<endl;
        }
    }
}

bool check(int start, int up_floor, map<int, int> &A_map, map<int, int> &B_map, int &wild_card){
    for(int i=start;i<start+up_floor;i++){
        int from = i;
        int to = i+up_floor;
        if(A_map.count(to)){
            return false;
        }
        if(B_map.count(from)){
            return false;
        }

        if((!A_map.count(from))&&(!B_map.count(to))){
            wild_card--;
            continue;
        }

        if(A_map.count(from)){
            if(A_map[from]!=-1 && A_map[from]!=to){
                return false;
            }
        }
        if(B_map.count(to)){
            if(B_map[to]!=-1 && B_map[to]!=from){
                return false;
            }
        }

    }
    if(wild_card<0){
        return false;
    }

    return true;
}

signed main(){
    int N; cin>>N;
    vec_int A(N);
    vec_int B(N);
    rep(i,N)cin>>A.at(i)>>B.at(i);
    map<int, int> A_map;
    rep(i,N)if(A.at(i)!=-1)A_map[A.at(i)]=B.at(i);

    map<int, int> B_map;
    rep(i,N)if(B.at(i)!=-1)B_map[B.at(i)]=A.at(i);

    int wild_card = 0;
    rep(i,N)if(A.at(i)==-1&&B.at(i)==-1)wild_card++;

    rep(i,N){
        if(A.at(i)>=0&&B.at(i)>=0){
            if(A.at(i)>=B.at(i)){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    set<int> num_set;
    rep(i,N){
        if(A.at(i)!=-1){
            if(num_set.count(A.at(i))){
                cout<<"No"<<endl;
                return 0;
            }else{
                num_set.insert(A.at(i));
            }
        }
        if(B.at(i)!=-1){
            if(num_set.count(B.at(i))){
                cout<<"No"<<endl;
                return 0;
            }else{
                num_set.insert(B.at(i));
            }
        }

    }

    set<P> start_set;

    queue<P> que;
    que.emplace(1, wild_card);

    while(!que.empty()){
        int start_floor, count; tie(start_floor, count) = que.front(); que.pop(); //start_floorは必ず奇数

        int max_up = (2*N-start_floor+1)/2;
        for(int i=1;i<=max_up;i++){
            int num = count;
            if(check(start_floor, i, A_map, B_map, num)){
                if(i==max_up){
                    cout<<"Yes"<<endl;
                    return 0;
                }
                int next = start_floor+i*2;
                if(!start_set.count(make_pair(next, num))){
                    start_set.insert(make_pair(next,num));
                    que.emplace(next,num);
                }
            }
        }
    }
    cout<<"No"<<endl;

    return 0;
}

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

int main(){
    int n;	cin >> n;
  	while(n%10==0 && n!=0)	n /= 10;
  	auto s = to_string(n);
  	int t = (int)s.size();
  	bool f = true;
  	for (int i=0;i<t/2;i++){
      	if(s[i]!=s[t-1-i])	f = false;
    }
  	if(f)	cout << "Yes" << endl;
  	else	cout << "No" << endl;
    return 0;
}


#include <cstdio>

int val[4];

int main()
{
	scanf("%d%d%d%d", &val[0], &val[1], &val[2], &val[3]);
	int sum = val[0] + val[1] + val[2] + val[3];
	bool flag = false;
	for (int i = 0; i < 16; ++i)
	{
		int tmp = 0;
		for (int j = 0; j < 4; ++j) if (1 << j & i) tmp += val[j];
		if (tmp * 2 == sum)
		{
			flag = true;
			break;
		}
	}
	if (flag) printf("Yes");
	else printf("No");
	return 0;
}

#include <bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    vi a(4);
    forn(i, 4) cin >> a[i];
    bool ok = false;
    forn(mask, 1 << 4) {
        int s = 0;
        forn(i, 4) (s += a[i] * ((mask >> i) & 1 ? 1 : -1));
        ok |= s == 0;
    }
    cout << (ok ? "Yes" : "No") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
#define M 88

ll n;

ll f[M];

int m,g[M];

std::vector<int> ans;

int main(){
	f[1]=f[2]=1;
	for(int i=3;i<M;i++)
		f[i]=f[i-1]+f[i-2];
	scanf("%lld",&n);
	for(int i=M-1;i;i--)
		if(n>=f[i]){
			if(!m)
				m=i;
			g[i]=n/f[i];
			n%=f[i];
		}
	for(int i=1;i<m;i++){
		while(g[m-i+1]--)
			ans.push_back((i&1)^(m&1)?2:1);
		ans.push_back((i&1)^(m&1)?3:4);
	}
	printf("%d\n",ans.size());
	for(auto i:ans)
		printf("%d\n",i);
}

#include <iostream>
#include <vector>

using ll = long long;

int const sigma = 86;
//int const sigma = 6;
ll fib[1 + sigma];
int seen[1 + sigma];

ll eval(std::vector<int> sol) {
  ll x = 0, y = 0;

  for(int i = 0; i < sol.size(); i++) {
    int op = sol[i];
    if(op == 1)
      x++;
    else if(op == 2)
      y++;
    else if(op == 3)
      x += y;
    else
      y += x;
  }
  return x;
}
int main() {
  ll n;
  std::cin >> n;
  fib[0] = fib[1] = 1;
  for(int i = 2; i <= sigma; i++)
    fib[i] = fib[i - 2] + fib[i - 1];
  for(int i = sigma; 0 <= i; i--)
    if(fib[i] <= n) {
      n -= fib[i];
      seen[i] = 1;
    }
  int op = 3;
  std::vector<int> sol;
  for(int i = sigma; 0 <= i; i--) {
    if(seen[i] == 1)
      sol.push_back(op - 2);
    sol.push_back(op);
    op = 7 - op;
  }

  std::cout << sol.size() << '\n';
  for(int i = 0; i < sol.size(); i++)
    std::cout << sol[i] << '\n';
  return 0;
}


#include<bits/stdc++.h>
#define  ll long long
typedef unsigned long long ull;
using namespace std;
const int Max=1e6+20;
const int Maxn=1e7+20;
const int mod=1e9+7;
const int c=231;
inline int read()
{
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1;}
    while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}
    while(ch>='0'&&ch<='9');return x*f;
}

int main()
{
   int t=read();
   ll n;
   while(t--)
   {
       cin>>n;
       if(n%4==0) cout<<"Even"<<endl;
       else if(n%2==0) cout<<"Same"<<endl;
       else cout<<"Odd"<<endl;
   }
   return 0;

}

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

long long int MAX = 21;
std::pair<long long int, long long int> func(long long int k, long long int s, long long int t)
{
	if(s<t)
	{
		if(s==0)
		{
			if(k%t==0) return std::make_pair(0,-(k/t));
			else return std::make_pair(0,0);
		}

		long long int a = t/s;
		std::pair<long long int, long long int> P = func(k,s,t%s);
		std::pair<long long int, long long int> ans = std::make_pair(P.first+a*P.second,P.second);
		ans.first += t, ans.second += s;
		long long int n1 = ans.first/t;
		long long int n2 = ans.second/s;
		long long int m = n1<n2?n1:n2;
		ans.first -= m*t, ans.second -= m*s;
		return ans;
	}
	else
	{
		if(t==0)
		{
			if(k%s==0) return std::make_pair((k/s),0);
			else return std::make_pair(0,0);
		}

		long long int a = s/t;
		std::pair<long long int, long long int> P = func(k,s%t,t);
		std::pair<long long int, long long int> ans = std::make_pair(P.first,P.second+a*P.first);
		ans.first += t, ans.second += s;
		long long int n1 = ans.first/t;
		long long int n2 = ans.second/s;
		long long int m = n1<n2?n1:n2;
		ans.first -= m*t, ans.second -= m*s;
		return ans;
	}
}

long long int gcd(long long int a, long long int b)
{
	return a?gcd(b%a,a):b;
}
long long int lcm(long long int a, long long int b)
{
	return (a/gcd(a,b))*b;
}

int main()
{
	for(int i=1;i<=17;i++) MAX *= 10;
	int T;
	scanf("%d",&T);
	while(T--)
	{
		long long int a,b,c,d;
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		long long int ans = MAX;
		for(long long int i = c-a-b+1;i<=c+d-a-1;i++)
		{
			long long int t;
			if(i==0)
			{
				long long int s1 = a;
				long long int s2 = c;
				t = s1>s2?s1:s2;
			}
			else
			{
				std::pair<long long int, long long int> P = func(i,2*a+2*b,c+d);
				if(P.first==0&&P.second==0) continue;

				long long int s1 = P.first * (2*a+2*b) + a;
				long long int s2 = P.second * (c+d) + c;
				t = s1>s2?s1:s2;
			}
			t %= lcm(2*a+2*b,c+d);
			ans = ans<t?ans:t;
		}
		if(ans==MAX) printf("infinity\n");
		else printf("%lld\n",ans);
	}
}


#include<cstdio>
using namespace std;
int a,b;
int main()
{
	scanf("%d %d",&a,&b);
	printf("%d",a/b);
	return 0;
}

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

int main(){
  int minv=100;
  vector<int> a(4);

  for (int i = 0; i < 4; ++i) cin >> a[i];

  for (int i = 0; i < 4; ++i){
    if (minv > a[i]) minv = a[i];
  }
  cout << minv << endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int main() {
	int n; cin >> n;
	double a1 = 0.0, a2 = 0.0, a3 = 0.0;
	ll m = 0, s1 = 0, s2 = 0;
	rep(i, n) {
		ll temp; cin >> temp;
		temp = max(temp, -temp);
		m = max(temp, m);
		s1 += temp;
		s2 += temp * temp;
	}
	a1 = s1;
	a2 = sqrt(s2);
	a3 = m;
	cout << setprecision(15) << a1 << endl;
	cout << setprecision(15) << a2 << endl;
	cout << setprecision(15) << a3 << endl;
}

#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.push_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}
template<typename T_vector>
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());

    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fio;
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        ll p = 2;
        ll curr = 2;
        ll x = 1, cnt = 0;
        // while(1)
        // {
        //     x = 1;
        //     if(pow(2, p) > n)
        //     break;
        //    while(x <= n)
        //    {
        //        x = (ll)pow(curr, p);
        //         curr++;
        //         cnt++;
        //         // cout << x << " ";
        //    }
        //    cnt--;
        // //    cout << endl;
        //    curr = 2;
        // p++;
        // }
        set<ll> s;
        for(ll i = 2; i <= 40; i++)
        {
            for(ll j = 2; (ll)pow(j, i) <= n; j++)
            {
                s.insert((ll)pow(j, i));
                cnt++;
            }
        }
        cout << n - (ll)s.size() << endl;
    }
    cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define all(v) v.begin(), v.end()

bool func(vector<int> x, vector<int> y, int N){
    for(int i = 0; i < N-2; i++){
        for(int j = i+1; j < N-1; j++){
            for(int k = j+1; k < N ; k++){
                if((x.at(j) - x.at(i)) * (y.at(k) - y.at(i)) == (x.at(k) - x.at(i)) * (y.at(j) - y.at(i)))
                    return true;
            }
        }
    }
    return false;
}
int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    rep(i, N) cin >> x.at(i) >> y.at(i);
    if(func(x, y, N)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(intt i=0;i<(intt)(n);i++)
#define rept(i,n) for(intt i=1;i<(intt)(n);i++)
#define all(x) (x).begin(),(x).end()
#define siz(s) (s).size()
using intt = int64_t;
using ldou = long double;
intt gcd(intt a,intt b){if(a%b==0){return b;}else{return gcd(b,a%b);}}//最大公約数
intt lcm(intt a,intt b){return a*b/gcd(a,b);}//最小公倍数
intt sum(const long &a,const long &b){return(a+b)*(b-a+1)/2;}//合計
vector<long long>enu(long long N){vector<long long>res;for(long long i=1;i*i<=N;++i){if(N%i==0){res.push_back(i);if(N/i!=i)res.push_back(N/i);}}sort(res.begin(),res.end());return res;}//約数全部
intt sumi(intt n){int x=0;while(n>=10){x+=n%10;n/=10;}x+=n;return x;}//各桁の和
bool sque(long long N){long long r=(long long)floor(sqrt((long double)N));return(r*r)==N;}//平方数
#include <cmath>
bool integ(double x){return std::floor(x)==x;}
void strsort(vector<string>&S){map<int,int>SwapInd;int maxi=0;for(int i=0;i<S.size();i++){if(S[i].size()>maxi)maxi=S[i].size();}for(int i=0;i<maxi;i++){int k=maxi-i;int sort_num=0;for(int j=0;j<S.size();j++){if(S[j].size()>=k){SwapInd[j]=1;sort_num++;}}int swapped=0;for(int j=0;j<S.size();j++){if(SwapInd[j]==1&&j<S.size()-sort_num){if(SwapInd[S.size()-sort_num+swapped]==0){iter_swap(S.begin()+j,S.begin()+S.size()-sort_num+swapped);}else{while(SwapInd[S.size()-sort_num+swapped]!=0){swapped++;if(S.size()-sort_num+swapped>=S.size()){break;}if(S.size()-sort_num+swapped<S.size()){iter_swap(S.begin()+j,S.begin()+S.size()-sort_num+swapped);}}}
     SwapInd[j]=0;SwapInd[S.size()-sort_num+swapped]=0;swapped++;}}vector<string>WhatSorted(sort_num);vector<pair<int,int>>char_and_index(sort_num);for(int j=0;j<sort_num;j++){if(S[S.size()-sort_num+j][k-1]>=65&&S[S.size()-sort_num+j][k-1]<=90){char_and_index[j].first=(int)S[S.size()-sort_num+j][k-1]+32;}else{char_and_index[j].first=(int)S[S.size()-sort_num+j][k-1];}char_and_index[j].second=j;WhatSorted[j]=S[S.size()-sort_num+j];}stable_sort(char_and_index.begin(),char_and_index.end());for(int j=0;j<sort_num;j++){S[S.size()-sort_num+j]=WhatSorted[char_and_index[j].second];}}}
int main() {
cout << fixed << setprecision(20);
int t;
cin>>t;
t+=100;
intt n;
cin>>n;
set<intt> a;
rept(i,101){
     intt x=i*t/100;
     a.insert(x);
}
vector<intt> b;
rept(i,t+1){
     if(a.count(i)){
     }
     else{
          b.push_back(i);
     }
}
intt x,y;
n--;
x=n/siz(b);
y=n%siz(b);/*
if(y==0){
     y+=siz(b)-1;
}
else{
     y--;
}*/
intt ans=x*t+b.at(y);
cout<<ans<<endl;
}


#include "bits/stdc++.h"
#include <chrono>
#include <random>

#define INF 1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NIL 0

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef unordered_map<int,int> umi ;
typedef unordered_set<int> usi ;
typedef pair<int,int> pi;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

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

bool ldequal(ld  a ,ld b){
    return abs(a-b) < 1e-9  ;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// shuffle(permutation.begin(), permutation.end(), rng); for permute
// uniform_int_distribution<int>(0, i)(rng) for rand

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

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

const ll N =1e18+1;

void gen(){} ;
bool tests=false ;

void solve(){
    unordered_map<ll,ll ,custom_hash> M ;
    ll e=0 ,o=0 ;
    M[0]++ ;
    int n ;
    cin>>n ;
    ll res =0 ,temp;
    REP(i,0,n){
        cin>>temp;
        if(i%2==0) e+=temp ;
        else o+=temp ;
        debug(i,e,o,temp,M[e-o]) ;
        res+=M[e-o] ;
        M[e-o]++ ;
    }
    cout<<res ;

}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    gen() ;
    long long test =1 ;
    if(tests) cin>>test ;
    REP(i,1,test+1){
        debug(i) ;
        //cout<<"Case #"<<i<<": " ;

        solve() ;
        //cout<<"\n" ;
    }
    return 0 ;
}

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

const int mn=1e5+67;
int f[mn],n,siz[mn];
vector<int> to[mn];

void dfs(int x)
{
    siz[x]=1;
    int sum=0;
    vector<int> vec;vec.clear();
    for(auto t:to[x]) {
        dfs(t);
        siz[x]+=siz[t];
        if(siz[t]%2) {
            vec.push_back(-f[t]);
        }
        else {
            if(f[t]<0) f[x]-=-f[t];
            else sum+=-f[t];
        }
    }
    sort(vec.begin(),vec.end(),greater<int> {});
    vec.push_back(sum);
    for(int i=0;i<vec.size();++i) {
        if(i%2) f[x]+=vec[i];
        else f[x]-=vec[i];
    }
}

int main()
{
    scanf("%d",&n);
    int p;
    for(int i=2;i<=n;++i) {
        scanf("%d",&p);
        to[p].push_back(i);
    }
    for(int i=1;i<=n;++i) f[i]=1;
    dfs(1);
    printf("%d",(n+f[1])/2);
}


#include <bits/stdc++.h>
#define sz(x) ((ll)x.size())
#define PB push_back
#define all(x) x.begin(),x.end()
#define i3 array<ll,3>
#define i2 array<ll,2>
using namespace std;
typedef long double ld;
typedef long long ll;
const ll N = 400100;
const int md = 3;
vector<int> g[N];
int n, dst[N], nxt[N], ans[N], tt = 0;

void dfs(int v, int p){
    dst[v] = 0;
    nxt[v] = -1;

    for (int u : g[v]){
        if (u == p) continue;

        dfs(u, v);

        if (dst[u] + 1 > dst[v]){
            dst[v] = dst[u] + 1;
            nxt[v] = u;
        }
    }
}

void last_dfs(int v, int p){
    ans[v] = ++tt;

    for (int u : g[v]){
        if (u == p || u == nxt[v])
            continue;

        last_dfs(u, v);
    }

    if (nxt[v] != -1)
        last_dfs(nxt[v], v);

    tt++;
}

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

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n;

    for (int i = 1; i < n; i++){
        int x, y; cin >> x >> y;

        x--; y--;

        g[x].PB(y);
        g[y].PB(x);
    }

    dfs(0, -1);

    int root = 0;

    while (nxt[root] != -1)
        root = nxt[root];

    dfs(root, -1);
    last_dfs(root, -1);

    for (int i = 0; i < n; i++)
        cout << ans[i] << " ";

    return 0;
}

//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
vector<int> al[200005];

vector<ii> v[200005];
int span[200005];
int mn[200005];
int gap[200005];

void dfs(int i,int p){
	int best=-1;
	for (auto &it:al[i]){
		if (it==p) continue;

		dfs(it,i);
		if (best==-1 || gap[best]<gap[it]) best=it;
	}

	//suibian put i on the edge
	v[i].pub(ii(i,1));
	span[i]=0;
	mn[i]=1;
	gap[i]=0;

	for (auto &it:al[i]){
		if (it==p) continue;
		if (it==best) continue;

		if (sz(v[i])>sz(v[it])){
			for (auto &it2:v[it]){
				v[i].pub(ii(it2.fi,it2.se-mn[it]+mn[i]+span[i]));
			}
		}
		else{
			for (auto &it2:v[i]){
				v[it].pub(ii(it2.fi,it2.se-mn[i]+mn[it]-span[i]));
			}
			mn[i]=mn[it]-span[i];
			swap(v[i],v[it]);
		}

		span[i]+=span[it];
	}

	if (best!=-1){
		int it=best;

		if (sz(v[i])>sz(v[it])){
			for (auto &it2:v[it]){
				v[i].pub(ii(it2.fi,it2.se-mn[it]+mn[i]+span[i]));
			}
		}
		else{
			for (auto &it2:v[i]){
				v[it].pub(ii(it2.fi,it2.se-mn[i]+mn[it]-span[i]));
			}
			mn[i]=mn[it]-span[i];
			swap(v[i],v[it]);
		}

		span[i]+=span[it];

		gap[i]=gap[it];
	}

	span[i]+=2;
	mn[i]--;
	gap[i]++;

	//cout<<mn[i]<<" "<<span[i]<<endl;
	//for (auto &it:v[i]) cout<<it.fi<<"_"<<it.se<<" "; cout<<endl;
	//cout<<endl;
}

int w[200005];
void dfs1(int i,int p){
	for (auto &it:al[i]){
		if (it==p) continue;

		w[it]=w[i]+1;
		dfs1(it,i);
	}
}

int ans[200005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);

	cin>>n;

	int a,b;
	rep(x,1,n){
		cin>>a>>b;

		al[a].pub(b);
		al[b].pub(a);
	}

	dfs1(1,-1);
	int root=1;
	rep(x,2,n+1) if (w[x]>w[root]) root=x;

	dfs(root,-1);

	for (auto &it:v[root]) ans[it.fi]=it.se-mn[root];

	rep(x,1,n+1) cout<<ans[x]<<" ";
}