//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back
#define F first
#define S second
//#pragma GCC optimize("Ofast")

const int maxn = 1000 + 5;

int n;
string s[maxn][2];

string inv(string ss)
{
	for(int i = 0; i < ss.size(); i++)
		ss[i] = (ss[i] == 'A' ? 'B' : 'A');
	return ss;
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	s[0][0] = "AB";
	int last = 1;
	for(int i = 1; i < n; i++)
	{
		//cout << "BOOM\n";
		for(int j = 0; j < last; j++)
			s[j][i % 2] = s[j][(i + 1) % 2] + s[j][(i + 1) % 2];//, cout << j << " " << s[j][i % 2] << '\n';
		for(int j = last; j < 2 * last; j++)
			s[j][i % 2] = s[j - last][(i + 1) % 2] + inv(s[j - last][(i + 1) % 2]);//, cout << j << " " << s[j][i % 2] << '\n';

		s[2 * last][i % 2] = "";
		for(int j = 0; j < (1 << i); j++)
			s[2 * last][i % 2].pb('A');
		for(int j = 0; j < (1 << i); j++)
			s[2 * last][i % 2].pb('B');
		last = 2 * last + 1;
	}
	//return 0;
	cout << last << '\n';
	for(int i = 0; i < last; i++)
		cout << s[i][(n - 1) % 2] << '\n';
	//cout << (n - 1) % 2 << '\n';
}

#include <bits/stdc++.h>
#include <unordered_set>
#include <cmath>
#include <algorithm>
// #include <atcoder/all>

// URL:

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vs = vector<string>;

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n)? "YES": "NO") << endl
#define Yes(n) cout << ((n)? "Yes": "No") << endl

#define rept(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fore(x, a) for(auto& (x) : (a))

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

#define ALL(a) (a).begin(), (a).end()

#define VECCIN(x) for(auto& youso_: (x)) cin >> youso_
#define VECCOUT(x) for(auto& youso_: (x)) cout << youso_ << " ";cout << endl

#define pb push_back
#define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)

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 ll INFL = numeric_limits<ll>::max() / 4;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  optimize_cin();

  ll N;
  cin >> N;

  vll A(N);
  vll C(N + 1);
  map<ll, ll> D;

  C[0] = 0;
  rep(i, N){
    cin >> A[i];
    C[i + 1] = C[i] + (i % 2 == 0? A[i] : - A[i] );
  }

  ll cnt = 0;
  rep(i, N + 1) {
    cnt += D[C[i]];
    D[C[i]]++;
  }

  cout << cnt << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>T dup(T x, T y){return (x+y-1)/y;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}
