#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()

const int n = 20;
const int n2 = 1 << n;
const vector<int> p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};

void solve(long long A, long long B) {
    vector<ll> dp(n2);
    dp.at(0) = 1;
    for (ll x = A; x <= B; ++x) {
        int s = 0;
        rep(i, n) {
            if (x % p.at(i) == 0) {
                s = s | (1 << i);
            }
        }
        rep(i, n2) {
            if (i & s) continue;
            dp.at(i | s) += dp.at(i);
        }
    }
    ll ans = 0;
    rep(i, n2) {
        ans += dp.at(i);
    }
    cout << ans << endl;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 100005
#define mid(l,r) l+(r-l)/2
#define removeduplicates(vec) vec.erase( unique( vec.begin(), vec.end() ), vec.end() )
#define memset1(v) memset(v,-1,sizeof(v))
#define memset0(v) memset(v,0,sizeof(v))
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll prime[20]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
ll dp[(1<<20)];
void solve(){
	ll a,b;
	cin>>a>>b;
	dp[0]=1;
	for(ll i=a;i<=b;i++){
		ll cur=0;
		for(int j=0;j<20;j++)if(i%prime[j]==0)cur|=(1<<j);
		for(int i=(1<<20)-1;i>=0;i--){
			if(i&cur)continue;
			dp[i^cur]+=dp[i];
		}
	}
	ll ans=0;
	for(int i=0;i<(1<<20);i++)ans+=dp[i];
	cout<<ans;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


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

int win[7][200010], memo[80];
bool judge(bool tak, bool w1, bool w2){return tak ? w1 || w2 : w1 && w2;}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; string s, x;
    cin >> n >> s >> x;
    for (int j = 0; j < 7; ++j) for (int i = 0; i < n + 1; ++i) win[j][i] = -1;
    for (int i = 0; i < 70; ++i) memo[i] = i % 7;

    auto dfs = [&](auto dfs, int res, int round)->bool{
        int num = s[round] - '0', tak = x[round] == 'T', n1 = memo[res * 10 + num], n2 = memo[res * 10];
        if (round == n - 1) return win[res][round] = judge(tak, memo[n1] == 0, memo[n2] == 0);
        else if (win[res][round] != -1) return win[res][round];

        bool w1 = dfs(dfs, n1, round + 1), w2 = dfs(dfs, n2, round + 1);
        return win[res][round] = judge(tak, w1, w2);
    };

    cout << (dfs(dfs, 0, 0) ? "Takahashi\n" : "Aoki\n");
    return 0;
}

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

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::max;

const int INF = 1001001001;

int h, w;
int a[2005][2005];

bool visited[2005][2005];
int memo[2005][2005];
int f(int i, int j) {
	if (i == h - 1 and j == w - 1) return 0;
	if (visited[i][j]) return memo[i][j];
	visited[i][j] = true;
	int res = -INF;
	if (j + 1 < w) res = max(res, a[i][j + 1] - f(i, j + 1));
	if (i + 1 < h) res = max(res, a[i + 1][j] - f(i + 1, j));
	return memo[i][j] = res;
}

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

	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];

	rep(i, h)rep(j, w) a[i][j] = s[i][j] == '+' ? 1 : -1;

	int score = f(0, 0);
	if (score == 0) puts("Draw");
	if (score < 0) puts("Aoki");
	if (score > 0) puts("Takahashi");

	return 0;
}


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

ll solve() {
    ll K, N, M;
    cin >> K >> N >> M;
    vector<ll> A(K);
    for ( int i = 0; i < K; i++ ) cin >> A[i];
    ll INF = 1LL<<60;
    vector<ll> b1(K), b2(K);
    auto is_ok = [&](ll x) -> bool {
        ll b1s = 0, b2s = 0;
        for ( int i = 0; i < K; i++ ) {
            b1[i] = (A[i]*M-x+N-1) > 0 ? (A[i]*M-x+N-1)/N : 0;
            b2[i] = (A[i]*M+x)/N;
            if ( b1[i] > b2[i] ) return false;
            b1s += b1[i];
            b2s += b2[i];
            if ( b2s > INF ) return true;
        }
        return b1s <= M && M <= b2s;
    };

    ll l = 0, r = max(M,N)+10;
    while ( r-l > 1 ) {
        ll m = (r+l)/2;
        if ( is_ok(m) ) r = m;
        else l = m;
    }
    is_ok(r);
    vector<ll> b(b1);
    ll bs = 0;
    for ( int i = 0; i < K; i++ ) {
        bs += b1[i];
    }
    for ( int i = 0; i < K; i++ ) {
        if ( bs < M ) {
            ll d = min(b2[i]-b1[i], M-bs);
            b[i] += d;
            bs += d;
        }
    }
    for ( int i = 0; i < K; i++ ) {
        cout << (i != 0 ? " " : "") << b[i];
    }
    cout << "\n";
    return 0;
}

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

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <sstream>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <assert.h>
#include <iomanip>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.rbegin(),v.rend())
#define div 1000000007
#define div2 998244353
#define PI 3.141592653589793
#define inf 1000000000000000000
#define blk 320
#define pb push_back

void solve()
{
    int k,n,m;cin>>k>>n>>m;
    int a[k],b[k];
    set<pair<int,int>> s;
    int sum=m;
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
        b[i]=a[i]*m/n;
        s.insert({b[i]*n-a[i]*m,i});
        sum-=b[i];
    }
    while(sum>0)
    {
        auto it=*s.begin();
        int num=it.F,idx=it.S;
        b[idx]++;sum--;
        s.erase(*s.begin());
    }
    for(int i=0;i<k;i++)
        cout<<b[i]<<" ";
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
constexpr long long INF = 1000000000 + 100;
constexpr long long LINF = 1000000000000000000 + 100;
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
#define rrep(i, n) for(int i=(n); i>=0; i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll N, M; cin >> N >> M;
    vector<pll> pawn(M);
    rep(i, M){
        ll x, y; cin >> x >> y;
        pawn[i] = {x, y};
    }
    sort(all(pawn));

    set<ll> pos{N};
    vector<ll> ins, era;
    ll pre_x = -1;
    for(auto p:pawn){
        ll x = p.first, y = p.second;
        //cout << "x:" << x << " y:" << y << ln;
        if(x != pre_x){
            //cout << "execute!" << ln;
            pre_x = x;
            for(auto p:era)pos.erase(p);
            for(auto p:ins)pos.insert(p);
            ins.clear();
            era.clear();
        }
        //cout << "pos: ";
        //for(auto s:pos)cout << s << " ";cout << ln;
        //not find
        if(pos.find(y-1) == pos.end() and pos.find(y+1) == pos.end()){
            era.push_back(y);
            //cout << "erase:" << y << ln;
        }
        //find
        else{
            ins.push_back(y);
            //cout << "insert:" << y << ln;
        }
    }
    for(auto p:era)pos.erase(p);
    for(auto p:ins)pos.insert(p);
    cout << pos.size() << ln;
}

