#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);cerr<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T> void verr(const set<T> &st) { repa(a, st) cerr << a << " "; cerr << endl; }
template <class S, class T> void verr(const map<S, T> &mp) { repa(a, mp) cerr << "{" << a.first << ", " << a.second << "} "; cerr << endl; }
template <class S, class T, class N> void verr(const vector<pair<S,T>>& a, const N& n) { rep(i, n) cerr << "{" << a[i].first << ", " << a[i].second << "} "; cerr << endl; }
template <class T, class N> void verr(const vector<T>& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << endl; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << endl; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-5;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N;
    cin >> N;
    vc<complex<ld>> S(N), T(N);
    rep(i, N) {
        ld a, b;
        cin >> a >> b;
        S[i] = {a, b};
    }
    rep(i, N) {
        ld a, b;
        cin >> a >> b;
        T[i] = {a, b};
    }

    complex<ld> sc(0, 0), tc(0, 0);
    rep(i, N) sc += S[i], tc += T[i];
    sc /= N, tc /= N;

    rep(i, N){
        S[i] -= sc;
        T[i] -= tc;
    }
    rep(i, N) rep(j, N){
        vc<complex<ld>> ss(N), tt(N);
        rep(si, N) ss[si] = S[si] * polar(1.0L, -arg(S[i]));
        rep(ti, N) tt[ti] = T[ti] * polar(1.0L, -arg(T[j]));

        bool ok = true;
        rep(si, N) {
            bool isok = false;
            rep(ti, N){
                if (abs(ss[si] - tt[ti]) < EPS) isok = true;
            }
            if(!isok){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

//Author: Xzirium
//Time and Date: 17:59:04  11 April 2021

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

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

template <typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template <typename T> using ordered_set1 = tree<T,null_type,greater<T>,rb_tree_tag,tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll b, ll e)
{
    ll r = 1ll;
    for(; e > 0; e /= 2, (b *= b) %= MOD)
        if(e % 2) (r *= b) %= MOD;
    return r;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);

}

//Work

vector<vector<ll>> ADJ;
vector<ll> C;

multiset<ll> curr;
vector<ll> ans;

void dfs(ll u, ll p=-1)
{
    if(curr.count(C[u])==0)
    {
        ans.pb(u);
    }
    curr.insert(C[u]);
    for(auto v:ADJ[u])
    {
        if(v!=p)
        {
            dfs(v,u);
        }
    }
    curr.erase(curr.find(C[u]));
}

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ADJ.resize(N+1);
    C.resize(N+1);
    FORI(i,1,N+1)
    {
        cin>>C[i];
    }
    FORI(i,0,N-1)
    {
        READV(u);
        READV(v);
        ADJ[u].pb(v);
        ADJ[v].pb(u);
    }
    dfs(1);
    sort(ans.begin(),ans.end());
    for(auto v:ans)
    {
        cout<<v<<endl;
    }

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

    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}


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

#define stp(var, init, end) for (auto var = init; var < end; ++var)
#define ll long long

bool comp(pair<int, int> l, pair<int, int> r)
{
    if (l.first < r.first)
        return true;
    else
        return false;
}

int main(void)
{
    int n;
    cin >> n;
    int a, b;
    vector<pair<int, int>> aa(n);
    vector<pair<int, int>> bb(n);
    int abmin = 1000000;
    stp(i, 0, n)
    {
        cin >> a >> b;
        if (a + b < abmin)
            abmin = a + b;
        aa[i] = pair<int, int>{a, i};
        bb[i] = pair<int, int>{b, i};
    }
    sort(aa.begin(), aa.end(), comp);
    sort(bb.begin(), bb.end(), comp);
    if (aa[0].second != bb[0].second)
    {
        cout << min(abmin, max(aa[0].first, bb[0].first));
    }
    else
    {
        int x = min(max(aa[0].first, bb[1].first), max(aa[1].first, bb[0].first));
        cout << min(abmin, x);
    }
    return 0;
}

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <ios>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

using namespace std;

using i64 = int64_t;
using u64 = uint64_t;
using i32 = int32_t;
using pi64 = pair<i64, i64>;

constexpr i64 MAXN = 3*100*1000LL+5LL;
constexpr i64 MOD = 1000000007LL;
constexpr i64 INF64 = MOD * MOD;
#define vec vector
#define let const
#define DRi64(x) i64 x; cin >> x;
#define DRS(x) string x; cin >> x;
#define DRVi64(v, n) vec<i64> v(n); { for (i64 i = 0; i < n; ++i) { cin >> v[i]; }}

#ifdef DEBUG
#define P(x) cerr << x << "\n"
#else
#define P(x)
#endif

i64
gcd(const i64 a, const i64 b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

int
main()
{
    ios_base::sync_with_stdio(false);
    const unsigned seed =
        chrono::system_clock::now().time_since_epoch().count();
    mt19937 gen(seed);

    DRi64(N);
    i64 l = 1;
    for (i64 i = 2; i <= N; ++i)
    {
        l = (l * i) / gcd(l, i);
    }
    cout << l + 1 << "\n";

    return 0;
}


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

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define all(v) v.begin(),v.end()
#define  mat vector<vector<ll>>
#define el cout<<'\n';
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve(){
    char a,b;
    cin>>a>>b;
    if(a=='Y')
    cout<<(char)(b&'_');
    else cout<<b;
    el

}
int main(){
 boost
 ll t=1;
 //cin>>t;

    while(t--){
      solve();
      el
        }
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main(){
    ll n,q;
    cin >> n >> q;
    vector<ll> arr(n);
    for(ll i=0; i<n; i++) cin >> arr[i];
    vector<ll> cnt(n);

    for(ll i=0; i<n; i++){
        cnt[i] = arr[i] - (i+1);
    }
    while(q--){
        ll k;
        ll l = 0;
        ll r = n-1;
        cin >> k;
        if(k > cnt[n-1]){
            cout << arr[n-1] + (k-cnt[n-1]) << "\n";
            continue;
        }
        ll ans = -1;
        while(l <= r){
            ll m = l + (r - l)/2;
            if(cnt[m] >= k){
                ans = m;
                r = m-1;
            }
            else if(cnt[m] < k){
                l = m+1;
            }
        }
        cout << arr[ans]-1 -(cnt[ans]-k) << "\n";
    }

}


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

const int inf = 1e9;
const string target = "atcoder";

int T;
string a;

int calc(int k, char c) {
	for (int i = 0; i + k < a.length(); i++) {
		if (a[i + k] > c) { return i; }
	}
	return inf;
}

int move(int k, char c) {
	for (int i = 0; i + k < a.length(); i++) {
		if (a[i + k] == c) {
			for (int j = 1; j <= i; j++) { a[j + k] = a[j + k - 1]; }
			a[k] = c;
			return i;
		}
	}
	return -1;
}

int main() {
#ifdef local
	freopen("1.in", "r", stdin);
#endif
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> T;
	while (T--) {
		cin >> a;

		int ans = inf;
		int sum = 0;

		if (a > target) {
			cout << 0 << endl;
			goto next;
		}
		for (int i = 0; i < target.length() && i < a.length(); i++) {
			ans = min(ans, sum + calc(i, target[i]));

			int mov = move(i, target[i]);
			if (mov == -1) {
				break;
			} else {
				sum += mov;
			}
		}
		cout << (ans >= inf ? -1 : ans) << endl;

	next:
		continue;
	}

	return 0;
}

#include <cstdio>

int main(){

	int T;
	int L, R;
	long long Ans=0LL;
	scanf("%d", &T);
	while(T--){
		scanf("%d%d", &L, &R);
		if(R-L<L)	puts("0");
		else{
			int Cnt=R-L-L+1;
			Ans=0LL;
			Ans=Cnt*(long long)(R-L+1)-((R*(long long)Cnt)>>1);
			printf("%lld\n", Ans);
		}
	}

	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e3+5;
vector<int>g[N];
bool vis[N];
int cnt = 0;

void dfs(int src)
{
    vis[src] = true;
    cnt++;
    for(auto  i :g[src]) if(!vis[i]) dfs(i);
}

int32_t main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    for(int i = 0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
    }
    int ans = 0;
    for(int i = 1;i<=n;i++)
    {
        dfs(i);
        //cout<<i<<" "<<cnt<<endl;
        ans += cnt;
        cnt = 0;
        memset(vis,0,sizeof(vis));
    }
    cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

vector<vector<int>> G;
bool temp[2010];
void dfs(int v){
    if(temp[v]) return;
    temp[v]=true;
    for(auto vv : G[v]) dfs(vv);
}

int main(){
    int N,M;
    cin>>N>>M;
    G.resize(N);
    rep(i,M){
        int a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
    }

    int ans=0;
    rep(i,N){
        rep(j,N) temp[j]=false;
        dfs(i);
        rep(j,N) if(temp[j]) ans++;
    }

    cout<<ans<<endl;
}


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

using namespace std;

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

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

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

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

const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;

int main(){
  vi A(3);
  rep(i,3) {
    cin >> A[i];
  }
  sort(ALL(A));
  if(A[0] == A[1]) {
    cout << A[2] << endl;
  }
  else if(A[1] == A[2]) {
    cout << A[0] << endl;
  }
  else {
    cout << 0 << endl;
  }
}


#include <algorithm>

#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vii = vector<int>;
using vvii = vector<vector<int>>;
using vvvii = vector<vector<vector<int>>>;
using vdd = vector<double>;
using vvdd = vector<vector<double>>;
using vvvdd = vector<vector<vector<double>>>;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define endl '\n'
#define stpr std::fixed << setprecision
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define cYes cout << "Yes" << endl
#define cNo cout << "No" << endl
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define drep(i, a, b, d) for (ll i = (a); i <= (b); i += d)
#define Rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define drrep(i, a, b, d) for (ll i = (a); i >= (b); i -= d)
#define rRep(i, a, b) for (ll i = a; i >= b; i--)
#define crep(i) for (char i = 'a'; i <= 'z'; ++i)
#define Crep(i) for (char i = 'A'; i <= 'Z'; ++i)
#define ALL(x) (x).begin(), (x).end()
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll MOD = 1000000007;
constexpr ll INF = 1000000011;
constexpr ll MOD2 = 998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS = 10e-10;
template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first;
  is >> p.second;
  return is;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &&x : v) is >> x;
  return is;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = begin(v); i != end(v); ++i) {
    if (i != begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
    string n,n2;
    cin >> n;
    ll l;
    l=n.size();
    if(n=="0"){cYes;}
    else{
        while(n.substr(l-1,1)=="0"){
            n=n.substr(0,l-1);
            l-=1;
        }
        rep(i,l){
            n2=n.substr(i,1) + n2;
        }
        if(n==n2){cYes;}
        else{cNo;}
    }
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  int len=s.length();

  while(1){
    if(s[len-1]=='0'){
      s=s.substr(0,len-1);
      len--;
      continue;
    }
    break;
  }
  //cout<<s<<endl;

  rep(i,len){
    if(s[i]==s[len-1-i]) continue;
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  return 0;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for (ll i = 0; i < (ll)n ;i++)
#define rept(i,k,n) for(ll i = (ll)(k);i < (ll)(n);i++)
#define all(vec) vec.begin(),vec.end()
#define ll int64_t
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << a*d-b*c << endl;
}

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

int t,n,m;
char a,b,c;

inline int qr()
{
	char a=0;int x=0,w=1;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();	}
	while(a<='9'&&a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	cin>>a>>b>>c;
	if(a==b&&b==c)
		cout<<"Won"<<endl;
	else
		cout<<"Lost"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

int main() {
    int n;
	cin >> n;
    cout <<"6 10 15 ";
    int count=3;
    fro(i,16,10001){
      if(count==n)break;
      if(i%6==0||i%10==0||i%15==0){
        cout <<i<<" ";
        count++;
      }
    }
}

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

//#define DEBUG
#ifdef DEBUG
template<typename ...Args>
int debug(const Args &...args){
	return fprintf(stderr,args...);
}
#else
#define debug(...) void()
#endif

typedef unsigned long long ull;
typedef unsigned uint;
typedef long long ll;
#define G getchar()
int read()
{
	int x=0; bool flg=false; char ch=G;
	for (;!isdigit(ch);ch=G) if (ch=='-') flg=true;
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return flg?-x:x;
}
#undef G
#define fi first
#define se second

const int mod=998244353;
inline int upd(const int &x){return x+(x>>31&mod);}
inline void add(int &x,const int &y){x=upd(x+y-mod);}
inline void iadd(int &x,const int &y){x=upd(x-y);}
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1) res=1LL*res*x%mod;
	return res;
}

//typedef pair<int,int> P;
#define rep(i,l,r) for (int i(l),_##i(r);i<=_##i;i++)
#define per(i,l,r) for (int i(r),_##i(l);i>=_##i;i--)
#define all(x) (x).begin(),(x).end()
#define forall(x,y) for (const int &y: e[x])

int n,w[110];
int dp[110][10010];

void solve(){
	n=read(); int S=0;
	rep(i,1,n) w[i]=read(),S+=w[i];
	if (S&1) return puts("0"),void();
	auto F=dp;
	F[0][0]=1;
	rep(_,1,n){
		const int &W=w[_];
		per(i,0,n){
			rep(j,0,n*100){
				if (i<n&&j+W<=n*100);
				else continue;
				add(F[i+1][j+W],F[i][j]);
			}
		}
	}
	static int fac[110];
	fac[0]=1; rep(i,1,n) fac[i]=1LL*fac[i-1]*i%mod;
	int z=0;
	rep(i,0,n) add(z,1LL*F[i][S>>1]*fac[i]%mod*fac[n-i]%mod);
	printf("%d\n",z);
}

int main()
{
	for (int T=1;T--;) solve();
	return 0;
}


//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
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);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

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

struct mint {
  unsigned int x;
  mint():x(0) {}
  mint(int64_t x_) {
    int64_t v = int64_t(x_ % mod);
    if(v < 0) v += mod;
    x = (unsigned int)v;
  }
  static mint row(int v) {
    mint v_;
    v_.x = v;
    return v_;
  }
  mint operator-() const { return mint(-int64_t(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) {
    uint64_t z = x;
    z *= a.x;
    x = (unsigned int)(z % 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;}
  friend bool operator==(const mint &a, const mint &b) {return a.x == b.x;}
  friend bool operator!=(const mint &a, const mint &b) {return a.x != b.x;}
  mint &operator++() {
    x++;
    if(x == mod) x = 0;
    return *this;
  }
  mint &operator--() {
    if(x == 0) x = mod;
    x--;
    return *this;
  }
  mint operator++(int) {
    mint result = *this;
    ++*this;
    return result;
  }
  mint operator--(int) {
    mint result = *this;
    --*this;
    return result;
  }
  mint pow(int64_t t) const {
    mint x_ = *this, r = 1;
    while(t) {
      if(t&1) r *= x_;
      x_ *= x_;
      t >>= 1;
    }
    return r;
  }
  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

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

string to_string(mint a) {
  return to_string(a.x);
}

mint inv[100];

mint c(int n, int k) {
  if(n < k) return 0;
  mint res(1);
  rep(i, k) res *= inv[i+1] * (n-i);
  return res;
}

//head

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  rep(i, 99) {
    inv[i+1] = mint(1)/(i+1);
  }
  int t;
  cin >> t;
  while(t--) {
    int n, a, b;
    cin >> n >> a >> b;
    mint z = c(n-a-b+2, 2);
    mint u = z * (n-a+1) * (n-b+1);
    u *= 4;
    mint v = z * z;
    v *= 4;
    cout << u-v << '\n';
  }
}

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

const int mod = 998244353;
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;
    }
};

int Grid[5002][5002];
static mint DP[5002][5002];

int main() {
#ifdef DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll H, W, K;
    cin >> H >> W >> K;
    for(int i = 0; i <= H; i++){
        fill(Grid[i], Grid[i]+W+1, 'O');
        fill(DP[i], DP[i]+W+1, 0);
    }
    for(int i = 0; i < K; i++){
        int h, w;
        string c;
        cin >> h >> w >> c;
        Grid[h][w] = c[0];
    }

    mint three = 3;
    mint all = three.pow(H*W-K);
    mint three_inv = three.inv();

    int O = 'O';
    int R = 'R';
    int D = 'D';

    DP[1][1] = all;
    for(int p = 0; p < W*H; p++){
        int i = p / W + 1;
        int j = p % W + 1;
        {
            if(Grid[i][j] == O){
                DP[i][j+1] += DP[i][j]*2*three_inv;
                DP[i+1][j] += DP[i][j]*2*three_inv;
            }
            else if(Grid[i][j] == R){
                DP[i][j+1] += DP[i][j];
            }
            else if(Grid[i][j] == D){
                DP[i+1][j] += DP[i][j];
            }else{
                DP[i][j+1] += DP[i][j];
                DP[i+1][j] += DP[i][j];
            }
        }
    }
    cout << DP[H][W].x << endl;
    return 0;
}


// Created by vamsi
#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0
#pragma comment(linker, "/STACK:200000000")
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define mset(mas,val) memset(mas,val,sizeof(mas))
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

#define forn(i,n) for (int i=0; i<int(n); ++i)
#define fornd(i,n) for (int i=int(n)-1; i>=0; --i)
#define forab(i,a,b) for (int i=int(a); i<int(b); ++i)

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

const int INF = (int) 1e9;
const long long INF64 = (long long) 1e18;
long double eps = 1e-6;
const long double pi = 3.14159265358979323846;

const int N = 1e6 + 100;
long long fact[N], modulo = INF + 7;

long long binpow(long long val, long long deg, long long mod) {
    if (!deg) return 1 % mod;
    if (deg & 1) return binpow(val, deg - 1, mod) * val % mod;
    long long res = binpow(val ,deg >> 1, mod);
    return (res*res) % mod;
}
/////////////////////////////////template ends//////////////////////////////////////////
int n;
vector<int> a;

ll ans = 0;

ll countIt(int ind){
	if( ind == 0){
		return 1;
	}
	else{
		ll ans = 0;
		if( a[ind-1] == 2) ans = (1ll<< (ind)) + countIt(ind-1);
		else ans = countIt(ind-1);
		return ans;
	}
}

void solve() {

     cin >> n;
     forn(i,n){
     	string s;
     	cin >> s;
     	if( s == "AND") a.push_back(1);
     	else a.push_back(2);
     }
    cout << countIt(n) << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc = 1;
    //cin >> tc;
    while(tc--) solve();
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef   long double ld;
#define syncboost ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define mp make_pair
#define pb push_back
#define psy push
#define pp pop_back
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vpl vector<pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define precise(n) cout << fixed; cout << setprecision(n)
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define setbit(x) __builtin_popcount(x)
#define run(i, v) for(auto &i: v)
#define hike(i, v) for(const auto &i: v)
#define srt(v) sort(v.begin(),v.end())
#define mem(x,val) memset(x,val,sizeof(x))
#define rep(i,init,n) for(ll i = init;i<n;i++)
#define rrep(i,n,init) for(ll i = n;i>=init;i--)
#define fi first
#define se second
long double pi = 3.14159265;
#define show(x) cerr << x
#define deb1(x) cout<<x<<"\n";
#define deb(x) show(#x << ": " << (x) << endl);
#define debn(x) show((x) <<" ");
#define debv(x) for(auto it : x ) debn(it);deb("\n");
#define det(x) cout<<x<<"\n";
#define No cout<<"No\n";
#define Yes cout<<"Yes\n";
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define sp " "
#define nl cout<<"\n";
#define ps(x,y)   fixed<<setprecision(y)<<x
const ll  mod  = 1000000007;
//const ll  mod  =998244353;
ll power(ll a, ll b, ll m)
{
  if(a == 0) return 0;
  if(b == 0) return 1;
  if(b == 1) return a % m;
  ll temp = power( a , b / 2 , m );
  temp = ( temp * temp ) % m;
  if(b % 2)
    temp = (a * temp) % m;
  return temp;
}
 ll modinv(ll x) {
    return power(x,mod-2,mod);
}

ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

const ll N = 1e15;
#define ll long long
map<int,set<int>> mpp;
ll dp[105][10005];
ll n;

ll go(ll mask , ll id)
{
  if(id>=101)
  {
    if(mask == ((1<<n)-1))
      return dp[id][mask] = 1;
    else
      return dp[id][mask] = 0;

  }

   if(dp[id][mask] !=  -1)
    return dp[id][mask];
  ll  ans = go(mask,id+1) %mod;
  for(int i = 0;i<n;i++)
  {
    if(((mask&(1<<i)) == 0) && mpp[i].find(id) != mpp[i].end())
      {
        ans += go((mask| (1<<i)) ,id+1) %mod;
        ans%= mod;
      }

  }
  return dp[id][mask] = ans;

}
void solve() {
   ll i, n, j, m, k, l, t;
    cin >> n;
    string s[n];
    rep(i,0,n) cin >> s[i];
    k=1;
   rep(i,0,n)
        if(s[i][0]=='O') k += (1LL<<(i+1));

    cout << k;
  return;
 }

signed  main()
{
    ll test = 1;
  //syncboost;
  //cin>> test;
   rep(testcase,1,test+1)
    {
    //   cout<<"Case #"<<testcase<<": ";
       solve();

       //nl
    }
 //cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";

   return 0;
}


#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

string to_string(const string& str) {
  return str;
}

template<typename T>
string to_string(const set<T>& mys) {
  if(mys.empty()) return "{}";
  string ret = "{";
  for(auto el: mys) ret += to_string(el) + ", ";
  ret.pop_back(), ret.pop_back(); // Remove last space and comma
  ret += "}";
  return ret;
}

template<typename T>
string to_string(const pair<T, T>& pr) {
  return "(" + to_string(pr.fi) + "," + to_string(pr.se) + ")";
}

template<typename T>
string to_string(const vector<T>& vc, int w) {
  if(vc.empty()) return "";
  if(w + 1 == vc.size()) return to_string(vc[w]);
  return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
  return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifdef DEBUG
  freopen("input.txt", "r", stdin);
  #endif

  int n;
  cin >> n;
  vector<ll> arr(n);
  for(auto& el: arr) cin >> el;
  map<ll, ll> mp;
  ll zer = 0, ans = 0;
  for(int i = 0; i < n; i++) {
    ll vl = arr[i];
    if(i & 1) vl = -vl;
    mp[zer]++;
    zer -= vl;
    ans += mp[zer];
  }
  cout << ans << '\n';
}

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  int S_count_1 = 0; // Sに含まれる1の個数
  int T_count_1 = 0;
  deque <int> S_1; // 1がある位置 0-indexed
  deque <int> T_1;

  ll ans = 0; // 答えである、回数

  rep(i,N){
    if (S[i] == '1'){
      S_count_1 ++;
      S_1.push_back(i);
    }
    if (T[i] == '1'){
      T_count_1 ++;
      T_1.push_back(i);
    }
  }

  if (S_count_1 < T_count_1 || ((S_count_1 - T_count_1) % 2 != 0) ){
    cout << -1 << endl;
    return 0;
  }

  rep(i,N){
    if (S[i] == T[i]){
      if (S[i] == '1') S_1.pop_front();
      continue;
    }
    else if(S[i] == '0'){
      if (S_1.empty()){
        cout << -1 << endl;
        return 0;
      }
      else{
        ans += S_1.front() - i;
        S[S_1.front()] = '0';
        S[i] = '1';
        S_1.pop_front();
      }
    }
    else if(S[i] == '1'){
      S_1.pop_front();
      if (S_1.empty()){
        cout << -1 << endl;
        return 0;
      }
      else{
        ans += S_1.front() - i;
        S[S_1.front()] = '0';
        S[i] = '0';
        S_1.pop_front(); // 二回popする
      }
    }
    // // デバッグ
    // rep(j,N){
    //   cout << S[j];
    // }
    // cout << endl;
    // cout << ans << endl;
    // rep(j,S_1.size()){
    //   cout << S_1[j] << " ";
    // }
    // cout << endl;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int n, q;
    string s;

    cin >> n >> s >> q;
    string sf = s.substr(0,n);
    string sb = s.substr(n,2*n);
    int flip = 0;
    V t(q);
    V a(q);
    V b(q);
    for (int i = 0; i < q; i++)
    {
        cin >> t[i] >> a[i] >> b[i];
    }

    for (int i = 0; i < q; i++)
    {
        if (t[i] == 2)
        {
            ++flip;
        }
        else
        {
            if (flip%2==0)
            {
                if ((a[i]-1) / n == 1)
                {
                    swap(sb[(a[i]-1)%n], sb[(b[i]-1)%n]);
                }
                else if ((b[i]-1) / n == 1)
                {
                    swap(sf[(a[i]-1)%n], sb[(b[i]-1)%n]);
                }
                else
                {
                    swap(sf[(a[i]-1)%n], sf[(b[i]-1)%n]);
                }
            }
            else
            {
                if ((a[i]-1) / n == 1)
                {
                    swap(sf[(a[i]-1)%n], sf[(b[i]-1)%n]);
                }
                else if ((b[i]-1) / n == 1)
                {
                    swap(sb[(a[i]-1)%n], sf[(b[i]-1)%n]);
                }
                else
                {
                    swap(sb[(a[i]-1)%n], sb[(b[i]-1)%n]);
                }
            }
        }
    }

    string ans;
    if (flip%2==0)
    {
        ans = sf + sb;
    }
    else
    {
        ans = sb + sf;
    }

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
/*-----------------------------------------------------------------------------------------*/
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
/*-----------------------------------------------------------------------------------------*/
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define vout(v) for(auto &x : v){cout << x << " ";}
#define vin(v) for (auto &x : v){cin >> x;}
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
/*-----------------------------------------------------------------------------------------*/
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 2000000000000000000;
/*-----------------------------------------------------------------------------------------*/
void kmax(ll &a, ll b){
    if(b > a)a = b;
}
void kmin(ll &a, ll b){
    if(b < a)a = b;
}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
/*-----------------------------------------------------------------------------------------*/
// const ll N = 3e5 + 5;
// bitset<N> dp;
// void partition(vll &v){
//     ll n = sz(v);
//     fo(i, n){
//         dp |= dp << v[i];
//     }
// }
/*-----------------------------------------------------------------------------------------*/
void solve(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll q;
    cin >> q;
    ll c = 0;
    fo(i, q){
        ll t, a, b;
        cin >> t >> a >> b;
        a--, b--;
        if(t == 1){
            if(c&1){
                swap(s[(n+a)%(2*n)], s[(n+b)%(2*n)]);
            } else {
                swap(s[a], s[b]);
            }
        }
        else{
            c++;
        }
    }
    fo(i, 2*n){
        cout << s[((c&1)*n+i)%(2*n)];
    }

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    fo(TT, TC){
        //cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include <bits/stdc++.h>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll mod = pow(10, 9) + 7;
  ll T;
  cin >> T;
  for (ll testcase = 0; testcase < T; ++testcase) {
    ll N, A, B;
    cin >> N >> A >> B;
    if (A + B > N) {
      cout << 0 << "\n";
      continue;
    }
    if (A < B) {
      swap(A, B);
    }
    ll num_a = (N - A + 1) * (N - A + 1) % mod;
    ll num_b = (N - B + 1) * (N - B + 1) % mod;
    ll ans = num_a * num_b % mod;
    ll rev = ((((B - 1) * (B - 1) % mod) * (2 * A + B - 2 * N - 2) % mod) * (2 * A + B - 2 * N - 2)) % mod;
    rev += ((B - 1) * (A - B + 1) % mod) * ((A - N - 1) * (2 * A + B - 2 * (N + 1)) % mod) * 2 % mod;
    rev %= mod;
    rev = (rev + ((N - A + 1) * (N - A + 1) % mod) * ((A - B + 1) * (A - B + 1) % mod) % mod) % mod;
    ans -= rev;
    if (ans < 0) {
      ans += mod;
    }
    cout << ans << "\n";
  }
}

#include <iostream>

using namespace std;
#define ll long long

const ll mod = 1e9 + 7;
const ll MAX = 2e5 + 1;

ll t;

ll power(ll x, ll p) {
  ll ans = 1;
  while (p) {
    if (p & 1) {
      ans = (ans * x) % mod;
      p--;
    }
    x = (x * x) % mod;
    p >>= 1;
  }
  return ans;
}

ll add(ll x, ll y) { return ((x % mod) + (y % mod)) % mod; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }
ll sub(ll x, ll y) { return ((x % mod) - (y % mod) + mod) % mod; }
ll nC2(ll x) { return mul(mul(x, x - 1), power(2, mod - 2)); }

void Solve() {
  ll n, a, b;
  cin >> n >> a >> b;
  if (a + b > n) {
    cout << 0 << endl;
    return;
  }
  ll tot = mul(mul(4, nC2(n - a - b + 2)), mul(n - a + 1, n - b + 1));
  ll overlap = mul(4, mul(nC2(n - a - b + 2), nC2(n - a - b + 2)));
  ll ans = sub(tot, overlap);
  cout << ans << endl;
}

signed main() {
  cin >> t;
  while (t--) {
    Solve();
  }
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 3*1e5+2;
const int MOD = 998244353;

namespace numb{
	vector<bool> isprime;
	vector<int> fac,rfac,phi;
	vector<vector<int>> prime_factors;
	int add(int a,int b)
	{
	      a+=b;
	      if(a>=MOD) a-=MOD;
	      return a;
	}
	int sub(int a,int b)
	{
	      a-=b;
	      if(a<0) a+=MOD;
	      return a;
	}
	int mul(int a,int b)
	{
	      return ((long long)a*b)%MOD;
	}
	int mpow(int a,int b)
	{
		int res=1;
		while(b>0){
			if(b&1)
				res=mul(res,a);
			a=mul(a,a);
			b=b>>1LL;
		}
		return res;
	}
	int rev(int a)
	{
		return mpow(a,MOD-2);
	}

	void seive(int n)
	{
		isprime.resize(n+2,true);
		isprime[0]=isprime[1]=false;
		for(int i=2;i*i<=n;i++)
		{
			if(isprime[i])
			{
				for(int j=i*i;j<=n;j+=i)
				{
					isprime[j]=false;
				}
			}
		}
	}
	void fact(int n)
	{
		fac.resize(n+2,0LL);
		rfac.resize(n+2,0LL);
		fac[0]=1;
		for(int i=1;i<=n;i++)
		{
			fac[i]=mul(fac[i-1],i);
		}
		rfac[n]=rev(fac[n]);
		for(int i=n-1;i>=0;i--)
		{
			rfac[i]=mul(rfac[i+1],i+1);
		}
	}

	int ncr(int n,int r)
	{
		if(r>n) return 0;
		int ans=mul(fac[n],mul(rfac[r],rfac[n-r]));
		return ans;
	}
	int phii(int n) {
		int result = n;
		for (int i = 2; i * i <= n; i++) {
		   if (n % i == 0) {
		       while (n % i == 0)
		           n /= i;
		       result -= result / i;
		   }
		}
		if (n > 1)
		   result -= result / n;
		return result;
	}
	void pre_phi(int n) {
		phi.resize(n+2,0);
		phi[0] = 0;
		phi[1] = 1;
		for (int i = 2; i <= n; i++)
		   phi[i] = i - 1;

		for (int i = 2; i <= n; i++)
		   for (int j = 2 * i; j <= n; j += i)
		         phi[j] -= phi[i];
	}
	int gcd(int a,int b)
	{
		return b?gcd(b,a%b):a;
	}
	int gcd(int a, int b, int & x, int & y) {
		if (a == 0) {
		   x = 0;
		   y = 1;
		   return b;
		}
		int x1, y1;
		int d = gcd(b % a, a, x1, y1);
		x = y1 - (b / a) * x1;
		y = x1;
		return d;
	}
	bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) {
		g = gcd(abs(a), abs(b), x0, y0);
		if (c % g) {
		   return false;
		}
		x0 *= c / g;
		y0 *= c / g;
		if (a < 0) x0 = -x0;
		if (b < 0) y0 = -y0;
		return true;
	}

}
using namespace numb;

int fa[N];

int nck(int n,int k)
{
	// cout<<n<<" "<<k<<" "<<fa[n]<<"\n";
	// return 0;
	return mul(fa[n],mul(rev(fa[k]),rev(fa[n-k])));
}
int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int n,k;
	cin>>n>>k;
	int a[n];
	fa[0]=1;
	for(int i=1;i<N;i++)
	{
		fa[i] = mul(fa[i-1],i);
	}
	for(int i=0;i<n;i++) cin>>a[i];
	int ans[k+1],ans2[k+1];
	for(int i=0;i<=k;i++){
		int sum=0;
		int sum2 =0 ;
		for(int j=0;j<n;j++)
		{
			sum=add(sum,mpow(a[j],i));
			sum2 = add(sum2,mpow(2*a[j],i));
		}
		ans2[i]=sum2;
		ans[i] = sum;
		// cout<<ans[i]<<" ";
	}
	// return 0;
	int ann =0 ;
	for(int x=1;x<=k;x++)
	{
		int an =0;
		for(int o=0;o<=x;o++)
		{
			// cout<<nck(x,o)<<" "<<ans[o]<<" "<<ans[x-o]<<"\n";
			// cout<<ans[o]<<"\n";
			an=add(an,mul(nck(x,o),mul(ans[o],ans[x-o])));
		}
		an=sub(an,ans2[x]);
		cout<<mul(an,rev(2))<<"\n";
		// ann=add(ann,an);
	}
	// cout<<ann;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
const int p=998244353;
const int maxn=2e5+1;
#define int long long
#define rep(a,b,c) for(int a=b;a<=c;a++)
int n,k,a[maxn],sum[301],fac[301],inv[301],inv2=(1ll*p+1)/2,s[maxn],ans,tmp;
inline int ksm(int a,int b) { int ans=1,tmp=a; for(;b;b>>=1,(tmp*=tmp)%=p) if(b&1) (ans*=tmp)%=p; return ans; }
inline int C(int a,int b) {
	return (((fac[a]*inv[b])%p)*inv[a-b])%p;
}
inline void solve() {
	scanf("%lld %lld",&n,&k);
	rep(i,1,n) scanf("%lld",&a[i]);
	fac[0]=1; inv[0]=1;
	rep(i,1,k) fac[i]=(fac[i-1]*i)%p,inv[i]=ksm(fac[i],p-2);
	rep(x,0,k) {
		if(!x) rep(i,1,n) s[i]=1;
		else rep(i,1,n) (s[i]*=a[i])%=p;
		sum[x]=0;
		rep(i,1,n) (sum[x]+=s[i])%=p;
	}
	rep(x,1,k) {
		ans=0;
		rep(i,0,x) {
			tmp=0; tmp+=(sum[i]*sum[x-i]); tmp%=p; tmp-=sum[x]; (tmp+=p)%=p; (tmp*=inv2)%=p;
			(ans+=(tmp*C(x,i)))%=p;
		}
		printf("%lld\n",ans);
	}
}
signed main() {
	//int TEST; scanf("%d",&TEST); while(TEST--)
	solve();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
    int T; cin >> T;
    while(T--){
        ll N; cin >> N;
        if(N & 1){
            cout << "Odd\n";
        } else{
            if((N / 2) & 1) cout << "Same\n";
            else cout << "Even\n";
        }
    }
}

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

#include <stdio.h>
#include <algorithm>
#include <tuple>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int bits[400001];
void add(int index, int value) {
	for (int i = index; i <= 400000; i += i & -i)
		bits[i] += value;
}
int sum(int index) {
	int res = 0;
	for (int i = index; 0 < i; i -= i & -i)
		res += bits[i];
	return res;
}

int n, a[310000];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i), a[i]++;

	ll t = 0;
	for (int i = 1; i <= n; i++) {
		t += sum(n) - sum(a[i]);
		add(a[i], 1);
	}

	for (int i = 1; i <= n; i++) {
		printf("%lld\n", t);
		t += (n - a[i]);
		t -= (a[i] - 1);
	}
}


#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    ll n;
    cin>> n;
    ll l = 1, r = 1e10;
    // <=
    while(l < r){
        ll mid = (l + r) / 2;
        ll sum = (mid * (mid + 1ll)) / 2ll;
        if(sum <= n + 1)
            l = mid + 1;
        else
            r = mid;
    }
    cout<< n - (l - 1ll) + 1ll<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer

int main()
{
    fast;
    int t = 1;
    // cin>> t;
    while(t--){
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);

/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/

// lower bound   >=
// upper bound   >
// vector<int>().swap(vec); //free memory from vec

// --------------------------------------------------<C++ TEMPLATE>------------------------------------------------
/**
    *  Nitin Gangwar
    *  @wargang (codechef,codeforces,spoj,atcoder)
    *  MNNIT allahabad
    *  CSE'23
    *  iamnitingangwar2000@gmail.com
**/

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

// MACROS
#define int                     long long
#define mp                      make_pair
#define pb                      push_back
#define MAX                     1e17
#define MIN                     -1e17
#define PI                      3.1415926535897932384626433832795
#define mod                     1000000007
#define set(x)                  memset(x, 0, sizeof(x))
#define clr(x)                  memset(x, -1, sizeof(x))
#define ff                      first
#define ss                      second
#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--)
#define sz(x)                   x.size()
#define endl                    "\n"
#define deb(x)                  cout << #x << "=" << x << endl
#define deb2(x, y)              cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x)                  x.begin(), x.end()
#define lb(a,x)                 lower_bound(all(a),x)
#define ub(a,x)                 upper_bound(all(a),x)

typedef priority_queue<int>     maxHeap;
typedef priority_queue<int,     vector<int>, greater<int>> minHeap;
typedef pair<int, int>          pii;
typedef vector<int>             vi;
typedef vector<string>          vs;
typedef vector<pii>             vpii;
typedef vector<vi>              vvi;
typedef map<int, int>            mpii;
typedef set<int>                seti;
typedef multiset<int>           mseti;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
template<typename T, typename T1>T amax(T &a, T1 b) {if (b > a)a = b; return a;}
template<typename T, typename T1>T amin(T &a, T1 b) {if (b < a)a = b; return a;}
// typedef long int                ld;
// typedef unsigned long int       lu;
// typedef long long int           ll;
// typedef unsigned long long int  llu;

// cout << fixed << setprecision(9) <<
int mpow(int base, int exp);

const int T2 = 105; const int T3 = 1005; const int T4 = 10005; const int T5 = 100005;
const int N = 3e5;

int arr[N], brr[N];

void solve() {
    int n;
    cin >> n;
    int sum = 0;
    rep(i, n) cin >> arr[i];
    rep(i, n) cin >> brr[i];
    rep(i, n) sum += arr[i] * brr[i];
    if (sum == 0) cout << "Yes\n";
    else
        cout << "No\n";

}

/* TIPS
1. for interactive prob remove fastio and endl
2. for vector pass as reference
3.

*/

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {

        // cout<<"Case #"<<i<<": ";

        solve();

    }
    return 0;
}

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
    return result;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  if (a == b)
    ans = c;
  if (a == c)
    ans = b;
  if (b == c)
    ans = a;

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

#include <iostream>
#include <string.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
#include <stdio.h>
using namespace std;

#define MOD 1000000007
#define MOD2 998244353
#define TEN5 100005
#define TEN6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
#define FOR(i,start,end) for(int i = (start);i < (end);i++)
#define FORE(i,start,end) for(int i = (start);i <= (end);i++)
#define IFOR(i,start,end) for(int i = (start);i > (end);i--)
#define IFORE(i,start,end) for(int i = (start);i >= (end);i--)

#define _debug 1
#if _debug
#endif // _debug

typedef long long int ll;
typedef unsigned long long int ull;

ll num[TEN5];
vector<pair<ll,ll>> vpll;
//__builtin_popcount()  calculate 1's number in n

int main(void)
{
    ll m,n,o;
    cin>>m>>n>>o;

    if(m==n) cout<<o;
    else if(m==o) cout<<n;
    else if(n==o) cout<<m;
    else cout<<0;

    return 0;
}


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

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
        ret.push_back(i);
        if(i * i != n) ret.push_back(n / i);
    }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

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

    vector<int> c(b + 10, 0);
    for (int i = a; i <= b; i++)
    {
        vector<int64_t> d = divisor(i);
        for (int j = 0; j < d.size(); j++)
        {
            c[d[j]]++;
        }
    }

    for (int i = b; i >= 0; i--)
    {
        if(c[i] >= 2)
        {
            cout << i << endl;
            break;
        }
    }

}

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const ll INF=1e18;
    const int mod=998244353;

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

      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;}
      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];
      }
     } c(200005);

    int main(){
      int n,m;
      cin>>n>>m;
      vector<mint>dp(m+1);
      dp[0]=1;
      for(int i=2;i<=m;i+=2){
        for(int j=0;j*2<=n;j++){
          if(i/2-j<0){continue;}
          dp[i]+=c(n,2*j)*dp[i/2-j];
        }
      }
      cout<<dp[m]<<endl;
      return 0;
    }