int keta(ll n) { int ret = 0; while (n>0) { n/=10; ret++; } return ret; }

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) { cerr << head; dump(); }
template <typename Head, typename... Tail> void dump(Head &&head, Tail &&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do { cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

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

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

pair<ll, ll> crt(const vector<ll> &b, const vector<ll> &m)
{
  ll r = 0, M = 1;
  for (int i=0; i<int(b.size()); i++) {
    ll p, q;
    ll d = ext_gcd(M, m[i], p, q);
    if ((b[i] - r) % d != 0) return {0, -1};
    ll tmp = (b[i] - r) / d * p % (m[i]/d);
    r += M * tmp;
    M *= m[i]/d;
  }
  return {(r%M + M)%M, M};
}

void solve()
{
  ll x,y,p,q; cin>>x>>y>>p>>q;
  ll a = 2*x + 2*y;
  ll b = p + q;

  ll ans = LINF;
  rep(i, y) rep(j, q) {
    vector<ll> v = {x+i, p+j};
    vector<ll> u = {a, b};
    auto ret = crt(v, u);
    if (ret.second >= 0) mins(ans, ret.first);
  }
  if (ans == LINF) cout << "infinity" << "\n";
  else cout << ans << "\n";

}

int main()
{
  int t;
  // t = 1;
  cin>>t;
  while (t--) solve();

  return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    if (len(s) < 4) {
        sort(all(s));
        do {
            ll v = atoi(s.c_str());
            if (v % 8 == 0) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        while(next_permutation(all(s)));
        cout << "No" << endl;
        return 0;
    }
    vector<ll> org(10, 0);
    rep(i, len(s)) org[s[i] - '0']++;
    rep(i, 1000) {
        if (i % 8 != 0) continue;
        string t = "";
        if (i < 10) t += "0";
        if (i < 100) t += "0";
        t += to_string(i);
        vector<ll> cnt(10, 0);
        rep(j, 3) cnt[t[j] - '0']++;
        bool f = true;
        rep(j, 10) {
            if (org[j] < cnt[j]) {
                f = false;
            }
        }
        if (f) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


#include<bits/stdc++.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#define MAXN 100005
#define Endl '\n'
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define up  upper_bound
#define ll long long int
#define pii pair<ll,ll>
#define all(v) v.begin(),v.end()
#define fi(x,n) for(ll i=x;i<n;i++)
#define fj(x,n) for(ll j=x;j<n;j++)
#define fk(x,n) for(ll k=x;k<n;k++)
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("Ofast","no-stack-protector")
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll exp(ll x,ll y,ll mod)
{
	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 modinverse(ll x,ll mod)
{
    return exp(x,mod-2,mod);
}
using namespace std;
const ll inf = 0x3f3f3f3f3f3f3f3fll;
void solve()
{
    ll h,w,n,m;
    cin>>h>>w>>n>>m;
    ll v1[h][w],v2[h][w];
    fi(0,h)
    {
        fj(0,w)
        {
            v1[i][j]=0;
            v2[i][j]=0;
        }
    }

    fi(0,n)
    {
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        v1[x][y]=1;
        v2[x][y]=1;
    }

    fi(0,m)
    {
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        v1[x][y]=2;
        v2[x][y]=2;
    }

    fi(0,h)
    {
        ll j=0,x=0;
        while(j<w)
        {
            if(v1[i][j]==2)
                x=0;
            else if(v1[i][j]==1)
                x=1;
            else
                v1[i][j]=x;

            j++;
        }

        j=w-1;
        x=0;
        while(j>=0)
        {
            if(v1[i][j]==2)
                x=0;
            else if(v1[i][j])
                x=1;
            else
                v1[i][j]=x;

            j--;
        }
    }

    fi(0,w)
    {
        ll j=0,x=0;
        while(j<h)
        {
            if(v2[j][i]==2)
                x=0;
            else if(v2[j][i]==1)
                x=1;
            else
                v2[j][i]=x;

            j++;
        }

        j=h-1;
        x=0;
        while(j>=0)
        {
            if(v2[j][i]==2)
                x=0;
            else if(v2[j][i]==1)
                x=1;
            else
                v2[j][i]=x;

            j--;
        }
    }

    ll res=0;
    fi(0,h)
    {
        fj(0,w)
        {
            if(v1[i][j]==1)
                res++;
            if(v2[i][j]==1)
                res++;

            if(v1[i][j]==1&&v2[i][j]==1)
                res--;
        }
    }
    cout<<res;

}
int main()
{
    fastio;
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ll t;
    t=1;
    while(t--)
        solve();

    return 0;
}

#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];

ll H, W, N, M;
ll s[1555][1555];
ll l[1555][1555];
ll r[1555][1555];
ll u[1555][1555];
ll d[1555][1555];

int main(void) {
  ll i, j, k;

  cin >> H >> W >> N >> M;
  for(i=0; i<N; i++) {
    ll a, b;
    cin >> a >> b;
    s[a][b]=1;
  }

  for(i=0; i<M; i++) {
    ll c, d;
    cin >> c >> d;
    s[c][d]=2;
  }

  for(i=1; i<=H; i++) {
    for(j=1; j<=W; j++) {
      if(s[i][j]) l[i][j]=s[i][j];
      else l[i][j]=l[i][j-1];
    }
  }

  for(i=1; i<=H; i++) {
    for(j=W; j>=1; j--) {
      if(s[i][j]) r[i][j]=s[i][j];
      else r[i][j]=r[i][j+1];
    }
  }

  for(j=1; j<=W; j++) {
    for(i=1; i<=H; i++) {
      if(s[i][j]) u[i][j]=s[i][j];
      else u[i][j]=u[i-1][j];
    }
  }

  for(j=1; j<=W; j++) {
    for(i=H; i>=1; i--) {
      if(s[i][j]) d[i][j]=s[i][j];
      else d[i][j]=d[i+1][j];
    }
  }

  ll ans=0;
  for(i=1; i<=H; i++) {
    for(j=1; j<=W; j++) {
      ans+=(l[i][j]==1 || r[i][j]==1 || u[i][j]==1 || d[i][j]==1);
    }
  }

  pt(ans);

}


#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>,
            rb_tree_tag,
            tree_order_statistics_node_update>
    pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(var,a,b,c) for(ll var=a;var<=b;var+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo finte_by_order  /// finte kth smallest by passing k-1
#define ook order_of_key  //// finte no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
#define input2darr(n,m,in) ll a[n+1][m+1];if(in==0){loop(i,0,n-1,1)loop(j,0,m-1,1)cin>>a[i][j];}else{loop(i,1,n,1)loop(j,1,m,1)cin>>a[i][j];}
#define output2darr(n,m,in) if(in==0){loop(i,0,n-1,1){loop(j,0,m-1,1)cout<<a[i][j]<<" ";cout<<endl;}}else{loop(i,1,n,1){loop(j,1,m,1)cout<<a[i][j]<<" ";}cout<<endl;}
#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll>,greater<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

bool valid(ll nn,ll m,auto &x)
{
    __int128 ans=0,c=1;
    for(ll i=0;i<x.length();i++)
    {
        if(c>m)return false;
        ll val=x[i]-'0';
        ans+=c*val;
        if(ans>m)return false;
        c*=nn;
    }
    return true;
}
void AcDegaYe()
{
    string s;
    cin>>s;
    ll m;
    cin>>m;
    ll mx=0;
    for(ll i=0;i<s.length();i++)
    {
        char ch=s[i];
        ll no=ch-'0';
        mx=max(mx,no);
    }
    if(s.length()==1)
    {
        if(s[0]-'0'<=m)cout(1);
        else cout(0);
        return;
    }
    ll ans=0;
    ll i=mx+1;
    reverse(all(s));
    ll st=i;
    ll e=1e18;
    // if(m==1e18)
    // {
    //     cout(1);
    //     return;
    // }
    while(st<=e)
    {
        //cout(i);
        ll mid=st+(e-st)/2;
        //cout(mid);
        if(valid(mid,m,s))
        {
            st=mid+1;
        }
        else
        {
            e=mid-1;
        }
    }
    cout(st-i);
}
int main()
{
    fastio

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    //ll t;
    //cin>>t;
    ll t=1;
    for(ll i=0;i<t;i++)
    {
        AcDegaYe();
    }
    //cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

#include<bits/stdc++.h>
#define mxn 200005
#define ld long double
using namespace std;
ld res[mxn], deno[mxn];
bool vis[mxn];
int ara[12];
int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    for(int i=0; i<k; i++)
    scanf("%d", &ara[i]), vis[ ara[i] ]= 1;

    int mx= 0;
    for(int i=0; i<=n; i++)
    if(vis[i])
    {
        int cnt= 0;
        while(vis[i])cnt++, i++;
        mx= max(mx, cnt);
    }

    if(mx>=m)
    {
        puts("-1");
        return 0;
    }

    ld sum= 0.0, sum2= 0.0;
    for(int i=n-1; i>=0; i--)
    {
        sum-= res[i+m+1];
        sum2-= deno[i+m+1];

        if(!vis[i])
        {
            for(int j=0; j<k; j++)
            if(ara[j]>i && ara[j]<=i+m)deno[i]+= (1.0/(ld)m);

            res[i]= 1.0+(1.0/(ld)m)*sum;
            sum+= res[i];

            deno[i]+= (1.0/(ld)m)*sum2;
            sum2+= deno[i];
        }
    }

    printf("%.10Lf\n", res[0]/(1.0-deno[0]));

    return 0;
}


#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
int f[5001];
int inv[5001], fact[5001], invfact[5001];
int C(int a, int b) {
	return 1ll*fact[a]*invfact[b]%mod*invfact[a-b]%mod;
}
int main() {
	int n, m;
	cin >> n >> m;
	inv[1] = 1;
	for (int i = 2; i <= n; i++) inv[i] = 1ll*(mod-mod/i)*inv[mod%i]%mod;
	fact[0] = invfact[0] = 1;
	for (int i = 1; i <= n; i++) fact[i] = 1ll*fact[i-1]*i%mod;
	for (int i = 1; i <= n; i++) invfact[i] = 1ll*invfact[i-1]*inv[i]%mod;
	f[0] = 1;
	if (m & 1) {
		cout << 0 << endl;
		return 0;
	}
	while (m) {
		for (int i = m; i >= 0; i--)
			for (int j = 2; j <= n && j <= i; j += 2)
				f[i] = (f[i] + 1ll*C(n,j)*f[i-j])%mod;
		for (int i = 0; i * 2 <= m; i++) f[i] = f[i*2+(m&2)];
		m >>= 2, m <<= 1;
	}
	cout << f[0] << endl;
}

#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> XY(M);
    rep(i, M) cin >> XY[i].first >> XY[i].second;
    XY.emplace_back(0, N);

    sort(all(XY));

    map<int, vector<pair<int, int>>> mp;
    rep(i, M + 1) {
        mp[XY[i].second].emplace_back(XY[i].first, i);
    }

    vv<int> graph(M + 1);
    rep(i, M + 1) {
        auto [x, y] = XY[i];
        int z;
        if (mp[y].back().second == i) {
            z = 2 * N + 1;
        }
        else {
            auto ub = lower_bound(all(mp[y]), make_pair(x + 1, 0));
            z = ub->first;
        }

        if (mp.find(y - 1) != mp.end()) {
            auto lb = lower_bound(all(mp[y - 1]), make_pair(x + 1, 0));
            auto ub = lower_bound(all(mp[y - 1]), make_pair(z + 1, 0));
            for (auto it = lb; it != ub; ++it) {
                graph[i].push_back(it->second);
            }
        }
        if (mp.find(y + 1) != mp.end()) {
            auto lb = lower_bound(all(mp[y + 1]), make_pair(x + 1, 0));
            auto ub = lower_bound(all(mp[y + 1]), make_pair(z + 1, 0));
            for (auto it = lb; it != ub; ++it) {
                graph[i].push_back(it->second);
            }
        }
    }

    vector<bool> can_visit(M + 1);
    can_visit[0] = true;
    auto dfs = [&](auto self, int u) -> void {
        for (int v : graph[u]) {
            if (can_visit[v]) continue;
            can_visit[v] = true;
            self(self, v);
        }
    };
    dfs(dfs, 0);

    set<int> ans;
    rep(i, M + 1) {
        auto [x, y] = XY[i];
        if (can_visit[i] && i == mp[y].back().second) {
            ans.insert(y);
        }
    }
    write((int)ans.size());
}


#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
	ll N, ai;
	cin >> N;
	vector<ll> A(N, 0), B(N, 0), C(N, 0);
	for (ll i = 0; i < N; i++) {
		cin >> ai;
		A[ai - 1]++;
	}
	for (ll i = 0; i < N; i++) cin >> B[i];
	for (ll i = 0; i < N; i++) cin >> C[i];
	vector<ll> BC(N, 0);
	for (ll i = 0; i < N; i++) {
		BC[B[C[i] - 1] - 1]++;
	}
	//for (ll i = 0; i < N; i++) cout << BC[i] << " ";
	//cout << endl;
	ll count = 0;
	for (ll i = 0; i < N; i++) {
		count += A[i] * BC[i];
	}
	cout << count << endl;
}

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;

//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a, ll b) {return (a + (b - 1)) / b;}
ll myfloor(ll a, ll b) {return a / b;}

int main() {
	//input
	ll N; cin >> N;

	vector<ll> A(N);
	REP(i, N) {
		cin >> A[i];
		A[i]--;
	}
	vector<ll> B(N);
	REP(i, N) {
		cin >> B[i];
		B[i]--;
	}
	vector<ll> C(N);
	REP(i, N) {
		cin >> C[i];
		C[i]--;
	}

	//calculation

	vector<ll> cnt_A(N, 0), cnt_B(N, 0);
	REP(i, N) {
		cnt_A[ A[i] ]++;
		cnt_B[ B[ C[i] ] ]++;
	}

	ll output = 0;
	REP(i, N) output += cnt_A[i] * cnt_B[i];

	//output
	cout << output << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
// vtqi6hy80o@email.edu.pl
#define rep(i, a, b) for(lli i = a; i < b; i++)
#define lli long long int
#define ld long double
#define all(v) v.begin(), v.end()
#define hell 1000000000000000
#define pb push_back
#define pf push_front
#define vi vector<lli>
#define vip vector<pair<lli, lli>>
#define F first
#define S second
#define pi 2*acos(0.0)
#define sz(s) s.size()
#define atmod (1000000000+7)
#define mod 998244353
// auto _C=clock();
/*
lli n = 10000000;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<bool> p(n + 1, true);
void sieve()
{
    for (long long int i = 2; i * i <= n; i++)
    {
        if (p[i])
        {
            for (long long int j = i + i; j <= n; j = j + i)
            {
                p[j] = false;
            }
        }
    }
}
*/
/*
WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!
Falling down is an accident, Staying down is a choice.
*/
/*lli binpow(lli a, lli n,lli m)
{
    lli r = 1;
    a %=m ;
    while (n > 0)
    {
        if (n & 1)
        {
            r = (r * a)%m ;
        }
        a = (a * a)%m ;
        n = n / 2;
    }
    return r;
}*/
/*bool cmp(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.F<b.F) return 1;
    else if(a.F==b.F) return(a.S>b.S);
    else return 0;
}*/
/*lli WaysFromOnetoOther(lli start,lli end,lli k)
{
    lli res = 0;
    if(k==1)
    {
        return 1;
    }
    rep(i,0,4)
    {
        if(i!=end&&i!=start)
        {
            res+=WaysFromOnetoOther(i,end,k-1);
        }
    }
    return res;
}*/
/*lli npr(lli n,lli r)
{
    lli res = 1;
    rep(i,1,r+1)
    {
        res=res%atmod*(n-r+i)%atmod;
        res%=atmod;
        // res/=i;
    }
    return res;
}*/
void solve()
{
    lli n;
    cin>>n;
    lli t[n];
    lli s = 0,sum=0;
    rep(i,0,n)cin>>t[i];
    rep(i,0,n)
    {
        s+=t[i];
    }
    sum = s;
    if(s%2==0)
    {
        s=s/2;
    }
    else
    {
        s++;
        s=s/2;
    }
    // cout<<s<<"\n";
    lli dp[s+1][n+1];
    rep(i,0,s+1)
    {
        dp[i][0] = 0;
    }
    rep(i,0,n+1)
    {
        dp[0][i] = 0;
    }
    rep(S,1,s+1)
    {
        rep(i,1,n+1)
        {
            if(t[i-1]<=S)
            {
                dp[S][i] = max(dp[S-t[i-1]][i-1]+t[i-1],dp[S][i-1]);
            }
            else
            {
                dp[S][i] = dp[S][i-1];
            }
        }
    }
    cout<< max(dp[s][n],sum-dp[s][n]);
    // rep(S,0,s+1)
    // {
    //     rep(i,0,n+1)
    //     {
    //         cout<<dp[S][i]<<" ";
    //     }
    //     cout<<endl;
    // }
}
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    // sieve();
    lli t = 1;
    // cin >> t;
    rep(i,1,t+1)
    {
        // cout<<"Case"<<" "<<"#"<<i<<":"<<" ";
        solve();
    }
    // cerr<<"\n\n\nTime elapsed: ";
    // cout<<"\n"<<(double)(clock()-_C)*1000.0/CLOCKS_PER_SEC<<"ms\n";
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
template<class T> void chmin(T& a, T b) {
   if (a > b) {
      a = b;
   }
}

int main(){
   ll N;
   cin >> N;
   vector<ll> T(N);
   for(int i = 0; i < N; i++){
      cin >> T.at(i);
   }
   sort(T.begin(), T.end());

   double full_time = 0;
   for(int i = 0; i < N; i++){
      full_time += T.at(i);
   }
   ll half_time = ceil(full_time/2);

   vector<vector<ll>> visit(N,vector<ll>(full_time+1,0));
   visit.at(0).at(0) = 1;
   visit.at(0).at(T.at(0)) = 1;

   for(int i=1; i<N; i++){
      for(int j=0; j <= full_time; j++){
         if(visit.at(i-1).at(j)>0){
            visit.at(i).at(j)=1;
            visit.at(i).at(j + T.at(i))=1;
         }
      }
   }

  for(int i=half_time; i<=full_time; i++){
    if(visit.at(N-1).at(i)>0){
      cout << i << endl;
      break;
    }
  }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define MOD          1000000007 //10^9 + 7
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))
#define MIN3(a,b,c)  min(a,min(b,c))

/*------------------------Bitmask-------------------------------*/
#define bitOn(N,pos)      (N | (1LL<<(pos)))
#define bitOff(N,pos)     (N & (~(1LL<<(pos))))
#define bitCheck(N,pos)   ((bool)(N & (1LL<<(pos)))) //check whether the (pos)th bit is On or Off in N(number)
#define bitFlip(a,k)      (a^(1LL<<(k)))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end()); //will have index if A.begin() is minus from it
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

/*----------------------- Graph Moves---------------------------*/
// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {0,0,1,-1,-1,1,-1,1} , dy[] = {-1,1,0,0,1,1,-1,-1};  // 8 Direction // Kings Move
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A;
//bitset<32> bset1;
//bool ok = true;
//char ch;
string S, T, U="";

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, flag=0, cnt=0;

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

    //cin>>t; while(t--){ }
    cin>>S;

    T=S;

    f3(i,S.sz-1,0)
    {
        if(S[i]=='0')
        {
            T.pop_back();
        }
        else
        {
            break;
        }
    }
    U=T;
    reverse(all(T));
    if(T==U)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr ll INF = 2e18;
constexpr ld EPS = 1e-9;
constexpr int MOD = 998244353;
// #define int long long

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

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
// Use int type for keys
template <typename T1, typename T2>
using safe_map = unordered_map<T1, T2, custom_hash>;

// Operator overloads
// cin >> pair<T1, T2>
template<typename T1, typename T2>
istream& operator>>(istream &istream, pair<T1, T2> &p)
{
    istream >> p.first >> p.second;
    return istream;
}
// cin >> vector<T>
template<typename T>
istream& operator>>(istream &istream, vector<T> &v)
{
    for (auto &it : v) cin >> it;
    return istream;
}
// cout << pair<T1, T2>
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, const pair<T1, T2> &p)
{
    ostream << p.first << " " << p.second;
    return ostream;
}
// cout << vector<T>
template<typename T>
ostream& operator<<(ostream &ostream, const vector<T> &c)
{
    for (auto &it : c) cout << it << " ";
    return ostream;
}

// Utility functions
template <typename T>
void print(T &&t)
{
    cout << t << "\n";
}
template <typename T, typename... Args>
void print(T &&t, Args &&... args)
{
	cout << t << " ";
	print(forward<Args>(args)...);
}

template <typename T>
int32_t size_i(T &container) { return static_cast<int32_t>(container.size()); }

// Mathematical functions
int GCD(int a, int b)
{
	if (!b) return a;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}
int modpow(ll x, int n, int m = MOD) {
    ll res = 1;
    while (n > 0)
	{
        if (n & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        n >>= 1;
    }
    return res;
}

int binpow(int x, int n) {
    int res = 1;
    while (n > 0)
	{
        if (n & 1)
            res = res * x;
        x = (x * x);
        n >>= 1;
    }
    return res;
}
// @param m should be prime
int modinv(int x, int m = MOD)
{
	return modpow(x, m - 2, m);
}

// Flags to use: -std=c++17 -O2 -Wshadow -DLOCAL_PROJECT -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -fsanitize=address -fsanitize=undefined
////////////////////////////////// START CODE HERE //////////////////////////////////

void preSolve()
{
}

void solve(int tc)
{
    string s;
    cin >> s;
    while (s.back() == '0')
        s.pop_back();
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != s[s.size() - 1 - i])
            return void(print("No"));
    }
    print("Yes");
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);
    cout << setprecision(12) << fixed;

    preSolve();
    int tests = 1;
    // cin >> tests;
    for (int t = 1; t <= tests; t++)
        solve(t);
    return 0;
}


#include <bits/stdc++.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (ll i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vii vector<int>
#define vvl vector<vector<ll>>
#define all(v) v.begin(),v.end()
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()
#define prec(x) cout<<fixed<<setprecision(12)<<x

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;
ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ceel(ll a,ll b){if(a%b==0) return a/b;else return a/b+1;}

//Valar Morghulis

void solve(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    fi(i,1,n+1){
        fi(j,1,k+1){
            ans+=(100*i)+j;
        }
    }
    cout<<ans;
}

int main(){
    fast
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }
    return 0;
}

#include <iostream>
#include<string>
#include <math.h>
#include<vector>
#include<algorithm>
#include <iomanip>
#include<map>
using ll = long long;
using namespace std;

int main() {
	int n, k; cin >> n >> k;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			int x = i * 100 + j;
			ans += x;
		}
	}
	cout << ans << endl;
}