#include <cstdio>
#include <algorithm>
#define ll long long int
int N, P[200010];
int need[200010], nxd;
int a[200010], r[200010];
void msort(int s, int t)
{
	if(s==t) return;
	int mid = (s+t)/2;
	msort(s, mid);
	msort(mid+1, t);
	int i = s, j = mid+1, k = s;
	while(i<=mid&&j<=t)
	{
		if(a[i]<=a[j])
		{
			r[k] = a[i]; i++; k++;
		}
		else
		{
			r[k] = a[j]; j++; k++;
			nxd += mid-i+1;
		}
	}
	while(i<=mid)
	{
		r[k] = a[i]; i++; k++;
	}
	while(j<=t)
	{
		r[k] = a[j]; j++; k++;
	}
	for(i=s;i<=t;i++)
	    a[i] = r[i];
}
int main()
{
	scanf("%d", &N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d", &P[i]);
		a[i] = P[i];
		if(P[i]>i)
			need[i] = P[i]-i;
		else
		    need[i] = 0;
	}
	msort(1, N);
//	printf("nxd = %d\n", nxd);
	if(nxd!=(N-1))
	{
		printf("-1\n");
		return 0;
	}

/*	for(int i=1;i<=N;i++)
	    printf("%d ", need[i]);
	printf("\n");
	*/

	for(int i=N-1;i>=1;i--)
	{
		int p = i;
		while(need[i])
		{
			printf("%d\n", p);
			p++;
			need[i]--;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define ms(x,a) memset(x,a,sizeof x)
typedef long long ll;
const int mod=1e9+7, inf=0x3f3f3f3f, MAXN=0;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    ll n; cin >> n;
    ll ans=n;
    for (ll i=2;i*i<=n;++i){
        bool flag=1;
        for (ll j=2;j*j<=i;++j){
            if (i%j) continue;
            ll tmp=i;
            while (tmp%j==0) tmp/=j;
            if (tmp==1) flag=0;
        }
        if (!flag) continue;
        ll tmp=i;
        while (tmp*i<=n){
            tmp*=i, ans--;
        }
    }
    cout << ans << '\n';
}

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long u64;
typedef pair<int,int> pii;
typedef vector<int> vi;
inline void read(int& x){
	static char c;
	while(!isdigit(c=getchar()));x=c^48;
	while(isdigit(c=getchar()))x=(x*10)+(c^48);
}
inline void read(ll& x){
	static char c;
	while(!isdigit(c=getchar()));x=c^48;
	while(isdigit(c=getchar()))x=(x*10)+(c^48);
}

const int N=1e5;
ll n;

int Prm[N+10],vis[N+10],Mu[N+10],tot;
inline void Euler(){
	Mu[1]=1;
	for(int i=2;i<=N;++i){
		if(!vis[i]) Prm[++tot]=i,Mu[i]=-1;
		for(int j=1;j<=tot&&i*Prm[j]<=N;++j){
			vis[i*Prm[j]]=1;
			if(i%Prm[j]==0) break;
			Mu[i*Prm[j]]=-Mu[i];
		}
	}
}

ll Ans;

inline void Work(){
	read(n),Euler();
	for(int i=2;;++i){
		ll sq=pow(n,1.0/i);
		ll l=1,r=sq+2,mid,ans=sq;
		while(l<=r){
			mid=l+r>>1;
			if(pow(mid,i)<=n) ans=mid,l=mid+1;
			else r=mid-1;
		}
		if(ans==1) break;
		Ans+=(ans-1)*Mu[i];
	}
	printf("%lld\n",n+Ans);
}

int main(){Work();}


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

int main(){
    ll N;
    cin >> N;
    for(ll i = 1; ; i++) if(stoll(to_string(i) + to_string(i)) > N){
        cout << i - 1 << endl;
        return 0;
    }
}

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

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

  int64_t ans= 0;
  int64_t div= 1'000;
  while(N >= div){
    ans+= N- (div- 1);
    div*= 1'000;
  }

  cout << ans << endl;
}


#include <bits/stdc++.h>

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

using namespace std;

int main()
{
	int N,Q; string S; cin >> N >> S >> Q;
	string sf = S.substr(0, N);
	string sb = S.substr(N, N);
	rep(i,Q)
	{
		int t,a,b; cin>>t>>a>>b;
		a--; b--;
		if (t==1)
		{
			if (b < N)
				swap(sf[a], sf[b]);
			else if (a >= N)
				swap(sb[a-N], sb[b-N]);
			else
				swap(sf[a], sb[b-N]);
		}
		if (t==2) swap(sf, sb);
	}
	cout << sf << sb << "\n";
}

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	int ans = INF;
	int a = INF, b = INF;
	vector<int> A(N), B(N);
	REP(i, N) scanf("%d %d", &A[i], &B[i]), chmin(ans, A[i] + B[i]);
	REP(i, N) REP(j, N) if (i != j) chmin(ans, max(A[i], B[j]));
	cout << ans << endl;
}


#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#define ynmes(a) (a) ? mes("Yes") : mes("No")
#define YNmes(a) (a) ? mes("YES") : mes("NO")
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{
    ll sum = 0, l = 0;
    string n;
    cin >> n;
    map<ll, ll> mp;
    l = n.length();
    rep(i, l)
    {
        sum += n[i] - '0';
        mp[(n[i] - '0') % 3]++;
    }
    if(sum%3==0)
    {
        mes(0);
        re0;
    }else if(sum%3==1)
    {
        if(mp[1]>0)
        {
            if (l == 1)
            {
                mes(-1);
                re0;
             }
            mes(1);
            re0;
        }else
        {
            if (l <=2)
            {
                mes(-1);
                re0;
            }
            mes(2);
            re0;
        }

    }else if(sum%3==2)
    {
        if (mp[2] > 0)
        {
            if (l == 1)
            {
                mes(-1);
                re0;
            }
            mes(1);
            re0;
        }
        else
        {
            if (l <= 2)
            {
                mes(-1);
                re0;
            }
            mes(2);
            re0;
        }
    }

}

#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

