#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64(Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)
#define rep(...) repeat(__VA_ARGS__)

using namespace std;
using i64 = long long;
using u64 = unsigned long long;

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

    i64 n;
    cin >> n;

    vector<pair<i64, string>> v(n);
    for (auto &vs : v) cin >> vs.second >> vs.first;

    sort(v.rbegin(), v.rend());

    cout << v[1].second << endl;

    return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second
#define int ll

int dp[70][2];
string arr[70];
int n;
int calc(int ind, bool last){
    if(ind == n){
        return last;
    }
    if(dp[ind][last] != -1){
        return dp[ind][last];
    }
    if(arr[ind] == "AND"){
        return dp[ind][last] = calc(ind + 1, last & 1) + calc(ind + 1, 0);
    }
    else{
        return dp[ind][last] = calc(ind + 1, last | 1) + calc(ind + 1, last);
    }
}
int32_t main(){
    FAST
    cin >> n;
    bool OR = 0;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << calc(0, 0) + calc(0, 1);
    return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <climits>

#define rep(i, n) for(int i = 0; i < n; i++)
#define per(i, n) for(int i = n - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define mod 1000000007
using namespace std;
template<class T, class U>
T &chmax(T &a, const U &b){ if(a < b) a = b; return a; }
template<class T, class U>
T &chmin(T &a, const U &b){ if(a > b) a = b; return a; }
int n,m;
vvi root;
vi visited;
//woutの頂点を通らずにposからたどれる場所を見る
void fill(int pos, vi &checked){
  if(checked[pos] != -1) return;
  checked[pos] = 1;
  for(int x : root[pos]){
    if(checked[x] != -1) continue;
    fill(x, checked);
  }
}
ll dfs(int pos, vi checked){
  vi cnt(3);
  for(int x : root[pos]){
    if(checked[x] == -1) continue;
    cnt[checked[x]]++;
  }
  ll ans = 0;
  rep(i, 3){
    if(cnt[i]) continue;
    checked[pos] = i;
    ll res = 1;
    vi temp = checked;
    for(int x : root[pos]){
      if(checked[x] != -1 || temp[x] != -1) continue;
      fill(x, temp);
      ll num = dfs(x, checked);
      res *= num;
    }
    ans += res;
  }
  return ans;
}

int main(){
  cin >> n >> m;
  root.resize(n);
  rep(i, m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    root[a].push_back(b);
    root[b].push_back(a);
  }
  visited.resize(n, -1);
  ll ans = 1;
  rep(i, n){
    if(visited[i] != -1) continue;
    fill(i, visited);
    ll num = dfs(i, vi(n, -1));
    ans *= num;
    if(!ans) break;
  }
  cout << ans << "\n";
}

#include <bits/stdc++.h>

using namespace std;

vector<int> a[27];
int used[27], color[27];
vector< pair<int,int> > t;

long long n,m,v1,v2,res,globalres;

void dfs(int v,int type) {
    used[v]=type;
    t.push_back({v,used[v]});
    for(auto to : a[v])
        if(used[to] == 0) dfs(to,2);
}

void put(int pos, int col) {
    int v = t[pos].first;
    for(auto to : a[v])
        if(color[to]==col) return;
    if(pos==n-1 || t[pos+1].second==1) res++;
    else {
        color[v] = col;
        put(pos+1, 1);
        put(pos+1, 2);
        put(pos+1, 3);
        color[v] = 0;
    }
}

int main() {
    cin >> n >> m;
    for(int i=1; i<=m; i++) {
        cin >> v1 >> v2;
        a[v1].push_back(v2);
        a[v2].push_back(v1);
    }

    for(int i=1; i<=n; i++)
        if(used[i]==0) {
            used[i]=1;
            dfs(i,1);
        }
    globalres = 1;
    for(int i=0; i<n; i++)
        if(t[i].second==1) {
            res = 0;
            put(i,1);
            put(i,2);
            put(i,3);
            globalres *= res;
        }
    cout << globalres << endl;
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    rep(i, k) {
        int len = s.size();
        int original = len;
        if (len % 2) {
            len *= 2;
        }
        string ns = "";
        rep(j, len) {
            int t = j % original;
            int nt = (j + 1) % original;
            if (s[t] == 'P') {
                if (s[nt] == 'S') {
                    ns += 'S';
                } else {
                    ns += 'P';
                }
            }
            if (s[t] == 'R') {
                if (s[nt] == 'P') {
                    ns += 'P';
                } else {
                    ns += 'R';
                }
            }
            if (s[t] == 'S') {
                if (s[nt] == 'R') {
                    ns += 'R';
                } else {
                    ns += 'S';
                }
            }
            ++j;
        }
        s = ns;
    }

    cout << s[0] << endl;
    return 0;
}

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

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
		return false;
	}
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

signed main(){
   	int a=read(),b=read();
   	int x,y;
   	x=(a+b)/2;
   	y=a-x;
   	printf("%lld %lld\n",x,y);
   	return 0;
}


#include <bits/stdc++.h>
#define debug(x) cout << #x << ":\t" << (x) << endl;
using namespace std;
#define ll long long
const int N = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
int n;
char s[N];
vector<int>G[N];
int vis[110];
void dfs(int u) {
	vis[u] = 1;
	for (int v : G[u]) {
		if (!vis[v]) {
			dfs(v);
		}
	}
}
double ans;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", s + 1);
		for (int j = 1; j <= n; j++) {
			if (s[j] == '1') {
				G[j].push_back(i);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof(vis));
		dfs(i);
		int t = 0;
		for (int j = 1; j <= n; j++)if (vis[j])t++;
		ans += 1.0 / t;
	}
	printf("%.10lf\n", ans);
	return 0;
}

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

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define p push
#define pp pop

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)     //no of 1 in binary
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define clz(n) __builtin_clz(n)       //count leading zeros in binary
#define clzll(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctz(n)      //count trailing zeros

#define B begin()
#define E end()
#define rB rbegin()
#define rE rend()
#define sz size()
#define C count()
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define mp make_pair
typedef long long int ll;
#define V(type) vector<type>
#define PQ(type) priority_queue<type>
#define pll pair<ll, ll>
#define F first
#define S second
#define rep(i,n) for(int i=0;i<n;i++)

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

#define mod 1000000007
#define INF 9223372036854775807
const double delta = 0.0000000001;
const double pi = 3.1415926535;

ll rand_int(ll l, ll r)
{ //[l, r]
    #ifdef LOCAL
    static mt19937_64 gen;
    #else
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    #endif
    return uniform_int_distribution<ll>(l, r)(gen);
}

void FAST() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
ll fact(ll n)   //O(N)
{
    if(n<2)return 1;
    else return n*fact(n-1);
}
ll xi(ll x,ll y,ll p){            //gives (x^y)%p             //O(n) atmax  ,not sure though
    ll r=1;
    x=x%p;
    while(y>0){
        if(y%2==0){
            x*=x;
            x=x%p;
            y/=2;
        }
    else {
        r=((r%p)*(x%p))%p;
        y--;
    }

    }
    return r;
}
ll countBits(ll n) {     //log n
    ll count = 0;
    while (n) {
        count++;
        n >>= 1;
    }
    return count;
}

ll isP(ll n) {               //returns 1 if prime          //O(sqrtN)
    if (n == 0 || n == 1) return 0;
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}

V(int) decTobin(int n)    //returns a vector binary number,  input a integer
{                               //O(log n)
        V(int) a,ans;
    while(n>0)
    {
        a.pb(n%2);
        n/=2;
    }
    for(int i=a.size()-1;i>=0;i--)
    {
        ans.pb(a[i]);
    }
    return ans;

}
inline ll modadd(ll a, ll b, ll m = mod)
{
    a += b;
    if (a >= m)
        a -= m;
    return a;
}

inline ll modmul(ll a, ll b, ll m = mod)
{
    return ((a % m) * (b % m)) % m;
}
void solve()
{
    int n;
    cin>>n;
    n=pow(2,n);
    ll maxa=0,maxb=0,posa=0,posb=0;;
    V(ll) arr(n/2),b(n/2);
    rep(i,n/2){cin>>arr[i];maxa=max(maxa,arr[i]);if(maxa==arr[i])posa=i;}
    rep(i,n/2){cin>>b[i];maxb=max(maxb,b[i]);if(maxb==b[i])posb=i;}
    if(maxa<maxb)cout<<posa+1;
    else cout<<n/2+posb+1;

    return;
}

int main()
{   FAST();
ll ttt;
//cin>>ttt;
ttt=1;
while(ttt--)
{
    solve();
}

return 0;
}


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

ll A,B,C,D;

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

    cin>>A>>B>>C>>D;

    vector<ll>V;
    V.pb(A);
    V.pb(B);
    V.pb(C);
    V.pb(D);

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

    if((V[0] + V[3]) == (V[1] + V[2]))
        cout<<"Yes"<<endl;

    else if(V[0] + V[1] + V[2] == V[3])
        cout<<"Yes"<<endl;

    else
        cout<<"No"<<endl;

    return 0;
}

#include <iostream>
using namespace std;

int cookies[4];