/*
    // editorial used
    author : aryan57
    created : 22-May-2021 21:32:36 IST
*/
#include <bits/stdc++.h>
using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define int long long
#define X first
#define Y second
#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define F(i, a, b) for (int i = a; i <= b; i++)
#define RF(i, a, b) for (int i = a; i >= b; i--)

const int mxn = 2e5;
const long long INF = 2e18;
const int32_t M = 1000000007;
// const int32_t M = 998244353;
const long double pie = acos(-1);

vector <int> adj[mxn+1];
vector <int> depth[2][mxn+1];
vector <int> tin(mxn+1);
vector <int> tout(mxn+1);
int T=0;

bool comp_tin(int u,int v)
{
    return tin[u]<tin[v];
}
bool comp_tout(int u,int v)
{
    return tout[u]<tout[v];
}

void dfs(int u,int par=-1,int dep=0)
{
    tin[u]=++T;
    depth[0][dep].push_back(u);
    depth[1][dep].push_back(u);
    for(int to : adj[u]){
        if(to==par)continue;
        dfs(to,u,dep+1);
    }

    tout[u]=++T;
}

void solve_LOG()
{
    int n;
    cin>>n;

    F(i,2,n)
    {
        int p;
        cin>>p;
        adj[p].push_back(i);
        adj[i].push_back(p);
    }

    dfs(1);

    F(i,0,n)
    {
        sort(all(depth[0][i]),comp_tin);
        sort(all(depth[1][i]),comp_tout);
    }

    int q;
    cin>>q;
    while (q--)
    {
        int u,d;
        cin>>u>>d;

        vector <int> &vec1=depth[0][d];
        vector <int> &vec2=depth[1][d];
        // dbg(vec1,vec2);

        int pos1=lower_bound(all(vec1),u,comp_tin)-vec1.begin();
        int pos2=upper_bound(all(vec2),u,comp_tout)-vec2.begin();
        // dbg(pos1,pos2);

        int ans=pos2-pos1;
        if(ans<0)ans=0;

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

    }

}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
#ifdef ARYAN_SIEVE
    sieve();
#endif
#ifdef ARYAN_SEG_SIEVE
    segmented_sieve();
#endif
#ifdef ARYAN_FACT
    fact_init();
#endif
    // cout<<fixed<<setprecision(10);
    int _t=1;
    // cin>>_t;
    for (int i=1;i<=_t;i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve_LOG();
    }
    return 0;
}

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

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

using ll = long long;

int dfs(int i, std::vector<int> &depth, std::vector<std::vector<int>> &tree, std::vector<int> &in, std::vector<int> &out, int cnt=0, int d=0) {
    in[i] = cnt;
    depth[i] = d;
    cnt++; d++;
    for (auto &t : tree[i]) {
        cnt = dfs(t, depth, tree, in, out, cnt, d);
    }
    out[i] = cnt;
    return cnt;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> tree(n);
    for (int i = 1, pi; i < n; i++) {
        std::cin >> pi;
        pi--;
        tree[pi].push_back(i);
    }

    std::vector<int> depth(n), in(n), out(n);

    dfs(0, depth, tree, in, out);

    std::vector<std::vector<int>> depth2in(n, std::vector<int>());

    for (int i = 0; i < n; i++) {
        depth2in[depth[i]].push_back(in[i]);
    }

    for (auto &di : depth2in) {
        std::sort(di.begin(), di.end());
    }

    int q;
    std::cin >> q;
    for (int i = 0, ui, di; i < q; i++) {
        std::cin >> ui >> di;
        ui--;

        auto left = std::lower_bound(depth2in[di].begin(), depth2in[di].end(), in[ui]);
        auto right = std::lower_bound(depth2in[di].begin(), depth2in[di].end(), out[ui]);
        std::cout << (right - left) << '\n';
    }

    return 0;
}


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