#include<iostream>
using namespace std;
int main()
{
	int k;
	int i;
	unsigned long n;

	cin >> n >> k;

	for (i = 1; i <= k; i++) {
		if (n % 200 == 0) {
			n = n / 200;
		}
		else {
			if (i <= k - 2) {
				n = n * (unsigned long)5 + (unsigned long)1;
				i++;
			}
			else {
				n = n * (unsigned long)1000 + (unsigned long)200;
			}
		}
	}

	cout << n << endl;

	return 0;
}

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

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

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

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

signed main(){

    int N, K; cin >> N >> K;
    REP(_, K){
        if(N % 200 == 0) N /= 200;
        else N = N * 1000 + 200;
    }
    Out(N);

    return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
int const MOD=1000000007ll;
int n,a[233333],fp,fs,gp,gs;
signed main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	fs=a[1];gs=1;
	for(int i=2;i<=n;i++){
		int pgs=gs,pgp=gp,pfp=fp,pfs=fs;
		gs=(pgs+pgp)%MOD;
		gp=pgs;
		fs=(pfs+pfp+gs*a[i]%MOD)%MOD;
		fp=(pfs-gp*a[i]%MOD+MOD)%MOD;
	}
	cout<<(fp+fs)%MOD<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,x,n) for(int i = x;i <= n;++i)