bool dfs(int index, int sum) {
    if(!sum) {
        return 1;
    }
    if(index == 4 || sum < 0) {
        return 0;
    }
    return dfs(index + 1, sum) || dfs(index + 1, sum - cookies[index]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int sum = 0;
    for(int i = 0; i < 4; i++) {
        cin >> cookies[i];
        sum += cookies[i];
    }
    cout << (!(sum & 1) && dfs(0, sum >> 1) ? "Yes" : "No");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if((a[2] - a[1]) == (a[1] - a[0]) ){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    set<ll>s;
    map<ll, ll>mp;
    ll d = 0;
    for(ll i = 0; i < 3; i++) {
        ll x; cin >> x;
        s.insert(x);
        mp[x]++;
        d = x;
    }
    if(s.size() == 3) {
        cout << 0 << '\n';
        return 0;
    }

    ll ans = 0;
    if(s.size() == 1) {
       cout << d << '\n';
       return 0;
    }

    for(auto i : mp) {
        if(i.second != 2) d = i.first;
    }

    cout << d << '\n';

}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

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

ll N, K;

ll nC2(ll n) {
    if (n<2) return 0;
    return n * (n-1) / 2;
}

ll nC1(ll n) {
    if (n<1) return 0;
    return n;
}

ll cnt_ijk(ll S) {
    ll res = nC2(S-3+2);
    res -= 3 * nC2(S-N-3+2);
    res += 3 * nC2(S-2*N-3+2);
    res -= nC2(S-3*N-3+2);
    return res;
}

ll cnt_jk(ll S) {
    ll res = nC1(S-2+1);
    res -= 2 * nC1(S-N-2+1);
    res += nC1(S-2*N-2+1);
    return res;
}

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

    ll cnt = 0, ijk = 0;
    for (ll i=3; i<=3*N; i++) {
        cnt += cnt_ijk(i);
        if (cnt>=K) {
            cnt -= cnt_ijk(i);
            ijk = i;
            break;
        }
    }

    ll imin = max(1LL,ijk-2*N), imax = min(N,ijk-2);
    ll I = 0, jk = 0;
    for (ll i=imin; i<=imax; i++) {
        cnt += cnt_jk(ijk-i);
        if (cnt>=K) {
            cnt -= cnt_jk(ijk-i);
            I = i;
            jk = ijk - i;
            break;
        }
    }

    ll jmin = max(1LL,jk-N), jmax = min(N,jk-1);
    ll J = 0;
    for (ll j=jmin; j<=jmax; j++) {
        cnt++;
        if (cnt==K) {
            J = j;
            cout << I << " ";
            cout << J << " ";
            cout << jk - J << endl;
            return 0;
        }
    }
}

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

using ll = long long;

const int N = 3;

int main(void) {
	int n;
	ll k;
	cin >> n >> k;
	vector<vector<ll>> dp(N + 1, vector<ll>(N * n + 2, 0LL));
	dp[0][0] = 1LL;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= (i * n); j++) {
			dp[i + 1][j + 1] += dp[i][j];
			dp[i + 1][j + 1 + n] -= dp[i][j];
		}
		for (int j = 1; j < (i + 1) * n + 2; j++) {
			dp[i + 1][j] += dp[i + 1][j - 1];
		}
	}
	int sum;
	for (sum = N; sum <= N * n; sum++) {
		if (k <= dp[N][sum]) {
			break;
		}
		k -= dp[N][sum];
	}
	vector<int> ans(N);
	for (int i = 0; i < N - 1; i++) {
		for (int j = 1; j <= n; j++) {
			if (k <= dp[N - i - 1][sum - j]) {
				ans[i] = j;
				sum -= j;
				break;
			}
			k -= dp[N - i - 1][sum - j];
		}
	}
	ans[N - 1] = sum;
	for (int i = 0; i < N; i++) {
		if (i) {
			cout << " ";
		}
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> Vll;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    vector<vector<int>> ss(h+1,vector<int>(w+1));
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
            if(s[i][j]=='#'){
                ss[i][j]++;
                ss[i+1][j]++;
                ss[i][j+1]++;
                ss[i+1][j+1]++;
            }
        }
    }
    ll ans=0;
    rep(i,h+1){
        rep(j,w+1){
            if(ss[i][j]%2==1)ans++;
        }
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
#define lli long long
#define lld double
#define test int t;cin>>t;while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define  mod 1000000007
#define ff first
#define ss second
#define ppl pair<lli , lli>
#define ppi pair<int , int>
#define large 1000000000000000000
using namespace std;
bool comp(const ppl &a,const ppl &b)
{
    return (a.ss < b.ss);
}
void solve()
{
    lli n , money , pre = 0;
    cin >> n >> money;
    vector<ppl>v(n);
    for(int i = 0 ; i < n ; i++)
    {
        cin >> v[i].ff >> v[i].ss;
    }
    sort(v.begin() , v.end());
    for(int i = 0 ; i < n ; i++)
    {
        if(money < (v[i].ff - pre))
        {
            break;
        }
        money -= (v[i].ff - pre);
        pre = v[i].ff;
        money += v[i].ss;
    }
    pre += money;
    cout << pre;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
#endif
    fast_io;
    //test
    {
        solve();
    }
    return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

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

#define mp make_pair

const int MOD =  998244353;

int mul(int a, int b) {
    return (1LL * a * b) % MOD;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=MOD) s-=MOD;
    return s;
}

int sub(int a, int b) {
    int s = (a+MOD-b);
    if (s>=MOD) s-=MOD;
    return s;
}

int po(int a, ll deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, MOD-2);
}

mt19937 rnd(time(0));

const int LIM = 200000;

vector<int> facs(LIM), invfacs(LIM);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<LIM; i++) facs[i] = mul(facs[i-1], i);
    invfacs[LIM-1] = inv(facs[LIM-1]);
    for (int i = LIM-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}

/*
struct DSU
{
    vector<int> sz;
    vector<int> parent;
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);

        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};*/

const int N = 10000;

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

    init();
    int n; cin>>n;
    vector<int> w(n);
    for (int i = 0; i<n; i++) cin>>w[i];
    vector<vector<int>> dp(N+1, vector<int>(n+1));

    dp[0][0] = 1;
    for (int i = 0; i<n; i++)
    {
        for (int W = N; W>=w[i]; W--)
            for (int cnt = i+1; cnt>=1; cnt--) dp[W][cnt] = add(dp[W][cnt], dp[W-w[i]][cnt-1]);
    }

    int tot = 0; for (auto it: w) tot+=it;
    if (tot%2==1) {cout<<0<<endl; return 0;}
    int need = tot/2;

    int ans = 0;

    for (int take = 0; take<=n; take++)
    {
        ans = add(ans, mul(dp[need][take], mul(facs[take], facs[n-take])));
    }

    cout<<ans;
}

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//#define ACL
#ifdef ACL
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#if __has_include("acl-all.h")
#include "acl-all.h" //on Wandbox
using namespace atcoder;
#endif
#endif //#ifdef ACL

typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef vector<vector<bool> > vvb;
typedef pair<ll, ll> pll;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rrep(i, n) for (int i = 1; i <= int(n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = int(n)-1; i >= 0; --i)

#define MES(a) MES2 a
#define MES2(a0,a1,a2,a3,a4,x,...) x
#define mes_1(x1) cout<<x1<<endl
#define mes_2(x1,x2) cout<<x1<<" "<<x2<<endl
#define mes_3(x1,x2,x3) cout<<x1<<" "<<x2<<" "<<x3<<endl
#define mes_4(x1,x2,x3,x4) cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<endl
#define mes_5(x1,x2,x3,x4,x5) cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<" "<<x5<<endl
#define mes(...) CHOOSE((__VA_ARGS__,mes_5,mes_4,mes_3,mes_2,mes_1,~))(__VA_ARGS__)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)

#define Ynmes(a) (a) ? mes("Yes") : mes("No")
#define YNmes(a) (a) ? mes("YES") : mes("NO")
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())

int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