int main() {
    long long int N, dig[20], k,  flag0 = 0, flag1 = 0, flag2 = 0, flag1_2 = 0,
                         flag2_2 = 0,ans=0,i,temp;
    cin >> N;
    temp=N;
    for(i = 1; i <= 20; i++) {
        dig[i] = N % 10;
        /*cout << dig[i]<< endl;*/
        N = (N - dig[i]) / 10;
        if(N < 1) {
            k = i;
            /*cout << k << endl;*/
            break;
        }
    }
    for(i = 1; i <= k; i++) {
        if(dig[i] % 3 == 1) {
            flag1 = 1;
        }
        if(flag1 == 1 && dig[i] % 3 == 1) {
            flag1_2 = 1;
        }
        if(dig[i] % 3 == 2) {
            flag2 = 1;
        }
        if(flag2 == 1 && dig[i] % 3 == 2) {
            flag2_2 = 1;
        }
    }

    N=temp;
    if(N % 3 == 0) {
        ans = 0;

    }
    if(N % 3 == 1 && flag1 == 1 && k>1) {
        ans = 1;
    }
    if(N % 3 == 1 && flag1 == 1 && k<=1) {
        ans = -1;
    }

    if(N % 3 == 1 && flag1 != 1 && flag2_2 == 1 && k>2) {
        ans = 2;
    }
    if(N % 3 == 1 && flag1 != 1 && flag2_2 == 1 && k<=2) {
        ans = -1;
    }

    if(N % 3 == 1 && flag1 != 1 && flag2_2 != 1 && k>2) {
        ans = -1;
    }
    if((N % 3 == 2) && (flag2 == 1) && k>1) {
        ans = 1;
    }
    if((N % 3 == 2) && (flag2 == 1) && k<=1) {
        ans = -1;
    }
    if(N % 3 == 2 && flag2 != 1 && flag1_2 == 1 && k>2) {
        ans = 2;
    }
    if(N % 3 == 2 && flag2 != 1 && flag1_2 == 1 && k<=2) {
        ans = -1;
    }
    if(N % 3 == 2 && flag2 != 1 && flag1_2 != 1) {
        ans = -1;
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ul  unsigned long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff first
#define INF 1000000001
#define inf1 1000000000000000001
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.ff << ", " << p.ss << ")"; }
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
/// RULESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS////
/// READ THEM ALOUD......................................................................................................
/// 1. Read the problem at least twice
/// 2. Brute force if contraints r low
/// 3. Check base cases or break case if found any T-T
/// 4. :D

lli const mod=998244353;
lli const maxn= 1e6+9;
namespace modop {
	lli madd(lli a, lli b) {
	  return (a + b) % mod;
	}
	lli msub(lli a, lli b) {
	  return (((a - b) % mod) + mod) % mod;
	}
	lli mmul(lli a, lli b) {
	  return ((a % mod) * (b % mod)) % mod;
	}
	lli mpow(lli base, lli exp) {
	  lli res = 1;
	  while (exp) {
		if (exp % 2 == 1){
			res = (res * base) % mod;
		}
		exp >>= 1;
		base = (base * base) % mod;
	  }
	  return res;
	}
	lli minv(lli base) {
	  return mpow(base, mod - 2);
	}
	lli mdiv(lli a, lli b) {
	  return mmul(a, minv(b));
	}
	lli ncr(lli n,lli r){lli ans=1;if(r>n-r)r=n-r;for(lli i=1;i<=r;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
}

using namespace modop;

lli n,k;
lli ans=0;

lli ways(lli i)
{
    lli tot=i-1;
    lli sub=max(0LL,i-n-1);
    return max(0LL,tot-2*sub);
}
void solve()
{
    cin>>n>>k;
    for(lli i=k+2;i<=2*n;i++)
    {
        ans+=ways(i)*ways(i-k);
    }
    cout<<ans<<endl;
}
int main()
{
    solve();
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
    return x * f;
}
int n,K;
int Calc(int x) {
	return min(x-1, 2*n-x+1);
}
signed main()
{
	n = read(), K = read();
	int ans = 0;
	for(int i=2;i<=2*n;++i) {
		if(i-K>=2 && i-K<=2*n) {
			ans += Calc(i)*Calc(i-K);
		}
	}
	printf("%lld\n",ans);
    return 0;
}
/*
2525 -425

10314607400
*/


#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

int V;
ll G[20][3] = {INF}; // グラフ
ll dp[150000][20];

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

    cin >> V;

    rep(i, V) {
        ll x, y, z;
        cin >> x >> y >> z;
        G[i][0] = x;
        G[i][1] = y;
        G[i][2] = z;
    }

    // dp の初期化
    rep(i, 150000) {
        rep(j, 20) { dp[i][j] = INF; }
    }
    dp[0][0] = 0; // スタートを頂点 0 とする
    ll a;

    rep(S, 1 << V) {
        rep(v, V) {
            rep(u, V) {
                if ((S & (1 << v)) == 0) { //Sにvが含まれないなら集合(S U v)を更新　集合への追加操作はS | (1 << v)
                    if (v != u)
                        dp[S | (1 << v)][v] =
                            min(dp[S | (1 << v)][v],
                                dp[S][u] + abs(G[v][0] - G[u][0]) +
                                    abs(G[v][1] - G[u][1]) +
                                    max(0LL, G[v][2] - G[u][2]));
                }
            }
        }
    }

    if (dp[(1 << V) - 1][0] != INF) {
        cout << dp[(1 << V) - 1][0] << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

# include <ciso646>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <map>
# include <queue>

namespace Main {
    namespace Source {
        typedef unsigned int uint;
        typedef long long unsigned int llu;
        template <const uint N>
        class Fenwick_tree {
            uint tree[N + 1];
            static inline const uint lowbit(const uint x) { return x bitand ~x + 1; }
        public:
            Fenwick_tree() { memset(tree, 0, sizeof tree); }
            inline const void add(uint x) { while (x <= N) ++tree[x], x += lowbit(x); }
            inline const uint query(uint x)
            { uint r(0); while (x) r += tree[x], x ^= lowbit(x); return r; }
        };
    }
    using namespace Source;
    enum { N = (const uint)2e5 };
    static uint n;
    static uint a[N + 1], b[N + 1];
    static llu sa, sb;
    static inline const bool mp(const uint a[N + 1], const uint b[N + 1]) {
        static uint t[N + 1], u[N + 1];
        for (register uint i(1); i <= n; ++i) t[i] = a[i], u[i] = b[i];
        std::sort(t + 1, t + n + 1), std::sort(u + 1, u + n + 1);
        for (register uint i(1); i <= n; ++i) if (t[i] not_eq u[i]) return false;
        return true;
    }
    static inline const void match(uint a[N + 1], const uint b[N + 1]) {
        static std::map<uint, uint> m;
        static std::queue<uint> p[N];
        for (register uint i(1); i <= n; ++i) if (not m.count(a[i])) m[a[i]] = m.size();
        for (register uint i(1); i <= n; ++i) p[m[b[i]]].push(i);
        for (register uint i(1); i <= n; ++i)
        { const uint t(m[a[i]]); a[i] = p[t].front(), p[t].pop(); }
    }
    static inline const llu inversion(const uint a[N + 1]) {
        Fenwick_tree<N> t; llu r(0);
        for (register uint i(n); i; --i) r += t.query(a[i] - 1), t.add(a[i]);
        return r;
    }
    static inline const void main() {
        scanf("%u", &n);
        for (register uint i(1); i <= n; ++i) scanf("%u", &a[i]), sa += a[i] += i;
        for (register uint i(1); i <= n; ++i) scanf("%u", &b[i]), sb += b[i] += i;
        if (not mp(a, b)) return (const void)puts("-1");
        match(a, b);
        printf("%llu\n", inversion(a));
    }
}

signed int main() { Main::main(); return 0; }


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}

int main()
{
	lli n,k,m;
	cin>>n>>k>>m;
	lli avg=0;
	for(int i=1;i<n;i++)
	{lli x;
		cin>>x;
		avg+=x;}
	lli ans=n*m-avg;
	if(ans<=0)
		cout<<0;
	else if(ans<=k)
		cout<<ans;
	else
		cout<<-1;

}

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

int main () {
    int n, k, m;
    std::cin >> n >> k >> m;
    std::vector<int> a(n - 1);
    int sum = 0;
    for (int i = 0; i < n - 1; i++)
    {
        std::cin >> a[i];
        sum += a[i];
    }

    bool f = false;
    int ans;
    for (int i = 0; i <= k; i++)
    {
        if((1.0*sum + i) / n >= m) {
            f = true;
            ans = i;
            break;
        }
    }

    if(!f) {
        ans = -1;
    }

    std::cout << ans << std::endl;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

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

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

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll T;

mint tri( ll x ) {
  if( x < 0 )
    return 0;

  return mint(x)*(x+1)/2;
}

int main() {
  std::cin >> T;

  rep( t, T ) {
    ll N, A, B;
    std::cin >> N >> A >> B;

    mint f = tri(N-A-B+1);

    mint X = mint(N-A+1)*(N-B+1)*f;
    mint Y = f*f;

    mint ans = X*4-Y*4;

    std::cout << ans.x << endl;
  }

  return 0;
}

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 998244353;

namespace modexp
{
	const int default_mod = h;

	constexpr long long p (long long x, long long y, int mod = default_mod)
	{
		long long ans = 1;
		while(y)
		{
			if(y & 1)
				(ans *= x) %= mod;
			(x *= x) %= mod;
			y /= 2;
		}
		return ans;
	}

	constexpr long long inv (const long long x, int mod = default_mod)
	{
		return p (x, mod - 2, mod);
	}
}
using modexp::p;
using modexp::inv;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n, k;
	cin >> n >> k;
	vl v(n);
	cin >> v;
	vvl c(k + 1, vl(k + 1));
	c[0][0] = 1;
	rep(i,1,k+1)
	{
		c[i][0] = 1;
		rep(j,1,k+1)
		{
			c[i][j] = (c[i-1][j] + c[i-1][j-1]) % h;
		}
	}
	vl p(k + 1);
	rep(i,0,n)
	{
		ll x = 1;
		rep(j,0,k+1)
		{
			(p[j] += x) %= h;
			(x *= v[i]) %= h;
		}
	}
	ll p2 = 2;
	for(int i = 1; i <= k; i++)
	{
		ll ans = 0;
		rep(j, 0, i + 1)
		{
			(ans += c[i][j] * p[j] % h * p[i - j]) %= h;
		}
		((ans -= p[i] * p2 % h) += h) %= h;
		(ans *= inv(2)) %= h;
		cout << ans << '\n';
		(p2 *= 2) %= h;
	}
}


#include <bits/stdc++.h>
#define setIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979
#define f first
#define s second
#define ar array
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<long long, long long> pll;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
typedef pair<double, double> pdd;
typedef pair<int, string> pis;
int main() { // Ladder: Do 43
    setIO;
    int a, b, c;
    cin>>a>>b>>c;
    if (pow(a,2)+pow(b,2)<pow(c,2)) cout << "Yes\n";
    else cout << "No";
}

#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cstdio>
#include<climits>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
#include<vector>
#include<set>
#include<chrono>
#include<iomanip>
using namespace std;
using namespace tr1;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define ff first
#define nitro_boost ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0);
#define ss second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
///////////////////////////////////////////////////////////////
#define curr_time std::chrono::high_resolution_clock::now()
int main(){
	nitro_boost;
	int a,b,c;
	cin>>a>>b>>c;
	cout<<((a*a+b*b<c*c)?"Yes":"No")<<'\n';
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,m,n) for (int i = (m); i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; --i)
#define RREP(i,m,n) for (int i = (n)-1; i >= (m); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

const int MAX_N = 2e6+10;
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(MAX_N);

int main() {
  int n, m, k; cin >> n >> m >> k;

  if (n < k+1) {
    cout << comb(m+n, m) << endl;
  } else if (n <= m+k) {
    cout << comb(m+n, m) - comb(m+n, m+k+1) << endl;
  } else {
    cout << 0 << endl;
  }
}

#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#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>>
#define INF (1ll << 60)
ll mod = 1000000007;
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 power(ll x, ll p) { ll a = 1; while (p > 0) { if (p & 1)a *= x; x *= x; p >>= 1; }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p & 1)a = a * x % mod;  x = x * x % mod; p >>= 1; }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k + 1) { 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; }
ll modinv(ll a) { ll b = mod, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }u %= mod; if (u < 0) u += mod; return u; }