#define  fl(i,a,b) for(long long i=a;i<b;i++)
#define  test long long t_c;cin>>t_c;for(long long ks=1;ks<=t_c;ks++)
#define pb push_back
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define cy cout<<"YES\n";
#define cn cout<<"NO\n";
#define nl cout<<endl;
#define case(x) cout<<"Case "<<x<<": ";

typedef long long ll;
typedef long long int lli;
void sc(int &x){scanf("%d",&x);}
void sc(lli &x){scanf("%lld",&x);}
void sc(char *x){scanf("%s",x);}
void sc(double &x){scanf("%lf",&x);}

using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   lli a,b;
   cin>>a>>b;
   if(abs(a-b)<3)
   {
       cout<<"Yes\n";
   }
   else
   {
       cout<<"No\n";
   }

}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n,q;cin>>n>>q;
  vector<ll>a(n);
  for(int i=0;i<n;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  for(int i=0;i<q;i++){
    ll k;cin>>k;
    ll old=(ll)(lower_bound(a.begin(),a.end(),k+1)-a.begin());
    ll kk=k+old;
    ll now=(ll)(lower_bound(a.begin(),a.end(),kk+1)-a.begin());
    while(now!=old){
      kk=k+now;
      old=now;
      now=(ll)(lower_bound(a.begin(),a.end(),kk+1)-a.begin());
    }
    cout<<kk<<endl;
  }
}


#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>

#define mod % 998244353
#define MAX 998244353
#define ll long long
using namespace std;

int main() {
  int high,wide,k;
  cin >> high;
  cin >> wide;
  cin >> k;
  ll ans = 0;
  if(high == wide and high == 1){
    cout << k mod << endl;
    return 0;
  }
  if(high == 1 or wide == 1){
    if(wide == 1){
      wide = high;
    }
    for(int i = 1;i <= k;i ++){
      int m = wide;
      vector<ll> mul(21);
      vector<ll> mult(21);
      mul[0] = i;
      mult[0] = i-1;
      ll pl = 1;
      ll plt = 1;
      for(int j = 0;j < 20;j++){
        mul[j+1] = (mul[j]*mul[j])mod;
        mult[j+1] = (mult[j]*mult[j])mod;
        if(m % 2 == 1){
          pl = (pl*mul[j])mod;
          plt = (plt*mult[j])mod;
        }
        m = m/2;
      }
      ans = (ans+MAX+pl-plt)mod;
    }
    cout << ans mod << endl;

    return 0;
  }

  for(int i = 1;i <= k;i ++){
    ll pl = 1;
    int m = wide;
    vector<ll> mul(21);
    mul[0] = k-i+1;
    for(int j = 0;j < 20;j ++){
      mul[j+1] = (mul[j]*mul[j])mod;
      if(m % 2 == 1){
        pl = (pl*mul[j]) mod;
      }
      m = m/2;
    }

    ll kakerua = 1;
    ll kakerub = 1;

    if(i == 1){
      kakerub = 0;
    }
    m = high;
    vector<ll> mult(21);
    mul[0] = i;
    mult[0] = i-1;
    for(int j = 0;j < 20;j ++){
      mul[j+1] = (mul[j]*mul[j])mod;
      mult[j+1] = (mult[j]*mult[j])mod;
      if(m % 2 == 1){
        kakerua = (kakerua*mul[j])mod;
        kakerub = (kakerub*mult[j])mod;
      }
      m = m/2;
    }
    kakerua = (MAX-kakerub+kakerua)mod;
    pl = (pl*kakerua)mod;
    ans = (ans +pl)mod;
  }
  cout << ans mod<< endl;

  return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 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; }
//const long long INF = 1LL<<60;
int inf = 1<<30;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

// 小文字から大文字
char c2u(char c){return toupper(c);}
// 大文字から小文字
char u2c(char c){return tolower(c);}
// stringをintに
auto s2i(string s){return atoi(s.c_str());}

int main() {
    double x,y,z;
    cin >> x >> y >> z;
    double tmp = y/x;
    //int kake = x*y;
    //cout << tmp << endl;
    for (double i = 1; i < 100000000; ++i) {
        double tmp2 = i/z;
        if(tmp <= tmp2){
            cout << i-1 << endl;
            return 0;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef struct Point {
	int x,y,z;
}Point;
int f(Point a ,Point b){
	int v1 = abs(a.x - b.x);
	int v2 = abs(a.y - b.y);
	int v3 = max(0,b.z - a.z);
	return v1+v2+v3;
}
int main(){
	int n; cin>>n;
	Point a[n];
	int x,y,z;
	for(int i=0;i<n;i++) { cin>>x>>y>>z; a[i]={x,y,z}; }
	int dp[1<<n][n];
	const int INF = 0x3f3f3f3f;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			dp[i][j]=INF;
		}
	}
	dp[1][0]=0;
	for(int i=2;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
			int tgt = i^(1<<j);
			for(int k=0;k<n;k++){
				dp[i][j]=min(dp[i][j],dp[tgt][k]+f(a[k],a[j]));
			}
		}
	}
}
int ans = INF;
for(int i=0;i<n;i++){ ans = min(ans,dp[(1<<n)-1][i]+f(a[i],a[0])); }
cout<<ans<<'\n';
return 0;
}

//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    ll n;
    cin>>n;
    vll x(n),y(n),z(n);
    rep(i,n)cin>>x[i]>>y[i]>>z[i];

    auto dis = [&](ll v, ll nv) {
        ll add = abs(x[v]-x[nv])+abs(y[v]-y[nv])+max(0ll,z[nv]-z[v]);
        return add;
    };

    vec<vll> dp(1<<n, vll(n+1,INF));
    dp[1][0] = 0;
    rep(bit,1<<n){
        rep(v,n){
            if(!(bit&(1<<v))) continue;//ｖが探索済みでないならスルー
            rep(nv,n){
                if(bit & (1<<n)) continue;//nvが探索済みならスルー
                int nbit = bit | (1<<nv); //bitに探索済みのものを入れる
                chmin(dp[nbit][nv],dp[bit][v]+dis(v,nv));
            }
        }
    }

    ll res=INF;
    rep(v,n){
        chmin(res,dp[(1<<n)-1][v]+dis(v,0));
    }

    cout<<res<<endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a)
#define dumparr(a,n)
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

void solve(long long N, std::vector<long long> a){
  tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> s;
  ll tentou=0;
  REP(N){
    tentou+=s.size()-s.order_of_key(a[i]);
    s.insert(a[i]);
  }
  REP(N){
    cout<<tentou<<endl;
    tentou+=(N-a[i]-1)-a[i];
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}

#include <bits/stdc++.h>
#define random mt19937 r(chrono::steady_clock::now().time_since_epoch().count())
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define all(x) x.begin(),x.end()
#define int long long
#define txin ifstream cin("input.txt")
#define txout ofstream cout("output.txt")
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii ;

const int M = 300*1000 + 16 ;

int k[M] , a[M] ;
ll fen[M] ;
ll inv ;

ll get(int p){
    ll ans=0;
    for( ; p > 0 ; p-=p&-p){
        ans += fen[p];
    }
    return ans ;
}

void add(int p , int val){
    for( ; p < M ; p+=p&-p){
        fen[p] += val ;
    }
}

ll inversion(int n){
    ll cnt =0 ;
    for(int i=n ; i>=1 ; i--){
        add(a[i] , 1) ;
        cnt += get(a[i]-1) ;
    }
    return cnt ;
}

int32_t main(){
    FAST;
    int n ;
    cin >> n ;
    for(int i =1 ; i <= n ; i++){
        cin >> a[i] ;
        a[i] += 2;
    }
    deque<int> d ;
    for(int i =1 ; i <= n ; i++){
        d.pb(a[i]-2) ;
    }
    int inv = inversion(n) ;
    cout << inv << '\n' ;
    for(int i =1 ; i<n ; i++){
        int l = d.front() ;
        d.pop_front() ;
        d.pb(l) ;
        inv = inv - l + (n-1-l) ;
        cout << inv << '\n' ;
    }
    return 0;
}


#line 1 "B.cpp"
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

int main() {
  int n, m, t; scanf("%d%d%d", &n, &m, &t);

  int now = 0;
  const int N = n;
  while(m--) {
    int a, b; scanf("%d%d", &a, &b);
    n -= (a - now);
    if(n <= 0) {
      printf("No\n");
      return 0;
    }
    n = std::min(N, n + (b - a));
    now = b;
  }
  n -= (t - now);
  if(n <= 0) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
	return 0;
}

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

#define FOR(x, a, b) for (int x = a; x <= b; x++)
#define FOD(x, a, b) for (int x = a; x >= b; x--)
#define REP(x, a, b) for (int x = a; x < b; x++)
#define RED(x, a, b) for (int x = a; x > b; x--)

void solve() {
    int n, m, t, s, e = 0;

    cin >> n >> m >> t;

    int p = n;

    REP(i, 0, m) {
        cin >> s;
        p = max(p - s + e, 0);

        if (p == 0) {
            cout << "No"; return;
        }

        cin >> e;
        p = min(p + e - s, n);
    }

    p = max(p - t + e, 0);
    if (p == 0) {
        cout << "No"; return;
    }

    cout << "Yes";
}

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

//    cin >> tests;
//    while (tests--) {
//        solve();
//    }

    solve();
}