ll fact_mod(ll n, ll mod) {
    ll f = 1; for (ll i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}

ll modpow(ll x, ll n, ll mod) {
    if(n == 0) return 1;
    ll res = modpow((x * x) % mod, n / 2 , mod);
    if(n & 1) res = (res * x) % mod;
    return res;
}

ll modncr(ll n, ll r, ll mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    ll a = 1;
    rep(i, r) a = a * ((n-i) % mod) % mod;
    ll b = modpow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

signed main() {
	ld n;
    ld x0, y0, xm, ym;
    cin >> n >> x0 >> y0 >> xm >> ym;
    ld cx = (x0 + xm) / 2;
    ld cy = (y0 + ym) / 2;

    ld x = x0 - cx;
    ld y = y0 - cy;
    ld rad = 2 * acos(-1) / n;
    ld x1 = cos(rad) * x - sin(rad) * y;
    ld y1 = sin(rad) * x + cos(rad) * y;
    printf("%.10Lf %.10Lf\n", x1+cx, y1+cy);

}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define len(a) (int)a.size()
#define all(a) a.begin(), a.end()

const int INF32 = 1 << 30;
const long long INF64 = 1LL << 60;
const double PI = acos(-1);

int main() {
    string S;
    cin >> S;
    list<char> T;

    int inv = 0;
    rep(i, len(S)) {
        if (S[i] == 'R') {
            inv++;
        }
        else {
            if (inv % 2 == 1) {
                if (!T.empty() && S[i] == T.front()) {
                    T.pop_front();
                }
                else {
                    T.push_front(S[i]);
                }
            }
            else {
                if (!T.empty() && S[i] == T.back()) {
                    T.pop_back();
                }
                else {
                    T.push_back(S[i]);
                }
            }
        }
    }

    if (inv % 2 == 1) T.reverse();
    string ans = "";
    for(auto itr = T.begin(); itr != T.end(); ++itr) {
        ans += *itr;
    }

    cout << ans << endl;
}

#include<cstdio>
#define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i)
using namespace std;
const int N=5e5+5;
template<typename T>void read(T &x)
{
	bool neg=false;
	unsigned char c=getchar();
	for(;(c^48)>9;c=getchar())if(c=='-')neg=true;
	for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48);
	if(neg)x=-x;
}
char s[N],a[2*N];
int n,l=N,r=N;
bool empty=true;
int main()
{
	scanf("%s",s);
	while(s[n])++n;
	F(i,0,n)
	{
		if(s[i]=='R')l^=r^=l^=r;
		else
		{
			if(empty)a[l=r]=s[i],empty=false;
			else
			{
				if(s[i]==a[r])
				{
					if(l!=r)r-=l<r?1:-1;
					else empty=true;
				}
				else r+=l<r?1:-1,a[r]=s[i],empty=false;
			}
		}
	}
	if(!empty)
	{
		if(l<r)F(i,l,r+1)putchar(a[i]);
		if(l>r)for(int i=l;i>=r;--i)putchar(a[i]);
		if(l==r)putchar(a[l]);
	}
	putchar('\n');
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
/* * * *   * * *   	* * * */
/* *
 *
 * Too many mind, no mind.
 *
 * */
const ll mod = 998244353;
ll add(ll a, ll b) { return a + b >= mod ? a + b - mod : a + b; }
ll sub(ll a, ll b) { return a >= b ? a - b : a - b + mod; }
ll mul(ll a, ll b) { return a * b % mod; }
ll powmod(ll b, ll e) {
	ll ans = 1;
	for (ll m = b; e; e >>= 1, m = mul(m, m))
		if (e & 1) ans = mul(ans, m);
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	vector <ll> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	ll sum = 0, p = 1, ans = 0, inv = powmod(2, mod - 2);
	for (int i = 0; i < n; ++i) {
		sum = add(sum, mul(a[i], p));
		p = mul(p, 2);
	}
	for (int i = 0; i < n; ++i) {
		sum = sub(sum, a[i]);
		sum = mul(sum, inv);
		ans = add(ans, mul(a[i], sum));
		ans = add(ans, mul(a[i], a[i]));
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;

long long const mod = 998244353;
struct mint{
	long long val;
	mint(long long val = 0): val(val % mod) {}
	mint& operator += (const mint n){
		val += n.val;
		if(val >= mod) val -= mod;
		return *this;
	}
	mint& operator -= (const mint n){
		val -= n.val;
		if(val < 0) val += mod;
		return *this;
	}
	mint& operator *= (const mint n){
		val *= n.val;
		val %= mod;
		if(val < 0) val += mod;
		return *this;
	}
	mint operator + (const mint n) const{
		mint res(*this);
		return res += n;
	}
	mint operator - (const mint n) const{
		mint res(*this);
		return res -= n;
	}
	mint operator * (const mint n) const{
		mint res(*this);
		return res *= n;
	}
	mint pow(long long n) const{
		if(n == 0) return 1;
		mint m = pow(n >> 1);
		m *= m;
		if(n & 1) m *= *this;
		return m;
	}
	// mint division for prime mod
	mint inv() const{
		return pow(mod - 2);
	}
	mint& operator /= (const mint n){
		return (*this) *= n.inv();
	}
	mint operator / (const mint n) const{
		mint res(*this);
		return res /= n;
	}
};

int main(){
	int N;
	cin >> N;
	vector<LL> A(N);
	rep(i,N) cin >> A[i];
	if(N == 1){
		cout << A[0] * A[0] % mod << endl;
		return 0;
	}
	sort(A.begin(), A.end());
	mint ans = 0;
	vector<mint> sum(N-1);
	sum[N-2] = 1;
	for(int i = N - 3; i >= 0; i--) sum[i] = sum[i+1] * 2;
	mint tot = 0;
	rep(i,N-1) tot += sum[i] * A[i];
	for(int i = N - 1; i >= 0; i--){
		ans += A[i] * A[i];
		ans += tot * A[i];
		if(i == 0) break;
		tot -= A[i-1];
		tot /= 2;
	}
	cout << ans.val << 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);
    ll n;
    cin>>n;
    ll ans=0;
    ll k =sqrt(n);
    set<ll>s;
    for(int i=2;i<=k;i++){
            ll p =i;
        for(int j=2;j<40;j++){
            p*=i;
            if(p>n)break;
            else s.insert(p);
        }
    }

cout<<n-s.size()<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
template<typename T,typename U>
ostream& operator<<(ostream& os, const pair<T,U>& p) {
    cerr << ' ' <<  p.x << ',' << p.y; return os; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
template<typename T,typename U>
ostream& operator<<(ostream& os, const map<T,U>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

const ll X = 6;
struct S {
    vll v;
    bool z;
    vll ret;
    ll hsh() {
        ll ret = 0;
        for(auto i: v) { ret = X*ret + i; }
        ret = 2*ret + z;
        return ret;
    }
};

vll solve(ll n, vll v) {
    ll x=0;
    vll ret;
    bool z = 1;
    while(x<n-X) {
        while(x<n && v[x]==x) x++;
        if(x==n) break;
        ll p; F(n) if(v[i]==x) p=i;
        if((p&1)==z) {
            while(p!=x) {
                swap(v[p-1],v[p]);
                ret.pb(p-1);
                z = !z;
                p--;
            }
        } else {
            F(X-1) {
                if(((n-i-1)&1)==z && v[n-i-1]!=x && v[n-i-2]!=x) {
                    swap(v[n-i-1],v[n-i-2]);
                    ret.pb(n-i-2);
                    z = !z;
                    break;
                }
            }
        }
    }
    if(x!=n) {
        x = max(0ll, n-X);
        queue<S> q;
        vll w; FOR(i,x,n) w.pb(v[i]-x);
        q.push({w,z});
        set<ll> vis;
        ll m = w.size();
        while(q.size()) {
            auto cur = q.front(); q.pop();
            if(vis.count(cur.hsh())) continue;
            vis.insert(cur.hsh());
            bool ok = 1;
            F(m) ok &= cur.v[i]==i;
            if(ok) {
                for(auto i: cur.ret) ret.pb(i+x);
                break;
            }
            FOR(i,1,m) if(((i+x)&1)==cur.z) {
                S ss = cur;
                ss.z = !ss.z;
                ss.ret.pb(i-1);
                swap(ss.v[i-1], ss.v[i]);
                q.push(ss);
            }
        }
    }
    return ret;
}

void SOLVE() {
    ll n; cin >> n;
    vll v(n);
    F(n) {
        cin >> v[i];
        v[i]--;
    }
    auto ret = solve(n,v);
    cout << ret.size() << endl;
    for(auto i: ret) cout << i+1 << ' ';
    cout << endl;
}

int main(void) {
    ios_base::sync_with_stdio(false);
    ll _T; cin >> _T;
    REP(_,_T) SOLVE();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MOD=3;
const int msize=400005;

int warusan[msize];
int mod3[msize];

void initComb(){
  for(int i=1;i<msize;i++){
    int t=i;
    while(t%3==0){
      t/=3;
      warusan[i]++;
    }
    mod3[i]=t%3;
  }
  for(int i=2;i<msize;i++){
    warusan[i]+=warusan[i-1];
    mod3[i]=mod3[i]*mod3[i-1]%MOD;
  }
}

int comb(int n,int r){
  if(warusan[n]>warusan[r]+warusan[n-r])return 0;
  if((mod3[n]+mod3[r]*mod3[n-r])%3==0)return 2;
  return 1;
}

int main(){
  initComb();
  int n;
  cin>>n;
  vector<short>a(n);
  char t;
  char ans[3]={'R','W','B'};
  for(int i=0;i<n;i++){
    cin>>t;
    switch(t){
      case 'R':a[i]=0;break;
      case 'W':a[i]=1;break;
      case 'B':a[i]=2;break;
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    sum=(sum+comb(n-1,i)*a[i])%3;
  }
  if(n%2==0)sum=(3-sum)%3;
  cout<<ans[sum]<<'\n';
}

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define maxm 600005
#define maxn 150005
#define ls (tot << 1)
#define rs (tot << 1 | 1)
#define PII pair<int, int>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const double eps = 1e-10;
inline ll read(){
    ll x = 0, f = 1;char ch = getchar();
    while(ch > '9' || ch < '0'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch -'0';ch = getchar();}
    return x * f;
}
int n;
char s[400005];
int getc(char c){
	if(c == 'B') return 0;
	if(c == 'R') return 1;
	return 2;
}
int c[20][20];
int C(int n, int m){
	if(m > n) return 0;
	if(n <= 3) return c[n][m];
	return C(n / 3, m / 3) * C(n % 3, m % 3);
}
int main(){
	n = read();
	scanf("%s", s);
	int sum = 0;
	int f = 1;
	c[0][0] = 1;
	for(int i = 1;i <= 10;i++){
		c[i][0] = 1;
		for(int j = 1;j <= i;j++){
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 3;
		}
	}
	if(n % 2 == 0) f = -1;
	for(int i = 0;i < n;i++){
		sum = (sum + C(n - 1, i) * f * getc(s[i])) % 3;
	}
	sum = sum + 3;
	sum %= 3;
	if(sum == 0) puts("B");
	else if(sum == 1) puts("R");
	else puts("W");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

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

  ll X, Y;
  cin >> X >> Y;
  for(ll i = -100; i <= 100; i++){
    for(ll j = -100; j <= 100; j++){
      if (i + j == X && i - j == Y){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) / 2 << " " << (a - b) / 2 << endl;
}


#include <bits/stdc++.h>
#define ll long long
//#include "crocodile.h"
#define pb push_back
#define task "asd"
#define pll pair<ll, ll>
#define pii pair<pll, ll>
#define fi first
#define se second

using namespace std;
const ll mod = 1e9+7;
const ll N = 2e5+5;
const int base = 313;
ll n, k, m, tong, ans, t, a[N], b[N];
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}
void sol()
{
    cin >> n >> k;
    cout << (k - 1) * pw(k-2, n-1) % mod;
}
int main()
{
    if(fopen(task".INP", "r"))
    {
       freopen(task".INP", "r", stdin);
       freopen(task".OUT", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}
/*
4
2 5
10 10
2 5
3 3
4 5
5 2 4 9
1
8 8
5 3 1 6 10 100 9 15

https://codeforces.com/contest/791/problem/E

*/

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

using namespace std;

// using mint = long double;
// using mint = modint998244353;
// using mint = modint1000000007;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<ll, vector<ll>> Pd;

const ll INF = 4e18;
const ll fact_table = 3200008;

priority_queue<ll> pql;
priority_queue<P> pqp;
// big priority queue
priority_queue<ll, vector<ll>, greater<ll>> pqls;
priority_queue<P, vector<P>, greater<P>> pqps;
// small priority queue
// top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/

#define p(x) cout << x << endl;
#define el cout << endl;
#define pe(x) cout << x << " ";
#define ps(x) cout << fixed << setprecision(25) << x << endl;
#define pu(x) cout << (x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = a; i <= (b); i++)
#define rep3(i, a, b) for (ll i = a; i >= (b); i--)
#define all(c) begin(c), end(c)

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

// vec v(n) -> 長さnのベクトルを宣言
// mat dp(h, vec(w)) -> h * w の行列を宣言

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll m = mod) {
    ll x = 1;
    while (b) {
        while (!(b & 1)) {
            (a *= a) %= m;
            b >>= 1;
        }
        (x *= a) %= m;
        b--;
    }
    return x;
}
vec rv(ll read) {
    vec res(read);
    for (int i = 0; i < read; i++) {
        cin >> res[i];
    }
    return res;
}
/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod) * rfact[n - r]) % mod;
}
*/
bool icpc = false;
bool multicase = false;

// 配列の長さ、取り間違えてない？

ll m_size = 2;

vec matmul(vec &dp, mat &mt) {
    vec ret(m_size, 0ll);
    for (ll i = 0; i < m_size; i++) {
        for (ll j = 0; j < m_size; j++) {
            ret[i] += mt[i][j] * dp[j];
            ret[i] %= mod;
        }
    }
    return ret;
}
mat update(mat &mt) {
    mat ret(m_size, vec(m_size, 0ll));
    for (ll i = 0; i < m_size; i++) {
        for (ll j = 0; j < m_size; j++) {
            for (ll k = 0; k < m_size; k++) {
                ret[i][j] += (mt[i][k] * mt[k][j]) % mod;
                ret[i][j] %= mod;
            }
        }
    }
    return ret;
}

void matpow(vec &dp, mat &mt, ll k) {
    ll m = dp.size();
    while (k) {
        if (k & 1) dp = matmul(dp, mt);
        mt = update(mt);
        k /= 2;
    }
    return;
}

bool solve() {
    ll n, p;
    cin >> n >> p;
    ll ans = mypow(p - 2, n - 1) * (p - 1);
    ans %= mod;
    p(ans);
    return true;
}

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

    if (icpc) {
        while (solve())
            ;
        return 0;
    }
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // cout << "Case #" << testcase << ": ";
        solve();
        testcase++;
    }

    // solve();
    return 0;
}


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

int main() {
  vector<char> a(12);
  for ( int k = 0; k < 12; k++){
    cin >> a.at(k);
  }
  int p = 0;
  for ( int i = 0; i < 9; i++){
  if (a.at(i) == 'Z' && a.at(i + 1) == 'O'){
    if (a.at(i + 2) == 'N' && a.at(i + 3) == 'e'){
      p++;
    }
  }
  }
    cout << p << endl;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define is_in(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define rng(a) a.begin(),a.end()
#define rngr(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
const int inf = 1<<30;
const double pi = acos(-1);
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vs vector<string>
#define vp vector<P>
#define vvp vector<vp>
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
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; }

int main()
{
    int n = 0;//"Yes";"No"
    string s;
    cin >> s;
    rep(i, sz(s))if(i+4 <= sz(s)){
        string t = s.substr(i, 4);
        if(t == "ZONe") ++n;
    }
    cout << n << endl;
    return 0;
}


#include <cstdio>
#include <cctype>
#define int long long
#define FOR(i,j,k) for(int i=j; i<=k; ++i)
inline long long read (void) {
	long long x = 0; int f = 1, ch = getchar();
	while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
	while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int maxn = 200005;
int tot_edge, head[maxn], to[maxn<<1], link[maxn<<1];
long long weight[maxn<<1], a[maxn], ans;
int b[65];
inline void add_edge (int x, int y, long long w) {
	to[++tot_edge] = y;
	link[tot_edge] = head[x];
	weight[tot_edge] = w;
	head[x] = tot_edge;
}
void dfs (int x, int f = 0) {
	for(int now = head[x]; now; now = link[now]) {
		if(to[now] == f) continue;
		a[to[now]] = a[x] ^ weight[now];
		dfs (to[now], x);
	}
}
signed main (void) {
	int n = read();
	FOR(i,2,n) {
		int x = read(), y = read(); long long w = read();
		add_edge (x, y, w);
		add_edge (y, x, w);
	}
	dfs (1);
	for(int i=n; i>=1; --i)
		for(int j=0; j<60; ++j)
			if((1ll<<j) & a[i]) ++ b[j];
	for(int i=1; i<=n; ++i)
		for(int j=0; j<60; ++j)
			if((1ll<<j) & a[i]) ans = (ans + (1ll<<j) % 1000000007 * (n-i- --b[j])) % 1000000007;
			else ans = (ans + (1ll<<j) % 1000000007 * b[j]) % 1000000007;
	printf("%lld\n", ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
//indexed set is using "int" here--------- use ll ...
// typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll 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;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ve <ll> exor,parent;
map <pair<ll,ll>,ll> wt;
void dfs(ll node, ve<pair <ll,ll>> adj[], ve<bool> &visited)
{
    visited[node] = true;
    // do stuff
    exor[node]=exor[parent[node]]^wt[{parent[node],node}];
    for (int i = 0; i < (int)adj[node].size(); i += 1)
    {
        if (!visited[adj[node][i].first])
        {
            parent[adj[node][i].first]=node;
            dfs(adj[node][i].first, adj, visited);
        }
    }
}
long long int sumXOR(ve <ll> arr, ll n)
{
    ll sum = 0;
    ll one =1;
    for (int i = 0; i < 61; i++)
    {
        //  Count of zeros and ones
        ll zc = 0, oc = 0;

        // Individual sum at each bit position
        long long int idsum = 0;
        for (int j = 0; j < n; j++)
        {
            if (arr[j] % 2 == 0)
                zc++;
            else
                oc++;
            arr[j] /= 2;
        }

        // calculating individual bit sum
        idsum = (((oc%rem) * (zc%rem))%rem * ((one << i)%rem))%rem;

        // final sum
        sum += idsum;
        sum%=rem;
    }
    return sum;
}
int main()
{
    FAST;
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin >> n;
    exor.assign(n+1,0);
    parent.assign(n+1,0);
    ve<pair<ll, ll>> adj[n + 1];
    rep(i, 0, n - 1)
    {
        ll u, v, w;
        cin >> u >> v >> w;
        wt[{u,v}]=w;
        wt[{v,u}]=w;
        adj[u].pb({v, w});
        adj[v].pb({u, w});
    }
    ve <bool> visit(n+1,false);
    dfs(1,adj,visit);
    ll sum=0;
    rep (i,1,n+1)
    {
        sum+=exor[i];
    }
    ve <ll> v1(n);
    rep (i,1,n+1)
    {
        v1[i-1]=exor[i];
    }
    ll ans=sumXOR(v1,n);
    cout<<ans<<"\n";
}


#include <bits/stdc++.h>

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << " end.\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 3e5+5;
const int mod = 1e9+7;
/**
Read problem statement carefully
**/
LL BT[N];
int arr[N];
int n;
void add(int x){
    for(; x <= n; x += x&-x)
        BT[x]++;
}
int query(int x){
    int res = 0;
    for(; x > 0; x -= x&-x)
        res += BT[x];
    return res;
}

void solve(){
    cin >> n;

    LL inv = 0;
    for(int i = 0; i < n; ++i){
        cin >> arr[i]; arr[i]++;
        inv += i - query(arr[i]);
        add(arr[i]);
    }
    int small, big;
    for(int i = 0; i < n; ++i){
        cout << inv << "\n";
        small = arr[i]-1;
        big = n - arr[i];
        inv += big - small;
    }
}

int main()
{
    Fast;
    //louisfghbvc
        solve();
    return 0;
}

/**
enjoy the problem.
**/

#include<bits/stdc++.h>
using namespace std;
//Ҫ��longlong��Ҫ��longlong��Ҫ��longlong��
//���鿪�������鿪�������鿪����
char s[200005];
int main() {
	int t, n;
	scanf("%d", &t);
	while(t--) {
		scanf("%d", &n);
		scanf("%s", s);
		scanf("%s", s);
		scanf("%s", s);
		for(int i = 1; i <= n; ++i)
			putchar('0');
		for(int i = 1; i <= n; ++i)
			putchar('1');
		putchar('0');
		puts("");
		/*if(s[0] == s[n - 1] && s[0] == '0') {

		}*/

	}
	getchar();
	getchar();
	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define FOR(i,a,b,c) for(int i=a;i<b;i+=c)
#define REV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef tree
<int,null_type,less <int>,rb_tree_tag,tree_order_statistics_node_update>
indexed_set;

typedef tree
<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>
indexed_multiset;

template <typename T>
istream & operator>>(istream &is, vector<T> &v) {
    for(auto &data:v){
        is>>data;
    }
    return is;
}

template <typename T>
ostream & operator<<(ostream &os,const vector<T> &v) {
    for(auto &data:v){
        os<<data<< " ";
    }
    return os;
}

class BUNrEaDaBlESTrInG {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int T=1;
	    while(T--){
	        string s;
	        in>>s;
	        int n=s.size();
	        string ans="Yes";
	        FOR(i,0,n,1){
	            if(i%2==0){
	                if(s[i]>=97 and s[i]<=122){

	                }
	                else{
	                    ans="No";
	                }
	            }
	            else{
	                if(s[i]>=65 and s[i]<=90){

	                }
	                else{
	                    ans="No";
	                }
	            }
	        }
	        out<<ans<< "\n";
	    }
	}
};

int32_t main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    BUNrEaDaBlESTrInG solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

#define inf 1001000009
#define infmx 1e18ll
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define all(x) x.begin(),x.end()
///debug
#define wh(x)   cerr<<#x<<" is "<<x<<endl;
#define error(args...){string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);err(_it,args);}
void err(istream_iterator<string>it){cout<<endl;}
template<class H,class... T>void err(istream_iterator<string>it,H a,T... t){cerr<<*it<<" = "<<a<<" | ";err(++it,t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class T>auto&operator<<(ostream& os,vector<T>_v){bool a=1;for(auto x:_v){os<<(a?"":" ")<<x;a=0;}return os;}
///
typedef pair<int,int>pi;
typedef pair<long long,long long>pll;
typedef pair<pi,int>ppi;
typedef pair<int,pi>pip;
typedef vector<int>vi;
typedef vector<pi>vpi;
const int mod=1e9+7;
ll power(ll a,ll p){ll r=1,y=a;while(p){if(p&1)r=(1LL*r*y)%mod;p>>=1;y=(1LL*y*y)%mod;}return r;}

const int N=2100000;
int ara[N];

int main()
{
    IOS;
    ll n;cin>>n;
    ll l=0,r=2000000000;
    while(l<=r){
        ll mid=(l+r)>>1;
        if(mid*(mid+1)/2>(n+1))r=mid-1;
        else l=mid+1;
    }
//    cout<<r<<endl;
    cout<<n-r+1<<endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define PI = 3.14159265359
#define INF 100100100
#define mod 10000007
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(l,n){
    int x = INF;
    for(int r = l; r < n; ++r){
      x = min(x, a[r]);
      ans = max(ans, (r-l+1)*x);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> a(N);
  rep(i,N) cin >> a.at(i);

  int64_t ans=0;
  rep(i,N){
    if(i != 0){
      if(a.at(i) == a.at(i-1)) continue;
    }
    int64_t now=0;
    for(int j=i-1; 0<=j; j--){
      if(a.at(i) <= a.at(j)) now += a.at(i);
      else break;
    }
    for(int j=i+1; j<N; j++){
      if(a.at(i) <= a.at(j)) now += a.at(i);
      else break;
    }
    now += a.at(i);
    ans = max(ans,now);
  }

  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define mod 1000000007

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int t;cin >> t;
	while(t--){
		ll l,r,count;
		cin >> l >> r;
		if(r/2<l)count =0;
		else count = r-l-l+1;
		cout << count*(count+1)/2 << '\n';
		}
}

#include "bits/stdc++.h"
using namespace std;
using LLI = long long;
#define INF 999999999
#define MOD 1000000007
#define FOR(i, s, e) for(LLI i = s, i##_lim = (e); i < i##_lim; i++)
#define FORR(i, s, e) for(LLI i = s-1, i##_lim = (e); i##_lim<=i; i--)
#define REP(i, n) FOR(i,0,n)
#define REPR(i, n) FORR(i,n,0)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define Mat2(type,name,h,w,def) vector<vector<type>> name(h,vector<type>(w, def))
#define Mat3(type,name,h,w,d,def) vector<vector<vector<type>>> name(h,vector<vector<type>>(w, vector<int>(d,def)))
// int 2.14E±9    LLIi 9.2E±18    double 1.7E±380

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

	int t;
	cin >> t;
	REP(i, t)
	{
		LLI l, r;
		cin >> l >> r;
		if (r < l * 2)
		{
			cout << 0 << endl;
		}
		else
		{

			cout << (r - l * 2 + 1) * (r - l * 2 + 2) / 2 << endl;
		}
	}

	return 0;
}


#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<int>> A(H, vector<int>(W, 0));
	int ans = 0;
	int min_val = 101;
	rep(i, H) {
		rep(j, W) {
			cin >> A[i][j];
			min_val = min(min_val, A[i][j]);
		}
	}

	rep(i, H) {
		rep(j, W) {
			ans += A[i][j] - min_val;
		}
	}

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

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

int main() {
  int H, W;
  cin >> H >> W;

  vector<int> A(H*W);
  for(int i = 0;i < H*W;i++){
    cin >> A.at(i);
  }

  int m = 100;
  for(int i = 0;i < H*W;i++){
    m = min(m, A.at(i));
  }

  int ans = 0;
  for(int i = 0;i < H*W;i++){
    ans += A.at(i) - m;
  }

  cout << ans << endl;
}


#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <bitset>

using namespace std;
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define rep2(i,n,i2,n2) for (ll i = 0; i < (n) ; i++) for (ll i2 = 0; i2 < (n2) ; i2++)
#define incRepFT(i,s,n) for (ll i = (s); i <= (n) ; i++)
#define decRepFT(i,s,n) for (ll i = (s); i >= (n) ; i--)

#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 998244353
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vstr vector<string>
#define vvstr vector<vector<string>>
typedef pair<ll,ll> P;

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

// for(char c : S)

//min({a1, a2, ..., an})
//max({a1, a2, ..., an})
//swap(a, b)
//S.substr(si)
// sort <--> reverse
//count(v.begin(), v.end(), x)
// char t - 'a'
// char t - '0'

//xを2進数にした時の1の数
//__builtin_popcount(x)
//__builtin_popcountll(x)

ll A;
ll B;
ll C;
ll D;
ll N;
ll M;
ll K;
ll T;
ll H;
ll W;
ll X;
ll Y;
ll Z;

string S;
vstr Ss;

ll ltmp;
string stmp;
double dtmp;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
P d_move[4] = {
    P(0 , 1),P(0 , -1),P(1 , 0),P(-1 , 0)//,P(1 , 1),P(1 , -1),P(-1 , 1),P(-1 , -1)
};
//for(P drc : d_move)

double double_hosei = 1000000; //求められる精度分補正をかけておく
map<char,ll> mapcnt[1010];
ll getPower(ll value,ll shisu,ll mod){
    ll ans = 1;
    ll cnt = shisu;
    while(cnt>0){
        if(cnt%2==1){
            ans = ans * value % mod;
        }
        value = value * value % mod;
        cnt = cnt/2;
    }
    return ans;
}
ll getans(){
    ll sentaku = 0;
    ll maxsum = (H-1) + (W-1);
    //cout << "start" << endl;
    for( ll si = 0 ; si <=maxsum ; si++ ){
        map<char,ll> mapcnt;
        ll hi_start = llmax(0,si-(W-1));
        for( ll hi = 0 ; hi <H ; hi++ ){
            ll wi = si - hi;
            if(wi < 0 ) break;
            if(wi > W-1) continue;
            //cout << si << " " << hi << " " << wi << endl;
            mapcnt[ Ss[hi][wi] ]++;
        }
        if(mapcnt['R']>0 && mapcnt['B']>0) return 0;
        else{
            if(mapcnt['R']==0 && mapcnt['B']==0) sentaku++;
        }
    }
    ll ans = getPower(2,sentaku,MOD);
    return ans;

}
int main(){

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

    cin >> H;
    cin >> W;

    Ss.resize(H);
    rep(hi,H) cin >> Ss[hi];
    cout << getans() << endl;

}

#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
string p[520];
signed main(){
	int mx = 0;
	int h,w;
	cin >> h >> w;
	int ans = 1;
	for(int i = 0;i < h;i++){
		cin >> p[i];
	}

	bool able = true;
	for(int i = 0;i < w;i++){
		int sti = i;
		int stj = 0;
		bool c = true;
		int cnt = 0;
		map<char,int> mp;
		while(sti >= 0 && stj < h){
			if(p[stj][sti] != '.'){
				if(mp[p[stj][sti]] == 0){
					cnt += 1;
					mp[p[stj][sti]] = 1;
					if(cnt == 2)able = false;
				}
				c = false;
			}
			sti--;
			stj++;
		}
		if(c) ans = (ans * 2ll)% 998244353;
	}
	for(int i = 1;i < h;i++){
		int sti = w - 1;
		int stj = i;
		bool c = true;
		int cnt = 0;
		map<char,int> mp;
		while(sti >= 0 && stj < h){
			if(p[stj][sti] != '.'){
				if(mp[p[stj][sti]] == 0){
					cnt += 1;
					mp[p[stj][sti]] = 1;
					if(cnt == 2)able = false;
				}
				c = false;
			}
			sti--;
			stj++;
		}
		if(c) ans = (ans * 2ll)% 998244353;
	}
	if(able == true)cout << ans << endl;
	else cout << 0 << endl;
}


#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll  = long long int;
using pii = pair<ll, ll>;
#define LOCAL
#ifdef LOCAL
#define trace(...) _f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
template <typename T> void _f(const char* name, T&& arg1){
    cerr << name << ": " << arg1 << endl;
}
template <typename T, typename... Args>
void _f(const char* names, T&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    _f(comma + 1, args...);
}

void solve() {
    ll m, h; cin >> m >> h;
    cout << (h % m == 0? "Yes" : "No") << endl;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t=1;;while(t--)solve();return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#define DEBUG(x) cerr << '(' << __LINE__ << ") " << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

int main() {
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  sort(a.begin(),a.end());
  if (a[2]-a[1]==a[1]-a[0]) cout << "Yes" << endl;
  else cout << "No" << endl;

}

// end


# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
#define MOD 1000000007
using namespace std;
using lint = long long;
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; }

int a, b, c, d;

int main(){
    cin >> a >> b;
    cin >> c >> d;

    cout << a*d - b*c << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vi2 vector<vector<int>>
#define vl vector<long long>
#define vl2 vector<vector<long long>>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    int n, k, m, sum=0;
    cin >> n >> k >> m;
    vi a(n-1);
    rep(i, n-1){
        cin >> a[i];
        sum += a[i];
    }
    sum = m*n-sum;
    if(sum>k) cout << -1 << endl;
    else cout << max(0,sum) << endl;
}


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

#define ll long long
#define print(a)          \
    for (auto x : a)      \
        cout << x << " "; \
    cout << endl
#define print_upto(a, n)        \
    for (ll i = 1; i <= n; i++) \
        cout << a[i] << " ";    \
    cout << endl
#define take(a, n)              \
    for (ll i = 1; i <= n; i++) \
        cin >> a[i];

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << "\n"
#define watch3(x, y, z) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << " and " << (#z) << " is " << (z) << "\n"

void my_debugger(string s, int LINE_NUM)
{
    cerr << endl;
}
template <typename start, typename... end>
void my_debugger(string s, int LINE_NUM, start x, end... y)
{
    if (s.back() != ',')
    {
        s += ',';
        cerr << "LINE(" << LINE_NUM << "): ";
    }
    int i = s.find(',');
    cerr << s.substr(0, i) << " = " << x;
    s = s.substr(i + 1);
    if (!s.empty())
        cerr << ", ";
    my_debugger(s, LINE_NUM, y...);
}
#define debug(...) my_debugger(#__VA_ARGS__, __LINE__, __VA_ARGS__);

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(), (c).end()
#define allr(c) (c).rbegin(), (c).rend()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define MOD 1000000007
#define inf 1e17
// cout << fixed << setprecision(15) << ans << nl;

typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> ppll;

const ll N = 200009;

void solve()
{
    ll m, h;
    cin >> m >> h;

    if (h % m == 0)
    {
        cout << "Yes" << nl;
    }
    else
    {
        cout << "No" << nl;
    }
}

int main()
{

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

    ll T = 1;
    // cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}

#include<bits/stdc++.h>
#define int long long
#define ld long double
#define fi first
#define se second
#define vll vector<int>
#define pii pair<int,int>
#define pb push_back
#define sz(v) (int)(v).size()
#define inf (int)(1e18)
#define md (int)(1e9+7)
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;

const int M = 2e5 + 10;

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

   	int B,C;
   	cin>>B>>C;
   	if(C==1) {
   		cout<<(B?2:1);
   		return 0;
   	}
   	// C=2k+1 -> -B-k -B+k 2k+1
   	// C=2k -> B-k, B+k-1  2k
   	int k=C/2;
   	if(C&1) {
   		int L=max(B-k,-B-k),R=min(B+k-1,-B+k);
   		cout<<(4*k+1-max(0ll,R-L+1));
   		return 0;
   	}
   	int L=max(B-k,-B-k+1),R=min(B+k-1,-B+k-1);
   	cout<<(4*k-1-max(0ll,R-L+1));

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  float a=0,b=0;
  cin >> a >> b;
  float ans=0.0;
  if(b!=0)
  {
    ans=(a*b)/100;
    cout <<  ans << "\n";
  }
  else
  {
    cout << "0" << "\n";
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i=0;i<n;i++)
#define INF 1000000001
#define lINF 1000000000000001
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vs = vector<string>;
using vc = vector<char>;
using P = pair<ll, ll>;
using si = stack<int>;
using ss = stack<string>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
//1e9<int型の最大値<1e10
//1e18<long型の最大値<1e19
//配列直入れ↓
//g++ -std=c++17 -Wshadow -Wall -D_GLIBCXX_DEBUG -o a b.cpp && ./a
//bit全探索
//2のk乗は"1<<k"で書ける

int main(){
    float a,b;
    cin>>a>>b;
    cout<<a/100*b<<endl;

}


#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define reps(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define prl(a) cout << (a) << endl
#define allrange(a) a.begin(),a.end()

bool solve_translated(vector<pair<int,int>> &S,vector<pair<int,int>> &T){
    int N = S.size();
    int dx = S[0].first-T[0].first;
    int dy = S[0].second-T[0].second;
    bool flg = true;
    reps(i,1,N){
        if(!((S[i].first==T[i].first+dx) && (S[i].second==T[i].second+dy))){flg = false; break;}
    }
    return flg;
}
vector<pair<int,int>> Pitagora_rot(vector<pair<int,int>> &S,int a, int b , int c){
    int N = S.size();
    vector<pair<int,int>> PS(N);
    auto pt0 = S[0];
    PS[0] = pt0;
    bool flg = true;
    int dx,dy,x,y;
    reps(i,1,N){
        dx = S[i].first - pt0.first;
        dy = S[i].second - pt0.second;
        x=dx*a-dy*b;
        y=dx*b+dy*a;
        if(((x%c)!=0) || ((y%c)!=0)) {flg = false; break;}
        PS[i] = make_pair(x/c+pt0.first, y/c+pt0.second);
    }
    if(flg) return PS;
    else return vector<pair<int,int>>();
}

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

    vector<pair<int,int>> S(N),T(N);
    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        S[i].first = x;S[i].second = y;
    }

    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        T[i].first = x;
        T[i].second = y;
    }
    sort(allrange(T));

/*ピタゴラ三角形
    5	12	13
    8	15	17
    3	4	5
*/
    constexpr int tri[12][3] ={
    {3,4,5},
    {4,3,5},
    {-3,4,5},
    {-4,3,5},
    {0,1,1},
    {1,0,1},
    {-1,0,1},
    {0,-1,1},
    {-3,-4,5},
    {-4,-3,5},
    {3,-4,5},
    {4,-3,5}
    };

 /*
    vector<vector<int>> tri(0);
    tri.push_back(vector<int>({3,4,5}));
    tri.push_back(vector<int>({4,3,5}));
    tri.push_back(vector<int>({-3,4,5}));
    tri.push_back(vector<int>({-4,3,5}));
    tri.push_back(vector<int>({0,1,1}));
    tri.push_back(vector<int>({1,0,1}));
    tri.push_back(vector<int>({-1,0,1}));
    tri.push_back(vector<int>({0,-1,1}));
    tri.push_back(vector<int>({-3,-4,5}));
    tri.push_back(vector<int>({-4,-3,5}));
    tri.push_back(vector<int>({3,-4,5}));
    tri.push_back(vector<int>({4,-3,5}));
 //   tri.push_back(vector<int>({-5, -12, 13}));
 //   tri.push_back(vector<int>({-12, -5, 13}));
 //   tri.push_back(vector<int>({-8,-15,17}));
 //   tri.push_back(vector<int>({-15,-8,17}));
 //   tri.push_back(vector<int>({5, 12, 13}));
 //   tri.push_back(vector<int>({12, 5, 13}));
 //   tri.push_back(vector<int>({8,15,17}));
 //   tri.push_back(vector<int>({15,8,17}));
 //   tri.push_back(vector<int>({-5, 12, 13}));
 //  tri.push_back(vector<int>({-12, 5, 13}));
  //  tri.push_back(vector<int>({-8,15,17}));
  //  tri.push_back(vector<int>({-15,8,17}));
 //   tri.push_back(vector<int>({5, -12, 13}));
 //   tri.push_back(vector<int>({12, -5, 13}));
 //   tri.push_back(vector<int>({8,-15,17}));
 //   tri.push_back(vector<int>({15,-8,17}));

 */
    bool flg;

    if(N==2){
        auto sx = S[0].first-S[1].first;
        auto sy = S[0].second-S[1].second;
        auto tx = T[0].first-T[1].first;
        auto ty = T[0].second-T[1].second;
        flg= (sx*sx+sy*sy==tx*tx+ty*ty);
    } else {
        rep(j,12){
            auto S2 = Pitagora_rot(S,tri[j][0],tri[j][1],tri[j][2]);
            if(S2.empty()) continue;
            sort(allrange(S2));
            flg = solve_translated(S2,T);
            if(flg) break;
        }
    }
    if(flg) prl("Yes"); else prl("No");
}

//Never stop trying
#include "bits/stdc++.h"
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
#define int ll
typedef string str;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
//constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
ll random(ll a, ll b){
    return a + rng() % (b - a + 1);
}
#ifndef LOCAL
#define cerr if(false) cerr
#endif
#define dbg(x) cerr << #x << " : " << x << endl;
#define dbgs(x,y) cerr << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << #v << " : " << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;
#define here() cerr << "here" << endl;

void IO() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
/////////////////////////ONLY CLEAN CODES ALLOWED/////////////////////////

const int C=1e15;

bool reasonable(int x){
	return x>=-C && x<=C;
}

int32_t main() {
    boost; IO();

    int N; cin>>N;
    vi X(N),Y(N);
    FOR(i,0,N) cin>>X[i]>>Y[i];

    int M; cin>>M;
    vpi vec;
    FOR(i,0,M){
    	int t,p=-1; cin>>t;
    	if(t>=3) cin>>p;
    	vec.eb(t,p);
    }

    int a[M],b[M],v[M],v2[M],c[M],d[M];

    int cur_a=1,cur_b=1,cur_v=0,cur_v2=1,cur_c=0,cur_d=0;
    FOR(i,0,M){
    	int t=vec[i].fi,p=vec[i].se;
    	if(t==2){
    		swap(cur_a,cur_b);
    		swap(cur_v,cur_v2);
    		swap(cur_c,cur_d);
    		cur_a*=-1;
    		cur_c*=-1;
    	}
    	else if(t==1){
    		swap(cur_a,cur_b);
    		swap(cur_v,cur_v2);
    		swap(cur_c,cur_d);
    		cur_b*=-1;
    		cur_d*=-1;
    	}
    	else if(t==3){
    		cur_a*=-1;
    		cur_c*=-1;
    		cur_c+=2*p;
    	}
    	else if(t==4){
    		cur_b*=-1;
    		cur_d*=-1;
    		cur_d+=2*p;
    	}

    	a[i]=cur_a; b[i]=cur_b;
    	v[i]=cur_v; v2[i]=cur_v2;
    	c[i]=cur_c; d[i]=cur_d;

    	/*dbg(cur_a)
    	dbg(cur_v)
    	dbg(cur_c)*/
    }

    int Q; cin>>Q;
    while(Q--){
    	int op,i; cin>>op>>i;
    	op--; i--;
    	if(op<0){
    		cout << X[i] << ' ' << Y[i] << endl;
    		continue;
    	}

    	int x=X[i],y=Y[i];

    	cur_a=a[op];
    	cur_b=b[op];
    	cur_c=c[op];
    	cur_d=d[op];

    	dbgs(cur_a,cur_b)

    	if(v[op]==0){
    		cout << cur_a*x+cur_c << ' ' << cur_b*y+cur_d << endl;
    	}
    	else{
    		cout << y*cur_a+cur_c << ' ' << cur_b*x+cur_d << endl;
    	}

    }

    return 0;
}
//Change your approach


#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;

class UnionFind {
private:
  vector<int> ps;

public:
  UnionFind(int n){
    ps.resize(n);
    for(int i = 0; i < n; i++){
      ps[i] = i;
    }
  }

  int find_set(int i){
    return ps[i] == i ? i : ps[i] = find_set(ps[i]);
  }

  void unite_sets(int i, int j){
    ps[find_set(i)] = find_set(j);
  }
};

const int MAXN = 60;

long long fat[MAXN * MAXN];

int main(){
  fat[0] = 1;
  for(int i = 1; i < MAXN*MAXN; i++){
    fat[i] = (i * fat[i-1])%MOD;
  }

  int N, K;
  while(scanf("%d%d", &N, &K) > 0){
    int a[N][N];
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
	scanf("%d", &a[i][j]);
      }
    }

    UnionFind uf(N);

    for(int x = 0; x < N; x++){
      for(int y = x+1; y < N; y++){
	bool test = true;
	for(int i = 0; i < N and test; i++){
	  test = a[x][i] + a[y][i] <= K;
	}
	if(test) uf.unite_sets(x, y);
      }
    }

    map<int,int> set_size;

    for(int i = 0; i < N; i++){
      set_size[uf.find_set(i)]++;
    }

    long long num_matrices = 1;

    for(auto s : set_size){
      num_matrices = (num_matrices * fat[s.second]) % MOD;
    }

    uf = UnionFind(N);

    for(int x = 0; x < N; x++){
      for(int y = x+1; y < N; y++){
	bool test = true;
	for(int i = 0; i < N and test; i++){
	  test = a[i][x] + a[i][y] <= K;
	}
	if(test) uf.unite_sets(x, y);
      }
    }

    set_size.clear();

    for(int i = 0; i < N; i++){
      set_size[uf.find_set(i)]++;
    }

    for(auto s : set_size){
      num_matrices = (num_matrices * fat[s.second]) % MOD;
    }

    printf("%lld\n", num_matrices);
  }
}

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define all(x) x.begin(), x.end()
#ifdef _DEBUG
#define disp(x) cout << #x << " : " << x << endl
#else
#define disp(x)
#endif
using namespace std;
using ll = int64_t;

const ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod){}
    mint operator-() const {return mint(-x);}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    ll val(){ return x; }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}

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

struct UnionFind {
    ll n;
    vector<ll> siz, parent;
    map<ll,vector<ll>> group;
    UnionFind(ll n_) : n(n_), parent(n_), siz(n_, 1) {
        for(ll i = 0; i < n; i++) parent[i] = i;
    }
    ll root(ll x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }
    void unite(ll x,ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return;
        if(siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        parent[ry] = rx;
    }
    bool same(ll x,ll y){
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
    void grouping(){
        for(ll i = 0; i < n; i++) root(i);
        for(ll i = 0; i < n; i++) group[parent[i]].push_back(i);
    }
    void clear(){
        for(ll i = 0; i < n; i++) { parent[i] = i; }
        siz = vector<ll>(n, 1);
        group.clear();
    }
    ll size(ll x){ return siz[root(x)]; }
};

mint fac(ll x) {
    mint res = 1;
    for(ll i = x; i > 1; i--) {
        res *= i;
    }
    return res;
}

int main(){
    int n, k; cin >> n >> k;
    int a[n][n]; rep(i, n)rep(j, n) cin >> a[i][j];

    UnionFind cntr(n), cntc(n);
    rep(i, n)loop(j, i+1, n){
        bool flag = true;
        rep(l, n) {
            if(a[i][l] + a[j][l] > k) flag = false;
        }
        if(flag) cntr.unite(i, j);
    }
    rep(i, n)loop(j, i+1, n) {
        bool flag = true;
        rep(l, n) {
            if(a[l][i] + a[l][j] > k) flag = false;
        }
        if(flag) cntc.unite(i, j);
    }
    cntr.grouping();
    cntc.grouping();
    mint ansr = 1, ansc = 1, ans = 1;
    for(auto p : cntr.group) {
        ansr *= fac(p.second.size());
    }
    for(auto p : cntc.group) {
        ansc *= fac(p.second.size());;
    }
    ans *= ansr;
    ans *= ansc;
    cout << ans << endl;

    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#include<iomanip>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define bpc(x) __builtin_popcount(x)
#define bpcll(x) __builtin_popcountll(x)
#define fps(n) fixed << setprecision(n)
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define eldn endl
#define elnd endl
#define icn cin
#define cotu cout
#define Endl endl
#define EE endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n; cin >> n;
    double ans = 0.0;
    reps(i,1,n-1){
        ans += (double)n * (1 / (double)i);
    }
    cout << fps(20) << ans << EE;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int N;cin>>N;
  string S[N];
  rep(i,N)cin>>S[i];
  vector<vector<int>> D(N,vector<int>(N,1e5));
  rep(i,N){
    rep(j,N){
      if(i==j)D[i][j]=0;
      if(S[i][j]=='1')D[j][i]=1;
    }
  }
  rep(k,N){
    rep(i,N){
      rep(j,N){
        D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
      }
    }
  }
  double ans=0,t;
  rep(i,N){
    t=0;
    rep(j,N)if(D[i][j]!=1e5)t++;
    ans+=1/t;
  }
  cout<<fixed<<setprecision(9)<<ans;
}


#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono;
const int mod=998244353;
const int mex=55;
#define ll long long
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int>
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++)
#define int long long
int power(int a,int b)
{
	int ans=1,f=a;
	while(b)
	{
		if(b&1ll) ans=ans*f%mod;
		f=f*f%mod;
		b=b>>1ll;
	}
	return ans%mod;
}
veci v1[mex];
int vis[mex];
int cp;
void dfs(int n)
{
	//cout<<n<<endl;
	vis[n]=1;
	cp++;
	fo(i,0,sz(v1[n]))
	if(vis[v1[n][i]]==0)dfs(v1[n][i]);
}

signed main()
{
	int fact[55];
	fact[0]=1;
	fo(i,1,mex)fact[i]=fact[i-1]*i%mod;
	int n,k;
	cin>>n>>k;
	int a[n][n];
	fo(i,0,n)
	fo(j,0,n)
	{
		cin>>a[i][j];
	}
	int c[n]={0},r[n]={0};
	fo(j,0,n)
	{
		int cnt=0;
		fo(k1,0,j)
		{
			int fg=0;
			fo(i,0,n)
			{
				if((a[i][j]+a[i][k1])<=k) fg++;
			}
			if(fg==n)
			{
				v1[j].pb(k1);
			v1[k1].pb(j);
			}
		}
		//c[j]=cnt;
	}
	int ans=1;
	fo(i,0,n)
 	if(vis[i]==0)
	{ dfs(i);
	ans=ans*fact[cp]%mod;
	cp=0;
	}
	fo(i,0,n+1)
	{
		vis[i]=0;
		v1[i].clear();
	}
	fo(j,0,n)
	{
		int cnt=0;
		fo(k1,0,j)
		{
			int fg=0;
			fo(i,0,n)
			{
				if((a[j][i]+a[k1][i])<=k) fg++;
			}
			if(fg==n)
			{v1[j].pb(k1);
			v1[k1].pb(j);
			}
		}
		//r[j]=cnt;
	}
	fo(i,0,n)
 	if(vis[i]==0)
	{ dfs(i);
	ans=ans*fact[cp]%mod;
	cp=0;
	}

	cout<<ans<<endl;

}

#include<ctime>
#include<cstdio>
#include<cctype>
#define ll long long
using namespace std;
const ll N=55;
const ll HgS=998244353;
ll read() {
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
ll f[N],sz[N],vis[N];
ll n,k,x,jc[N],a[N][N];
void start(){
	for(ll i=1;i<=n;++i){
		f[i]=i;
		sz[i]=1;
		vis[i]=0;
	}
}
ll get(ll x){
	if(x==f[x])
		return x;
	f[x]=get(f[x]);
	return f[x];
}
void merge(ll x,ll y){
	x=get(x);
	y=get(y);
	if(x==y)
		return;
	f[y]=x;
	sz[x]+=sz[y];
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	x=1;
	jc[0]=1;
	n=read();
	k=read();
	for(ll i=1;i<=n;++i)
		jc[i]=jc[i-1]*i%HgS;
	for(ll i=1;i<=n;++i)
	for(ll j=1;j<=n;++j)
		a[i][j]=read();
	start();
	for(ll i=1;i<=n;++i)
	for(ll j=1;j<=n;++j){
		ll flg=1;
		for(ll l=1;l<=n;++l){
			if(a[i][l]+a[j][l]>k){
				flg=0;
				break;
			}
		}
		if(flg)
			merge(i,j);
	}
	for(ll i=1;i<=n;++i){
		get(i);
		if(vis[f[i]])
			continue;
		vis[f[i]]=1;
		x*=jc[sz[f[i]]];
		x%=HgS;
	}
	start();
	for(ll i=1;i<=n;++i)
	for(ll j=1;j<=n;++j){
		ll flg=1;
		for(ll l=1;l<=n;++l){
			if(a[l][i]+a[l][j]>k){
				flg=0;
				break;
			}
		}
		if(flg)
			merge(i,j);
	}
	for(ll i=1;i<=n;++i){
		get(i);
		if(vis[f[i]])
			continue;
		vis[f[i]]=1;
		x*=jc[sz[f[i]]];
		x%=HgS;
	}
	printf("%lld",x);
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100010];
inline int read()
{
	int x=0,w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
int gcd(int N,int M)
{while(N^=M^=N^=M%=N);return M;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		a[1]=gcd(a[1],a[i]);
	}
	cout<<a[1]<<'\n';
}

#include <iostream>

using namespace std;

const int kMaxN = 21;

int l[kMaxN][kMaxN], a[kMaxN], b[kMaxN];
int n, m, x, y, t, c;
long long ans = 1;

void S(int x) {
  if (b[x]) {
    return;
  }
  a[++t] = x;
  b[x] = 1;
  for (int i = 1; i <= n; i++) {
    if (l[x][i]) {
      S(i);
    }
  }
}

void P(int x) {
  if (x > t) {
    c++;
    return;
  }
  int v[4] = {0};
  for (int i = 1; i < x; i++) {
    if (l[a[i]][a[x]]) {
      v[b[a[i]]] = 1;
    }
  }
  for (int i = 1; i <= 3; i++) {
    if (!v[i]) {
      b[a[x]] = i;
      P(x + 1);
    }
  }
}

int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    l[x][y] = l[y][x] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!b[i]) {
      t = c = 0;
      S(i);
      P(1);
      ans *= c;
    }
  }
  cout << ans;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXS =  5e4 + 7;
#define FASTIO {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define f(i,n) for(int i = 1 ; i <= N ; i ++)
#define f0(i,n) for(int i = 0 ; i < N ; i ++)

int main(){

	FASTIO
	int T;
	T = 1;
	//cin >> T;
	while(T --){
		int A , B;
		cin >> A >> B;
		int temp = min(A , B) + 3;
		if(temp > max(A,B))
			cout << "Yes" << "\n";
		else
			cout << "No" << "\n";
	}

}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF (int)1e9
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
//
#define FOR(i, a, b, in) for (int i=a ; i<(b) ; i+=in)
#define RFOR(i, a, b, in) for (int i=a-1 ; i>=(b) ; i-=in)
#define REP(i, a, b) FOR(i, a, b, 1)
#define RREP(i, a, b) RFOR(i, a, b, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define all(cont) cont.begin(), cont.end()

void solve () {
	int ans = 0;
	int n;
	cin >> n;
	int a = 1e5 + 1;
	int b = 1e5 + 1;
	int bb = b;
	int p = 0;
	int pb = 0;
	REP (i, 0, n) {
		int tmp, bbb;
		cin >> tmp >> bbb;
		if (tmp < a) {
			a = tmp;
			p = i;
		} else if (tmp == a) p = -1;
		if (bbb <= b) {
			bb = b;
			b = bbb;
			pb = i;
		}
	}
	if (p == pb) {
		ans = min(a + b, max(a, bb));
	} else {
		ans = max(a, b);
	}

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

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

	return 0;
}
//$ sudo g++ -o name name.cpp
//$ ./name


#include "bits/stdc++.h"
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, m =0, n = 0, p = 0, q = 0, mod=998244353;
    string s;
    char moji;
    cin >> a;
    n=0;
    for(int i=1;n<a;i*=2)
    {
        m++;
        for(int j=0;j<i&&n+j<a;j++)
        {
            cout << m << ' ';
        }
        n+=i;
    }
    return 0;
}

#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N,1);
  int i,j;
  for(i=1;i<N;i++) {
    for(j=1;j*j<=i+1;j++) {
      if((i+1)%j == 0) {
        A[i] = max(A[i],max(A[j-1],A[(i+1)/j-1]));
      }
    }
    A[i]++;
  }
  for(i=0;i<N;i++)cout << A[i] << " ";
  cout << endl;
}


#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
const long long  MOD = 1000000007;
typedef long long ll;
using namespace std;

ll gcd(ll m,ll n){
    if(n==0) return m;
    return gcd(n,m%n);
}

int main(){
    int x, y;
    cin >> x >> y;
    if(x == 0 && y == 0) cout << 0 << endl;
    if(x == 1 && y == 1) cout << 1 << endl;
    if(x == 2 && y == 2) cout << 2 << endl;
    if(x == 0 && y == 1) cout << 2 << endl;
    if(x == 1 && y == 0) cout << 2 << endl;
    if(x == 1 && y == 2) cout << 0 << endl;
    if(x == 2 && y == 1) cout << 0 << endl;
    if(x == 0 && y == 2) cout << 1 << endl;
    if(x == 2 && y == 0) cout << 1 << endl;
    return 0;
}

/*

GNU G++ compiler
Author-Ajay Raj Singh

while(alive)
{
    eat();
    sleep();
    code();
}

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//#include<boost/multiprecision/cpp.hpp>
//#include<boots/algorithms/string.hpp>
#define ll long long int
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pii>
#define vs vector<string>
#define vvi vector<vector<ll>>
#define pb push_back
#define flush fflush(stdout)
#define freq(x,val) count(x.begin(),x.end(),val)
#define permute(v) next_permutation(v.begin(),v.end())
#define all(x) x.begin(),x.end()
#define add(v) accumulate(v.begin(),v.end(),0)
#define mci map<char,ll>
#define mii map<ll,ll>
#define endl "\n"
#define db long double
const ll mod=1e9+7;
using namespace __gnu_pbds;
using namespace std;
ll pow(ll x,ll y)
{
    ll res=1;
    x=x%mod;
    while(y>0)
    {
        if(y&1)
        res=(res*x)%mod;
        y=y>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll modinv(ll a)
{
    return pow(a,mod-2);
}
void printval(ll x,ll y)
{
    cout<<"Case #"<<x<<": "<<y<<endl;
    return;
}
void solution()
{
    ll x,y;
    cin>>x>>y;
    if(x==y)
    cout<<x<<endl;
    else
    cout<<(3-(x+y))<<endl;
}
int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solution();
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define f(x, m) for(auto x : m)
#define cpu() ios::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int ,int>>
#define vll vector<pair<ll ,ll>>
#define all(v) v.begin(),v.end()
#define sor(a) sort( a.begin(), a.end() )
#define ros(a) sort( a.rbegin(), a.rend())
#define prec(n) fixed << setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it : x) cout << it << " ";
#define debug(x) cerr << #x << " is " << x << endl;
#define rq(x, y) range_query(1, 0, n, x, y)
#define ru(x, y, val) range_update(1, 0, n, x, y, val)
typedef long long ll;
using namespace std;
// using namespace __gnu_pbds;
#define dbg(args...){ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << "NEXT\n"; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << ", ";
err(++it, args...);
}
template<typename... T>
void rd(T& ... args){
  ((cin >> args), ...);
}
template<typename... T>
void ps(T ... args){
  ((cout << args << ' '), ...);
  cout << '\n';
}
// using ordered_set = tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7, MOD1 = 998244353LL, MAX = 1e5 + 5;
const char nl = '\n';
const ll INF = 2e18 + 5;
int n;
ll x;
int res(int y, int re){
  if(y < 0){
    y += re;
  }
  assert(y >= 0);
  return y;
}
void solve(){
  cin >> n >> x;
  vi a(n);
  for(int& it : a){
    cin >> it;
  }
  ll ans = INF;
  for(int i = 1; i <= n; i++){
    vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(i, vector<ll>(i + 1, -INF)));
    // dp[i][j][k] elemento i, con j de modulo con k elementos
    for(int j = 0; j < i; j++)
      dp[0][j][0] = 0;
    for(int l = 1; l <= i; l++){
      for(int j = l; j <= n; j++){
        for(int k = 0; k < i; k++){
          // if(j < l) continue;
          dp[j][k][l] = dp[j - 1][k][l];
          if((dp[j - 1][res(k - (a[j - 1] % i), i)][l - 1]) % i == res(k - (a[j - 1] % i), i))
            dp[j][k][l] = max(dp[j - 1][res(k - (a[j - 1] % i), i)][l - 1] + a[j - 1], dp[j][k][l]);
          // dbg(j, k, l, dp[j][k][l]);
        }
      }
    }
    if(dp[n][x % i][i] > 0){
      // dbg(i, x%i, dp[n][x%i][i]);
      ans = min(ans, (x - dp[n][x % i][i]) / i);
    }
  }
  cout << ans << '\n';
}
int main(){
  cpu();
  int __ = 1;
  // cin >> __;
  while(__--){
    solve();
  }
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N;
    cin >> N;
    vll X(N), Y(N);
    rep(i, N) cin >> X[i] >> Y[i];
    ll M;
    cin >> M;
    vvll op(M, vll(2, 0));
    rep(i, M){
        cin >> op[i][0];
        if(op[i][0]>=3) cin >> op[i][1];
    }
    ll Q;
    cin >> Q;
    vll A(Q), B(Q);
    rep(i, Q) cin >> A[i] >> B[i];

    ll a = 1, b = 0, c = 0;
    ll d = 0, e = 1, f = 0;

    vll as = {a}, bs = {b}, cs = {c}, ds = {d}, es = {e}, fs = {f};

    rep(m, M){
        switch(op[m][0]){
            case 1:{
                ll u = a, v = b, w = c;
                a = d;
                b = e;
                c = f;
                d = -u;
                e = -v;
                f = -w;
                break;
            }
            case 2:{
                ll u = a, v = b, w = c;
                a = -d;
                b = -e;
                c = -f;
                d = u;
                e = v;
                f = w;
                break;
            }
            case 3:{
                a = -a;
                b = -b;
                c = -c + 2*op[m][1];
                break;
            }
            case 4:{
                d = -d;
                e = -e;
                f = -f + 2*op[m][1];
                break;
            }
        }
        as.push_back(a);
        bs.push_back(b);
        cs.push_back(c);
        ds.push_back(d);
        es.push_back(e);
        fs.push_back(f);
    }

    rep(q, Q){
        ll x = as[A[q]]*X[B[q]-1] + bs[A[q]]*Y[B[q]-1] + cs[A[q]];
        ll y = ds[A[q]]*X[B[q]-1] + es[A[q]]*Y[B[q]-1] + fs[A[q]];
        cout << x << " " << y << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 200000;
ll mod = INF;

int main(){
  string s;
  int n,x;
  cin >> n>>x;
  rep(i,n){
    char c;
    cin >> c;
    if(c=='o'){
      x++;
    }else{
      x=max(0,x-1);
    }
  }
  cout << x<<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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

ll a, b, k;

int main() {
    cin >> a >> b >> k;
    ll sum = a+b;
    ll now = 0;
    ll acnt = 0;
    ll bcnt = 0;
    string ans;
    for(ll i = 0; i < sum; ++i) {
        // cout << "now " << now << endl;
        if(a-acnt == 0) {
            ans.push_back('b');
            bcnt++;
            continue;
        }
        if(b-bcnt == 0) {
            ans.push_back('a');
            acnt++;
            continue;
        }
        ll ca = a-acnt-1LL;
        ll cb = b-bcnt;
        ll ue = 1LL;
        map<ll, ll> uecnt;
        if(ca >= cb) {
            for(ll j = 0; j < cb; ++j) {
                ll tar = sum-(i+1)-j;
                ll tt = tar;
                for(ll k = 2; k*k <= tt; ++k) {
                    if(tar%k == 0) {
                        while(tar%k == 0) {
                            tar /= k;
                            uecnt[k]++;
                        }
                    }
                }
                uecnt[tar]++;
                ll tar2 = cb-j;
                ll tt2 = tar2;
                for(ll k = 2; k*k <= tt2; ++k) {
                    if(tar2%k == 0) {
                        while(tar2%k == 0) {
                            tar2 /= k;
                            uecnt[k]--;
                        }
                    }
                }
                uecnt[tar2]--;
            }
        }else {
            for(ll j = 0; j < cb; ++j) {
                ll tar = sum-(i+1)-j;
                ll tt = tar;
                for(ll k = 2; k*k <= tt; ++k) {
                    if(tar%k == 0) {
                        while(tar%k == 0) {
                            tar /= k;
                            uecnt[k]++;
                        }
                    }
                }
                uecnt[tar]++;
                ll tar2 = cb-j;
                ll tt2 = tar2;
                for(ll k = 2; k*k <= tt2; ++k) {
                    if(tar2%k == 0) {
                        while(tar2%k == 0) {
                            tar2 /= k;
                            uecnt[k]--;
                        }
                    }
                }
                uecnt[tar2]--;
            }
        }
        ll kasan = 1LL;
        for(auto x : uecnt) {
            for(int l = 0; l < x.second; ++l) {
                kasan *= x.first;
            }
        }
        // cout << "now " << kasan << endl;
        ll check = now+kasan;
        if(check >= k) {
            // ここはaを使う
            ans.push_back('a');
            acnt++;
        }else {
            now += kasan;
            ans.push_back('b');
            bcnt++;
        }
    }
    cout << ans << endl;
}