int main(void) {
	int n, k;
	cin >> n >> k;
	vector<vector<int>> a(n, vector<int>(n));
	int r = 0, l = 0;
	rep(i, 0, n)rep(j, 0, n)cin >> a[i][j], r = max(r, a[i][j]);
	while (r - l > 1) {
		int m = (r - l) / 2 + l;
		vector<vector<int>> s(n + 1, vector<int>(n + 1));
		rep(i, 0, n) {
			rep(j, 0, n) {
				if (a[i][j] > m)s[i + 1][j + 1] = 1;
				s[i + 1][j + 1] += s[i][j + 1] + s[i + 1][j] - s[i][j];
			}
		}
		bool ok = false;
		rep(x, 0, n - k + 1) {
			rep(y, 0, n - k + 1) {
				if (s[x + k][y + k] - s[x][y + k] - s[x + k][y] + s[x][y] < k * k / 2 + 1) {
					ok = true;
					break;
				}
			}
			if (ok)break;
		}
		if (ok)r = m;
		else l = m;
	}
	printf("%d\n", r);
	return 0;
}


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

int main(){
  int N,W,a,b;
  cin >> N >> W >> a >> b;
  vector<vector<char>> data(N, vector<char>(W));
  for (int i=0;i<N;i++){
    for(int j=0;j<W;j++){
      cin >> data[i][j];
    }
  }
  int count =-3;
  for(int i =b-1;i<W;i++){
    if(data[a-1][i]=='.') count++;
    else break;
  }
  for(int i =b-1;i>-1;i--){
    if(data[a-1][i]=='.') count++;
    else break;
  }
  for(int i =a-1;i<N;i++){
    if(data[i][b-1]=='.') count++;
    else break;
  }
  for(int i =a-1;i>-1;i--){
    if(data[i][b-1]=='.') count++;
    else break;
  }

  cout << count <<endl;
}

/*
    I love the sound you make when you shut up.
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
/*-------typedefs------*/
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update> ;
using ll = long long;
using pi = pair<int, int>;
/*-----in and out--------*/
#define pf(a) cout << a << endl
#define forIn(arr, num) for(int i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(int i = 0; i < int(ans.size()); i++) cout << ans[i] << (i + 1 < int(ans.size()) ? ' ' : '\n');
/*---useful defines------*/
#define sz(x) (int)(x).size()
#define pb push_back
#define mem(a, b) memset(a,(b), sizeof(a))
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
/*----- the binary answer of life-----*/
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
/*---checking and pushing-----*/
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
/*---- FAST I/O and file read ---*/
void go() {
    ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
}
/*-------- test-case stuff--------------*/
#define ssolve solve();
#define msolve int T;cin >> T;while(T--) {solve();}
#define mcsolve int T;cin >> T;for(int tt = 1;tt <= T;tt++) {cout << "Case #" << tt << ": ";solve();}
/*-------- movement in a 2D array ------*/
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
/*----------------------------------------------------------------*/
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
/*-------------- Push your limits here ---------------------------*/
ll score(string s) {
    vector<ll> cnt(10);
    iota(all(cnt), 0);
    for(char c : s) cnt[c - '0'] *= 10;
    return accumulate(all(cnt), 0);
}

void solve() {
    ll k;cin >> k;
    string S, T;
    cin >> S >> T;

    vector<ll> cnt(10, k);
    for(char c : S + T) cnt[c - '0']--;
    ll win = 0;
    for(ll x = 1;x < 10;x++) for(ll y = 1;y < 10;y++) {
        S.back() = '0' + x;
        T.back() = '0' + y;
        if(score(S) <= score(T)) continue;
        win += cnt[x] * (cnt[y] - (x == y));
    }

    ll rem = 9 * k - 8;
    double ans = (1.0 * win) / (1.0 * rem * (rem - 1));
    cout << fixed << setprecision(10) << ans << endl;
}

int main() {
    go();
    ssolve
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native")

#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(vector<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(set<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(unordered_set<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 826
#endif
template<typename T> void print(T && x) {cout << x << "\n";}
template<typename T, typename... S> void print(T && x, S&&... y) {cout << x << ' ';print(y...);}

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=200005;

//i_am_noob
//#define wiwihorz
int n,m;
pii a[maxn];
map<int,vector<int>> mm;
set<int> st;

void orzck(){
    cin >> n >> m;
    rep(m){
        int x,y;
        cin >> x >> y;
        mm[x].pb(y);
    }
    st.insert(n);
    for(auto p: mm){
        vector<int> vec=p.second;
        set<int> st1,st2;
        for(auto i: vec){
            if(st.count(i-1)||st.count(i+1)) st1.insert(i);
            else st2.insert(i);
        }
        for(auto i: st1) st.insert(i);
        for(auto i: st2) st.erase(i);
    }
    print(sz(st));
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    #ifdef i_am_noob
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    freopen("output2.txt","w",stderr);
    #endif
    cout << fixed << setprecision(15);
    int t;
    #ifdef wiwihorz
    cin >> t;
    #else
    t=1;
    #endif
    while(t--) orzck();
    return 0;
}

#include<bits/stdc++.h>
#define db double
#define reg register
#define LL long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ull unsigned long long
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define erep(i,a) for(int i=head[a];i;i=e[i].nxt)

using namespace std;
bool Handsome;
inline void Mi(int &x,int y){if(x>y && (x=y));}
inline void Mx(int &x,int y){if(x<y && (x=y));}
const int M=4e5+5;
int n,m,x[M],y[M],c[M],cnt;
vector<int> g[M];
bool vis[M],p[M];
int ID(int x){
	return x-n+m;
}
bool check(int x){
	if(x<0 || x>(m<<1))return 0;
	return 1;
}
bool Most;
int main(){
//	printf("%.2lfMB\n",(&Most-&Handsome)/1024.0/1024.0);
	scanf("%d%d",&n,&m);
	rep(i,1,m)scanf("%d%d",&x[i],&y[i]),c[i]=x[i];
	sort(c+1,c+m+1);cnt=unique(c+1,c+m+1)-c-1;
	rep(i,1,m)g[lb(c+1,c+cnt+1,x[i])-c].pb(y[i]);
	rep(i,1,cnt)sort(g[i].begin(),g[i].end());
	vis[m]=1;
	rep(i,1,cnt){
		rep(j,0,g[i].size()-1){
			int x=ID(g[i][j]);
			if(!check(x))continue;
			if(check(x-1) && vis[x-1])p[x]=1;
			if(check(x+1) && vis[x+1])p[x]=1;
		}
		rep(j,0,g[i].size()-1){
			int x=ID(g[i][j]);
			if(!check(x))continue;
			vis[x]=p[x];p[x]=0;
		}
	}
	int ans=0;
	rep(i,0,m<<1)ans+=vis[i];
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define ls k<<1
#define rs k<<1|1
#define lson k<<1, l, mid
#define rson k<<1|1, mid+1, r
#define lowbit(x) ((x) & (-(x)))
#define ll long long
using namespace std;

struct my_hash {
  static uint64_t splitmix64(uint64_t x) {
    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);
  }

  // 针对 std::pair<int, int> 作为主键类型的哈希函数
  size_t operator()(pair<uint64_t, uint64_t> x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM) ^
           (splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

const ll MOD = 1e9+7;
const int MAX = 3e3+50;
ll a[MAX], sum[MAX], p[MAX][MAX], dp[MAX][MAX];
int n;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        sum[i] = sum[i - 1] + a[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            p[i][j] = sum[j] % i;
        }
    }
    for (int i = 1; i <= n; i++) dp[1][i] = 1;
    for (int i = 2; i <= n; i++) {
        unordered_map<ll, ll, my_hash> mp;
        for (int j = i; j <= n; j++) {
            mp[p[i][j - 1]] = (mp[p[i][j - 1]] + dp[i - 1][j - 1]) % MOD;
            dp[i][j] = mp[p[i][j]];
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) ans = (ans + dp[i][n]) % MOD;
    printf("%lld\n", ans);
    return 0;
}

 #include <bits/stdc++.h>
using namespace std;
using ll = long long;
//素数判定　O√N
bool is_prime(long long x)
{
  assert(0<=x);
  if(x<2)
  {
    return false;
  }
  for(long long i=2;i*i<=x;i++)
  {
    if(x%i==0)
    {
      return false;
    }
  }
  return true;
}
template<class T> void chmin(T& a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T& a,T b){
    if(a<b){
        a=b;
    }
}
//約数列挙
vector<ll> enumeration_divisor(ll n){
  vector<ll> res_divisor;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i==0){
      res_divisor.push_back(i);
      if(i*i!=n){
        res_divisor.push_back(n/i);
      }
    }
  }
  sort(res_divisor.begin(),res_divisor.end());
  return res_divisor;
}
ll mod = 1000000007;
ll n,a[1<<18],p[1<<18],ans=1;
int main(){
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  sort(a+1,a+n+1);
  ll ans=1;
  for(int i=1;i<=n;i++){
    p[i]=a[i]-a[i-1];
  }
  for(int i=1;i<=n+1;i++){
    ans*=(p[i]+1LL);
    ans%=mod;
  }
  cout << ans << endl;
}


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