#define forr(i,x,n) for(int i = n;i >= x;--i)
#define Angel_Dust ios::sync_with_stdio(0);cin.tie(0)

const int N = 1e5+7,MOD = 1e9+7;
int a[N],f[N][2],c[N][2];

int main()
{
    int n;scanf("%d",&n);
    forn(i,1,n) scanf("%d",&a[i]);
    f[1][0] = a[1];
    c[2][0] = 1;c[2][1] = 1;
    forn(i,3,n) c[i][0] = (c[i - 1][0] + c[i - 1][1]) % MOD,c[i][1] = c[i - 1][0];
    forn(i,2,n)
    {
        f[i][0] = (1ll * f[i - 1][0] + f[i - 1][1] + 1ll * c[i][0] * a[i] % MOD) % MOD;
        f[i][1] = ((f[i - 1][0] - 1ll * c[i][1] * a[i] % MOD) % MOD + MOD) % MOD;
    }
    printf("%d\n",((f[n][0] + f[n][1]) % MOD + MOD) % MOD);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define ull unsigned long long
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i,k,j) for(int i=(k);i>=(j);i--)
#define For(i,k,j) for(int i=(k);i<=(j);i++)
#define Foe(i,u) for(int i=lst[u],v=e[i].v;i;i=e[i].nxt,v=e[i].v)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Fin(s) freopen(s,"r",stdin)
#define Fout(s) freopen(s,"w",stdout)
#define file(s) Fin(s".in"),Fout(s".out")
#define INF ((1<<30)-1)
#define int long long
const int P=1e9+7; //
using namespace std;
template<typename T>inline void ckmax(T &a,T b) {(a<b)&&(a=b);}
template<typename T>inline void ckmin(T &a,T b) {(a>b)&&(a=b);}
inline int mul(int a,int b) {return 1ull*a*b%P;}
inline int add(int a,int b) {return a+b>=P?a+b-P:a+b;}
inline int sub(int a,int b) {return a-b>=0?a-b:a-b+P;}
inline void mulmod(int &a,int b) {a=mul(a, b);}
inline void addmod(int &a,int b) {((a+=b)>=P)&&(a-=P);}
inline void submod(int &a,int b) {((a-=b)<0)&&(a+=P);}
inline int ksm(int a,int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline void fprint(const int &x,char c=' ') {fprintf(stderr,"%d%c",x,c);}
inline void fprint(const pii &x,char c='\n') {fprintf(stderr,"%d %d%c",x.first,x.second,c);}
inline void fprint(const int *f,const int &n,char c='\n') {for(int i=1;i<=n;i++) fprint(f[i]); fprintf(stderr,"%c",c);}
inline void fprint(const vector<int> &f,char c='\n') {for(int i=0;i<(int)f.size();i++) fprint(f[i]); fprintf(stderr,"%c",c);}
inline int inv(int a) {return ksm(a,P-2);}
namespace FastIO {
  const int SIZE=1<<16; char buf[SIZE],obuf[SIZE],str[64]; int bi=SIZE,bn=SIZE,opt;
  int read(char *s) {
    while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
    int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
  }
  bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
  void write(int x) {
    if(!x) obuf[opt++]='0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
    if (opt>=(SIZE>>1)){fwrite(obuf,1,opt,stdout); opt=0;}
  }
  void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf,1,opt,stdout); opt=0;}}
	void Fflush() {if (opt) fwrite(obuf,1,opt,stdout); opt=0;}
};
inline int read() {int x; FI(x); return x;}
const int MN=5e5+5;
int n,a[MN],sum[MN];
signed main() {
	#ifndef ONLINE_JUDGE
		freopen("pro.in","r",stdin);
		freopen("pro.out","w",stdout);
	#endif
	n=read();
	For(i,1,n) a[i]=read();
	sort(a+1,a+1+n);
	sum[n+1]=0; For(i,1,n) sum[i]=a[i]+sum[i-1];
	int ans=1e18;
	For(i,1,n) {
		int now=(sum[n]-sum[i]-(n-i)*a[i])*2+n*a[i];
//		cerr<<i<<' '<<now<<endl;
		if(ans>now) ans=now;
	}
	printf("%.10lf\n",0.5*ans/n);
	return FastIO::Fflush(),0;
}

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

