#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <queue>

#define	INF   1010101010LL
#define INFLL 1010101010101010101LL

using namespace std;

//const int mod = 1000000007;
//const int mod = 998244353;

class BIT {
public:
	BIT(int n) : a(n) {}

	void add(int p, long long num)
	{
		while (p < a.size()) {
			a[p] += num;
			p |= p + 1;
		}
	}

	/* i から j までの和 [i, j] */
	long long sum(int i, int j)
	{
		long long s = 0, t = 0;
		i--;
		while (i >= 0) {
			s += a[i];
			i = (i & (i + 1)) - 1;
		}
		while (j >= 0) {
			t += a[j];
			j = (j & (j + 1)) - 1;
		}
		return t - s;
	}

private:
	vector<long long> a;
};

vector<int> compress_num, compressed_num;
int find_comp(int x)
{
	return lower_bound(compress_num.begin(), compress_num.end(), x) - compress_num.begin();
}

int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	vector<long long> t(q), x(q), y(q);
	for (int i = 0; i < q; i++) {
		cin >> t[i] >> x[i] >> y[i];
		x[i]--;
	}

	for (int i = 0; i < q; i++) {
		compress_num.emplace_back(y[i]);
	}
	compress_num.emplace_back(0);
	sort(compress_num.begin(), compress_num.end());
	compress_num.erase(unique(compress_num.begin(), compress_num.end()), compress_num.end());
	/*for (int i = 0; i < compress_num.size(); i++) {
		compressed_num[i] = lower_bound(compress_num.begin(), compress_num.end(),
			compress_num[i]) - compress_num.begin();
	}*/

	long long sum = 0;
	vector<int> a(n), b(m);
	BIT bita(q+10), bitb(q + 10);
	BIT numa(q+10), numb(q + 10);
	numa.add(0, n);
	numb.add(0, m);
	for (int i = 0; i < q; i++) {
		if (t[i] == 1) {
			sum -= bitb.sum(find_comp(a[x[i]]), q+5) + a[x[i]] * numb.sum(0, find_comp(a[x[i]]) - 1);
			bita.add(find_comp(a[x[i]]), -a[x[i]]);
			numa.add(find_comp(a[x[i]]), -1);
			a[x[i]] = y[i];
			numa.add(find_comp(a[x[i]]), 1);
			bita.add(find_comp(a[x[i]]), a[x[i]]);
			sum += bitb.sum(find_comp(a[x[i]]), q+5) + y[i] * numb.sum(0, find_comp(a[x[i]]) - 1);
			cout << sum << endl;
		} else {
			sum -= bita.sum(find_comp(b[x[i]]), q + 5) + b[x[i]] * numa.sum(0, find_comp(b[x[i]]) - 1);
			bitb.add(find_comp(b[x[i]]), -b[x[i]]);
			numb.add(find_comp(b[x[i]]), -1);
			b[x[i]] = y[i];
			numb.add(find_comp(b[x[i]]), 1);
			bitb.add(find_comp(b[x[i]]), b[x[i]]);
			sum += bita.sum(find_comp(b[x[i]]), q + 5) + y[i] * numa.sum(0, find_comp(b[x[i]]) - 1);
			cout << sum << endl;
		}
		/*for (int j = 0; j < n; j++) {
			cout << a[j] << " ";
		}
		cout << endl;
		for (int j = 0; j < m; j++) {
			cout << b[j] << " ";
		}
		cout << endl;*/
	}

	return 0;
}

// Jai Shree Ram

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

const int N=1e9+5;
const int M=1e7;

struct node{
	int l;int r;
	int val;
	int cnt;
}t[M];
int cnt=0;

int n;

void extend(int v){
	if(t[v].l==0){
		t[v].l=++cnt;
		t[v].r=++cnt;
	}
}

void pushup(int v){
	t[v].val = t[t[v].l].val + t[t[v].r].val;
	t[v].cnt = t[t[v].l].cnt + t[t[v].r].cnt;
}

void update(int v,int l,int r,pii val,int tl=0,int tr=1e9){
	if(tl>r || l>tr)return;
	if(l<=tl && tr<=r){
		assert(tl == tr);
		t[v].val += val.x;
		t[v].cnt += val.y;
		return;
	}
	extend(v);
	int mid=(tl+tr)/2;
	update(t[v].l,l,r,val,tl,mid);
	update(t[v].r,l,r,val,mid+1,tr);
	pushup(v);
}

pii query(int v,int l,int r,int tl=0,int tr=1e9){
	if(tl>r || l>tr)return {0,0};
	if(l<=tl && tr<=r){
		return {t[v].val,t[v].cnt};
	}
	int mid=(tl+tr)/2;
	extend(v);
	pii a =query(t[v].l,l,r,tl,mid);
	pii b =query(t[v].r,l,r,mid+1,tr);
	return {a.x+b.x,a.y+b.y};
}