int main(){
    ll t;cin >> t;
    while(t--){
        string s;cin >> s;
        bool ok=true;
        rep(i,s.size())if(s[i]!='a')ok=false;
        if(ok){cout << -1 <<endl;continue;}
        if(s>"atcoder"){cout << 0 <<endl;continue;}
        if(s[1]!='a'){cout << 1 <<endl;continue;}
        rep(i,s.size()){
            if(s[i]!='a'){
                if(s[i]>'t'){cout << i-1 <<endl;break;}
                else {cout << i <<endl;break;}
            }
        }
    }
}

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
#include <random>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline bool chmin(T &x, const T &y){ if(y < x){ x = y; return true; } return false; }
template <class T> inline bool chmax(T &x, const T &y){ if(x < y){ x = y; return true; } return false; }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif

#if __cplusplus >= 201402L
#define lambda(e) ([&](const auto &_){ return (e); })
#define lambda2(e) ([&](const auto &_a, const auto &_b){ return (e); })
#endif

#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8

multiset<pii> func(const vint &as, const vint &bs, int i, int j){
	multiset<pii> ret;
	int t = as[j] - as[i];
	int u = bs[j] - bs[i];
	int n = as.size();
	REP(k, n){
		int v = as[k] - as[i];
		int w = bs[k] - bs[i];
		pii p(t * v + u * w, t * w - u * v);
		ret.insert(p);
	}
	return ret;
}

int sq(int x){ return x * x; }

void mainmain(){
	int n;
	cin >> n;
	if(n == 1){
		cout << "Yes\n";
		return;
	}
	vint as(n), bs(n), cs(n), ds(n);
	REP(i, n){ cin >> as[i] >> bs[i]; }
	REP(i, n){ cin >> cs[i] >> ds[i]; }
	multiset<pii> m1 = func(as, bs, 0, 1);
	int e = sq(as[1] - as[0]) + sq(bs[1] - bs[0]);
	REP(i, n)
	REP(j, n){
		if(i == j){ continue; }
		if(sq(cs[j] - cs[i]) + sq(ds[j] - ds[i]) != e){ continue; }
		multiset<pii> m2 = func(cs, ds, i, j);
		if(m1 == m2){
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\n";
}

}
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}


#include <bits/stdc++.h>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 128
#define K 16384

char s[N];
int a[N], d[N];
int b[K][N];

bool check(int n, int k)
{
    int q = a[0]/k, r = a[0]%k;
    int pos = r;

    for (int i = 0; i < r; ++i) b[i][0] = q+1;
    for (int i = r; i < k; ++i) b[i][0] = q;
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < k; ++i) b[i][j+1] = b[i][j];
        if (s[j] == '<') {
            /// +1
            for (int i = 0; i < k; ++i) ++b[i][j+1];
            for (int i = 0; i < d[j]-k; ++i) {
                ++b[pos][j+1];
                if (++pos >= k) pos = 0;
            }
        } else {
            /// -1
            for (int i = 0; i < k; ++i) {
                retif(--b[i][j+1] < 0) false;
            }
            for (int i = 0; i < d[j]-k; ++i) {
                if (--pos < 0) pos = k-1;
                retif(--b[pos][j+1] < 0) false;
            }
        }
    }
    return true;
}

int main()
{
    canhazfast();

    int n, lo = 1, hi = K;

    cin >> n >> s;
    for (int i = 0; i <= n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) {
        d[i] = abs(a[i+1]-a[i]);
        hi = min(hi, abs(d[i]));
    }
    while (lo < hi) {
        int m = (lo+hi+1)/2;
        if (check(n, m)) lo = m;
        else hi = m-1;
    }
    check(n, hi);
    cout << hi << '\n';
    for (int i = 0; i < hi; ++i) {
        for (int j = 0; j <= n; ++j) cout << b[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}

#include<bits/stdc++.h>

#define ll long long

using namespace std;

int read()
{
	int a=0,f=1,c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')f=-1;
		c=getchar();
	}
	while(isdigit(c))
	{
		a=a*10+c-'0';
		c=getchar();
	}
	return a*f;
}

const int N=500+10;
const int P=998244353;

int n,m;
char s[N][N];
int f[N*2];

int main()
{
//	freopen("1.in","r",stdin);

	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",s[i]+1);

	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			int c=0;
			if(s[i][j]=='R')c=1;
			else if(s[i][j]=='B')c=2;

			if(c>0)
			{
				if(f[i+j]>0 && f[i+j]!=c)
				{
					puts("0");
					return 0;
				}
				f[i+j]=c;
			}
		}

	int ans=1;
	for(int i=2;i<=n+m;++i)ans=(ans*(f[i]>0 ? 1 : 2))%P;
	printf("%d\n",ans);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<pair<int,string>> data(n);
    for(int i=0;i<n;i++){
        cin>>data.at(i).second>>data.at(i).first;
    }
    sort(data.begin(),data.end());
    cout<<data.at(n-2).second<<endl;
}

#include <bits/stdc++.h>
#define LOCAL

using namespace std;

using ll = long long;
// const int MOD = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

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

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_vector(vector<ll> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

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

inline void solve() {
    int n;
    cin >> n;

    vector<pair<int, string>> a(n);

    REP(i, n) {
        string s;
        int h;

        cin >> s >> h;
        a[i] = make_pair(h, s);
    }

    sort(ALL(a));

    cout << a[n-2].second << endl;

}

int main() {
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        // cout << "Case #" << _ << ": ";
        solve();
    }

    return 0;
}


// Problem: A - kcal
// Contest: AtCoder - AtCoder Beginner Contest 205
// URL: https://atcoder.jp/contests/abc205/tasks/abc205_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());int get_rand(int l, int r){uniform_int_distribution<int> uid(l,r);return uid(rng);}
vector<ll> Fac(1,1);int Last_Index = 0;
ll nCr(ll n,ll r,ll m){if(r>n) return 0;if(n>Last_Index){for(ll i=Last_Index+1;i<=n;++i){Fac.push_back(Fac[i-1]*i);Fac[i]%=m;}Last_Index=n;}return (((Fac[n]*power(Fac[r],m-2,m))%m)*power(Fac[n-r],m-2,m))%m;}ll gcd(ll a, ll b) {return (b ? gcd(b, a % b) : a);}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
int Google_Test;
void solve()
{
	// cout << "Case #" << ++Google_Test << ": ";
	double a,b;
	cin >> a >> b;
	cout << (a*b)/100 << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}

#include <bits/stdc++.h>  // This will work only for g++ compiler.

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())

using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

void solve()
{
    ll arr[3];
    for(ll i=0;i<3;i++)
    {
        cin >> arr[i];
    }
    sort(arr,arr+3);
    cout<<arr[1]+arr[2];
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    // ll t;
    // cin>>t;
    // while(t--)
        solve();
    return 0;

}


#include <bits/stdc++.h>

using namespace std;

vector<vector<long long>> memo(201, vector<long long>(12, -1));