#define rep2(i,k,n) for(i64 i=(i64)(k);i<(i64)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) begin(x),end(x)
#ifdef ENV_LOCAL
#define dump if (1) cerr
#else
#define dump if (0) cerr
#endif

using namespace std;
using namespace std::string_literals;

using i32 = int32_t;
using i64 = int64_t;
using f64 = double;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;

//using namespace harudake;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n;
  cin>>n;
  vi64 a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  i64 sum = 0;
  i64 h = (n+1)/2;
  i64 x2 = a[h-1];
  rep2(i,h,n) {
    sum += a[i] - x2;
  }
  double ans = x2 / 2.0;
  ans += sum / double(n);
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}


#include <iostream>
using namespace std;

int main()
{
  float V, T, S, D;
  scanf("%f %f %f %f", &V, &T, &S, &D);
  float s = D / V;
  if ((T <= s) & (s <= S)) {
    printf("No");
  }
  else {
    printf("Yes");
  }
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
      int n;
      cin>>n;
      if(n%2) cout<<"Black";
      else cout<<"White";
    }
}


#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // University of Warsaw
using LL = long long;
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
#define ssize(x) int((x).size())
template<class A, class B> auto& operator<<(ostream &o, pair<A, B> p) {
	return o << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &o, T x) -> decltype(x.end(), o) {
	o << '{'; int i = 0; for(auto e : x) o << (", ")+2*!i++ << e; return o << '}';
}
#ifdef DEBUG
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#else
#define debug(...) {}
#endif