int solve(){
		int n,m,q; cin >> n >> m >> q;

		int ans = 0;
		int roota = ++cnt;
		int rootb = ++cnt;

		vector<int>v1(n+1),v2(m+1);
		update(roota,0,0,{0,n});
		update(rootb,0,0,{0,m});

		rep(i,0,q){
			int t; cin >> t;
			int x,y; cin >> x >> y;
			if(t == 1){
				if(y > v1[x]){
					auto s = query(rootb,0,y);
					ans += s.y*y;
					s = query(rootb,v1[x]+1,y);
					ans -= s.x;
					s = query(rootb,0,v1[x]);
					ans -= v1[x]*s.y;
				}
				else if(y < v1[x]){
					auto s = query(rootb,0,v1[x]);
					ans -= s.y*v1[x];
					s = query(rootb,0,y);
					ans += s.y*y;
					s = query(rootb,y+1,v1[x]);
					ans += s.x;
				}
				update(roota,v1[x],v1[x],{-v1[x],-1});
				update(roota,y,y,{y,1});
				v1[x] = y;
			}
			else{
				if(y > v2[x]){
					auto s = query(roota,0,y-1);
					ans += s.y*y;
					s = query(roota,0,v2[x]-1);
					ans -= s.y*v2[x];
					s = query(roota,v2[x],y-1);
					ans -= s.x;
				}
				else if(y < v2[x]){
					auto s = query(roota,0,v2[x]-1);
					ans -= s.y*v2[x];
					s = query(roota,0,y-1);
					ans += s.y*y;
					s = query(roota,y,v2[x]-1);
					ans += s.x;
				}
				update(rootb,v2[x],v2[x],{-v2[x],-1});
				update(rootb,y,y,{y,1});
				v2[x] = y;
			}
			cout << ans << endl;
		}
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>
#include<cassert>

using namespace std;

#define ll long long
#define reps(i, a, b) for(int i = a; i < b; i++)
#define rreps(i, a, b) for(int i = a-1; i >= b; i--)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) rreps(i, n, 0)
#define P pair<int, int>
#define vec vector<int>
#define mat vector<vec>

const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    mat x(n, vec(3));
    mat dist(n, vec(n));
    rep(i, n){
        rep(j, 3) cin >> x[i][j];
    }
    rep(i, n){
        rep(j, n){
            dist[i][j] = abs(x[i][0]-x[j][0]) + abs(x[i][1]-x[j][1]) + max(0, x[j][2]-x[i][2]);
        }
    }
    mat dp(1<<n, vec(n, INF));
    reps(i, 1, n){
        dp[(1<<i)][i] = dist[0][i];
    }
    rep(i, 1<<n){
        rep(j, n){
            rep(k, n){
                if((i>>k)&1){
                    dp[i|(1<<j)][j] = min(dp[i][k]+dist[k][j], dp[i|(1<<j)][j]);
                }
            }
        }
    }
    // rep(i, 1<<n){
    //     rep(j, n){
    //         cout << dp[i][j] << " ";
    //     }cout << endl;
    // }

    cout << dp[(1<<n)-1][0] << endl;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef tuple<LL, LL, LL> TP;
constexpr LL kInf = 1e18;

template<typename T>
auto makeNdVector(int n, const T& v) {
  return vector<T>(n, v);
}

template<typename T, typename N, typename... Tail>
auto makeNdVector(const N& n, const Tail&... tail) {
  auto vec = makeNdVector<T>(tail...);
  vector<decltype(vec)> vecs(n, vec);
  return vecs;
}

void chmin(LL& a, LL b) { a = min(a, b); }
LL dist(TP t1, TP t2) {
  auto [x1, y1, z1] = t1;
  auto [x2, y2, z2] = t2;
  return abs(x2 - x1) + abs(y2 - y1) + max(0LL, z2 - z1);
}

int main() {
  int N; cin >> N;
  vector<TP> tps(N);
  for (int i = 0; i < N; ++i) {
    int x, y, z; cin >> x >> y >> z;
    tps[i] = {x, y, z};
  }

  auto dp = makeNdVector<LL>(1 << N, N, kInf);
  dp[1][0] = 0;

  for (int S = 0; S < (1 << N); ++S) {
    bitset<18> b(S);
    for (int i = 0; i < N; ++i) {
      if (b.test(i)) {
        for (int j = 0; j < N; ++j) {
          LL d = dist(tps[i], tps[j]);
          chmin(dp[S | (1 << j)][j], dp[S][i] + d);
        }
      }
    }
  }

  cout << dp[(1 << N) - 1][0] << endl;
}


#include <bits/stdc++.h>
#define ALL(x) std::begin(x), std::end(x)
using namespace std;

// @title 行列
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template< class T >
struct Matrix {
  size_t H, W;
  vector< vector< T > > A;
  Matrix() {}
  Matrix(size_t n, size_t m) : H(n), W(m), A(H, vector< T >(W, 0)) {}
  Matrix(size_t n) : H(n), W(n), A(H, vector< T >(W, 0)) {};
  Matrix(const vector<vector<T>>& a) : A(a) {
      H = a.size();
      assert(H > 0);
      W = a[0].size();
  }
  size_t height() const { return H; }
  size_t width() const { return W; }
  inline const vector< T > &operator[](int k) const { return (A.at(k)); }
  inline vector< T > &operator[](int k) { return (A.at(k)); }
  static Matrix I(size_t n) {
    Matrix mat(n);
    for(int i = 0; i < n; i++) mat[i][i] = 1;
    return (mat);
  }

  Matrix &operator+=(const Matrix &B) {
    assert(H == B.H && W == B.W);
    for(int i = 0; i < H; i++)
      for(int j = 0; j < W; j++)
        (*this)[i][j] += B[i][j];
    return (*this);
  }

  Matrix &operator-=(const Matrix &B) {
    assert(H == B.H && W == B.W);
    for(int i = 0; i < H; i++)
      for(int j = 0; j < W; j++)
        (*this)[i][j] -= B[i][j];
    return (*this);
  }

  Matrix &operator*=(const Matrix &B) {
    assert(W == B.H);
    vector< vector< T > > C(H, vector< T >(B.W, 0));
    for(int i = 0; i < H; i++)
      for(int j = 0; j < B.W; j++)
        for(int k = 0; k < W; k++)
          C[i][j] += ((*this)[i][k] * B[k][j]);
    A.swap(C);
    return (*this);
  }

  Matrix &operator^=(long long k) {
    Matrix B = Matrix::I(H);
    while(k > 0) {
      if(k & 1) B *= *this;
      *this *= *this;
      k >>= 1LL;
    }
    A.swap(B.A);
    return (*this);
  }

  vector<T> operator*(const vector<T> &v) {
    assert(W == v.size());
    vector<T> ret(H, 0);
    for(int i = 0; i < H; i++)
      for(int j = 0; j < W; j++)
        ret[i] += ((*this)[i][j] * v[j]);
    return ret;
  }

  Matrix operator+(const Matrix &B) const { return (Matrix(*this) += B); }
  Matrix operator-(const Matrix &B) const { return (Matrix(*this) -= B); }
  Matrix operator*(const Matrix &B) const { return (Matrix(*this) *= B); }
  Matrix operator^(const long long k) const { return (Matrix(*this) ^= k); }

  friend ostream &operator<<(ostream &os, Matrix &p) {
    for(int i = 0; i < p.H; i++) {
      for(int j = 0; j < p.W; j++) {
        os << p[i][j] << (j + 1 == p.W ? "\n" : " ");
      }
    }
    return (os);
  }
};

using ll = long long;
using matrix = Matrix<ll>;
matrix l1({
    {0, 1, 0},
    {-1, 0, 0},
    {0, 0, 1}
});
matrix l2({
    {0, -1, 0},
    {1, 0, 0},
    {0, 0, 1}
});

struct Pos { int x, y; };
int main() {
    int n; cin >> n;
    vector<Pos> pos;
    for (int i = 0; i < n; ++i) {
        int x, y; cin >> x >> y;
        pos.push_back((Pos){x, y});
    }
    vector<matrix> mat;
    mat.push_back(matrix({
        {1, 0, 0},
        {0, 1, 0},
        {0, 0, 1}
    }));
    int m; cin >> m;
    for (int i = 0; i < m; ++i) {
        int op; cin >> op;
        int p;
        if (op >= 3) cin >> p;
        matrix &b = mat.back();
        if (op == 1) {
            mat.push_back(l1*b);
        }
        else if (op == 2) {
            mat.push_back(l2*b);
        }
        else if (op == 3) {
            matrix l3({
                {-1, 0, 2*p},
                {0, 1, 0},
                {0, 0, 1}
            });
            mat.push_back(l3*b);
        }
        else {
            matrix l4({
                {1, 0, 0},
                {0, -1, 2*p},
                {0, 0, 1}
            });
            mat.push_back(l4*b);
        }
    }
    int q; cin >> q;
    for (int i = 0; i < q; ++i) {
        int a, b; cin >> a >> b;
        Pos p = pos[b-1];
        vector<ll> l = {p.x, p.y, 1};
        vector<ll> ans = mat[a]*l;
        cout << ans[0] << " " << ans[1] << endl;
    }

    return 0;
}


#include<iostream>
#include<math.h>
#include<time.h>
#include<algorithm>
#include<random>
#include<vector>
#include<string>
using namespace std;

int num_cand = 3000;

mt19937 engine(time(0));

vector<vector<double>> x_path(100, vector<double>(100, 5000.0));  //(30, 29)
vector<vector<double>> y_path(100, vector<double>(100, 5000.0));  //(29, 30)

string basic_path(int j_def, int i_def){
    string result;
    if(j_def > 0){
        for(int j = 0; j < j_def; j++){
            result += "R";
        }
    }else{
        for(int j = 0; j < - j_def; j++){
            result += "L";
        }
    }

    if(i_def > 0){
        for(int i = 0; i < i_def; i++){
            result += "D";
        }
    }else{
        for(int i = 0; i < - i_def; i++){
            result += "U";
        }
    }

    return(result);
}

class path{
    public:
        double expected_cost;
        string movement;
        void assign_cost(int i_now, int j_now);
        void modify_expectation(int i_now, int j_now, int real_cost);
};

void path::assign_cost(int i_now, int j_now){
    int N = movement.length();
    for(int l = 0; l < N; l++){
        if(movement.at(l) == 'D'){
            expected_cost += y_path.at(i_now).at(j_now);
            i_now += 1;
        }else if(movement.at(l) == 'U'){
            expected_cost += y_path.at(i_now-1).at(j_now);
            i_now -= 1;
        }else if(movement.at(l) == 'R'){
            expected_cost += x_path.at(i_now).at(j_now);
            j_now += 1;
        }else{
            expected_cost += x_path.at(i_now).at(j_now-1);
            j_now -= 1;
        }
    }
}

void path::modify_expectation(int i_now, int j_now, int real_cost){
    int N = movement.length();
    double new_expectation = real_cost / (double)N;
    for(int l = 0; l < N; l++){
        if(movement.at(l) == 'D'){
            y_path.at(i_now).at(j_now) = new_expectation;
            i_now += 1;
        }else if(movement.at(l) == 'U'){
            y_path.at(i_now-1).at(j_now) = new_expectation;
            i_now -= 1;
        }else if(movement.at(l) == 'R'){
            x_path.at(i_now).at(j_now) = new_expectation;
            j_now += 1;
        }else{
            x_path.at(i_now).at(j_now-1) = new_expectation;
            j_now -= 1;
        }
    }
}

int main(){
    for(int k = 0; k < 1000; k++){
        int sy, sx, ty, tx;
        cin >> sy >> sx >> ty >> tx;

        int dx = tx - sx;
        int dy = ty - sy;

        string basics = basic_path(dx, dy);

        vector<path> paths(num_cand);
        double min_cost = pow(10, 9);
        int min_cost_id = -1;
        for(int i = 0; i < num_cand; i++){
            shuffle(basics.begin(), basics.end(), engine);
            paths.at(i).movement = basics;
            paths.at(i).assign_cost(sy, sx);

            if(paths.at(i).expected_cost < min_cost){
                min_cost = paths.at(i).expected_cost;
                min_cost_id = i;
            }
        }

        cout << paths.at(min_cost_id).movement << endl;

        int real_cost;
        cin >> real_cost;

        paths.at(min_cost_id).modify_expectation(sy, sx, real_cost);
    }
}

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

int main(){
    for(int i=0;i<1000;i++){
        int si,sj,ti,tj;
        cin>>si>>sj>>ti>>tj;
        int difx=si-ti;
        int dify=sj-tj;

        if(difx>0){
            for(int i=0;i<difx;i++){
                cout<<'U';
            }
        }else{
            for(int i=0;i<abs(difx);i++){
                cout<<'D';
            }
        }

        if(dify>0){
            for(int i=0;i<dify;i++){
                cout<<'L';
            }
        }else{
            for(int i=0;i<abs(dify);i++){
                cout<<'R';
            }
        }

        cout<<endl;

        long long num;
        cin>>num;
    }
}


/*
 * Author: Utkal Sinha
 * Created on: 2020-10-31, Sat, 17:21
 * Problem:
 * Platfrom: General
 * */
#if USE_BOOST2
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; //int512_t or //int128_t
typedef bst::cpp_bin_float_100 vdouble;
#endif

#include <bits/stdc++.h>
using namespace std;
#define GETTIME std::chrono::system_clock::now()
#define DURATION std::chrono::duration<double>
#ifdef MY_DEV_ENV2
#define LOCALDEV
#endif
typedef long long ll;
typedef std::chrono::system_clock::time_point TPT;
static TPT starttime, endtime, timelimit;
static double problem_tle = 1.5;
static inline void calc_problem_end_time() {timelimit = starttime + std::chrono::milliseconds(int (problem_tle * 1000));}
// template end

ll mod = 998244353;

void love() {
    ll a, b, c;
    cin >> a >> b >> c;

    ll na = (a * (a+1)/2)%mod;
    ll nb = (b * (b+1)/2)%mod;
    ll nc = (c * (c+1)/2)%mod;

    ll ans = (na*nb)%mod;
    ans = (ans * nc)%mod;

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    srand(time(0));
#ifdef LOCALDEV
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
#ifdef LOCALDEV
    starttime = GETTIME;
    calc_problem_end_time();
#endif
    while(t--) love();
#ifdef LOCALDEV
    endtime = GETTIME;
    DURATION elapsed_seconds = endtime - starttime;
    DURATION time_limit_seconds = timelimit - starttime;
    clog << "Elapsed time: " << elapsed_seconds.count() << "s\n";
    clog << "Time limit: " << time_limit_seconds.count() << "s\n";
#endif
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
signed main()
{
    long double x,y,r;long long t=0;cin>>x>>y>>r;r+=1e-14;
    for(int i=ceil(x-r);i<=floor(x+r);++i) t+=floor(y+sqrt(r*r-(i-x)*(i-x)))-ceil(y-sqrt(r*r-(i-x)*(i-x)))+1;
    cout<<t;return 0;
}


//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;

using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);

//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r) { return uniform_int_distribution<int> (l, r)(rng); }

int te;
main() {
  file("paint");
  ios;
  cin >> te;
  while (te--) {
    ll x;
    cin >> x;
    ll cnt = 0;
    if (x % 2 == 0) x /= 2, ++cnt;
    if (x % 2 == 0) x /= 2, ++cnt;
    if (!cnt) cout << "Odd\n";
    else if (cnt == 1) cout << "Same\n";
    else cout << "Even\n";
  }
  return 0;
}
/**

*/

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

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

    int t;
    cin >> t;
    while(t--){
        long long x;
        cin >> x;
        if(x & 1LL){
            cout << "Odd\n";
        }
        else if((x / 2) % 2 == 0){
            cout << "Even\n";
        }
        else{
            cout << "Same\n";
        }
    }

}