long long C(long long n, long long k) {
	if(memo[n][k] > 0) return memo[n][k];
	if(n == k) return memo[n][k] = 1;
	if(k == 0) return memo[n][k] = 1;
	return memo[n][k] = C(n - 1, k) + C(n - 1, k - 1);
}

int main(void) {
	long long L;
	cin >> L;
	cout << C(L - 1, 11) << '\n';
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 2147483647;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll LLMAX = 9223372036854775805;

ll powpow(ll x, ll n) {
  if (n == 0) return 1;
  ll val = powpow(x, n / 2);
  val *= val;
  if (n % 2 == 1) val *= x;
  return val;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 1;

    for(ll i = 1;i<=11;i++){
        ans *= n-i;
        ans /= i;
    }
    cout << ans << endl;
}


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

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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
   	ll a,b;
   	cin>>a>>b;
	cout<<(a+b)/2<<" "<<(a-b)/2<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!

#include<iostream>

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	printf("%d %d",(x+y)/2,(x-y)/2);
}


#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>

namespace internal {
  __attribute__((const)) constexpr bool is_pow2(int n) { return __builtin_popcount(n) == 1; }
  __attribute__((const)) constexpr int floor_log2(int n) { return std::numeric_limits<int>::digits - __builtin_clz(n); }
  __attribute__((const)) constexpr int ceil_pow2(int n) { return is_pow2(n) ? n : (1 << (floor_log2(n) + 1)); }
}  // namespace internal

template <class ElemType = long long, ElemType id = 0, class operation = std::plus<void>>
class segment_tree {
  int size;
  std::vector<ElemType> data;

  template <class ReturnType>
  ReturnType query(const int node, const int node_L, const int node_R, const int L, const int R) const {
    if (R <= node_L || node_R <= L) return static_cast<ReturnType>(id);
    if (L <= node_L && node_R <= R) return static_cast<ReturnType>(data[node]);
    const int mid = node_L + (node_R - node_L) / 2;
    return operation {}(query<ReturnType>(node * 2, node_L, mid, L, R), query<ReturnType>(node * 2 + 1, mid, node_R, L, R));
  }

  public:
  segment_tree(void) : size() {}
  segment_tree(const int n) : size(internal::ceil_pow2(n)), data(size * 2, id) {}

  ElemType get(const int idx) const {
    return data[idx + size];
  }

  template <class ReturnType = ElemType>
  ReturnType prod(const int L, const int R) const {
    assert(L <= R);
    return query<ReturnType>(1, 0, size, L, R);
  }

  void set(int idx, const ElemType val) {
    idx += size;
    data[idx] = val;
    while (idx > 1) {
      if ((idx & 1) == 0)
        data[idx >> 1] = operation {}(data[idx], data[idx + 1]);
      else
        data[idx >> 1] = operation {}(data[idx - 1], data[idx]);
      idx >>= 1;
    }
  }
};

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++)
    std::cin >> A[i];

  struct op {
    constexpr auto operator()(long long x, long long y) { return std::min(x, y); }
  };

  constexpr int INF        = 1000000000;
  constexpr long long LINF = 1000000000000000000LL;

  segment_tree<long long, LINF, op> S(N + 1);

  for (int i = 0; i <= N; i++)
    S.set(i, i);
  for (int i = 0; i < M; i++) {
    long long tmp = S.get(A[i]);
    S.set(A[i], tmp + INF);
  }

  long long ans = LINF;

  for (int i = 0; i <= N - M; i++) {
    ans = std::min(ans, S.prod(0, N + 1));

    long long tmp = S.get(A[i]);
    S.set(A[i], tmp - INF);

    if (i < N - M) {
      tmp = S.get(A[i + M]);
      S.set(A[i + M], tmp + INF);
    }
  }

  std::cout << ans << '\n';
}

#include<bits/stdc++.h>

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

#define in(x) long long x;cin>>x
#define pb push_back
#define F first
#define S second
#define endl "\n"

#define test() int t;cin>>t;while(t--)
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
#define deb(x) cout<<#x<<" "<<x<<endl;

const long long mod = 1e9 + 7;
const int MAX = INT_MAX;
const long long inf = 1e18 + 5;
const double pi = 3.14159265358979323846;

int dirX[] = {1, -1, 0, 0};
int dirY[] = {0, 0, 1, -1};

using namespace std;
vector<int> adjlist[200001];
pll indexes[200005];
int ind;
map<int, vector<int>> dist;