#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const long double PI = acos(-1.0);
// #include <atcoder/all>
// using namespace atcoder;

signed main() {
    int N;
	cin >> N;
	map<string, int> mp;
	rep(i,N){
		string S;
		cin >> S;
		int M = S.size();
		bool ok = false;
		if(S[0] == '!'){
			ok = true;
			S = S.substr(1);
		}
		if(ok) mp[S] += 10000000;
		else mp[S]++;
	}
	for(auto p : mp){
		int x = p.second/10000000;
		int y = p.second%10000000;
		if(x > 0 && y > 0){
			cout << p.first << endl;
			return 0;
		}
	}
	cout << "satisfiable" << endl;
}

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;

using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int n;  cin >> n;
    int ma, mi;
    mi = 0;
    vector<int> c(200001,0);
    for(int i=0; i<n; i++){
        int p;  cin >> p;
        c[p] = 1;
        if(c[mi] == 0)  print(mi);
        else{
            while(mi <= 200000){
                mi++;
                if(c[mi] == 0){
                    print(mi);
                    break;
                }
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
const int MAX = 2e5 + 10;
const int modn = 1e9 + 7;
const int INF = 0x3f3f3f3f3f3f;
int a[MAX];
int n;
void init(){
    int ans=1;
    for(int i=n-1;i>=0;i--){
        a[i]=ans%7;
        ans=(ans*10)%7;
    }
}
int f[MAX][10];
void solve() {
    cin>>n;
    init();
    string s,op;
    cin>>s>>op;
    f[n][0]=1;
    for(int i=n-1;i>=0;i--){
        int shu=s[i]-'0';
        if(op[i]=='A'){
            for(int j=0;j<7;j++){
                if(f[i+1][j]&&f[i+1][(j+a[i]*shu)%7])f[i][j]=1;
            }
        }else{
            for(int j=0;j<7;j++){
                if(f[i+1][j]||f[i+1][(j+a[i]*shu)%7])f[i][j]=1;
            }
        }
    }
    if(f[0][0]){
        cout<<"Takahashi";
    }else{
        cout<<"Aoki";
    }
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int _ = 1;
    //cin >> _;
    for (int i = 1; i <= _; i++) {

        solve();
    }
    return 0;
}

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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;

vector<ll>adj[N];
ll c[N];
ll n;
ll in[N];
bool visited[N];
ll timer=0;
ll temp[N];
ll a[N],b[N];

void dfs(ll x)
{
    visited[x]=true;

    in[x]=timer++;

    for(auto it: adj[x])
    {
        if(!visited[it])
        dfs(it);
    }
}

void dfs1(ll x,ll sum)
{
    sum+=temp[x];

    visited[x]=true;

    c[x]=sum;

    for(auto it: adj[x])
    {
        if(!visited[it])
        {
            dfs1(it,sum);
        }
    }
}

int main()
{
    cin>>n;

    rep(i,0,n-1)
    {
        cin>>a[i]>>b[i];

        adj[a[i]].pb(b[i]);
        adj[b[i]].pb(a[i]);
    }

    dfs(1);

    ll q;
    cin>>q;

    while(q--)
    {
        ll type,e,x;

        cin>>type>>e>>x;

        if(type==1)
        {
            if(in[a[e-1]]<in[b[e-1]])
            {
                temp[1]+=x;
                temp[b[e-1]]-=x;
            }
            else
            {
                temp[a[e-1]]+=x;
            }
        }
        else
        {
            if(in[b[e-1]]<in[a[e-1]])
            {
                temp[1]+=x;
                temp[a[e-1]]-=x;
            }
            else
            {
                temp[b[e-1]]+=x;
            }
        }
    }

    clr(visited);
    dfs1(1,0);

    rep(i,1,n+1)
    cout<<c[i]<<endl;

return 0;
}


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

double rec2(int i){
    if(i==n)return 0;
    return dp[i]=rec2(i+1)+(double)n/(n-i);
}

int main(){
    in(n);
    dp.resize(n,-1);
    out(rec2(1));
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int a, b; cin >> a >> b;
    cout << (2*a + 100 -b) << endl;
    return 0;
}


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

#define pi 3.1415926535
#define int long long
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define sz(x) (int)x.size()
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define nitro ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const int inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 50;

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a > b)
    {
        cout << "Takahashi";
    }
    else if(a < b)
    cout << "Aoki";
    else
    {
        if(c == 1)
            cout << "Takahashi";
        else
            cout << "Aoki";
    }
}

int32_t main()
{
    nitro;
    int tc = 1;
//    cin >> tc;
    while(tc--) solve();
}

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

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

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,Y,Z; cin>>X>>Y>>Z;
    cout<<(Y*Z+X-1)/X-1<<"\n";
    return 0;
}


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

int primer[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 };
int cnt[10];

int main() {
    int n;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        int x = i;
        for (int j = 0; j < 10; ++j) {
            int c = 0;
            while (x % primer[j] == 0) {
                x /= primer[j];
                ++c;
            }
            cnt[j] = max(cnt[j], c);
        }
    }
    unsigned long long res = 1;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < cnt[i]; ++j) {
            res *= primer[i];
        }
    }
    cout << res + 1 << endl;
    return 0;
}

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

#define ni(n) ((n) * (n))
#define rep(i,n) for(i=0;i<n;i++)
#define N 100050

int main(void){
	int a;
	int i;
	int sum = 0;
	rep(i,2){
		scanf("%d",&a);
		sum += a;
	}
	if(sum == 0) printf("0");
	else if(sum == 4) printf("2");
	else printf("%d",3-sum);
	return 0;
}


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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

template <typename Arg1>
void prn(Arg1&& arg1) { cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) { cout<<arg1<<" "; prn(args...); }

template <typename Arg1>
void prs(Arg1&& arg1) { cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) { cout<<arg1<<" "; prs(args...); }

template <typename Arg1>
void read(Arg1&& arg1) { cin>>arg1; }
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { cin>>arg1; read(args...); }

#define int                     long long
#define all(ds)                 ds.begin(), ds.end()
#define uniq(v)                 (v).erase(unique(all(v)),(v).end())
#define gcd(x,y)                __gcd(x,y)
#define rep(i,a,b)              for(int i=a;i<b;i++)
#define precise(x)              cout<<fixed<<setprecision(x)
#define endl                    "\n"

const long long INF = 1e18;
const int32_t MOD = 1e9+7;
const int N = 1005;

int n, m, k, q, r, l, x, y, z;
int a[N], b[N], c[N];
string s, t;
int ans = 0;

float findSlope(pair<int, int>p1, pair<int, int>p2){
    int x = p2.second - p1.second;
    int y = p2.first - p1.first;
    return (float)(float(x)/(float(y)));
}

void solve(){
    read(n);
    pair<int,int>a[n];
    rep(i,0,n){
        int x, y;
        read(x, y);
        a[i] = {x,y};
    }
    for(int i = 0; i < n-1; ++i){
        for(int j = i+1; j < n; ++j){
            float z = findSlope(a[i], a[j]);
            // prn(z);
            if(z >= -1.0 && z <= 1.0){
                ans++;
            }
        }
    }
    prn(ans);

}

signed main()
{
#ifndef ONLINE_JUDGE
    input_output
#else
    fastio
#endif

#ifdef SIEVE
    sieve();
#endif

#ifdef NCR
    init();
#endif

    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
// #define LOCAL // 提出時はコメントアウト
#define DEBUG_

typedef long long ll;
const double EPS = 1e-9;
const ll INF = ((1LL<<62)-(1LL<<31));
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;
template<typename T> using uset = unordered_set<T>;
template<typename T, typename U> using mapv = map<T,vector<U>>;
template<typename T, typename U> using umap = unordered_map<T,U>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define sz(x) (ll)x.size()
ll llceil(ll a,ll b) { return (a+b-1)/b; }
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; }
template<class T> vector<vector<T>> genarr(ll n, ll m, T init) { return vector<vector<T>>(n,vector<T>(m,init)); }

///// DEBUG
#define DUMPOUT cerr
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
template<typename T>istream&operator>>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T,typename U>ostream&operator<<(ostream&os,pair<T,U>&pair_var){os<<"("<<pair_var.first<<", "<<pair_var.second<<")";return os;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&vec){os<<"{";for(int i=0;i<vec.size();i++){os<<vec[i]<<(i+1==vec.size()?"":", ");}
os<<"}";return os;}
template<typename T,typename U>ostream&operator<<(ostream&os,map<T,U>&map_var){os<<"{";repi(itr,map_var){os<<*itr;itr++;if(itr!=map_var.end())os<<", ";itr--;}
os<<"}";return os;}
template<typename T>ostream&operator<<(ostream&os,set<T>&set_var){os<<"{";repi(itr,set_var){os<<*itr;itr++;if(itr!=set_var.end())os<<", ";itr--;}
os<<"}";return os;}
void dump_func(){DUMPOUT<<endl;}
template<class Head,class...Tail>void dump_func(Head&&head,Tail&&...tail){DUMPOUT<<head;if(sizeof...(Tail)>0){DUMPOUT<<", ";}
dump_func(std::move(tail)...);}
#ifndef LOCAL
#undef DEBUG_
#endif
#ifdef DEBUG_
#define DEB
#define dump(...)                                                          \
DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
        << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
        << endl                                                            \
        << "    ",                                                         \
    dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

//////////

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