/*

*/


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

const int M=1000005;

int n,a[M],cnt=3;

int main()
{
	scanf("%d",&n);
	printf("6 10 15 ");
	for(int i=2;;i++)
	{
		if(i*6>10000)break;
		a[++cnt]=i*6;
	}
	for(int i=2;;i++)
	{
		if(i*10>10000)break;
		a[++cnt]=i*10;
	}
	for(int i=2;;i++)
	{
		if(i*15>10000)break;
		a[++cnt]=i*15;
	}
//	printf("%d\n",cnt);
	sort(a+1,a+cnt+1);
	int tot=unique(a+1,a+cnt+1)-a-1;
//	cout<<tot<<endl;
//	int cc=0;
	for(int i=4;i<=n;i++)
	{
		printf("%d ",a[i]);
//		if(a[i]%15==0)cc++;
	}
//	cout<<cc;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N;
	vector<int> A;
	for(int i = 2; i <= 10000; i+= 2){
		if(i % 3 == 0 || i % 5 == 0 || i % 7 == 0){
			A.push_back(i);
		}
	}
	cout << 105 << " ";
	for(int i = 0; i < N-1; i++){
		cout << A[i] << " ";
	}
	cout << "\n";
}


/*
    This code belongs to Aadit Ambadkar
    Date: 2021-06-13 05:08:53
*/
#include <bits/stdc++.h>
using namespace::std;

typedef long long ll;
#define F0R(i, n) for (int i = 0; i < n; i++)
#define R0F(i, n) for (int i = n-1; i >= 0; i--)
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define FMOD 998244353
#define MOD 1000000007

int main() {
    fastio;
    int a, b, c; cin >> a >> b >> c;
    if (a==b) {
        cout << "=\n";
        return 0;
    }
    if (-a==b && c%2==0) {
        cout << "=\n";
        return 0;
    }
    if (a<=0 && b<=0) {
        if (c%2==0) {
            if (a<b) {
                cout << ">\n";
            } else {
                cout << "<\n";
            }
        } else {
            if (a<b) {
                cout << "<\n";
            } else {
                cout << ">\n";
            }
        }
    } else if (a<=0 && b>=0) {
        if (c%2==0) {
            if (-a<b) {
                cout << "<\n";
            } else {
                cout << ">\n";
            }
        } else {
            cout << "<\n";
        }
    } else if (a>=0 && b<=0) {
        if (c%2==0) {
            if (a<-b) {
                cout << "<\n";
            } else {
                cout << ">\n";
            }
        } else {
            cout << ">\n";
        }
    } else if (a>=0 && b>=0) {
        if (a<b) {
            cout << "<\n";
        } else {
            cout << ">\n";
        }
    }
}

#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
# include <iostream>
# include <array>
# include <string>
# include <vector>
# include <algorithm>
# include <functional>
# include <cmath>
# include <iomanip>
# include <stack>
# include <queue>
# include <numeric>
# include <map>
# include <set>
# include <unordered_map>
# include <unordered_set>
# include <chrono>
# include <random>
# include <bitset>
# include <cassert>
# include <climits>

template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

#define rep2(i,t,n) for (int i = (t); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

using namespace std;
typedef long long ll;

int a,b,x,y;