int main() {
	cin.tie(0)->sync_with_stdio(0);

	int n;
	string s;
	cin >> n >> s;
	vector<int> a(n + 1);
	for(int &ai : a)
		cin >> ai;

	auto good = [&](int i, int vali, int valip1) {
		if(s[i] == '<')
			return vali < valip1;
		else
			return vali > valip1;
	};

	auto get_b = [&](int k) {
		vector<vector<int>> b;
		REP(j, k) {
			vector<int> row;
			REP(i, n + 1) {
				row.emplace_back(a[i] / k + bool((a[i] % k) > j));
				if(i > 0 and not good(i - 1, row[i - 1], row[i]))
					return vector<vector<int>>();
			}
			b.emplace_back(row);
		}
		REP(j, k)
			debug(k, b[j]);
		return b;
	};

	int mx = *max_element(a.begin(), a.end());
	for(int j = mx; j >= 1; --j) {
		auto b = get_b(j);
		if(ssize(b) == 0)
			continue;
		cout << j << '\n';
#ifndef DEBUG
		for(auto &v : b) {
			for(int vi : v)
				cout << vi << ' ';
			cout << '\n';
		}
#endif
		return 0;
	}
}

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

int main(){
  int N;cin>>N;
  string S;cin>>S;S+="<<";
  vector<int> a(N+1); rep(i,N+1) cin >> a[i];
  int k=10010;
  rep(i,N) k=min(abs(a[i]-a[i+1]),k);
  cout << k << endl;
  rep(j,k){
    vi b(N+1);
    rep(i,N+1){
      b[i]=(a[i]+j)/k;
    }
    rep(i,N+1){
      cout << b[i];
      if(i<N+1-1) cout << ' ';
      else cout << endl;
    }
  }
  return 0;
}


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