void dfs(int src, int dis)
{
	ind++;
	indexes[src].F = ind;
	dist[dis].push_back(ind);
	for (auto it : adjlist[src])
	{
		dfs(it, dis + 1);
	}
	indexes[src].S = ind;
}
int func(int s, int e, int d)
{
	auto l = lower_bound(dist[d].begin(), dist[d].end(), s) - dist[d].begin();
	auto r = upper_bound(dist[d].begin(), dist[d].end(), e) - dist[d].begin();
	r--;
	return r - l + 1;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	in(n);
	for (int i = 2; i <= n; i++)
	{
		in(t);
		adjlist[t].pb(i);
	}
	ind = 0;
	dfs(1, 0);
	// for (int i = 1; i <= n; i++)
	// {
	// 	cout << i << "-> ";
	// 	for (auto it : adjlist[i])
	// 		cout << it << " ";
	// 	cout << endl;
	// }
	// cout << endl;
	// for (int i = 1; i <= n; i++)
	// 	cout << i << " -> " << indexes[i].F << " " << indexes[i].S << endl;
	// cout << endl;
	// for (auto it : dist)
	// {
	// 	cout << it.F << "-> ";
	// 	for (auto i : it.S)
	// 		cout << i << " ";
	// 	cout << endl;
	// }
	test()
	{
		in(u); in(d);
		int s = indexes[u].F;
		int e = indexes[u].S;
		// cout << s << " " << e << endl;
		cout << func(s, e, d) << endl;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <array>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <chrono>
#include <valarray>
#include <bitset>
using ll = long long;
using std::cin;
using std::cout;
using std::endl;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
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 int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

bool check(const std::vector<int> &res, ll n)
{
  ll x = 0, y = 0;
  for(const auto &e : res)
  {
    if(e == 1)
      x += 1;
    if(e == 2)
      y += 1;
    if(e == 3)
      x += y;
    if(e == 4)
      y += x;
    // cout << x <<" "<<y << endl;
  }
  return x == n;
}
void solve()
{
  const int N = 84;
  const int MAX = 1e6;
  std::vector<ll> fibo(N);
  fibo[0] = fibo[1] = 1;
  for (int i = 2; i < N; ++i)
  {
    fibo[i] = fibo[i - 1] + fibo[i - 2];
  }
  ll n; cin >> n;
  auto tn = n;
  std::vector<int> cnt(N), res;
  std::vector<int> dp(MAX, inf), back(MAX, -1);
  dp[0] = 0;
  for (int i = 0; i < MAX; ++i)
  {
    for (int j = 0; j < N; ++j)
    {
      if(i + fibo[j] >= MAX)
        break;
      if(chmin(dp[i + fibo[j]], dp[i] + 1 + j))
      {
        back[i + fibo[j]] = j;
      }
    }
  }
  while(n > 0)
  {
    int id = std::upper_bound(fibo.begin(), fibo.end(), n) - fibo.begin();
    id -= 1;
    if(id == 1)
      id = 0;
    // cout <<"id:"<<id<<endl;
    n -= fibo[id];
    cnt[id] += 1;
  }
  while(n > 0)
  {
    int b = back[n];
    n -= fibo[b];
    cnt[b] += 1;
  }
  int turn = -1;
  ll x = 0, y = 0;
  for(int i = N - 1; i >= 0; i--)
  {
    if(cnt[i] > 0)
    {
      if(turn == -1)
      {
        if(i % 2 == 0)
        {
          turn = 0;
        }
        else
        {
          turn = 1;
        }
      }

      for (int j = 0; j < cnt[i]; ++j)
      {
        if(turn == 0)
        {
          res.emplace_back(1);
          x += 1;
        }
        else
        {
          res.emplace_back(2);
          y += 1;
        }
      }
    }
    if(x == tn)
      break;
    if(turn == 0)
    {
      res.emplace_back(4);
      y += x;
      turn ^= 1;
    }
    else if(turn == 1)
    {
      res.emplace_back(3);
      x += y;
      turn ^= 1;
    }
  }
  if(not check(res, tn))
  {
    cout <<"WA"<<" " << x << " " << y << endl;
  }

  cout << res.size() << "\n";

  for (const auto &t : res)
  {
    cout << t << "\n";
  }

}

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

  int kkt = 1;
  // cin >> kkt;
  while(kkt--)
    solve();
  return 0;
}

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define pf              push_front
#define mkp             make_pair
#define mkt             make_tuple
#define pii             pair<int,int>
#define tii             tuple<int,int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rall(v)         v.rbegin(),v.rend()
#define endl            "\n"
using cd = complex<double>;
const double PI = acos(-1);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int maxm(int a, int b)
{
    return (a >= b ? a : b);
}

int minm(int a, int b)
{
    return (a <= b ? a : b);
}

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    if (x == 0)
        return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

#define FMAX 1000010
vector<int> fact(FMAX, 1);
vector<int> fact_inv(FMAX, 1);
vector<int> spf(FMAX);

int nCrmodp(int n, int r, int p)
{
    if (r > n)
        return 0;
    int pro = (fact[n] * fact_inv[r]) % p;
    pro = (pro * fact_inv[n - r]) % p;
    return pro;
}
void precompute()
{
    int x = 1;
    for (int i = 1; i < FMAX; ++i)
    {
        x *= i;
        x %= mod;
        fact[i] = x;
        fact_inv[i] = power(x, mod - 2, mod);
    }
}

void spf_calc()
{
    for (int i = 1; i < FMAX; ++i)
        spf[i] = i;

    for (int i = 2; i * i < FMAX; ++i)
        if (spf[i] == i)
            for (int j = i * i; j < FMAX; j += i)
                if (spf[j] == j)
                    spf[j] = i;
}

int next_smaller(vector<int>v, int val)
{
    int l = 0, r = v.size() - 1, ans = -1;
    while (l <= r)
    {
        int mid = (l + r) / 2;
        if (v[mid] <= val)
        {
            ans = mid;
            l = mid + 1;
        }
        else
            r = mid - 1;
    }
    return ans;
}

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

signed main()
{
    c_p_c();
    map<int, int>mp;
    mp[0] = 0;
    mp[6] = 9;
    mp[9] = 6;
    mp[1] = 1;
    mp[8] = 8;
    string str;
    cin >> str;
    int  n = str.length();
    for (int i = 0; i < n; ++i)
        cout << mp[str[n - 1 - i] - '0'];
    cout << endl;
    return 0;
}


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

int main(){
  long long n;
  cin >> n ;
  int ans1 =0;
  int ans2 =0;
  bool judge = false;

  for(int i=1;i<100;i++){
    for(int j=1;j<50;j++){
      if((powl(3,i)+powl(5,j))==n){
        judge = true ;
        ans1 = i;
        ans2 = j;
        break;
      }
    }
  }

  if(judge) cout << ans1 << ' ' << ans2 << endl;
  else cout << -1 << endl;
}


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

const long long MOD=1e9+7;
const int N=1e5+5;

bool vis[N];
int u,v,c,n,m,r[N];
vector<pair<int,int>> adj[N];

void dfs(int x, int y){
	vis[x]=true;
	for(auto p:adj[x]){
		if(vis[p.first]) continue;
		if(p.second!=y) r[p.first]=p.second;
		else r[p.first]=p.second%n+1;
		dfs(p.first,r[p.first]);
	}
}

int main(){
	/*scanf("%d", &t);
	while(t--){
		scanf("%d", &n);
		for(int i=0;i<n;i++){
			scanf("%d", &a[i]);
		}
	}
	*/
	scanf("%d %d", &n, &m);
	for(int i=0;i<m;i++){
		scanf("%d %d %d", &u, &v, &c);
		adj[u].push_back({v,c});
		adj[v].push_back({u,c});
	}
	r[1]=1;
	dfs(1,1);
	for(int i=1;i<=n;i++) printf("%d\n", r[i]);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
struct Node;
vector<Node> V;
int N;
struct Node {
  int label = -1;
  vector<int> nbr;
  vector<int> edge;
  bool vst = false;
  void dfs() {
    vst = true;
    REP(i, nbr.size()) {
      if(!V[nbr[i]].vst) {
        if(label == edge[i]) V[nbr[i]].label = (edge[i] + 1) % N;
        else V[nbr[i]].label = edge[i];
        V[nbr[i]].dfs();
      }
    }
  };
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int M;
  cin >> N >> M;
  V = vector<Node>(N);
  REP(i, M) {
    int u, v, c;
    cin >> u >> v >> c;
    u--; v--; c--;
    V[u].nbr.push_back(v);
    V[v].nbr.push_back(u);
    V[u].edge.push_back(c);
    V[v].edge.push_back(c);
  }
  V[0].label = 0;
  V[0].dfs();
  REP(i, N) cout << (V[i].label + 1) << "\n";
}


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

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

using namespace std;

ll a[25];
int n;

int main() {
    cin >> n;
    rep(i,n){
    	cin >> a[i];
    }
    ll xormin = 1<<30;
    ll tmpx = 0;
    ll tmpo =0;
    if(n==1){
    	cout << a[0];
    	return 0;
    }
    rep(i,1<<(n-1)){
    	if(i == 0) continue;
        tmpx = 0;
        tmpo =0;
    	rep(j,n+1){
    		if(j == n){
    			tmpo = tmpo|a[j];
    			tmpx = tmpx^tmpo;
    			break;
    		}
    		tmpo = tmpo|a[j];
    		if(i&(1<<j)){
    			tmpx = tmpx^tmpo;
    			//,,cout << tmpo << endl;
    			tmpo = 0;
    		}
    	}
    	//cout << "-----" << tmpx << endl;
    	if(tmpx < xormin) xormin=tmpx;
    }
    cout << xormin;
    return 0;
}

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
#define LL long long
#define M 1005
#define N 5005
#define Mod 1000000007
void read(LL &x){
	x=0;char c=getchar();LL f=1;
	while(c<'0'||c>'9'){
		if(c=='-')
			f=-f;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	x*=f;
}
void print(LL x){
	if(x<10){
		putchar('0'+x);
		return ;
	}
	print(x/10);
	putchar(x%10+'0');
}
void write(LL x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	print(x);
	return ;
}
LL mint(LL a,LL b){
	return a<b?a:b;
}
LL maxt(LL a,LL b){
	return a>b?a:b;
}
char c[4];
LL n,f[M];
LL qkpow(LL a,LL k){
	LL ret=1;
	while(k){
		if(k&1)
			ret=ret*a%Mod;
		a=a*a%Mod;
		k>>=1;
	}
	return ret;
}
int main(){
	read(n);
	f[0]=1;
	f[1]=2;
	for(int i=2;i<=n;i++)
		f[i]=(f[i-1]+f[i-2])%Mod;
	for(int i=0;i<4;i++){
		c[i]=getchar();
		getchar();
	}
	if(n==2){
		write(1);
		return 0;
	}
	if(c[1]=='B'){
		if(c[3]=='B')
			write(1);
		else if(c[2]=='A')
			write(qkpow(2,n-3));
		else
			write(f[n-3]);
	}
	if(c[1]=='A'){
		if(c[0]=='A')
			write(1);
		else if(c[2]=='B')
			write(qkpow(2,n-3));
		else
			write(f[n-3]);
	}
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) cout << c;
  else if(b == c) cout << a;
  else if(c == a) cout << b;
  else cout << 0;
  return 0;
}

#include <bits/stdc++.h>

int main(){
    int V, T, S, D;
    std::cin >> V >> T >> S >> D;

    int begin = V * T;
    int end = V * S;

    if(D >= begin && D <= end){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void){

    long long int N;
    int M,T;

    cin >> N >> M;

    int an,bn;

    int rn[M+1][M+1];

    for (int i=0;i<M+1;i++){
        for (int j=0;j<M+1;j++){
            rn[i][j] = -1;
        }
    }

    if (M!=1){
    an = 1;
    bn = 0;
    }else{
    an = 0;
    bn = 1;
    }

    for (int i=1;i<M*M+10;i++){

    bn = (10*bn+(10*an)/M)%M;
    an = (10*an)%M;

    if (rn[an][bn] == -1){
        rn[an][bn] = i;
    }else{
        T=i-rn[an][bn];
        N = min(N,(N-rn[an][bn])%T+rn[an][bn]);
        break;
    }

    }
    for (int i=0;i<M+1;i++){
        for (int j=0;j<M+1;j++){
        if (rn[i][j] == N){
        cout << j << endl;
        return 0;
        }
        }
    }

}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define pb push_back
#define em emplace_back
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vd vector<double>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define fast  \
  cin.tie(0); \
  ios::sync_with_stdio(false);
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
  fast;
  ll n, m;
  cin >> n >> m;
  ll l = m * m;
  ll cnt = 10, ans = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      ans *= cnt;
      ans %= l;
    }
    cnt = cnt * cnt;
    cnt %= l;
    n /= 2;
  }
  cout << ans / m << endl;
  return 0;
}


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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef vector<bool> VB;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) LL((a).size())