int main() {
  cin >> a >> b >> x >> y;

  int diff = abs(a - b);

  int ans = 0;

  if(a > b) {
    diff--;
    ans += x;
  } else {
    ans += x;
  }

  rep(i,diff) {
    ans += 2 * x < y ? 2 * x : y;
  }

  cout << ans << endl;

  return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pb push_back
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

ll fac[1000001];

void pre(){
    fac[0]=fac[1]=1;
    for(int i=2;i<=1000001;i++)
{

    fac[i]=(fac[i-1]*1LL*i)%mod;
}
}

ll binpower(ll a,ll n){
    ll res=1;
    while(n){

    if(n%2)
        res = (res*1LL*a)%mod;

        n/=2;
        a=(a*1LL*a)%mod;

    }
    return res;

}

ll nCrmod(ll n,ll r){

ll res= fac[n];
res = (res*1LL*binpower(fac[r],mod-2))%mod;
res= (res*1LL*binpower(fac[n-r],mod-2))%mod;
return res;

}

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll modexp(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  modexp(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*modexp(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return modexp(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}

void SieveOfEratosthenes(ll n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (ll p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

vector<int> Centroid(vector<int>g[],int n) {

        vector<int> centroid;
        vector<int> sz(n+1);
        function<void (int, int)> dfs = [&](int u, int prev) {
                sz[u] = 1;
                bool is_centroid = true;
                for (auto v : g[u]) if (v != prev) {
                        dfs(v, u);
                        sz[u] += sz[v];
                        if (sz[v] > n / 2) is_centroid = false;
                }
                if (n - sz[u] > n / 2) is_centroid = false;
                if (is_centroid) centroid.push_back(u);
        };
        dfs(1, 0);
        return centroid;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    set<string>s;
    vector<string>v(n);
    vector<string>k;
    string ans="satisfiable";
    for(int i=0;i<n;i++){
       cin>>v[i];
       s.insert(v[i]);
       if(v[i][0]!='!')k.pb(v[i]);

           }
           for(auto x:k){
            string p=x;
            string q="!";
            for(int j=0;j<x.length();j++)q+=x[j];
            if(s.count(q)){
                ans=x;
                break;
            }
           }
    cout<<ans;

    return 0;
}

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << (#x) << " : " << x << '\n'

void solve() {
	int n; cin >> n;
	vector<string> v;
	set<string> st;
	while (n--) {
		string s;
		cin >> s;
		if (s.front() == '!') st.emplace(s);
		else v.emplace_back(s);
	}
	for (const auto& i : v) {
		if (st.count("!" + i)) {
			cout << i << '\n';
			return;
		}
	}
	cout << "satisfiable\n";
}

// #define GTcoding
int main() {
#ifndef GTcoding
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
#else
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
	clock_t time = clock();
#endif
	int t = 1;
//	cin >> t;
	while (t--) solve();
#ifdef GTcoding
	cout << "\nUse "
	     << static_cast<double>(clock() - time) / CLOCKS_PER_SEC
	     << " seconds\n";
#endif
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
int main(){
     int n,m;
     cin>>n>>m;
     V<ll> res={},a(n),b(m);
     set<ll> s,t;
     for(int i=0;i<n;i++){
          cin>>a[i];
          s.insert(a[i]);
     }
     for(int i=0;i<m;i++){
          cin>>b[i];
          t.insert(b[i]);
     }
     for(int i=0;i<n;i++){
            if(!t.count(a[i])){
                 res.emplace_back(a[i]);
            }
     }
     for(int i=0;i<m;i++){
            if(!s.count(b[i])){
                 res.emplace_back(b[i]);
            }
     }
     sort(all(res));
     print(res);
}

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int ans[1001];
int n, m;

int main() {
	cin >> n >> m;
	rep(i, n) {
		int a;
		cin >> a;
		ans[a]++;
	}
	rep(i, m) {
		int b;
		cin >> b;
		ans[b]++;
	}
	bool first = false;

	rep(i, 1001) {
		if (!first && ans[i] == 1) {
			cout << i;
			first = true;
		}
		else if (ans[i] == 1) cout << " " << i;
	}

	cout << endl;

	return 0;
}


/* CODER::==>ARYAN KANSAGARA
  CF HANDLE:=>Good_Devil
-----------------------------------------------*/

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

#define int long long int
#define endl "\n"

void solve()
{
	string S; cin >> S;
	int ans = 0;
	for (int i = 0; i <= 9999; i++) {
		vector<bool> flag(10);
		int X = i;
		for (int j = 0; j < 4; j++) {
			flag[X % 10] = true;
			X /= 10;
		}
		bool flag2 = true;
		for (int j = 0; j < 10; j++) {
			if (S[j] == 'o' && !flag[j]) flag2 = false;
			if (S[j] == 'x' && flag[j]) flag2 = false;
		}
		ans += flag2;
	}
	cout << ans;
}

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

	return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define mod 1000000007

const int N = 2e5 + 5;
vector<int> tree[N], depth(N);
vector<int> time_in(N), time_out(N);
vector<int> orders[N];
int timer = 0, n;

void dfs(int s) {
	time_in[s] = timer++;
	orders[depth[s]].push_back(time_in[s]);
	for (int v : tree[s]) {
		depth[v] = 1 + depth[s];
		dfs(v);
	}
	time_out[s] = timer++;
}

void test_case() {
	cin >> n;
	int j;
	for (int i = 2; i <= n; i++) {
		cin >> j;
		tree[j].push_back(i);
	}
	dfs(1);
	int q;
	cin >> q;
	while (q--) {
		int u, d;
		cin >> u >> d;
		auto &arr = orders[d];
		auto y = lower_bound(arr.begin(), arr.end(), time_out[u]);
		auto x = lower_bound(arr.begin(), arr.end(), time_in[u]);
		cout << y - x << "\n";
	}
}

signed main() {
	FastIO;
	test_case();
	return 0;
}
/*
         ▄              ▄
        ▌▒█           ▄▀▒▌
        ▌▒▒█        ▄▀▒▒▒▐
       ▐▄█▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
     ▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
   ▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌
  ▐▒▒▒▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▌
  ▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
 ▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌
 ▌░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌
▌▒▒▒▄██▄▒▒▒▒▒▒▒▒░░░░░░░░▒▒▒▐
▐▒▒▐▄█▄█▌▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▒▒▌
▐▒▒▐▀▐▀▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▐
 ▌▒▒▀▄▄▄▄▄▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▒▌
 ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒▒▄▒▒▐
  ▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒▄▒▒▒▒▌
    ▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀
      ▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀
         ▀▀▀▀▀▀▀▀▀▀▀▀
*/


#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> F(89, 0), a;
    F[1] = 1;
    rep(i, 2, 89) {
        F[i] = F[i - 1] + F[i - 2];
    }
    //rep(i, 0, 89) cout << i << " " << F[i] << endl;
    while (N > 0) {
        int idx = upper_bound(F.begin(), F.end(), N) - F.begin();
        //cout << "N=" << N << " idx=" << idx << endl;
        a.push_back(idx - 1);
        N -= F[idx - 1];
    }
    /*
    rep(i, 0, a.size()) {
        cout << a[i] << " " << F[a[i]] << endl;
    }
    */
    int K = a[0] + a.size();
    cout << K << endl;
    int j = 0;
    for (int i = a[0]; i > 0; i--) {
        if (i == a[j]) {
            if (i % 2) {
                cout << 1 << endl;
            } else {
                cout << 2 << endl;
            }
            j++;
        }
        if (i % 2) {
            cout << 3 << endl;
        } else {
            cout << 4 << endl;
        }
    }
}

#pragma region Macros
#include <bits/stdc++.h>
#if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG)
#include <atcoder/all>
#endif
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class T>using vec = vector<T>;
template<class T, class U>using umap = unordered_map<T, U>;
template<class T>using uset = unordered_set<T>;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
//using T = tuple<ll, ll, ll>;
using vl = vec<ll>;
#define fi first
#define se second
#define el endl
constexpr ll INF = numeric_limits<ll>::max()/2-1;
#pragma endregion

#pragma region IOMacros
template<class T>
istream &operator>>(istream &stream, vec<T>& o){REP(i, o.size())stream >> o[i];return stream;}
template<class T>
ostream &operator<<(ostream &stream, vec<T>& objs){REP(i, objs.size())stream << objs[i] << " ";stream << el;return stream;}

#define I(T, ...) ;T __VA_ARGS__;__i(__VA_ARGS__);
void __i() {}
template<class T, class... Ts> void __i(T&& o, Ts&&... args){cin >> o;__i(forward<Ts>(args)...);}

void O() {cout << el;}
template<class T, class... Ts> void O(T&& o, Ts&&... args){cerr << o << " ";O(forward<Ts>(args)...);}
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

vl fibb(const vl& seed, ll N){
    vl fib(seed.size());
    copy(ALL(seed), fib.begin());
    for(ll i = seed.size();;i++){
        ll t = fib[i-1]+fib[i-2];
        if(t > N) break;
        fib.push_back(t);
    }
    return fib;
}

void Main(){
    I(ll, N);
    vl seed({0, 1});
    vl fib = fibb(seed, N);
    ll cnt = 1 + fib.size() - 2;
    ll i = 1;
    ll siz = fib.size();
    if(fib[fib.size()-1] == N){
        goto last;
    }
    while(1){
        seed[i]++;cnt++;
        fib = fibb(seed, N);
        if(fib[fib.size()-1] == N){
            goto last;
        }
        if(siz > fib.size()){
            seed[i]--;
            seed.push_back(seed[i-1] + seed[i]);
            i++;
        }
    }
last:
    //cout << fib << el;
    bool x = fib.size()&1;
    vl ans;
        // 逆かも
    REP(i, fib[1]){
        ans.push_back(x+1);
    }
    x = !x;
    ans.push_back(x+3);
    FOR(i, fib.size(), 2){
        REP(j, fib[i]-fib[i-1]-fib[i-2]){
            ans.push_back(x+1);
        }
        x = !x;
        ans.push_back(x+3);
    }
    ll s = min(130, (int)ans.size());
    cout << s << el;
    REP(i, s){
        cout << ans[i] << el;
    }
}


#include <bits/stdc++.h> //Header Files

#define ll long long int
#define mod 1000000007
#define endl "\n"

using namespace std;

template <class T>
void out(int t, T ans)
{
    cout << "Case #" << t << ": " << ans << endl;
}

template <class T>
void out(int t, T ans[])
{
    cout << "Case #" << t << ": ";
    for (T val : ans)
        cout << val << " ";
    cout << endl;
}

template <class T>
void out(int t, vector<T> &ans)
{
    cout << "Case #" << t << ": ";
    for (T val : ans)
        cout << val << " ";
    cout << endl;
}

void runTest(int o)
{
    // Start coding here ...
    int h, w;
    cin >> h >> w;

    int mini = INT_MAX;
    int a[h][w];

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
            mini = min(mini, a[i][j]);
        }

    ll sum = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            sum += a[i][j] - mini;
        }

    cout << sum << endl;
}

int main()
{

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

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; i++)
        runTest(i + 1);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define print(v,n) for(i=0;i<n;i++) cout<<v[i]<<" ";
#define No cout<<"NO"<<endl;return
#define Yes cout<<"YES"<<endl;return
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
#define PI 3.14159265   ;
ll mod =1e9+7;
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i*i <= n; i = i + 6)
        if (n%i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll powe(ll x, ll y) {
    ll res = 1;
    while (y > 0) {
        if (y & 1) res =( res * x)%mod;
        y = y >> 1;
        x = (x * x)%mod;
    }
    return res;
}
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
unsigned long long power(unsigned long long x, int y, int p)
{
    unsigned long long res = 1; // Initialize result

    x = x % p; // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n,int p)
{
    return power(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n,int r, int p)
{
    if (n < r)
        return 0;
    // Base case
    if (r == 0)
        return 1;
    unsigned long long fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;

    return (fac[n] * modInverse(fac[r], p) % p
            * modInverse(fac[n - r], p) % p)
           % p;
}

void solve()
{
    ll i, x, y, j, k4, h, n, w, k1, k2,k3,q;
    cin>>n>>x;
    vll v;
    f(i,0,n)
    {
        cin>>j;
        if(j!=x) v.pb(j);
    }
    f(i,0,v.size()) cout<<v[i]<<" ";
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fast;
    ll i, j, l, k, t, n;
    t=1;
    //cout<<0;
    for (i = 1; i <= t; i++)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
    }
}
//


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

int solve(vector<pair<int, int>> ans)
{
    return 0;
}

void Main()
{
    int n, m;
    cin >> n >> m;
    int c = n-abs(m);
    if (m < 0 || m == n || (m >= n-1 && n >= 2)) {
        cout << -1 << endl;
        return;
    }
    vector<pair<int, int>> ans;
    int num = (m==0 ? n : n-1);
    for (int i = 0; i < num; i++)
    {
        ans.push_back(make_pair(3*i+2, 3*i+4));
    }
    if (m > 0) {
        ans.push_back(make_pair(1, 3*m+3));
    }

    for (int i = 0; i < n; i++)
    {
        cout << ans[i].first << " " << ans[i].second << endl;
    }

//     -- -- -- --
//    -----
//            -----
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//using Bint = mp::cpp_int;

#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(12) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }

int main(){
    ll ret=100000;
    minin(ret, ii());
    minin(ret, ii());
    minin(ret, ii());
    minin(ret, ii());
    oie(ret);
    return 0;
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
ll power(ll a, ll b){ll res=1;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1LL;}return res;}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo LLONG_MAX
const ll dx[]={-1,0,1, 0,-1,1, 1,-1};
const ll dy[]={ 0,1,0,-1, 1,1,-1,-1};

void solve(){
    ll r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    int ans = 3;
    if (r1 == r2 && c1 == c2) ans = min(ans, 0);
    if (r1 + c1 == r2 + c2) ans = min(ans, 1);
    if (r1 - c1 == r2 - c2) ans = min(ans, 1);
    if (abs(r1 - r2) + abs(c1 - c2) <= 3) ans = min(ans, 1);
    if ((r1 % 2 == r2 % 2) && (c1 % 2 == c2 % 2)) ans = min(ans, 2);
    if ((r1 % 2 != r2 % 2) && (c1 % 2 != c2 % 2)) ans = min(ans, 2);
    if (abs((r1 + c1) - (r2 + c2)) <= 4) ans = min(ans, 2);
    if (abs((r1 - c1) - (r2 - c2)) <= 4) ans = min(ans, 2);
    cout<<ans;
}
int main(){
    Boost();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	c-=a;
	d-=b;
	d=abs(d);
	c=abs(c);
	if ( c> d)
		swap( c,d);
	if ( abs( d)==abs(c)){
		if ( d==0)
			cout<<0<<"\n";
		else
			cout<<1<<'\n';
	}
	else
	if ( abs( d)+abs( c)<=3){
		cout<<1<<'\n';
	}
	else
	if ( d-c<=3||d+c<=6)
	{
		cout<<2<<'\n';
	}
	else
	if ( (d+c)%2==0)
		cout<<2<<'\n';
	else
		cout<<3<<'\n';
}


#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define forn(i,x1,n)     for(int i=x1; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x1)      __builtin_popcountll(x1)
#define zrobits(x1)      __builtin_ctzll(x1)
#define mod             1000000007
// #define mod             998244353
#define inf             1e18
#define ps(x1,y)         fixed<<setprecision(y)<<x1
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x1)            int x1; cin>>x1; while(x1--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void zeus()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

	zeus();

	int a, b, c, d; cin >> a >> b >> c >> d;

	if (d * c - b <= 0) {
		cout << -1 << endl;
	}
	else {
		cout << ceil(1.0 * a / (d * c - b)) << endl;
	}

}


#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 f(i,j,n) for(long long i = j ; i < n ; ++i)
#define ones(x) __builtin_popcount(x)
#define endl '\n'

using namespace std;
//using namespace __gnu_pbds;
typedef long long  ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef deque<int> di;
typedef deque<long long> dll;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long>> vpll;
/*typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
const ll N = 1e6 + 100;
const ll M = 1e5 + 100;
const ll inf = 1e18 +1;
const ll mod = 1e9 + 33;
string s;
ll a[27],b[27];
bool c[27];

int main(){
	fastio;
	cin >> s;
	ll n = s.size();
	ll ans = 0;
	f(i,0,26) c[i] = 0,a[i] = -1;
	for(ll i = n-1 ; i >= 1 ; --i){
		ll x = s[i] - 'a';
		b[x]++;
		if(s[i] == s[i-1]){
			ans += (n-i);
			ans -= b[x];
			f(j,0,26){
				if(j != x) b[j] = 0;
				else b[j] = n-i;
			}
		}
	}
	cout << ans << endl;
	/*f(i,0,26){
		if(a[i] == -1) continue;
		//cout << i << endl;
		//cout << a[i] << " " << b[i] << endl;
		ll p = (n-1-a[i]+1);
		ans = max(ans,p-b[i]);
	}
	cout << ans << endl;*/
	return 0;
}

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

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

int main() {
    ll n;
    cin >> n;

    vector<bool> flag(10001, 0);
    flag[6] = 1, flag[10] = 1, flag[15] = 1;
    ll cnt = 3;

    repi(i, 1, 10001) {
        if (cnt == n) break;
        if ((i % 6 == 0 || i % 10 == 0 || i % 15 == 0) && (flag[i] == 0)) {
            flag[i] = 1, cnt++;
        }
    }
    rep(i, 10001) if (flag[i]) cout << i << ' ';
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll mod = 3e5+2;

int n;
ll t[4*mod];

void build(ll h[],int v,int tl,int tr){
    if(tl == tr) t[v] = h[tl];
    else{
        int tm = (tl+tr)/2;
        build(h,v<<1,tl,tm);
        build(h,(v<<1)+1,tm+1,tr);
        t[v] = (t[v<<1]^t[(v<<1) +1]);
    }
}

ll query(int v,int tl,int tr,int l,int r){
    if(l>r) return 0;
    if(l==tl && r==tr) return t[v];

    int tm = (tl+tr)/2;
    int left = v<<1;
    return (query(left,tl,tm,l,min(r,tm))^query(left+1,tm+1,tr,max(l,tm+1),r));
}

void update(int v,int tl,int tr,int pos,ll y){
    if(tl == tr) t[v]^= y;
    else{
        int tm = (tl+tr)/2;
        int left = v<<1;
        if(pos<=tm) update(left,tl,tm,pos,y);
        else update(left+1,tm+1,tr,pos,y);

        t[v] = (t[left]^t[left+1]);
    }
}
main(){
    int n,q;
    cin>>n>>q;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    build(a,1,0,n-1);
    while(q--){
        int t;cin>>t;
        if(t==1) {
            ll x,y;
            cin>>x>>y;
            update(1,0,n-1,x-1,y);
        }
        else{
            ll x,y;
            cin>>x>>y;
            cout<<query(1,0,n-1,x-1,y-1)<<"\n";
        }
    }
}

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

//0-indexed
template<class T, T (*op)(T,T), T(*e)()>
class segtree
{
private:
    int n;
    vector<T> v;
public:
    segtree(int n_)
    {
        int x = 1;
        while (n_ > x) x <<= 1;
        n = x;
        v.resize(2 * n - 1, e());
    }

    void set(int k, T x)
    {
        k += n - 1;
        v[k] = x;
        while (k > 0)
        {
            k = (k - 1) / 2;
            v[k] = op(v[k*2+1],v[k*2+2]);
        }
    }
    T get(int k) { return v[k + n - 1]; }

    //[a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) return e();
        if (a <= l && r <= b) return v[k];
        T c1 = query_sub(a, b, 2 * k + 1, l, (l + r) / 2);
        T c2 = query_sub(a, b, 2 * k + 2, (l + r) / 2, r);
        return op(c1,c2);
    }

    //display segtree value
    void display(string text = "segtree value")
    {
        cout << text << endl;
        int cnt = 0;
        int end = 1 << cnt;
        int l = v.size();
        for (int i = 0; i < l; ++i)
        {
            cout << v[i] << " ";
            if (i == end - 1)
            {
                ++cnt;
                end += 1<<cnt;
                cout << endl;
            }
        }
        cout << endl;
    }
};

int op(int a, int b) { return a ^ b; }
int e() { return 0; }

int main()
{
	int n,q;
    cin >> n >> q;
    segtree<int,op,e> sg(n);
    rep(i, n)
    {
        int ai; cin >> ai;
        sg.set(i,ai);
    }
    rep(i, q)
    {
        int t, x, y;
        cin >> t >> x >> y;
        --x;
        if (t == 1) sg.set(x, op(sg.get(x), y));
        else printf("%d\n", sg.query(x,y));
    }
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int N=2e5+5;
const int mod=1e9+7;

int l;
string s,x;
bool dp[N][7],visited[N][7];

bool DP(int pos,int val)
{
    if(pos == l)return (val == 0);
    if(visited[pos][val])return dp[pos][val];
    visited[pos][val]=1;
    bool &ans=dp[pos][val];
    if(x[pos] == 'T')
    {
        ans=0;
        ans |= DP(pos+1,(val*10)%7);
        ans |= DP(pos+1,(val*10+s[pos]-48)%7);
    }
    else
    {
        ans=1;
        ans &= DP(pos+1,(val*10)%7);
        ans &= DP(pos+1,(val*10+s[pos]-48)%7);
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> l >> s >> x;
    if(DP(0,0))cout << "Takahashi";
    else cout << "Aoki";
    return 0;
}
//

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

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    string x;
    cin >> x;
    vector<bool> dp(7, false);
    dp[0] = true;

    for (int i = n - 1; i >= 0; i--)
    {
        vector<bool> tdp(7, false);
        if (x[i] == 'A')
        {
            for (int j = 0; j < 7; j++)
            {
                int a = (j * 10) % 7;
                int b = (j * 10 + (s[i] - '0')) % 7;
                tdp[j] = dp[a] && dp[b];
            }
        }
        else
        {
            for (int j = 0; j < 7; j++)
            {
                int a = (j * 10) % 7;
                int b = (j * 10 + (s[i] - '0')) % 7;
                tdp[j] = dp[a] || dp[b];
            }
        }
        dp = tdp;
    }
    if (dp[0])
    {
        cout << "Takahashi" << endl;
    }
    else
    {
        cout << "Aoki" << endl;
    }
}

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


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

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N,A,B; cin>>N>>A>>B;
    cout<<N-A+B<<endl;
}

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

//solution:
#define int int64_t

auto gcd(int a, int b) {
  if(!b) return make_tuple(a, 1LL, 0LL);
  auto [g, x, y] = gcd(b, a % b);
  return make_tuple(g, y, x - (a / b) * y);
}

int linsolver(int a, int b, int m) {
  if(b % __gcd(a, m)) return -1;
  auto [g, x, y] = gcd(a, m);
  a /= g, b /= g, m /= g;
  return ((b * x % m) + m) % m;
}

void hike() {
  int n, s, k; cin >> n >> s >> k, s = n - s;
  cout << linsolver(k, s, n) << "\n";
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  int t = 1; cin >> t;
  while(t--) hike();
  return 0;
} //farewell, until we meet again..


#include <iostream>
#include <string>
#include <vector>

int main(){
  int n;
  std::string s, t;
  std::cin >> n >> s >> t;

  int ans = 0;
  int sums = 0;
  int sumt = 0;
  for(int i = 0; i < n; i++){
    sums += s[i] - '0';
    sumt += t[i] - '0';
    if(s[i] < t[i] && sums < sumt) ans++;
    if(s[i] > t[i] && sums > sumt) ans++;
    else if(s[i] == '0' && t[i] == '0' && sums != sumt) ans++;
  }
  if(sums == sumt) printf("%d\n", ans);
  else puts("-1");

  return 0;
}

//
//  main.cpp
//  test
//
//  Created by wyzwyz on 2021/5/13.
//

#include<cstdio>
#include<cctype>

#define maxn 505505

template<class T>

inline T read(){
    T r=0,f=0;
    char c;
    while(!isdigit(c=getchar()))f|=(c=='-');
    while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar();
    return f?-r:r;
}

template<class T>

inline T min(T a,T b){
    return a<b?a:b;
}

int n,s_a[2],a[2][maxn];

char s[maxn],t[maxn];

int main(){
    n=read<int>();
    scanf("%s\n%s",s+1,t+1);
    for(int i=1;i<=n;i++){
        if(s[i]=='0')a[0][++s_a[0]]=i;
        if(t[i]=='0')a[1][++s_a[1]]=i;
    }
    if(s_a[0]^s_a[1])return puts("-1"),0;
    int ans=0;
    for(int i=1;i<=s_a[0];i++)
    ans+=(a[0][i]-a[1][i])!=0;
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

char s[4];

int main() {
    scanf("%s", s);
    printf("%c%c%c", s[1], s[2], s[0]);
}

// author: rdd6584

#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)(x).size()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;

#ifdef LOCAL//ONLINE_JUDGE
#include "D:\c_c++\template.h"
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;
			a=a*a%mod;
    }
    return res;
}

void solve(){
	string s;
	cin>>s;
	if(s[0]==s[1] && s[0]==s[2]){
		cout<<"Won\n";
	}else{
		cout<<"Lost\n";
	}
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
//    #ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
    int tc=1;
    // cin>>tc;
    while(tc--)solve();
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define p(x,y) pair<x,y>
#define oset(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define scan(a) for(auto &it:a)cin>>it;
#define print(a) {for(auto it:a)cout<<it<<" ";cout<<endl;}
#define out(x) cout<<((x)?"YES":"NO")<<endl;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define int ll

void solve()
{
    int n,k;
    cin>>n>>k;
    while(k--)
    {
        if(n%200==0)
            n/=200;
        else
        {
            n*=1000;
            n+=200;
        }
    }
    cout<<n<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1;
    //init();
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#pragma region DEBUG
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef
tree<
  pair<int,int>,
  null_type,
  less<pair<int,int>>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
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
#pragma endregion DEBUG
#define MOD 1000000007
#define MAX 500005
#define endl "\n"
vector <lli> fact(MAX,1);
vector <lli> invfact(MAX,1);
void solve(){
    lli n,k;
    cin>>n>>k;
    for(lli i = 0; i<k; i++){
        if(n%200 == 0){
            n /= 200;
            continue;
        }
        else{
            n = n*1000;
            n += 200;
        }
    }
    cout<<n<<endl;
}
int main(){
    /* freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   /*  for(lli i = 1; i<MAX-5; i++){
        fact[i] = i*fact[i-1]%MOD;
        invfact[i] = binpow(fact[i],MOD-2);
    } */
    lli t;
    t = 1;
   // cin>>t;
    lli p = 0;
    while(t--){
        p++;
       // cout<<"Case #"<<p<<": ";
        solve();
    }
}


// Problem: B - 200th ABC-200
// Contest: AtCoder - KYOCERA Programming Contest 2021（AtCoder Beginner Contest 200）
// URL: https://atcoder.jp/contests/abc200/tasks/abc200_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Made by Licykoc
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define int long long
#define UP(x,l,r) for (int x=l;x<=r;++x)
#define DOWN(x,l,r) for (int x=l;x>=r;--x)
#define IOS ios::sync_with_stdio(0),cin.tie(0)
#define low(x) (x&(-x))
#define fi first
#define se second
#define pb push_back
#define isdigit(c) (c>='0'&&c<='9')
using namespace std;
inline void read (int &x) {
	char c=getchar(); int w=0; x=0;
	for (;!isdigit(c);c=getchar()) w^=!(c^45);
	for (;isdigit(c);c=getchar()) x=(x*10)+(c^48);
	x=w?-x:x;
}
int n,T;
signed main () {
	read(n),read(T);
	while (T--) {
		if (!(n%200)) n/=200; else n=n*1000ll+200;
	}
	printf("%lld\n",n);
}

#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ll;

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

    ll n, k;
    cin>>n>>k;

    while(k--){
        if(n%200==0){
            n/=200;
        }
        else{
            n*=1000;
            n+=200;
        }
    }
    cout<<n;

    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> // Common file
#include<ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define F first
#define S second
#define ld long double
#define rep(i,a,n) for (int i = (a) ; i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
#define M_PI 3.14159265358979323846
#define int ll
typedef tree <
pair<int, int>,
     null_type,
     less<pair<int, int>>,
     rb_tree_tag,
     tree_order_statistics_node_update > od_st; // find_by_order() and order_of_key()

const ll mod = 1e9 + 7;
const ll inf = 1e9;

void solve() {
	string s;
	cin >> s;
	char temp = s[0];
	s[0] = s[1], s[1] = s[2], s[2] = temp;
	cout << s << endl;
}

int32_t main() {
	FASTIO
	int t = 1;
	// create();
	// cin >> t;
	ll k = 1;
	while (t--) {
		// cout << "Case #" << k++ << ": ";
		solve();
	}
	return 0;
}
/*
1 1 1 1 0 0 0 0
1 1 1 0 1 0 0 0
1 1 0 1 0 1 0 0
1 0 1 0 1 0 1 0
*/

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>
#include <ctype.h>

using namespace std;

typedef long long ll;

const int INF = (1<<30)-1;
const ll LINF = (1LL<<60)-1;

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

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

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

//コーナーケースに気をつけろ！
int main() {
    string s;   cin >> s;
    rep(i, 3)
        cout << s[(i+1)%3];
    cout << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;


#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>

#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <string>

#define il inline
#define re register
#define lc(p) p << 1
#define rc(p) p << 1 | 1
#define Mem(a, b) memset(a, b, sizeof(a));
#define For(a, b, c, d) for(re int a = b, a <= c;a = a + d);
#define foread(a, b) cin >> a;for(int i = 1;i <= a;i++) cin >> b[i];
#define forout(a, x, b, c) if(x) cout << a; for(int i = 1;i <= a;i++) cout << b[i] << c;
#define rep(a, b, c) for(re long long a = b;a <= c;a++)
#define per(a, b, c) for(re long long a = b;a >= c;a--)
#define IOS std::ios::sync_with_stdio(0)

using namespace std;

typedef long long ll;
typedef double ld;
typedef unsigned long long ull;

const int MAXN = 100005;
const int MAXM = 105;
const int INF = 0x3f3f3f3f;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const double PI = 3.141593;
const double E = 2.718282;
const double PHI = 1.618034;

int n, s, d;

int main(){
    cin >> n >> s >> d;
    for(int i = 1;i <= n;i++){
    	int x, y;
    	cin >> x >> y;
    	if(x < s && y > d){
    		cout << "Yes" << endl;
    		return 0;
		}
	}
	cout << "No" << endl;
    return 0;
}

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

int main()
{
    int N, S, D;
    cin >> N >> S >> D;
    int flag    =0;
    for(int i=0; i<N; i++){
        int X, Y;
        cin>> X>> Y;
        if(X<S && Y>D){
            flag=1;
            cout << "Yes"<< endl;
            return 0;
        }
    }
    cout << "No"<< endl;

}


#include <bits/stdc++.h>
using namespace std;
// clang-format off
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
// using mint = modint998244353

using ll = int64_t;
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& a : v) cin >> a;
    return is;
}
template <class T>
istream& operator>>(istream& is, vector<pair<T, T>>& v) {
    for (auto& a : v) cin >> a.first >> a.second;
    return is;
}
template <class T>
istream& operator>>(istream& is, vector<tuple<T, T, T>>& v) {
    for (auto& a : v) {
        T a1, a2, a3;
        cin >> a1 >> a2 >> a3;
        a = {a1, a2, a3};
    }
    return is;
}
template<typename T>
istream& operator>>(istream &is, complex<T>& c) {
    double x, y;
    is >> x >> y;
    c.real(x);
    c.imag(y);
    return is;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
    for (auto& a : v) os << a << " ";
    os << endl;
    return os;
}
template<class T>
bool chmin(T &a, T b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<class T>
bool chmax(T &a, T b) {
    if (a < b) { a = b; return true; }
    return false;
}
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
#define TRC1(a) cout << #a ":" << a
#define TRC2(a, b) TRC1(a); cout << " "; TRC1(b)
#define TRC3(a, b, c) TRC2(a, b); cout << " "; TRC1(c)
#define TRC4(a, b, c, d) TRC3(a, b, c); cout << " "; TRC1(d)
#define GET_NAME(_1,_2,_3,_4,NAME,...) NAME
#define TRC(...) GET_NAME(__VA_ARGS__, TRC4, TRC3, TRC2, TRC1) (__VA_ARGS__) << endl
using veci = vector<int>;
using vecll = vector<ll>;
using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
const int IINF = INT32_MAX;
const ll LINF = INT64_MAX;

// cout << fixed << setprecision(15);
void solve();
int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cout << fixed << setprecision(15); solve(); return 0; }
// clang-format on

void solve() {
    int N;
    cin >> N;
    veci A(N);
    cin >> A;
    sort(all(A));
    ll s = 0;
    ll ans = 0;
    rep(i, N) {
        ans += (ll)i * A[i] - s;
        s += A[i];
    }
    cout << ans << endl;
}

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

void print(vector<int> &a){for(auto l : a) cout<<l<<" "; cout<<'\n';}

void solve(){
    ll n;
    cin>>n;
    ll a[n];

    for(int i=0;i<n;++i) cin>>a[i];
    sort(a,a+n);
    ll ans = 0;
    for(int i=0;i<n;++i){
        ans+= (2 * i - n +1) * a[i];
    }
    cout<<ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("lex.in", "r", stdin);//freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e18, P=998244353;

ll q=1, n, m, y, z, l, r, k, a[N], b[N], f[N], ans, o, u, g, Ans[N];
string s[N],x;

int solve (int n, int r) {
    vector<int> p;
    for (int i=2; i*i<=n; ++i)
        if (n % i == 0) {
            p.push_back (i);
            while (n % i == 0)
                n/=i;
        }
    if (n>1)p.push_back (n);

    int sum = 0;
    for (int msk=1; msk<(1<<p.size()); ++msk) {
        int mult = 1,
            bits = 0;
        for (int i=0; i<(int)p.size(); ++i)
            if (msk & (1<<i)) {
                ++bits;
                mult *= p[i];
            }

        int cur = r / mult;
        if (bits % 2 == 1)
            sum += cur;
        else
            sum -= cur;
    }

    return r - sum;
}

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

	cin>>l>>r;
	if(l==1)l++;
	ans=(r-l+1)*(r-l);
	for(int i=l; i<=r; i++)ans-=solve(i, r)-solve(i, l-1);
	ans>>=1;
	for (int i=l; i<=r; i++)ans-=r/i-1;

	cout<<ans*2<<endl;

}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int h, w, i, j;
  string buff;
  vector<vector<int> > field, score;

  cin >> h >> w;
  field.resize(h,vector<int>(w));
  score.resize(h,vector<int>(w));
  for(i=0;i<h;i++){
    cin >> buff;
    for(j=0;j<w;j++){
      if(buff[j]=='+') field[i][j] = 1;
      else field[i][j] = -1;
    }
  }

  if((h+w)%2==0){
    score[h-1][w-1] = field[h-1][w-1];
  }
  else{
    score[h-1][w-1] = field[h-1][w-1] * -1;
  }

  j = w-1;
  for(i=h-2;i>=0;i--){
    if((i+j)%2==0){
      score[i][j] = score[i+1][j] + field[i][j];
    }
    else{
      score[i][j] = score[i+1][j] - field[i][j];
    }
  }
  i = h-1;
  for(j=w-2;j>=0;j--){
    if((i+j)%2==0){
      score[i][j] = score[i][j+1] + field[i][j];
    }
    else{
      score[i][j] = score[i][j+1] - field[i][j];
    }
  }

  for(i=h-2;i>=0;i--){
    for(j=w-2;j>=0;j--){
      if((i+j)%2==0){
        score[i][j] = min(score[i+1][j],score[i][j+1]) + field[i][j];
      }
      else{
        score[i][j] = max(score[i+1][j],score[i][j+1]) - field[i][j];
      }
    }
  }

  if(h==1){
    if(w==1){
      cout << "Draw" << endl;
      return 0;
    }
    score[0][0] = score[0][1];
  }
  else if(w==1){
    score[0][0] = score[1][0];
  }
  else{
    score[0][0] = min(score[1][0],score[0][1]);
  }

  if(score[0][0]>0){
    cout << "Aoki" << endl;
  }
  else if(score[0][0]<0){
    cout << "Takahashi" << endl;
  }
  else{
    cout << "Draw" << endl;
  }

  return 0;
}


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

#define foo ios_base::sync_with_stdio(0),cin.tie(nullptr),cout.tie(nullptr)

#define ll long long

using namespace std;

ll makeInt(vector<int> v){
    reverse(v.begin(), v.end());
    int decimal = 1;
    int total = 0;
    for (auto& it : v)
    {
        total += it * decimal;
        decimal *= 10;
    }
    return total;
}

vector<int> makearray(ll n){

    vector<int> a;

    while(n > 0)
    {
        a.push_back(n%10);

        n/=10;
    }
    return a;

}

void sol(){

   ll n;
   ll k;
   cin>>n>>k;

  vector<int> t;
  ll a, b;
   while(k--){

       t = makearray(n);
       sort(t.begin(),t.end());
       a = makeInt(t);
       sort(t.begin(),t.end(),greater<int>());
       b = makeInt(t);

       n = abs(a-b);

   }

   cout<<n;
}

int main() {
	foo;

	    sol();

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

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

	int n;
	cin >> n;

	vector<string> ss(n);
	trav(s, ss) cin >> s;

	ld ans = 0;
	rep(i,0,n){
		vector<bool> vis(n, false);
		stack<int> st;
		vis[i] = true;
		st.push(i);
		while(!st.empty()){
			int j = st.top(); st.pop();
			rep(k,0,n) if(ss[k][j]=='1' && !vis[k]){
				vis[k] = true;
				st.push(k);
			}
		}
		ans += ld(1) / count(all(vis), true);
	}
	cout.precision(12);
	cout << ans << endl;
}


            #include <bits/stdc++.h>
            #include <ext/pb_ds/assoc_container.hpp>
            #include <ext/pb_ds/tree_policy.hpp>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i, a , b) for (ll i =a ; i < b ; i++)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            typedef long long  int ll;
            const ll N =  3e3+5;
            const ll mod = 998244353;
            const ll inf = 1e18;
            ll   n  , k  , m , q  , w , u , x , y , v , z , dp[N][N] ;

    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt , pt %= mod;
        if(n&1)
            pt *= a  ,pt %= mod;
        return pt;
    }

    int solve( int n , int k )
    {
        if( n < k )
        {
            return 0;
        }
        if( k == 0 )
        {
            return (n == 0);
        }
        ll &ans = dp[n][k];
        if(ans != -1)
        {
            return ans;
        }
        ans = solve(n-1,k-1) + solve( n , 2*k );
        if( ans >= mod ) ans -= mod;
        return ans;
    }

    int main()
    {
         IOS;
         int ts =1;
         ///cin >> ts ;
         while(ts--)
         {
             cin >> n >> k;
             memset(dp , -1, sizeof(dp));
             cout << solve(n ,k ) << endl;
         }
    }

// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,fma")

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

#define ll long long
#define ull unsigned long long
#define dd double
#define ld long double
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
#define pll pair <ll, ll>
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define inf (1LL << 61)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define for1(i, stop) for(ll i = 1; i <= stop; ++i)
#define for0(i, stop) for(ll i = 0; i < stop; ++i)
#define rep1(i, start) for(ll i = start; i >= 1; --i)
#define rep0(i, start) for(ll i = (start-1); i >= 0; --i)
#define ms(n, i) memset(n, i, sizeof(n))
#define casep(n) printf("Case %lld:", ++n)
#define pn printf("\n")
#define pf printf
#define EL '\n'
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    ll n;
    cin >> n;

    ll lcm = 1;

    for1(i, n) {
        ll mul = lcm * i;
        ll g = __gcd(lcm, i);

        lcm = mul / g;
    }

    cout << lcm + 1 << EL;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<tuple<int,int,int>,double> M;
double T(int A,int B,int C,double K){
    if(K == 0) return 0;
    if(M[make_tuple(A,B,C)] > 0){
        return M[make_tuple(A,B,C)] * K;
    }
    if(A >= 100 || B >= 100 || C >= 100){
        return K;
    }
    double S = 0,Q = 1.0 / (A + B + C);
    if(A != 0){
        S += T(A + 1,B,C,Q * A);
    }
    if(B != 0){
        S += T(A,B + 1,C,Q * B);
    }
    if(C != 0){
        S += T(A,B,C + 1,Q * C);
    }
    M[make_tuple(A,B,C)] = S + 1;
    return K * (S + 1);
}
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    double ans = 0.0;
    ans = T(A,B,C,1.0);
    cout << fixed << setprecision(15) << ans - 1.0 << endl;
}


/*
 * @Author: Krishnakant
 * @Date: 2021-03-19 23:18:20
 * @Last Modified by: Krishnakant
 * @Last Modified time: 2021-03-20 01:23:11
 */
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
typedef long long ll;
#define _cin                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
#define endl "\n"
#define pb push_back
#define rp(i, b) for (ll i = 0; i < b; ++i)
#define rpd(i, a) for (ll i = a; i >= 0; --i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define mll map<ll, ll>
#define sz(x) (ll) x.size()
#define sll set<ll>
#define pll pair<ll, ll>
#define F first
#define S second
#define eb emplace_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define precise(x) cout << fixed << setprecision(x)
const ll MAX = 1000004;
const ll INF = 1e18L + 5;
template <class T, class U>
void chmin(T &t, const U &u)
{
    if (t > u)
        t = u;
}
template <class T, class U>
void chmax(T &t, const U &u)
{
    if (t < u)
        t = u;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}
template <typename Arg1>
void pn(Arg1 &&arg1)
{
    cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1 &&arg1, Args &&...args)
{
    cout << arg1 << "\n";
    pn(args...);
}
template <typename Arg1>
void ps(Arg1 &&arg1)
{
    cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1 &&arg1, Args &&...args)
{
    cout << arg1 << " ";
    ps(args...);
}
template <typename Arg1>
void read(Arg1 &&arg1)
{
    cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1 &&arg1, Args &&...args)
{
    cin >> arg1;
    read(args...);
}

void solve()
{
    string s;
    read(s);
    string ans = "";
    for (auto i : s)
    {
        if (i == '.')
            break;
        ans += i;
    }
    pn(ans);
}

int main()
{

    _cin
        ll tc = 1;
    // cin >> tc;
    while (tc--)
    {
        solve();
    }
}

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cassert>
#include <map>
#include <numeric>
#include <cstring>
#include <set>
#include <ctime>
#include <queue>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <unordered_set>

using namespace std;

class InputReader {
public:
    InputReader() {}
    InputReader(const char *file_name) {
        input_file = fopen(file_name, "r");
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    inline InputReader &operator >>(int &n) {
        while((buffer[cursor] < '0' || buffer[cursor] > '9') && buffer[cursor] != '-') {
            advance();
        }
        int sign = 1;
        if (buffer[cursor] == '-') {
            sign = -1;
            advance();
        }
        n = 0;
        while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
            n = n * 10 + buffer[cursor] - '0';
            advance();
        }
        n *= sign;
        return *this;
    }
    inline InputReader &operator >>(long long &n) {
        while((buffer[cursor] < '0' || buffer[cursor] > '9') && buffer[cursor] != '-') {
            advance();
        }
        int sign = 1;
        if (buffer[cursor] == '-') {
            sign = -1;
            advance();
        }
        n = 0;
        while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
            n = n * 10 + buffer[cursor] - '0';
            advance();
        }
        n *= sign;
        return *this;
    }
private:
    FILE *input_file;
    static const int SIZE = 1 << 17;
    int cursor;
    char buffer[SIZE];
    inline void advance() {
        ++ cursor;
        if(cursor == SIZE) {
            cursor = 0;
            fread(buffer, SIZE, 1, input_file);
        }
    }
};

const int MAXN = 200000;

int a[1 + MAXN], b[1 + MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //fstream cin("input.txt");
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    long long c = 0;
    for (int i = 1, ma = 0; i <= n; i++) {
        ma = max(ma, a[i]);
        c = max(c, 1LL * b[i] * ma);
        cout << c << "\n";
    }
    return 0;
}


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

using ll = long long;

const int N = 26;
const int M = 10;

void add_vars(vector<char> &vars, string &s) {
	for (char c : s) {
		if (find(vars.begin(), vars.end(), c) == vars.end()) {
			vars.emplace_back(c);
		}
	}
}

ll process(string &s, vector<int> &dict) {
	ll res = 0LL;
	for (char c : s) {
		res = res * 10LL + dict[c - '0'];
	}
	return res;
}

bool solve(string &s1, string &s2, string &s3, vector<char> &vars, vector<int> &dict, vector<bool> &used,
		long unsigned int idx) {
	if (idx == vars.size()) {
		return process(s1, dict) + process(s2, dict) == process(s3, dict);
	}
	char c = vars[idx];
	for (int i = 0; i < M; i++) {
		if ((0 == i) && ((c == s1[0]) || (c == s2[0]) || (c == s3[0]))) {
			continue;
		}
		if (!used[i]) {
			used[i] = true;
			dict[c - '0'] = i;
			if (solve(s1, s2, s3, vars, dict, used, idx + 1)) {
				return true;
			}
			used[i] = false;
		}
	}
	return false;
}

int main(void) {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	vector<char> vars;
	add_vars(vars, s1);
	add_vars(vars, s2);
	add_vars(vars, s3);
	if (vars.size() > M) {
		cout << "UNSOLVABLE" << endl;
		return 0;
	}
	vector<int> dict(N);
	vector<bool> used(M, false);
	if (solve(s1, s2, s3, vars, dict, used, 0)) {
		cout << process(s1, dict) << endl;
		cout << process(s2, dict) << endl;
		cout << process(s3, dict) << endl;
	} else {
		cout << "UNSOLVABLE" << endl;
	}
	return 0;
}

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
   #include <atcoder/all>
   using namespace atcoder;
#endif
#define all(v) v.begin(), v.end()
using in = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const in INF=(in)1e18+7;
const int inf=max(int(1e18)+7,int(1e9)+7);
using P=pair<int,int>;
using T=tuple<int,int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};
template <typename Typ>
bool chmin(Typ &a, const Typ& b) {if (a > b) {a = b; return true;} return false;}
template <typename Typ>
bool chmax(Typ &a, const Typ& b) {if (a < b) {a = b; return true;} return false;}
template <typename Typ>
Typ ceil(Typ x, Typ y){return (x+y-1)/y;}
#ifdef  _DEBUG
    #define debug(x) cout<<"debug:"<<x<<endl
    #define vdebug(x) cout<<"debug:";\
                      for(auto asdf:x) cout<<asdf<<" ";\
                      cout<<endl