vector<ll> divisors(ll n) {
    vector<ll> res;
    REP(i,1,int(sqrt(n))+1) {
        if (n%i==0) {
            res.push_back(i);

            if (i!=n/i)
                res.push_back(n/i);
        }
    }
    return res;
}

int main() {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    ll N, ans = 0;
    cin>>N;

    N *= 2;
    for (auto n : divisors(N)) {
        ll r = N / n;
        if ((r-n-1) % 2 == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll mod = 998244353ll;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n;
	cin >> n;
	vector<int> x(n), y(n), z(n), num;
	rep(i, 0, n) {
		cin >> x[i] >> y[i] >> z[i];
	}
	x.push_back(x.front());
	y.push_back(y.front());
	z.push_back(z.front());
	n++;
	vector<vector<ll>> dp(n, vector<ll>(1 << n, 1ll << 60));
	dp[0][1] = 0;
	rep(_i, 1, 1 << n) {
		rep(i, 0, n) {
			if (_i >> i & 1) {
				rep(i2, 0, n) {
					if (_i >> i2 & 1) {
						dp[i][_i] = min(dp[i][_i], dp[i2][_i ^ (1 << i)] + abs(x[i] - x[i2]) + abs(y[i] - y[i2]) + max(0, z[i] - z[i2]));
						//printf("_i:%d i:%d i2:%d %lld %lld\n", _i, i, i2, dp[i][_i], dp[i2][_i ^ (1 << i)]);
					}
				}
			}
		}
	}
	printf("%lld\n", dp[n - 1][(1 << n) - 1]);
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
constexpr int INF = 1e9, MOD = 1e9 + 7;
constexpr int64_t LINF = 5e18, LMOD = 998244353;
// #include <atcoder/all>
// using namespace atcoder;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

// BEGIN CUT HERE
/**
 * @brief セグメント木
 * @tparam S 要素モノイド
 */
template<class S>
struct SegmentTree {
public:
	/**
	 * @brief 単位元で初期化
	 * @param N サイズ
	 * @param F 二項演算 (S, S) -> S
 	 * @param e 要素モノイドの単位元
	 */
	SegmentTree(const size_t N, const function<S(S, S)>& F, const S& e) : SegmentTree(vector<S>(N, e), F, e) {}
	/**
	 * @brief 与配列で初期化
	 * @param v 配列
	 * @param F 二項演算 (S, S) -> S
 	 * @param e 要素モノイドの単位元
	 */
	SegmentTree(const vector<S>& v, const function<S(S, S)>& F, const S& e) : F(F), e(e) {
		N = 1 << pow2(v.size());
		val = vector<S>(N << 1, e);
		for(size_t i = 0; i < v.size(); ++i) {
			val[N + i] = v[i];
		}
		for(size_t i = N - 1; i >= 1; --i) {
			update(i);
		}
	}
	/**
	 * @brief 1点更新
	 */
	void set(size_t idx, const S& _val) {
		assert(idx < N);
		idx += N;
		val[idx] = _val;
		while(idx > 1) {
			idx >>= 1;
			update(idx);
		}
	}
	/**
	 * @brief 区間取得[l, r)
	 */
	S get(size_t l, size_t r) {
		assert(l < r and r <= N);
		S valL = e;
		S valR = e;
		for(l += N, r += N; l < r; l >>= 1, r >>= 1) {
			if(l & 1) {
				valL = F(valL, val[l++]);
			}
			if(r & 1) {
				valR = F(val[--r], valR);
			}
		}
		return F(valL, valR);
	}
	/**
	 * @brief 1点取得
	 */
	S get(const size_t idx) {
		assert(idx < N);
		return val[N + idx];
	}
	/**
	 * @brief 1点取得
	 */
	S operator[](const size_t idx) {
		assert(idx < N);
		return val[N + idx];
	}
private:
	const function<S(S, S)> F;
	const S e;
	size_t N;
	vector<S> val;
	/**
	 * @return n <= 2^k なる最小の k
	 */
	size_t pow2(const size_t n) {
		size_t k = 0;
		while((1 << k) < n) {
			++k;
		}
		return k;
	}
	/**
	 * @brief v[idx]の更新
	 */
	void update(size_t idx) {
		val[idx] = F(val[idx << 1], val[(idx << 1) | 1]);
	}
};
// END CUT HERE

int main() {
	int n, m, q; cin >> n >> m >> q;
	vector<tuple<int, int, int>> query;
	vector<int> val;
	rep(i,q) {
		int t, x, y; cin >> t >> x >> y;
		query.emplace_back(t, x - 1, y);
		val.emplace_back(y);
	}
	val.emplace_back(0);
	sort(val.begin(), val.end());
	val.erase(unique(val.begin(), val.end()), val.end());
	int vn = val.size();
	SegmentTree<int64_t> seg_a(vn, [](int64_t l, int64_t r) {
		return l + r;
	}, 0);
	SegmentTree<int64_t> seg_b(vn, [](int64_t l, int64_t r) {
		return l + r;
	}, 0);
	SegmentTree<int64_t> seg_a_cnt(vn, [](int64_t l, int64_t r) {
		return l + r;
	}, 0);
	SegmentTree<int64_t> seg_b_cnt(vn, [](int64_t l, int64_t r) {
		return l + r;
	}, 0);
	int64_t ans = 0;
	int a[n] = {};
	int b[m] = {};
	seg_a_cnt.set(0, n);
	seg_b_cnt.set(0, m);
	for(auto [t, x, y] : query) {
		if(t == 1) {
			ans -= seg_b.get(a[x], vn);
			if(0 < a[x]) ans -= seg_b_cnt.get(0, a[x]) * val[a[x]];

			seg_a.set(a[x], seg_a[a[x]] - val[a[x]]);
			seg_a_cnt.set(a[x], seg_a_cnt[a[x]] - 1);
			a[x] = lower_bound(val.begin(), val.end(), y) - val.begin();
			seg_a.set(a[x], seg_a[a[x]] + val[a[x]]);
			seg_a_cnt.set(a[x], seg_a_cnt[a[x]] + 1);

			ans += seg_b.get(a[x], vn);
			if(0 < a[x]) ans += seg_b_cnt.get(0, a[x]) * val[a[x]];
		} else {
			ans -= seg_a.get(b[x], vn);
			if(0 < b[x]) ans -= seg_a_cnt.get(0, b[x]) * val[b[x]];

			seg_b.set(b[x], seg_b[b[x]] - val[b[x]]);
			seg_b_cnt.set(b[x], seg_b_cnt[b[x]] - 1);
			b[x] = lower_bound(val.begin(), val.end(), y) - val.begin();
			seg_b.set(b[x], seg_b[b[x]] + val[b[x]]);
			seg_b_cnt.set(b[x], seg_b_cnt[b[x]] + 1);

			ans += seg_a.get(b[x], vn);
			if(0 < b[x]) ans += seg_a_cnt.get(0, b[x]) * val[b[x]];
		}
		cout << ans << '\n';
	}
	return 0;
}


#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 rrep(i, n) for (ll i = 1; i < (ll)(n + 1); i++)
int digsum(ll N){
    bool a=true;
    ll ans=0;
    while(a==true){
        if(0<N){
            ans+=N++;
            N-=N%10;
            N/=10;
        }
        else{
            a=false;
        }
    }
    return ans;
}
int main() {
    int N;
    cin>>N;
    vector<ll>A(N);
    vector<ll>B(N);
    vector<ll>cn(N);
    ll cnt=0;
    ll ans=0;
    ll an=0;
    rep(i,N){
        cin>>A[i];
        cin>>B[i];
        cn[i]=A[i]*2+B[i];
        cnt+=A[i];
    }
    sort(cn.rbegin(),cn.rend());
    rep(i,N){
        ans+=cn[i];
        if(cnt<ans){
            cout<<i+1<<endl;
            i+=N;
        }
    }
}

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

bool cmp(pair<ll,ll>a,pair<ll,ll>b){
    ll suma = 2*a.first+a.second;
	ll sumb = 2*b.first+b.second;
	return suma > sumb;
}

int main(){
    ll n,k;
    cin>>n;
    vector<pair<ll,ll>>vp;
	ll d=0,t=0,cnt;
    for(int i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
    	d+=a;
        vp.push_back({a,b});
    }

	sort(vp.begin(),vp.end(),cmp);

	t=0,cnt=1;
	for(auto it:vp)
	{
		t+=it.first+it.second;
		d-=it.first;
		if(t<=d)
		    cnt++;
		else break;
	}

	cout<<cnt<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

int n,m,i,j,k,l;
char f[101][101];
char a[101];

char work(char c1,char c2)
{
	if (c1==c2) return c1;
	if (c1=='R')
	{
		if (c2=='S') return c1;
		return c2;
	}
	if (c1=='P')
	{
		if (c2=='R') return c1;
		return c2;
	}
	if (c1=='S')
	{
		if (c2=='P') return c1;
		return c2;
	}
}

int main()
{
	#ifdef file
	freopen("c.in","r",stdin);
	#endif

	scanf("%d%d",&n,&m);
	scanf("%s",a+1);
	fo(i,1,n) f[0][i]=a[i];
	l=1;
	fo(i,1,m)
	{
		fo(j,1,n)
		{
			k=(j+l-1)%n+1;
			f[i][j]=work(f[i-1][j],f[i-1][k]);
		}
		l=l*2%n;
	}
	printf("%c\n",f[m][1]);

	fclose(stdin);
	fclose(stdout);
	return 0;
}

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

using namespace std;

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

char solve(string S, int k) {
	assert(!S.empty());
	if (k == 0) return S[0];
	if ((int) S.size() % 2 == 1) S += S;
	assert((int) S.size() % 2 == 0);
	string S2 = "";
	for (int i = 0; i < (int) S.size(); i += 2) {
		if (S[i] == S[i + 1]) {
			S2 += S[i];
		} else {
			pcc H = {min(S[i], S[i + 1]), max(S[i], S[i + 1])};
			if (H == pcc(min('R', 'S'), max('R', 'S'))) {
				S2 += 'R';
			} else if (H == pcc(min('R', 'P'), max('R', 'P'))) {
				S2 += 'P';
			} else {
				S2 += 'S';
			}
		}
	}
	return solve(S2, k - 1);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	string S;
	cin >> S;
	cout << solve(S, k) << endl;
}
//RPSRPS -> PRS


#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;

#define REP(i,b,e) for(int i=b; i<e; i++)
#define PRINT(vec) {printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");}
#define fi first
#define se second

const int MOD = 1e9+7;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	int a[n+1], b[m+1];
	REP(i, 0, n) scanf("%d", &a[i]);
	REP(i, 0, m) scanf("%d", &b[i]);
	a[n] = b[m] = 1010;

	std::vector<int> ans;
	int i = 0, j = 0;
	while(i<n or j<m){
		if(i>=n){
			ans.push_back(b[j]);
			j++;
			continue;
		}else if(j>=m){
			ans.push_back(a[i]);
			i++;
			continue;
		}

		if(a[i]==b[j]){
			i++;
			j++;
		}else if(a[i]<b[j]){
			ans.push_back(a[i]);
			i++;
		}else{
			ans.push_back(b[j]);
			j++;
		}
	}

	for(int x: ans) if(x!=1010) printf("%d ", x);
	puts("");
	return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> b(m);
  for (int i=0;i<n;i++) cin >> a[i];
  for (int i=0;i<m;i++) cin >> b[i];
  vector<int> nums(1001,0);
  for (int i=0;i<n;i++) {
    nums[a[i]]++;
  }
  for (int i=0;i<m;i++) {
    nums[b[i]]++;
  }
  vector<int> ans;
  for (int i=1;i<=1000;i++) {
    if (nums[i] == 1) {
      ans.emplace_back(i);
    }
  }
  for (int i=0;i<ans.size();i++) {
    if (i != 0) cout << ' ';
    cout << ans[i];
  }
  cout << endl;
}


/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
#include "bits/stdc++.h"
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define ll long long
#define ld long double
#define gap ' '
#define endl '\n'
#define Mod 1e9+7
/*
*/
vector<char> v;
map<char,int> mp;
pair<int,int> get(string s) {
	int r=0;
	for(char c: s)
	r=r*10+mp[c];
	int d=0,R=r;
	while(r) r/=10,d++;
	return {R,d};
}
void solve(int testcase) {
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	set<char> chars;
	for(char c: s1) chars.insert(c);
	for(char c: s2) chars.insert(c);
	for(char c: s3) chars.insert(c);
	if(chars.size()>10) {
		cout<<"UNSOLVABLE"<<endl;
		return;
	}
	for(char c: chars) v.push_back(c);
	while(v.size()<10) v.push_back('z'+1);
	do {
		for(int i=0;i<10;i++)
			mp[v[i]]=i;

		auto n1=get(s1),n2=get(s2),n3=get(s3);
		if(n1.first+n2.first==n3.first and n1.second==s1.size() and n2.second==s2.size() and n3.second==s3.size()) {
			cout<<n1.first<<endl;
			cout<<n2.first<<endl;
			cout<<n3.first<<endl;
			return;
		}
	} while(next_permutation(v.begin(),v.end()));
	cout<<"UNSOLVABLE"<<endl;
}

int32_t main() {
	fio
	int T=1;
	//cin>>T;
	for(int t=1;t<=T;t++) solve(t);
	return 0;
}
//tag and rating

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

using namespace std;
//using namespace atcoder;

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

    set<int> A;
    int Aa[N];
    for(int i=0;i<N;i++) Aa[i]=0;
    for(int i=0;i<K;i++){
        int Ain;
        cin>>Ain;
        Aa[Ain]=1;
        A.insert(Ain);
    }

    if(N>M){
        int c=0;
        for(int i=0;i<M;i++){
            c+=Aa[i];
        }
        if(c>=M){
            cout<<"-1"<<endl;
            return 0;
        }
        for(int i=M;i<N;i++){
            c+=Aa[i];
            c-=Aa[i-M];
            if(c>=M){
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }

    double l=0;
    double r=DBL_MAX/N-1;
    int c=0;
    while(1){
        double m=(l+r)/2;
        double dp[N+1];
        for(int i=0;i<N+1;i++) dp[i]=0;
        double wa=0;
        for(int i=N-1;i>=0;i--){
            if(A.find(i)==A.end()) dp[i]=wa/M+1;
            else dp[i]=m;
            wa+=dp[i];
            if(i+M<=N) wa-=dp[i+M];
            //cout<<i<<","<<wa<<endl;
        }
        //cout<<m<<","<<dp[0]<<endl;
        if(dp[0]<m) r=m;
        else l=m;
        c++;
        if(c>=2000) break;
    }
    printf("%.12f\n",(l+r)/2);

}


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

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;

const int N = 2e5+5;

void solve(){

	int n, m;
	cin>>n>>m;
        if(n==1 && m==0)
	   done("1 2");
	if(m<0 || m>=n-1)
		done(-1);

	vpii v;
	v.pb({1,2*m+4});
	fr(i,1,m+1)
		v.pb({2*i, 2*i+1});
	int cnt = 2*m+5;
	while(sz(v)<n)
		v.pb({cnt++,cnt++});

	trav(p, v)
		cout << p.fi << " " << p.se << endl;

}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

#include <bits/stdc++.h>

using namespace std;

//#define MULTITEST

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e8);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

int n, m;

bool read () {
	if (scanf("%d%d", &n, &m) != 2)
		return false;
	return true;
}

void solve() {
	if (m == 0){
		forn(i, n) printf("%d %d\n", 2 * i + 1, 2 * i + 2);
		return;
	}

	if (m < 0 || m >= n - 1){
		puts("-1");
		return;
	}

	vector<pt> ans;
	ans.pb(mp(0, 2 * m + 2));
	forn(i, m) ans.pb(mp(2 * i + 1, 2 * i + 2));
	ans.pb(mp(2 * m + 1, 2 * m + 3));

	int lst = 2 * m + 3;
	while (sz(ans) < n){
		ans.pb(mp(lst + 1, lst + 2));
		lst += 2;
	}

	for (auto it : ans)
		printf("%d %d\n", it.x + 1, it.y + 1);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef MULTITEST
	int tc;
	scanf("%d", &tc);
	while(tc--){
		read();
#else
	while(read()) {
#endif
		solve();

#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}


#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,int>
#define mp make_pair

using namespace std;

const int nax = 5e5 + 5;

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

    int n; cin>>n;
    string s,t; cin>>s>>t;
    int bal = 0;
    for(int i=n-1;i>=0;i--)
    {
        if(s[i] == '1') bal++;
        if(t[i] == '1') bal--;

        if(bal < 0)
        {
            cout<<-1;
            return 0;
        }
    }

    if(bal % 2 == 1)
    {
        cout<<-1;
        return 0;
    }

    vector<int> pos1;
    vector<int> pos2;
    for(int i=0;i<n;i++)
    {
        if(s[i] == '1') pos1.pb(i);
        if(t[i] == '1') pos2.pb(i);
    }

    stack<int> wyjebansko;
    ll ans = 0;
    int done = 0;
    for(int i=0;i<pos1.size();i++)
    {
        int cur = pos1[i];
        if(wyjebansko.size() == 1)
        {
            int pop = wyjebansko.top();
            wyjebansko.pop();
            ans += (cur - pop);
        }
        else
        {
            if(done < pos2.size() && cur >= pos2[done])
            {
                ans += cur - pos2[done];
                done++;
            }
            else wyjebansko.push(cur);
        }
    }
    cout<<ans;

    return 0;
}

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

const int N = 500005;

int n;
char s[N], t[N];

int solve() {
  scanf("%d", &n);
  scanf("%s", s);
  scanf("%s", t);

  vector<int> v1, v2;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '1') v1.push_back(i);
    if (t[i] == '1') v2.push_back(i);
  }

  long long ans = 0;
  int cur = 0;
  for (int i = 0; i < v1.size(); ++i) {
    if (cur >= v2.size() || v2[cur] > v1[i]) {
      if (i + 1 >= v1.size()) return 0 * printf("-1\n");
      ans += v1[i + 1] - v1[i];
      ++i;
    } else {
      ans += v1[i] - v2[cur];
      ++cur;
    }
  }

  if (cur < v2.size()) return 0 * printf("-1\n");

  printf("%lld\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    solve();
  }
  return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
//#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(v) v.begin(), v.end()
#define front(v) *v.begin()
#define back(v) *(--v.end())
#define len(v) v.size()
#define int long long

using longl = long long;
using longd = long double;

const longl INF = 1e9;
const longl LINF = 1e18;
const longl mod = 1e9 + 7;
const double PI = acos(-1);
//------------------------------------------------------------------------------------------------

longl divup(longl a, longl b){
    return (a + b - 1) / b;
}

longl bin_pow(longl a, longl b){
    longl res = 1;

    while (b > 0){
        if (b % 2)
            res = res * a % mod;

        a = a * a % mod;
        b /= 2;
    }
    return res;
}

//------------------------------------------------------------------------------------------------
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int a, b;
    cin >> a >> b;

    int n;
    int k;
    if (a > b) {
        n = a;
        k = 1;
    }
    else {
        n = b;
        k = -1;
    }

    int sum = 0;
    int sum2 = 0;
    vector<int> tmp;
    for (int i = 0; i < n; i++){
        cout << (i + 1) * k << ' ';
        sum += (i + 1) * k;

        if (i < min(a, b) - 1){
            cout << -((i + 1) * k) << ' ';
        }
        else {
            sum2 += (i + 1) * k;
        }
    }

    cout << -sum2;

    return 0;
}

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

using namespace std;

int main()
{
    long A, B;
    cin >> A;
    cin >> B;

    long sum = 0;

    vector<long> Ea, Eb;

    int C;
    if (A<B)
    {
        for (int i = 1; i <= B; i++)
        {
            Eb.push_back(i*-1);
            if (i >= A)
                sum += i;
        }
        for (int i = 1; i <= A; i++)
        {
            if (i == A)
                Ea.push_back(sum);
            Ea.push_back(i);
        }
    }

    else if (A>B)
    {
        for (int i = 1; i <= A; i++)
        {
            Ea.push_back(i);
            if (i >= B)
                sum += i;
        }
        for (int i = 1; i <= B; i++)
        {
            if (i == B)
                Eb.push_back(sum*-1);
            Eb.push_back(i*-1);
        }
    }
    else
    {
        for (int i = 1; i <= A; i++)
        {
            Ea.push_back(i);
            Eb.push_back(i*-1);
        }
    }

    for (int i = 0; i < A; i++)
        cout << Ea[i] << " ";
    for (int i = 0; i < B; i++)
        cout << Eb[i] << " ";

    return 0;
}


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

#define ll              long long
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vll;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

const int mod = 1000000007;
const int N = 1e5+5, M = N;

void solve()
{
    ll n, m;
    scanf("%lld %lld",&n ,&m);

    printf("%lld %lld\n",(n+m)/2 , (n-m)/2);
}

int main()
{
    int t = 1;

    //scanf("%d",&t);

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

    return 0;
}

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  os << "{";
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
  return os << "}";
}
[[maybe_unused]] constexpr ll MOD = 998244353;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ll a, b;
  cin >> a >> b;

  // x + y = a, x - y = b
  // x * 2 = a + b
  // y * 2 = a - b
  cout << (a + b) / 2 << " " << (a - b) / 2 << endl;

  return 0;
}


#include <bits/stdc++.h>

#define int long long

using namespace std;

long long n, ans;

int judge(int x, int s) {
    if(x * s * 10 + x <= n) return 1;
    else return 0;
}

signed main() {

    scanf("%lld", &n);
    long long tmp = n, len = 0;
    while(tmp) len ++, tmp /= 10;
    for(int i = 2;i <= len; i += 2) {
        // cout << i << " " << len << "\n";
        if(len > i) ans += 9ll * pow(10, i / 2 - 1);
        else {
            int s = pow(10, i / 2 - 1), t = pow(10, i / 2) - 1;
            for(int j = s;j <= t; j++) { if(judge(j, s)) ans ++;}
        }
        // cout << i << " " << ans << "\n";
    }
    printf("%lld", ans);

    return 0;
}

/*
1234122356

1000000000000
*/

#include <bits/stdc++.h>
#define forloop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ll long long int
#define ld long double
#define pb emplace_back
#define ravi ios_base::sync_with_stdio(false);
#define parmar2002 cin.tie(NULL); cout.tie(NULL);
#define nl "\n"
#define whole(x) x.begin(), x.end()
#define wholer(x) x.rbegin(), x.rend()
#define len(s) s.size()
#define endline cout << "\n";
#define v(arr, n) vector<ll> arr(n);
#define vin(arr, n) forloop(i, 0, n) cin >> arr[i];
#define T(T) ll tt; cin >> tt; forloop(T, 1, tt + 1)
using namespace std;
void factors(ll n)
{

}
void solve()
{
    double n;
    cin>>n;
    cout<<ceill(n/100)<<nl;
}
int main()
{
    ravi parmar2002
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    //clock_t tStart = clock();
    // T(T)
    solve();
    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


//BELIEVE IN YOURSELF
//next_permutation

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define sec second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define sortr(v) sort(v.rbegin(),v.rend());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

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

ll n,m;

bool isvalid(ll x,ll y)
{
	if(x>=0 && y>=0 && x<n && y<m)
	{
		return true;
	}
	return false;
}

int main()
{
		fast;

		cin>>n>>m;
		ll i,j;
		string s;
		vector<string>g;

		for(i=0;i<n;i++)
		{
			cin>>s;
			g.pb(s);
		}

		ll a[n+1][m+1];
//		ll vis[n+1][m+1];

		ll inf=1e17;
		ll sx=0,sy=0,ex=0,ey=0;

		vector<vector<pair<ll,ll> > >tp(26);

		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				a[i][j]=inf;
				if(g[i][j]=='S')
				{
					a[i][j]=0;
					sx=i;
					sy=j;
				}
				if(g[i][j]=='G')
				{
					ex=i;
					ey=j;
				}
				if(g[i][j]>='a' && g[i][j]<='z')
				{
					char c=g[i][j];
					tp[c-'a'].pb(mp(i,j));
				}
			}
		}

		queue<pair<ll,ll> >q;

		q.push(mp(sx,sy));

		while(!q.empty())
		{
			ll x,y;
			pair<ll,ll>now =q.front();
			q.pop();

			x=now.fi;
			y=now.sec;

			for(i=0;i<4;i++)
			{
				ll nx,ny;
				pair<ll,ll>next = mp(x+dx[i],y+dy[i]);

				nx=next.fi;
				ny=next.sec;

				if(isvalid(nx,ny))
				{
					if(g[nx][ny]!='#' && a[nx][ny]==inf)
					{
						a[nx][ny]=a[x][y]+1;
						q.push(mp(nx,ny));
					}
				}

			}

			char c=g[x][y];

			if(islower(c))
			{
				for(auto next:tp[c-'a'])
				{
					ll nx,ny;
					nx=next.fi;
					ny=next.sec;

					if(a[nx][ny]==inf)
					{
						a[nx][ny]=a[x][y]+1;
						q.push(mp(nx,ny));
					}
				}

				tp[c-'a'].clear();

			}

		}

		ll ans=a[ex][ey];

		if(ans==inf)
		{
			cout<<-1<<Endl;
		}
		else
		{
			cout<<ans<<endl;
		}

	return 0;
}

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0 ; i < (n); ++i)
using namespace std ;
typedef long long ll ;
const int mod=1000000007;
const int INF=1e5 ;