#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ROF(i,a,b) for(LL i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL LARGE_INT = 1e9+100;
const LL INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const LL MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL TIME_LIMIT = 1992;

LL start_time;
string result_string;
LL result_point=0;
LL h=50;
LL w=50;
VVL t;
VVL p;

void check(string result, LL point){
    if(point > result_point){
        result_point = point;
        result_string = result;
    }
}

void dfs(LL x, LL y, VB v, string result, LL point){
    LL time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
    if(time-start_time > TIME_LIMIT){
        check(result, point);
        return;
    }

    v[t[x][y]]=true;

    VL dx={1,-1,0,0};
    VL dy={0,0,1,-1};

    VVL tp;

    REP(i,4){
        LL nx = x+dx[i];
        LL ny = y+dy[i];
        if(nx >= h || nx < 0 || ny >= w || ny < 0){
            continue;
        }
        if(v[t[nx][ny]]){
            continue;
        }
        LL dist = min(nx,h-nx)*min(nx,h-nx) + min(ny,w-ny)*min(ny,w-ny);

        tp.PB({-dist,p[nx][ny],i,nx,ny});
    }

    if(tp.empty()){
        check(result, point);
        return;
    }

    SORT_DESC(tp);

    for(auto w : tp){
        LL np = w[1];
        LL i = w[2];
        LL nx = w[3];
        LL ny = w[4];
        //cerr<<np<<" "<<i<<" "<<nx<<" "<<ny<<endl;
        string d;
        if(i==0){
            d = "D";
        }
        if(i==1){
            d = "U";
        }
        if(i==2){
            d = "R";
        }
        if(i==3){
            d = "L";
        }
        dfs(nx, ny, v, result+d, point+np);
    }
}

void Main()
{
    start_time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
    //dump(start_time)
    LL si,sj;cin>>si>>sj;

    t.resize(h);
    REP(i,h){
        t[i].resize(w);
        REP(j,w){
            cin>>t[i][j];
        }
    }
    p.resize(h);
    REP(i,h){
        p[i].resize(w);
        REP(j,w){
            cin>>p[i][j];
        }
    }

    VB v(h*w);
    string result = "";
    LL point = 0;

    dfs(si, sj, v, result, point);

    cout<<result_string<<endl;

	return;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define sz(x) ((int)(x).size())
#define all(x) x.begin() , x.end()
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define deb(x) cout<<#x<<"="<<x<<endl
#define debs(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll

const int mod = 1000000007;
const int MAX = INT_MAX;
const int MIN = INT_MIN;
const char nl = '\n';
const long long INF = 1e18;

void build(int64_t  *a, int64_t  *seg,int64_t  s,int64_t  e,int64_t  tind){
    if(s==e){ seg[tind] =a[s-1] ; return ;}
    int64_t  mid = (s+e)/2 ;
    build(a,seg,s,mid,2*tind);
    build(a,seg,mid+1,e,2*tind+1);
    seg[tind] = seg[2*tind]^seg[2*tind+1] ;
}
void update(int64_t  *a,int64_t  *seg,int64_t  s,int64_t  e,int64_t  tind,int64_t  ind ,int64_t  val){
    if(s==e){ a[ind-1]= a[ind-1]^val ; seg[tind] = seg[tind]^val ; return ;}
    int64_t  mid = (s+e)/2 ;
    if(ind>mid)update(a,seg,mid+1,e,2*tind+1,ind,val);
    else update(a,seg,s,mid,2*tind,ind,val) ;
    seg[tind] = seg[2*tind] ^ seg[2*tind+1] ;
}
int64_t  query(int64_t  *seg,int64_t  s,int64_t  e,int64_t  tind,int64_t  l,int64_t  r){
    if(s>r || e<l) return 0 ;
    if(s>=l && e<=r)return seg[tind] ;
    int64_t  mid =(s+e)/2 ;
    return query(seg,s,mid,2*tind,l,r) ^ query(seg,mid+1,e,2*tind+1,l,r);
}

void solve(){
    int64_t  n, k ; cin>>n>>k ;
    int64_t  a[n] ;
    for(int i=0;i<n;i++){
        cin>>a[i] ;
    }
    int64_t seg[4*n] ;
    mem(seg,0) ;
    build(a,seg,1,n,1);
    while(k--){
        int64_t  c ; cin>>c ;
        if(c==1){
            int64_t  ind , val ; cin>>ind>>val ;
            update(a,seg,1,n,1,ind,val) ;
        }
        else{
            int64_t  l ,r ; cin>>l>>r ;
            cout<<query(seg,1,n,1,l,r)<<endl;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);cout << fixed;
#ifndef ONLINE_JUDGE
    freopen("F:/input.txt", "r", stdin);
    freopen("F:/output.txt", "w", stdout);
#endif
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
}


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

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

vector<i64> divisor(i64 n) {
  vector<i64> res;
  for (i64 i = 1; i * i <= n; i++) {
    if (n % i != 0) continue;
    res.emplace_back(i);
    if (i * i == n) continue;
    res.emplace_back(n / i);
  }

  return res;
}

void solve() {
  i64 s = input(), p = input();

  auto ds = divisor(p);
  for (auto &d : ds) {
    i64 n = d, m = p / d;
    if (n + m != s) continue;

    cout << "Yes" << endl;
    return;
  }

  cout << "No" << endl;
}

signed main() {
  solve();
}

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

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

// size(x), rbegin(x), rend(x) need C++17
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sor(x) sort(all(x))
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

#define mset(a,b) memset(a, b, sizeof(a))
#define dbg(x) cout << "[" << #x << "]: " << x << endl;
#define forn(i,n) for(int i=0; i < n;i++)
#define nrof(i,n) for(int i = n-1; i >= 0; i--)
#define fori(i,a,b) for(int i = a; i <= b; i++)
#define irof(i,b,a) for(int i = b; i >= a; i--)
#define each(val, v) for(auto &val : v)

using ll = long long;
using db = long double; //pode ser double

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const db EPS = 1e-9;
const db PI = acos((db)-1);

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

	vl a(n);

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

	vl pref(n);

	pref[0] = a[0];
	vl soma(n);

	soma[0] = pref[0];
	forn(i,n){
		if(i == 0) continue;

		pref[i] = pref[i-1] + a[i];
		soma[i] = soma[i-1] + pref[i];
	}

	vl maxx(n);

	maxx[0] = a[0];

	for(int i = 1; i < n; i++){
		maxx[i] = max(maxx[i-1], a[i]);
	}

	forn(i,n){
		ll ans = soma[i] + (i+1)*maxx[i];
		cout << ans << '\n';
	}
}

int main(){

    ios::sync_with_stdio(false); cin.tie(NULL);

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

    return 0;
}

/*
PRESTA ATENCAO!!!!

NAO FIQUE PRESO EM UMA ABORDAGEM
A SUA INTUICAO PODE ESTAR ERRADA - TENTE OUTRAS COISAS
LIMPOU TUDO PARA O PROXIMO CASO?
caso especial? n == 1

*/


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

int main() {
  string S,T;
  cin >> S >>T;
  if(S=="Y"&&T=="a"){
    cout << "A" << endl;
  }else if(S=="Y"&&T=="b"){
    cout << "B" << endl;
  }else if(S=="Y"&&T=="c"){
    cout << "C" << endl;
  }else{
    cout << T << endl;
  }
}

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

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

int main () {
    char s, t;
    cin >> s >> t;
    if(s == 'Y'){
        cout << char(t - 0x20) << endl;
    } else {
        cout << t << endl;
    }
    return 0;
}