const ll SEG_LEN = (1 << 20);

ll seg[SEG_LEN * 2];

void update(ll ind, ll val){
    ind += SEG_LEN;
    bitset<30> VAL(val);
    bitset<30> leaf(seg[ind]);
    auto nleaf = VAL ^ leaf;
    seg[ind] = nleaf.to_ullong();
    while (1){
        //cout << seg[ind] << " ";
        ind /= 2;
        if (ind == 0) break;
        bitset<30> r(seg[ind * 2]);
        bitset<30> l(seg[ind * 2 + 1]);
        auto cur = r ^ l;
        seg[ind] = cur.to_ullong();
    }
    // cout << endl;
}

ll XOR(int ql, int qr, int sl = 0, int sr = 1 << 20, int pos = 1){
    //被らない
    if (qr <= sl || sr <= ql) return 0;
    //完全に包まれる
    if (ql <= sl && sr <= qr) return seg[pos];
    //部分的に被る
    int sm = (sl + sr) / 2;
    ll left = XOR(ql, qr, sl, sm, pos * 2);
    ll right = XOR(ql, qr, sm, sr, pos * 2 + 1);
    bitset<30> L(left);
    bitset<30> R(right);
    auto x = L ^ R;
    return x.to_ullong();
}

int main(){
    int n, q;
    cin >> n >> q;
    rep(i,n) {
        ll ai;
        cin >> ai;
        update(i, ai);
    }

    // for (auto ele : seg){
    //     cout << ele << endl;
    // }

    rep(i,q){
        int ti, xi, yi;
        cin >> ti >> xi >> yi;
        if (ti == 1) update(xi-1, yi);
        if (ti == 2) {
            ll ans = XOR(xi-1, yi);
            cout << ans << endl;
        }
    }

    // for (auto ele : seg){
    //     cout << ele << endl;
    // }
}

#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
struct SegTree {
    int N;
    vector<int> A;
    SegTree(int n) {
        N = 1;
        while (N < n) N *= 2;
        A.resize(2 * N);
    }
    void add(int idx, int val) {
        idx += N;
        A[idx] ^= val;
        idx >>= 1;
        while (idx > 0) {
            A[idx] = A[2*idx+0] ^ A[2*idx+1];
            idx >>= 1;
        }
    }
    int get(int L, int R) {
        int ans = 0;
        L += N, R += N;
        while (L < R) {
            if (L & 1) ans ^= A[L++];
            if (R & 1) ans ^= A[--R];
            L >>= 1;
            R >>= 1;
        }
        return ans;
    }
};
int main() {
    int N, Q; cin >> N >> Q;
    vector<int> A(N); for (auto &a : A) cin >> a;
    SegTree st(N);
    for (int i = 0; i < N; i++) {
        st.add(i, A[i]);
    }
    for (int i = 0; i < Q; i++) {
        int T, X, Y; cin >> T >> X >> Y;
        if (T == 1) {
            st.add(X - 1, Y);
        } else {
            cout << st.get(X - 1, Y) << '\n';
        }
    }
    return 0;
}


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

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

const int IM = 2e9;
int dat[400004];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

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

	int N = getint();
	dat[0] = -IM;
	ll kotae = -IM * ll(N);
	for (int i = N + 1; i > 1; i--) {
		dat[i] = getint();
		kotae += dat[i];
	}

	for (int i = 2; i < N + 2; i++) {

		int p = 2 + (dat[2] > dat[3]);
		int v = dat[i] - IM;
		while (v > dat[p]) {
			dat[p >> 1] = dat[p];
			p <<= 1;
			p += dat[p] > dat[p + 1];
		}
		dat[p >> 1] = v;

		int a = getint();
		kotae += a;
		p = i;
		v = a - IM;
		while (v < dat[p >> 1]) dat[p] = dat[p >> 1], p >>= 1;
		dat[p] = v;

		kotae -= dat[1];
	}

	co(kotae);

	Would you please return 0;
}

#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 rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,1,0,-1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}

int main(){
  ll n;cin >> n;
  vl a(n),b(n);rep(i,n)cin >> a[i];rep(i,n)cin >> b[i];rev(all(a));
  priority_queue<ll,vl,greater<ll>> que;
  ll sum=accumulate(all(a),0LL)+accumulate(all(b),0LL);
  ll ans=0;
  rep(i,n){
    que.push(a[i]);que.push(b[i]);
    ans+=que.top();que.pop();
  }
  cout << sum-ans <<endl;
}


#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <bits/stdc++.h>
using namespace std;
using p = pair<int,int>;

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int32_t N;
  cin >> N;
  int64_t X = (1 << N);
  N = X/2;
  vector<p> A(N);
  vector<p> B(N);
  for (int i=0; i < N; i++) {
    cin >> A[i].first;
    A[i].second = i+1;
  }
  for (int i=0; i < N; i++) {
    cin >> B[i].first;
    B[i].second = i+N+1;
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  int res = 0;
  if (A[N-1].first < B[N-1].first) {
    res = A[N-1].second;
  } else {
    res = B[N-1].second;
  }
  cout << res << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define endl "\n"
#define int long long int
int number=1,number1;
void solve()
{
	vector<pair<int,int>> vec;
int n;
cin>>n;

for(int i=1;i<=pow(2,n);i++)
{
	cin>>number;
	vec.push_back({number,i});
}

while(vec.size()>2)
{
vector<pair<int,int>> vec1;

for(int i=0;i<vec.size()-1;i=i+2)
{
if(vec[i].first>vec[i+1].first)
{
vec1.push_back(vec[i]);
}
else
{
vec1.push_back(vec[i+1]);
}
}

vec=vec1;

}

if(vec[0].first<vec[1].first)cout<<vec[0].second<<endl;
else cout<<vec[1].second<<endl;

vec.clear();

}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("Input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("Output.txt", "w", stdout);
#endif
	int t=1;
	//cin >> t;
	while (t > 0)
	{
      solve();
		--t;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main(){
  int N; cin >> N;
  ll K; cin >> K;
  vector<pair<ll,ll>> A(N);
  rep(i,N) cin >> A[i].first >> A[i].second;
  sort(A.begin(),A.end());
  for(auto a : A){
    if(K < a.first) break;
    K += a.second;
  }
  cout << K << "\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_instance;

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
map<int,int>m;
int a[200005],b[200005];
set<int>s;
signed main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld",&a[i],&b[i]);
		m[a[i]]+=b[i];
		s.insert(a[i]);
	}

	set<int>::iterator it=s.begin();
	int t=0;
	while(k)
	{
		if(it==s.end())
		{
			t+=k;
			break;
		}
		k-=(*it-t);
		if(k>=0)
		{
			k+=m[*it];
			t=*it;
			it++;

		}
		else
		{
			k+=(*it-t);
			t+=k;
			break;
		}
	}
	printf("%lld\n",t);

	return 0;
}


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

const int inf = 1e8;
const ll llinf = 1e18;
const double PI = acos(-1);
#define yes "Yes"
#define no "No"
#define all(n) n.begin(), n.end()

using Graph = vector<vector<int>>;
vector<int> visited(false);
ll ans = 0;

void dfs(const Graph &G, int v) {
  visited[v] = true;
  for (auto next : G[v]) {
    if (visited[next]) continue;
    ans++;
    dfs(G, next);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
  }

  rep(i, n) {
    visited.assign(n, 0);
    dfs(g, i);
  }

  cout << ans + n << endl;
  // cout << fixed << setprecision(9) << ans << endl;
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef struct edge{
	int to;
	int cost;
}Edge;
typedef pair<int,int> P;

long long INF=250000010;
int V;
vector<Edge> G[1000000];
long long d[1000000];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
	fill(d,d+V,INF);
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(unsigned int i=0;i<G[v].size();i++){
		  Edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
			  d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

int main(){
  int R,C;
  cin>>R>>C;
  V=R*C*2;
  vector<vector<int>> A,B;
  for(int i=0;i<R;i++){
    vector<int>tmp(C-1);
    for(int j=0;j<C-1;j++)cin>>tmp.at(j);
    A.push_back(tmp);
  }
  for(int i=0;i<R-1;i++){
    vector<int>tmp(C);
    for(int j=0;j<C;j++)cin>>tmp.at(j);
    B.push_back(tmp);
  }
  int q=R*C;
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      if(j<C-1){
        G[C*i+j].push_back({C*i+j+1,A.at(i).at(j)});
      }
      if(j>0){
        G[C*i+j].push_back({C*i+j-1,A.at(i).at(j-1)});
      }
      if(i<R-1){
        G[C*i+j].push_back({C*(i+1)+j,B.at(i).at(j)});
      }
      G[C*i+j].push_back({q+C*i+j,1});
      G[q+C*i+j].push_back({C*i+j,0});
      if(i>0){
        G[q+C*i+j].push_back({q+C*(i-1)+j,1});
      }
    }
  }
  dijkstra(0);
  printf("%d\n",d[R*C-1]);
  return 0;
}


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

#define debug(args...) (Debugger()), args
class Debugger {
   public:
    Debugger(const std::string &_separator = " => ") : first(true), separator(_separator) {}

    template <typename ObjectType>
    Debugger &operator,(const ObjectType &v) {
        if (!first)
            cerr << separator;
        cerr << v;
        first = false;
        return *this;
    }
    ~Debugger() {
        cerr << endl;
    }

   private:
    bool first;
    string separator;
};
#define debug_var(x) debug(#x, x)

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

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

#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(container) container.begin(), container.end()
#define rall(container) container.rbegin(), container.rend()
#define forin(it, container) for (auto it = container.begin(); it != container.end(); it++)
#define rforin(it, container) for (auto it = container.rbegin(); it != container.rend(); it++)

typedef long l;
typedef long long ll;
typedef pair<int, int> ipi;
typedef pair<ll, ll> lpl;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

#define MOD 1'000'000'007

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

ll xpow(ll a, ll b, ll m) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * a) % m;
        }
        a = (a * a) % m;
        b /= 2;
    }
    return res;
}