pair<int,int> dir[4]={{0,1},{1,0},{-1,0},{0,-1}};

void solve(){

	int h,w ;
	cin>>h>>w ;

	vector<string> s(h) ;

	rep(i,h){
		cin>>s[i] ;
	}

	queue<pair<int,int>> q ;

	vector<vector<pair<int,int>>> l(26) ;

	vector<vector<int>> dist(h,vector<int>(w,INF)) ;

	pair<int,int> d ;

	rep(i,h)rep(j,w){
		if(s[i][j]=='S'){
		q.push({i,j}) ;
		dist[i][j]=0 ;
	}
	if(s[i][j]=='G'){
		d.first=i ;
		d.second=j ;
		}
	}

	rep(i,h)rep(j,w){
			if(islower(s[i][j]))
			l[s[i][j]-'a'].push_back({i,j}) ;
	}

	while(!q.empty()){

		int i=q.front().first ;
		int j=q.front().second ;

		q.pop() ;

		for(auto v:dir)
		{
			int ni=i+v.first ;
			int nj=j+v.second ;

			if(ni<0 || ni>=h || nj<0 || nj>=w) continue ;
			if(s[ni][nj]=='#') continue ;
			if(dist[ni][nj]!=INF)	continue ;
			dist[ni][nj]=dist[i][j]+1 ;
			q.push({ni,nj}) ;
		}

		if(islower(s[i][j])){

			for(auto p:l[s[i][j]-'a']){
				int ni=p.first ;
				int nj=p.second ;
				if(dist[ni][nj]!=INF) continue ;
				dist[ni][nj]=dist[i][j]+1 ;
				q.push({ni,nj}) ;

			}

		l[s[i][j]-'a']=vector<pair<int,int>>() ;

		}
	}

	if(dist[d.first][d.second]==INF)
		cout<<-1 ;
	else
		cout<<dist[d.first][d.second]	;
}

int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){

			solve() ;

		}
	return 0 ;
}


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

#define ll long long int

int main(){
    int n;
    cin>>n;
    int a[n];
    int b[n];

    ll ans = 100000000000000 ;

    for(int i = 0 ; i < n ; i++){
        cin>>a[i]>>b[i];
        ll ch = a[i]+b[i] ;
        ans = min(ans,ch);
    }

    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            if(i == j) continue ;
            ll ch = max(a[i],b[j]) ;
            // cout<<ch<<endl;
            ans = min(ans , ch);
        }
    }

    cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;

// a + (a+1) + ... + b
long sum(const long &a, const long &b) { return (a + b) * (b - a + 1) / 2; }

int main() {
  int T;
  cin >> T;
  while (T--) {
    long L, R;
    cin >> L >> R;
    const long minC = L;
    const long maxC = R - L;
    if (minC > maxC) {
      cout << 0 << endl;
    } else {
      cout << sum(R - maxC - L + 1, R - minC - L + 1) << endl;
    }
  }
  return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int y=(b-a)/2;
  y=-y;
  int x=a-y;
  cout << x << " " << y << endl;
  return 0;
}

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

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (a+b)/2 << ' ' << (a-b)/2 << endl;
    return 0;
}