#else
    #define debug(x)
    #define vdebug(x)
#endif

int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cout << fixed << setprecision(12);
    int N,D,H;  cin>>N>>D>>H;
    vector<int> d(N),h(N);
        rep(i,N) cin>>d[i]>>h[i];
    double ans=0;
    rep(i,N){
        double tmp=H;
        tmp -= (double)(D)*(double)(H-h[i])/(double)(D-d[i]);
        chmax(ans,tmp);
    }
    cout<<ans<<"\n";

}/*
./problem.exe
*/


// Generated by 2.3.1 https://github.com/kyuridenamida/atcoder-tools

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

void solve(long long n, std::vector<long long> a){
    vector<pair<i64,int>> v;
    for(int i = 0; i < 2 * n; ++i){
        v.emplace_back(a[i], i);
    }
    sort(v.begin(), v.end());
    vector<int> fl(2 * n, 0);
    for(int i = 0; i < n; ++i){
        fl[v[i].second] = true;
    }
    queue<bool> que;
    string s;
    for(int i = 0; i < 2 * n; ++i){
        if(!que.empty() && que.front() != fl[i]){
            s += ')';
            que.pop();
        }
        else{
            que.emplace(fl[i]);
            s += '(';
        }
    }
    assert(que.empty());
    cout << s << endl;
}