ll xmul(ll a, ll b, ll m) {
    ll res = 0;
    ll v = 1, k;
    while (b > 0) {
        if (b & 1) {
            k = (a * v) % m;
            res = (res + k) % m;
        }
        v = (v * 2) % m;
        b /= 2;
    }
    return res;
}

int main() {
    int n;
    ll ans = LONG_LONG_MAX;
    ll a, p, x;
    cin >> n;
    rep(i, 0, n) {
        cin >> a >> p >> x;
        if (x > a) {
            chmin(ans, p);
        }
    }
    cout << (ans == LONG_LONG_MAX ? -1 : ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rrep(i,a,b) for(ll i=a;i>=b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll INF = 1e18+10;
const ll mod = 1e9 + 7;
const ll MAXN = 6e6+100;

ll poww(ll a, ll b) {
    if(b<0) return 0LL;
    ll ans = 1;
    while (b) {
        if (b & 1)ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
ll binpow(ll a, ll b)
{
    if (b < 0) return 0LL;
    if (a <= 0)return 0LL;
    a %= mod;

    ll ans = 1LL;
    while (b) {
        if (b & 1)ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll modinv(ll n) {
    return binpow(n, mod - 2);
}

const ll A = 30;
ll dp[A+10][A+10];

ll recur(ll a, ll b) {
    if(dp[a][b]!=-1) return dp[a][b];
    dp[a][b] = recur(a-1,b) + recur(a,b-1);
    return dp[a][b];
}

void solve() {
    ll a,b,k; cin>>a>>b>>k;

    FOR(i,A+1) {
        FOR(j,A+1) dp[i][j] = -1;
    }
    dp[0][0] = 1;
    for(ll i=0; i<=A; i++) dp[i][0] = 1;
    for(ll i=0; i<=A; i++) dp[0][i] = 1;
    recur(A,A);

    ll rem = k, ua = a, ub = b;
    string s = "";
    while(rem>0) {
        for(ll i=ua; i>=0; i--) {
            if(dp[i][ub]<rem) {
                rem -= dp[i][ub];
                FOR(j,ua-i-1) s += 'a';
                s += 'b';
                ua = i+1; ub--;
                break;
            }
            else if(dp[i][ub]==rem) {
                FOR(j,ua-i) s += 'a';
                FOR(j,ub) s += 'b';
                FOR(j,i) s += 'a';
                rem = 0;
                break;
            }
        }
    }
    cout<<s;
}

int main() {
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    //ll no_of_test_cases; cin>>no_of_test_cases;
    ll no_of_test_cases = 1;
    //cout<<fixed<<setprecision(10);
    for(ll i=1; i<=no_of_test_cases; i++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(), v.end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
void YES(bool t = 1) { cout << YESNO[t] << endl; }
void Yes(bool t = 1) { cout << YesNo[t] << endl; }
void yes(bool t = 1) { cout << yesno[t] << endl; }

const int mxN = 2e5 + 5;
int n,m;
int a[mxN],b[mxN];
string s;

void code()
{

   cin>>n;

      /*
         1  2
         o  o nope
         e  e tick
         e  o if(hun>1 && hun%2==0)
         o  e nope
      */

}

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

 string s; cin>>s;

 for(int i=0;i<s.length();i++){
    if(s[i]=='.'){
       return 0;
    }
    cout<<s[i];
 }

}

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// Policy based data structure
// template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i,st,en) for(ll i=st;i<en;i++)
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdout);
#define gin(x) cerr<<#x<<" : "<<x<<" ";
#define fin cerr<<endl;
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 200009
#define PI 3.14159265358979323846
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}

void solve(){
	string x;
	cin>>x;

	string ans;

	for(int i=0; i<x.length(); i++) {
		if(x[i] == '.')
			break;
		ans += x[i];
	}

	cout<<ans;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	clock_t t1=clock();
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
	cerr<<"Time elapsed: "<<(double)(clock()-t1)/1000<<" s"<<endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+50;
const int mod=1e9+7;
char s[N];
int k;
int dig[N];
// 低i位满足有k个不同数位的数字个数
ll dp[N][22];
void print(int x){
    if(x){
        print(x/2);
    }
    printf("%d",x%2);
}
ll dfs(int idx,int sta,int dif,bool lead,bool limit){
    if(idx==-1){
        // 一个合法数字(这题要排除含前导零的数)，有时候要单独考虑0的情况
        // 其实我觉得前导零的命名有点误导性，其实lead为true就是表示现在搜索的前缀是一串0
        if(dif==k && !lead){
            return 1;
        }else{
            return 0;
        }
    }
    // 记忆化的都是无上限的
    if(!limit && dp[idx][dif]!=-1){
        return dp[idx][dif];
    }
    // 这一位的枚举上限
    int up=limit?dig[idx]:15;
    ll ans=0;
    for(int i=0;i<=up;i++){
        if(lead && i==0 || (sta>>i)&1){
            ans+=dfs(idx-1,sta,dif,lead && i==0,limit && i==up);
        }else{
            ans+=dfs(idx-1,sta|(1<<i),dif+1,lead && i==0,limit && i==up);
        }
        ans%=mod;
    }
    if(!limit){
        dp[idx][dif]=ans%mod;
    }
    return ans%mod;
}
int main(){
    scanf("%s %d",s,&k);
    int n=strlen(s);
    for(int i=n-1;i>=0;i--){
        if(s[i]>='A'){
            dig[n-1-i]=s[i]-'A'+10;
        }else{
            dig[n-1-i]=s[i]-'0';
        }
    }
    memset(dp,-1,sizeof(dp));
    // 从高位搜索下去
    ll ans=dfs(n-1,0,0,true,true);
    printf("%lld\n",ans%mod);
    return 0;
}


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

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

const int MAXN = 1000;

int n;
int e[MAXN][2];

int d[MAXN];
int q[MAXN], qhead, qtail;

void solve() {
	REP(i, n) REP(j, 2) e[i][j] = (2 * i + j) % n;
	int cur = 0;
	REP(s, n) {
		REP(i, n) d[i] = INT_MAX;
		qhead = qtail = 0;
		d[s] = 0, q[qhead++] = s;
		while (qtail < qhead) {
			int at = q[qtail++];
			REP(j, 2) { int to = e[at][j]; if (d[to] == INT_MAX) d[to] = d[at] + 1, q[qhead++] = to; }
		}
		REP(i, n) cur = max(cur, d[i]);
	}
	assert(cur <= 10);
	//if (cur != INT_MAX) printf("%d\n", cur);
}

void run() {
	scanf("%d", &n);
	solve();
	REP(i, n) printf("%d %d\n", e[i][0] + 1, e[i][1] + 1);
}

void stress() {
	for (n = 1; n <= MAXN; ++n) { printf("solving %d\n", n); solve(); }
}

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) begin(v), end(v)
#define sz(v) v.size()
#define INF 1e18+9
#define EPSILON 1e-14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> pawn(M);
    rep(i, M){
        cin >> pawn.at(i).first >> pawn.at(i).second;
    }
    sort(all(pawn));
    set<ll> movable;
    movable.insert(N);
    ll row = 0;
    rep(i, M){
        set<ll> A, B;
        row = pawn.at(i).first;
        while(i < M && row == pawn.at(i).first){
            if(movable.count(pawn.at(i).second-1) || movable.count(pawn.at(i).second+1)){
                A.insert(pawn.at(i).second);
            }
            if(movable.count(pawn.at(i).second)){
                B.insert(pawn.at(i).second);
            }
            i++;
        }
        i--;
        for(ll x : B){
            movable.erase(x);
        }
        for(ll x : A){
            movable.insert(x);
        }
    }
    cout << sz(movable) << '\n';
}


#include<cstdio>
using namespace std;
typedef long long ll;
ll n,sum1,sum2,i,j;
int main()
{
	scanf("%lld",&n);
	sum1=3;i=1;
	while(sum1<n)
	{
		sum2=5;j=1;
		while(sum1+sum2<n)
		{
			j++;
			sum2=5ll*sum2;
		}
		if(sum1+sum2==n)
		{
			printf("%lld %lld\n",i,j);
			return 0;
		}
		i++;
		sum1=3ll*sum1;
	}
	printf("-1\n");
	return 0;
}

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
int main(){
    ll N,z,x,y;
    bool sw=0;
    cin >> N;
    ll a=0,b=0;
    for(ll i=1;i<=25;i++){
        for(ll j=1;j<=39;j++){
            //cout << pow(5,i)+pow(3,j) << endl;
            x=1;
            y=1;
            rep(ii,i){x*=5;}
            rep(jj,j){y*=3;}
            //cout << x+y << endl;
            //z=pow(5,i)+pow(3,j);
            z=x+y;
            if(z==N){
                sw=1;
                a=j;
                b=i;
                break;
                }
            //cout << sw << endl;
            //if(pow(5,i)+pow(3,j)==N){
            //    sw=1;
            //    a=j;
            //    b=i;
            //}
        }
    }

    if(sw){cout << a << " " << b << endl;}
    else{cout << -1 << endl;}

    return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<fstream>
constexpr int Mod = 998244353;
using namespace std;

struct Node {
    string name;
    int h;
};

bool comp(Node a, Node b) {
    return a.h > b.h;
}

int main() {
    int N;
    cin >> N;
    string s;
    int he;
    vector<Node> q;
    for (int i = 1; i <= N; i++) {
        cin >> s >> he;
        q.push_back(Node{ s,he });
    }
    sort(q.begin(), q.end(), comp);
    cout << q[1].name << endl;

    return 0;
}

#include <algorithm>
#include <bitset>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define rd1(a) cin >> (a)
#define rd2(a, b) cin >> (a) >> (b)
#define rd3(a, b, c) cin >> (a) >> (b) >> (c)
#define rd4(a, b, c, d) cin >> (a) >> (b) >> (c) >> (d)

#define init1(a) int (a); rd1((a));
#define init2(a, b) int (a), (b); rd2((a), (b));
#define init3(a, b, c) int (a), (b), (c); rd3((a), (b), (c));
#define init4(a, b, c, d) int (a), (b), (c), (d); rd4((a), (b), (c), (d));

#define repa(i, a, b) for (auto i = (a); i <= (b); ++i)
#define repd(i, a, b) for (auto i = (a); i >= (b); --i)
#define forz(i, n) for (auto i = 0; i < n; ++i)
#define fori(i, n) for (auto i = 1; i <= n; ++i)
#define fore(i, t) for (auto &&i : t)

#define all(x) (x).begin(), (x).end()
#define repmin(x, y) x = min(x, y)
#define repmax(x, y) x = max(x, y)
#define ll long long
#define lll __int128
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(t) ((int)(t).size())
#define vi vector<int>
#define vs vector<string>
#define vd vector<ld>
#define inf 1000000100
#define neginf -1000000100
#define DBG(var)                                                               \
  cerr << "[" << __LINE__ << "] " << #var << " = " << (var) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &s, pair<T1, T2> &t) {
  return s << "(" << t.first << "," << t.second << ")";
}

template <typename T>
void read_vec(T& v, size_t n) {
  forz(i, n) { typename T::value_type t; cin >> t; v.pb(t); }
}

template <typename T>
void write_vec(T& v) {
  forz(i, sz(v)) { cout << v[i] << " \n"[i == sz(v) - 1]; }
}

template <typename T> ostream &operator<<(ostream &s, vector<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T> ostream &operator<<(ostream &s, set<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T> ostream &operator<<(ostream &s, unordered_set<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T, typename S>
ostream &operator<<(ostream &s, map<T, S> &m) {
  s << "{ ";
  for (auto i = m.begin(); i != m.end(); i++)
    s << "(" << i->first << " -> " << i->second << ") ";
  s << "}";
  return s;
}

// globals
//

void preproc() {
  // add any preprocessing valid for all tests here
  //
}

void single(int testId) {
  // add code here
  //
  init1(n);
  vector<pair<int, string>> tt;
  forz(i, n) {
      string s; int t;
      cin >> s >> t;
      tt.pb({t, s});
  }
  sort(all(tt), greater<pair<int,string>>());
  cout << tt[1].second << "\n";
}

void multiple() {
  // multiple tests in single file
  int T;
  cin >> T;
  for (auto t = 1u; t <= T; t++)
    single(t);
}

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

  preproc();

  single(0);
  //multiple();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> S(N);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  int god = 0;
  int e = 0;
  int ans = 2;
  for(int i = 2; i < 1001; i++) {
    for(int j = 0; j < N; j++) {
      if(S.at(j) % i == 0) god++;
    }
    if(god > e){
      ans = i; e = god;
    }
    god = 0;
  }
  cout << ans << endl;
}

/*Bismillahi-r-Rahmani-r-Rahim*/
#include<bits/stdc++.h>
using namespace std;
#define  ll         long long
#define  pi         acos(-1.0)
#define  mod        1000000007
#define  yes        cout<<"YES"<<endl
#define  no         cout<<"NO"<<endl
#define  vi         vector<int>
#define  vl         vector<ll int>
#define  pb         push_back
#define  test       cin>>t;while(t--)
#define  lcm(a,b)   a*b/__gcd(a,b)
#define  sd         second
#define  ft         first

int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d,cnts=0,w;
     cin>>n;
    ll int ara[n];
     for(i=0;i<n;i++){
        cin>>ara[i];
     }
     if(n==1){
        cout<<ara[0]<<endl;return 0;
     }
     sort(ara,ara+n);
     m=0;
     p=ara[0];
     for(i=0;i<n-1;i++){
        l=0;r=ara[i];
        for(j=i+1;j<n;j++){
            if(__gcd(r,ara[j])>1){
                l++;
                r=__gcd(r,ara[j]);
            }
        }
        if(l>m){
            m=l;
            p=r;
        }
     }
     cout<<p<<endl;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;

map<ll, ll> factorize(ll n) {
    map<ll, ll> m;
    ll lim = (ll)sqrt(n) + 10;
    while (n % 2 == 0) {
        n >>= 1;
        m[2]++;
    }
    for (int i = 3; i < lim; i += 2) {
        while (n % i == 0) {
            n /= i;
            m[i]++;
        }
    }
    if (n > 1) m[n]++;
    return m;
}

int main() {
    ll n;
    cin >> n;
    map<ll, ll> m;
    for (ll i = 2; i <= n; ++i) {
        map<ll, ll> f = factorize(i);
        for (const auto [k, x]: f) {
            m[k] = max(m[k], x);
        }
    }
    ll result = 1;
    for (const auto [k, x]: m) {
        for (int i = 0; i < x; ++i) {
            result *= k;
        }
    }
    cout << result + 1 << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long
ll kpk(ll m, ll n){
	ll a = m;
	ll b = n;
	ll r = m%n;
	while(r != 0)
    {
        m = n;
        n = r;
        r = m % n;
    }
    return a*b/n;
}
int main(){
	ll a;
	cin >> a;
	ll k = kpk(a,a-1);
	for(int i=a-2;i>2;i--){
		k = kpk(k,i);
	}
	cout << k+1;
}


#include <bits/stdc++.h>
constexpr int DEBUG = 0;
using namespace std;
using int64 = long long;

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

  int n; cin >> n;
  cout << (n + 99) / 100 << endl;
}

#import<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin >> n;
	for( int i=1;i<=n;++i )	cout << int(log2(i))+1 << " ";
	cout << "\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair

typedef vector<int> vi;
typedef pair<int,int> pi;
#define REP(i,a,b) for (int i = a; i <= b; i++)

void solve(){

ll n;
cin>>n;
for (ll i = 0; i < n+5; i++)
{
    if((i*(i+1))/2 >=n){
        cout<<i;
        return;
    }
}

}

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n =1;
// cin>>n;
while(n--){
    // cout<<n;
    solve();
}
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) begin(v), end(v)
using namespace std;
using P = pair<int,int>;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Graph = vector<vector<int>>;

ll ll_pow(ll a, ll n) {
  ll ans = 1;
  for(ll i = 0; i < n; i++) ans *= a;
  return ans;
}

vector<vector<int>> G;
bool temp[100001];

void dfs(int v){
  	if(temp[v]) return;
  	temp[v] = true;
  	for(auto vv:G[v]) dfs(vv);
}

int main() {
  int n,i;
  cin >> n;
  for(i=1;i<n;i++){
    if(i*(i+1)/2 >= n) break;
  }
  cout << i <<endl;
  return 0;
}