signed main(){
    long long N;
    std::scanf("%lld", &N);
    std::vector<long long> A(2*N);
    for(int i = 0 ; i < 2*N ; i++){
        std::scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}

    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline","03") // Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero=upper") // Enable AVX
//#pragma GCC target("avx2") // Enable AVX
//#pragma comment(linker, "/STACK:1024000000,1024000000") // Increase stack limit
//#pragma GCC target("sse,sse2,sse,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") // I don't know what it is
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const int mod2 = 998244353;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 1ll * mod * mod;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){ return qpow(x,mod-2); }
bool isprime(int x){
    for(int i=2; i*i<=x; i++)
        if( x % i == 0 )
            return false;
    return true;
}
/// My Code -------------------------------------------------

int tc;

int fcmp(ii a,ii b){
    if( a.f != b.f ) return a.f < b.f;
        else return a.s > b.s;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int n;
    cin >> n;
    n += n;

    vector<ii> a(n+1);
    for(int i=1; i<=n; i++){
        cin >> a[i].f;
        a[i].s = i;
    }
    sort(all(a),fcmp);

    vector<int> c(n+1);
    for(int i=1; i<=n/2; i++){
        c[a[i].s] = 1;
        c[a[n-i+1].s] = -1;
    }

    string ans;
    int bal = 0;
    for(int i=1; i<=n; i++){
        bal += c[i];
        if( bal > 0 && c[i] == 1 ) ans += '(';
        if( bal >= 0 && c[i] == -1 ) ans += ')';
        if( bal < 0 && c[i] == -1 ) ans += '(';
        if( bal <= 0 && c[i] == 1 ) ans += ')';
    }
    cout << ans << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
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, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

signed main(){

    int N; cin >> N;
    string S; cin >> S;

    if(S[0] != S[N - 1]) Out(1);
    else{
        char t = S[0];
        bool ok = false;
        REP(i, N - 1) if(S[i] != t && S[i + 1] != t) ok = true;
        chOut(ok, 2, -1);
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
const int mod=998244353;
typedef long long ll;
int fa[N];

int find(int x)
{
    return x==fa[x]?fa[x]:fa[x]=find(fa[x]);
}
ll qpow(ll a,ll b)
{
       ll res=1;
       while(b)
       {
            if(b&1)
            {
                res=(res*a)%mod;
            }
            a=(a*a)%mod;

            b/=2;

       }
       return res;
}
int main()
{
       int n;
       cin>>n;
       int a[n+10];
       for(int i=1;i<=n;i++)
          fa[i]=i;
       for(int i=1;i<=n;i++)
          cin>>a[i];
       for(int i=1;i<=n;i++)
       {
           if(find(i)!=find(a[i]))
           {
                 fa[find(i)]=find(a[i]);
           }
       }
       int cnt=0;
       for(int i=1;i<=n;i++)
          if(find(i)==i)
               cnt++;
       cout<<qpow(2,cnt)-1<<endl;
}


#include <bits/stdc++.h>

using namespace std;

#define closeSync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const int MAXN = 1005;
const int LIM = 30;

map<pii,int> mp;
int n,m;
vector<int> G[MAXN][LIM];
struct Node{
    int u,v;
    int stp;
};
int vis[MAXN][MAXN];
int ans = INF;

inline void bfs(int st,int ed)
{
    queue<Node> q;
    q.push({st,ed,0});
    vis[st][ed] = vis[ed][st] = 1;
    while (!q.empty())
    {
        Node cur = q.front();
        q.pop();
        int u = cur.u,v = cur.v;
        if (mp.count({u,v}))
        {
            ans = min(ans,cur.stp+(u != v));
            continue;
        }
        for (int i=0;i<='z'-'a';i++)
        {
            for (auto uu : G[u][i])
            {
                for (auto vv : G[v][i])
                {
                    if (vis[uu][vv] == 0)
                    {
                        vis[uu][vv] = vis[vv][uu] = 1;
                        q.push({uu,vv,cur.stp+2});
                    }
                }
            }
        }
    }
}

inline void solve()
{
    cin >> n >> m;
    for (int i=1;i<=m;i++)
    {
        int u,v;char c;    cin >> u >> v >> c;
        G[u][c-'a'].push_back(v);
        G[v][c-'a'].push_back(u);
        mp[{u,v}] = mp[{v,u}] = 1;
    }
    for (int i=1;i<=n;i++)
        mp[{i,i}] = 1;

    bfs(1,n);
    cout << (ans==INF ? -1 : ans) << endl;

    return ;
}

int main()
{closeSync;
    // int T;  cin >> T;
    // while (T--)
        solve();
    return 0;
}

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
template<typename T>void ckmn(T&a,T b){a=min(a,b);}
template<typename T>void ckmx(T&a,T b){a=max(a,b);}
void rd(int&x){scanf("%i",&x);}
void rd(ll&x){scanf("%lld",&x);}
void rd(char*x){scanf("%s",x);}
void rd(ldb&x){scanf("%lf",&x);}
void rd(string&x){scanf("%s",&x);}
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&i:x)rd(i);}
template<typename T,typename...A>void rd(T&x,A&...args){rd(x);rd(args...);}
template<typename T>void rd(){T x;rd(x);return x;}
int ri(){int x;rd(x);return x;}
template<typename T>vector<T> rv(int n){vector<T> x(n);rd(x);return x;}
template<typename T>void ra(T a[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]);}
template<typename T1,typename T2>void ra(T1 a[],T2 b[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]),rd(b[st+i]);}
template<typename T1,typename T2,typename T3>void ra(T1 a[],T2 b[],T3 c[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]),rd(b[st+i]),rd(c[st+i]);}
void re(vector<int> E[],int m,bool dir=0){for(int i=0,u,v;i<m;++i){rd(u,v);E[u].pb(v);if(!dir)E[v].pb(u);}}
template<typename T>void re(vector<pair<int,T>> E[],int m,bool dir=0){for(int i=0,u,v;i<m;++i){T w;rd(u,v,w);E[u].pb({v,w});if(!dir)E[v].pb({u,w});}}

const int mod=1e9+7;
int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
void ckadd(int&a,int b){a=add(a,b);}
int sub(int a,int b){a-=b;return a<0?a+mod:a;}
void cksub(int&a,int b){a=sub(a,b);}
int mul(int a,int b){return (ll)a*b%mod;}
void ckmul(int&a,int b){a=mul(a,b);}
int powmod(int x,int k){int ans=1;for(;k;k>>=1,ckmul(x,x))if(k&1)ckmul(ans,x);return ans;}
int inv(int x){return powmod(x,mod-2);}

const int N=10050;
int F[N],I[N];
int binom(int n, int k){ return mul(F[n],mul(I[k],I[n-k]));}
void calc()
{
	F[0]=1;
	for(int i=1;i<N;i++) F[i]=mul(F[i-1],i);
	I[N-1]=inv(F[N-1]);
	for(int i=N-2;~i;i--) I[i]=mul(I[i+1],i+1);
}

int main(){
	int n=ri();
	calc();
	char AA,AB,BA,BB;
	scanf("\n%c",&AA);
	scanf("\n%c",&AB);
	scanf("\n%c",&BA);
	scanf("\n%c",&BB);
	if(n<=3)return 0*printf("1\n");
	if(AA=='A'&&BB=='B')return 0*printf("1\n");
	if(AA=='B'&&BB=='A'){
		if(AB!=BA)return 0*printf("%i\n",powmod(2,n-3));
		int ans=0;
		for(int ba=0;ba*2<=n-2;ba++){
			int a=n-2-ba*2;
			ckadd(ans,binom(ba+a,a));
		}
		printf("%i\n",ans);
		return 0;
	}
	if(AA=='A'){
		AA='B';
		AB=AB=='A'?'B':'A';
		BA=BA=='A'?'B':'A';
		BB='B';
		//swap(AB,BA);
	}
	//AA -> ABA
	//BB -> BBB
	if(AB=='B'){
		//AB -> ABB
		printf("1\n");
		return 0;
	}else{
		//AB -> AAB
		if(BA=='A'){
			//BA -> BAA
			int ans=0;
			for(int ba=0;ba*2<=n-2;ba++){
				int a=n-2-ba*2;
				ckadd(ans,binom(ba+a,a));
			}
			printf("%i\n",ans);
			return 0;
		}else{
			//BA -> BBA
			int ans=powmod(2,n-3);
			printf("%i\n",ans);
			return 0;
		}
	}
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

static const int MOD = 1000000007;
static const int INF = (1 << 30);

int main() {
    ll x, y;
    cin >> x >> y;
    if(x > y) {
        if(x < y + 3) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if(x + 3 > y) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

int main(){
    int X, Y;
    cin >> X >> Y;
    int d = X - Y;
    d = abs(d);
    string ans = "No";
    if(d<=2){
        ans = "Yes";
    }

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