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

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

    int n,min = INT_MAX;

    for(int i = 0 ; i < 4; i++)
    {
        cin >> n;
        if(n < min) min = n;
    }

    cout << min << endl;

    return 0;
}

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

int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    rep(i,100){
        if(C==0){
            A--;
            if(A<=0){
                printf("Aoki");
                return 0;
            }
            B--;
            if(B<=0){
                printf("Takahashi");
                return 0;
            }
        }else{
            B--;
            if(B<=0){
                printf("Takahashi");
                return 0;
            }
            A--;
            if(A<=0){
                printf("Aoki");
                return 0;
            }
        }

    }
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;

int main() {
    int n; cin >> n;
    V<V<int> > c(n, V<int>(n));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) cin >> c[i][j];
    }

    int am = 1000000001, p = 0;
    for(int i = 0; i < n; i++){
        if(c[i][0] < am){
            am = c[i][0];
            p = i;
        }
    }

    V<int> a(n);
    for(int i = 0; i < n; i++){
        a[i] = c[i][0] - am;
    }

    V<int> b(n);
    for(int i = 0; i < n; i++){
        b[i] = c[0][i] - a[0];
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(a[i] + b[j] == c[i][j]) continue;
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 0; i < n; i++) {
        if(i != n - 1) cout << a[i] << ' ';
        else cout << a[i] << endl;
    }
    for(int i = 0; i < n; i++) {
        if(i != n - 1) cout << b[i] << ' ';
        else cout << b[i] << endl;
    }

    return 0;
}

/**
*    author:  tomo0608
*    created: 19.06.2021 20:59:50
**/

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

typedef long long ll;
typedef long double ld;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;

#define all(x) x.begin(),x.end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
template<class... T>void input(T&... a){(cin >> ... >> a);};
#define INT(...) int __VA_ARGS__; input(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
#define STRING(...) string __VA_ARGS__; input(__VA_ARGS__)
void print(){cout << '\n';}
template<class T, class... Ts>void print(const T& a, const Ts&... b){cout << a; (cout << ... << (cout << ' ', b)); cout << '\n';}
template<class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {os << *itr;++itr;if(itr != set_var.end()) os << ", ";itr--;}os << "}";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {os << "{";for(auto itr = map_var.begin(); itr != map_var.end(); itr++) {os << *itr;itr++;if (itr != map_var.end()) os << ", ";itr--;}os << "}";return os;}
#ifdef __LOCAL
void debug_out(){ cerr << endl;}
template < class Head, class... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
template<class T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
#define pb push_back
#define eb emplace_back
#define elif else if
#define mp make_pair
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template<typename T> T gcd(T x, T y){if(x%y == 0)return y;return gcd(y, x%y);}
template<typename T> T gcd(vector<T> a){T res = a[0];for(auto &x: a)res = gcd(res, x);return res;}
template <typename T>T mypow(T x, ll n){T ret = 1;while(n > 0){if(n & 1)(ret *= x);(x *= x);n >>= 1;}return ret;}
#define endl '\n'
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

void solve(){
    LL(n);
    map<int,int> dat;
    ll ans = 0;
    rep(i,n){
        INT(a);
        if(dat.count(a)){
            ans += dat[a];
            dat[a]++;
        }else{
            dat[a] = 1;
        }
    }
    print(n*(n-1)/2 - ans);
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << setprecision(20);
    int codeforces = 1;
    //cin >> codeforces;
    while(codeforces--){
        solve();
    }
    return 0;
}


#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define BACK(x) x.rbegin(),x.rend()
#define MOD 1000000007
#define INF INT_MAX
#define FLOAT_ANS setprecision(30)
#define TORAD(x) (x*acos(-1)/180.0)
#define TODEG(x) (x*180/acos(-1))
#define elif else if

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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

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

ll modpow(ll a, ll n, ll mod) {
    ll res=1;
    while (n>0) {
        if(n&1)res=(res*(a%mod))%mod;
        a=((a%mod)*(a%mod))%mod;
        n>>=1;
    }
    return res;
}

// MAIN PROGRAM -------------

int main(){
	ll a,b;
	bool spd=false;
	cin>>a>>b;
	if(a<b){
		swap(a,b);
		spd=true;
	}

	ll n=0;
	rep(i,a){
		if(spd)cout<<-(i+1)<<" ";
		else cout<<i+1<<" ";
		n+=i+1;
	}

	rep(i,b-1){
		if(spd)cout<<(i+1)<<" ";
		else cout<<-(i+1)<<" ";
		n-=i+1;
	}

	if(spd)cout<<n;
	else cout<<-n;
}

/*

*/

#include "bits/stdc++.h"
#include <chrono>
#include <random>

#define INF 1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef unordered_map<int,int> umi ;
typedef unordered_set<int> usi ;
typedef pair<int,int> pi;

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

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

bool ldequal(ld  a ,ld b){
    return abs(a-b) < 1e-9  ;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// shuffle(permutation.begin(), permutation.end(), rng); for permute
// uniform_int_distribution<int>(0, i)(rng) for rand

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

//declare here-------------------------------------------------------------------------------
const int N =1e2 ;

//solve here---------------------------------------------------------------------------------
void solve(){
    int a ,b ;
    cin>>a>>b ;
    int pr=1 ;
    if(b>a){
      pr=-1 ;
      swap(a,b) ;
    }
    vi ans  ;
    REP(i,1,a+1)ans.PB(i) ;
    REP(i,1,b) ans.PB(-i) ;
    int sm=0 ;
    REP(i,b,a+1) sm+=i ;
    ans.PB(-sm) ;
    for(auto x:ans) cout<<pr*x<<" " ;
}

int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long test =1 ;
     //cin>>test ;

    REP(i,1,test+1){
        debug(i) ;
        //cout<<"Case #"<<i<<": " ;

        solve() ;
        cout<<"\n" ;
    }
    return 0 ;
}


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

ll solve_sub(ll N, vector<ll>& V) {
    priority_queue<pii> q;
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        int i2 = 2*N-1-i;
        q.push(pii(V[i],i));
        q.push(pii(V[i2],i2));
        ans += q.top().first;
        q.pop();
    }
    return ans;
}

ll solve_sub_0(ll N, vector<ll>& V) {
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        int i1 = N-1-i, i2 = N+i;
        ans += max(V[i1],V[i2]);
    }
    return ans;
}

ll solve() {
    ll N;
    cin >> N;
    vector<ll> V(2*N);
    for ( int i = 0; i < 2*N; i++ ) cin >> V[i];
    ll ans = solve_sub(N, V);
    return ans;
}

auto solve_small_1(ll N, vector<ll>& V) {
    ll ans = 0;
    vector<ll> ans_v;
    vector<ll> used(2*N);
    auto dfs = [&](auto self, int d, ll s) -> void {
        if ( d == N ) {
            ans = max(ans, s);
            return;
        }
        int h0, h1, c = 0;
        for ( int i = 0; i < 2*N; i++ ) {
            if ( used[i] == 0 ) {
                c++;
                if ( c <= N-d ) {
                    h0 = i;
                } else {
                    h1 = i;
                    break;
                }
            }
        }
        for ( int i = 0; i < 2*N; i++ ) {
            if ( used[i] > 0 ) continue;
            int i1 = i;
            int i2 = i < h1 ? h1 : h0;
            used[i1] = 1;
            used[i2] = 1;
            ans_v.push_back(i1);
            self(self, d+1, s+V[i1]);
            ans_v.pop_back();
            used[i1] = 0;
            used[i2] = 0;
        }
    };
    dfs(dfs,0,0LL);
    return ans;
}
struct Data {
    int id;
    ll N;
    vector<ll> V;
};
void test() {
    mt19937_64 mt64(0);
    uniform_int_distribution<ll> rnd_n(3, 4);
    uniform_int_distribution<ll> rnd_v(0, 9);

    int id = 0;
    vector<Data> ts;
    ts.push_back({++id,4,{3,2,8,6,7,6,1,6}});
    ts.push_back({++id,3,{1,2,3,4,5,6}});
    ts.push_back({++id,4,{1,4,5,8,7,6,3,2}});
    for ( int i = 0; i < 100; i++ ) {
        int n = rnd_n(mt64);
        vector<ll> a;
        for ( int j = 0; j < 2*n; j++ ) {
            a.push_back(rnd_v(mt64));
        }
        ts.push_back({++id,n,a});
    }

    for ( Data& t : ts ) {
        auto ans0 = solve_sub(t.N,t.V);
        auto ans1 = solve_small_1(t.N,t.V);
        if ( ans0 != ans1 ) {
            cout << t.id << " " << ans0 << " " << ans1 << "\n";
        }
    }
    cout << "end" << "\n";
}

int main() {
    // test();

    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];

    ll ans = a[0];
    rep(i,n) ans = __gcd(ans, a[i]);
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string.h>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
#include <vector>
#include <queue>
#include <numeric>

#define MM (1000000000 + 7)
typedef unsigned long long ull;

int N, Q;
string S;
int T, A, B;
string ans;

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

	int i, j, k;
	bool l = false;
	int m, n;

	cin >> N >> S >> Q;

	for (i = 0; i < Q; i++) {
		cin >> T >> A >> B;
		if (T == 1) {
			int m = A - 1;
			int n = B - 1;

			if (l) {
				m += N;
				m %= (N << 1);
				n += N;
				n %= (N << 1);
			}
			char tmp = S[m];
			S[m] = S[n];
			S[n] = tmp;
		}
		else {
			l = !l;
		}
	}

	if (l) {
		ans = "";
		for (i = N; i < 2 * N; i++) {
			ans += S[i];
		}
		for (i = 0; i < N; i++) {
			ans += S[i];
		}
		cout << ans << '\n';
	}
	else {
		cout << S << '\n';
	}

	return 0;
}

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main()
{
int n,q,k;
string s;
cin>>n>>s>>q;
k=0;
vector<int> v(3*q);
for(int i=0; i<3*q; i++) cin>>v.at(i);
for(int i=0; i<q; i++){
    if(v.at(3*i)==1){
        if(k%2==0){
            string x;
            x=s.at(v.at(3*i+1)-1);
            s.at(v.at(3*i+1)-1)=s.at(v.at(3*i+2)-1);
            s.at(v.at(3*i+2)-1)=x.at(0);
        }
        else{
            string x;
            x=s.at((v.at(3*i+1)-1+n)%(2*n));
            s.at((v.at(3*i+1)-1+n)%(2*n))=s.at((v.at(3*i+2)-1+n)%(2*n));
            s.at((v.at(3*i+2)-1+n)%(2*n))=x.at(0);
        }
    }
    else k++;
}
if(k%2==1){
      s = s.substr(n,n)+s.substr(0,n);
}
cout<<s<<endl;

}


#include<bits/stdc++.h>
#define ll long long int
#define pll pair<ll,ll>
#define vpll vector< pll >
#define mpll map<ll,ll>
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define s(v) v.size()
#define test ll t;cin>>t;while(t--)
#define vec vector<ll>
#define read0(v,n) for(int i=0;i<n;i++)cin>>v[i];
#define read1(v,n) for(int i=1;i<=n;i++)cin>>v[i];
#define trav(a,x) for (auto& a: x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cut(x) {cout<<x;return 0;}
#define print(x) {cout<<x<<nl;continue;}
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define err1(a) {cout<<#a<<' '<<a<<nl;}
#define err2(a,b) {cout<<#a<<' '<<a<<' '<<#b<<' '<<b<<nl;}

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define nl '\n'
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gcd(ll a, ll b)
{
	if (b==0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
ll bpow(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

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

	fast
	ll a,b;
	cin>>a>>b;
    if(a==b)
    {
        FOR(i,1,a)cout<<-i<<' '<<i<<' ';
        return 0;
    }
    if(a>b)
    {
        FOR(i,1,b-1)cout<<i<<' '<<-i<<' ';
        ll sum=0;
        FOR(i,b,a)
        {
            cout<<i<<' ';
            sum+=i;
        }
        cout<<-sum;
    }
    else
    {
        FOR(i,1,a-1)cout<<i<<' '<<-i<<' ';
        ll sum=0;
        FOR(i,a,b){sum+=i;cout<<-i<<' ';}
        cout<<sum;
    }
}

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define e "\n"
#define fl(x,n) for(ll i=x;i<=n;i++)
#define fl2(x,n) for(ll i=x;i>=n;i--)
using namespace std;

int main()
{

       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
        int a,b;
        cin >> a >> b;
        if(a>b)
        {
            ll s1=(a*(a+1))/2;
            b--;
            ll s2=(b*(b+1))/2;
            fl(1,a)
            cout << i << " ";
            fl(1,b)
            cout << -i << " ";
           ll temp=s1-s2;
           cout << -temp << e;
        }
        else if(a<b)
        {
             ll s1=(b*(b+1))/2;
             a--;
            ll s2=(a*(a+1))/2;
            fl(1,b)
            cout << -i << " ";
            fl(1,a)
            cout << i << " ";
           ll temp=s1-s2;
           cout << temp << e;
        }
        else
        {
            fl(1,a)
            cout << i << " ";
            fl(1,b)
            cout << -i << " ";
            cout << e;

        }

       return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a,v) memset((a), v, sizeof(a))

using namespace std;

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

const int MOD = 998244353;

const int N = 55;

int n, z;
int dat[N][N];
ll fact[N];

struct DisjointSet {

	int total;
	int par[N], subsize[N];

	void init(int n) {
		total = n;
		for (int i = 0; i < n; i++) {
			par[i] = i;
			subsize[i] = 1;
		}
	}

	int findSet(int x) {
		return par[x] == x ? x : par[x] = findSet(par[x]);
	}

	void uni(int a, int b) {
		int x = findSet(a), y = findSet(b);
		if (x != y) {
			par[y] = x;
			subsize[x] += subsize[y];
		}
	}
};

DisjointSet dsR, dsC;

int main() {
	for (int i = 0; i < N; i++) {
		if (i == 0) fact[i] = 1;
		else fact[i] = (1ll*i*fact[i-1]) % MOD;
	}

	cin >> n >> z;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> dat[i][j];
		}
	}
	dsR.init(n);
	dsC.init(n);
	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			bool ok = true;
			for (int k = 0; k < n; k++) {
				if (dat[k][i] + dat[k][j] > z) ok = false;
			}
			if (ok) {
				dsC.uni(i,j);
			}

			ok = true;
			for (int k = 0; k < n; k++) {
				if (dat[i][k] + dat[j][k] > z) ok = false;
			}
			if (ok) {
				dsR.uni(i,j);
			}
		}
	}

	ll ans = 1;
	for (int i = 0; i < n; i++) {
		if (dsR.findSet(i) == i) {
			ans = (ans * fact[dsR.subsize[i]]) % MOD;
			// printf("%d %d\n", i, dsR.subsize[i]);
		}
		if (dsC.findSet(i) == i) {
			ans = (ans * fact[dsC.subsize[i]]) % MOD;
			// printf("%d %d\n", i, dsC.subsize[i]);
		}
	}
	cout << ans << "\n";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		int a[n];
		int count[n]={0};
		for(int i=0;i<n;i++){
			cin>>a[i];
			count[a[i]]++;
		}
		priority_queue<int, vector<int>, greater<int>> p;
		int ans=0;
		int m=1e9;
		int filled=0;
		for(int i=0;i<n-1;i++){
			m=min(m,count[i]);
			count[i]=min(m,count[i]);
			count[i+1]=min(m,count[i+1]);
			if(count[i]>count[i+1]){
				int x=count[i]-count[i+1];
				for(int j=0;j<x;j++){
					if(filled<k){
						filled++;
						p.push(i+1);
						ans+=i+1;
					}
					else{
						if(p.top()<i+1){
							ans+=i+1-p.top();
							p.pop();
							p.push(i+1);
						}
					}
				}

			}
		}
		cout<<ans;
		cout<<endl;
	}
}


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

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

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

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

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

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

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

#include<bits/stdc++.h>

typedef   long long  int ll;
typedef  long double ld;
typedef std::vector<ll> vi;
typedef std::vector<std::vector<ll> > vv;
typedef std::vector<std::pair<ll,ll> > pii;

#define mod 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,b) for(i=a;i<b;i++)
#define forr(i,a,b) for(i=a;i>=b;i--)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;
#define all(a) a.begin(),a.end()
#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];
#define ms(a,val) memset(a,val,sizeof(a))
using namespace std;

const int N = 2e5+ 5;

ll expo_pow(ll x, ll y) {
	if (y == 0)
		return 1;
	y = y % (mod - 1);
	x %= mod;
	if (y == 0)
		y = mod - 1;
	ll res = 1;
	while (y) {
		if (y & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		y >>= 1;
	}
	return res;
}

ll modInverse(ll a, ll m = mod) {
	return expo_pow(a, m - 2);
}

using matrix = vector<vector<ll>>;

matrix matMul(matrix A, matrix B) {
	//assert((int)A[0].size() == (int)B.size());
	matrix res((ll)A.size(), vector<ll>((ll)B[0].size(), 0));
	for (int i = 0; i < (int)A.size(); ++i) {
		for (int j = 0; j < (int)B[0].size(); ++j) {
			for (int k = 0; k < (int)A[0].size(); ++k) {
				res[i][j] += (A[i][k] * B[k][j]) % mod;
				res[i][j] %= mod;
			}
		}
	}
	return res;
}

matrix matPow(matrix M, int p) {
	if (p == 1) return M;
	if (p % 2) return matMul(M, matPow(M, p - 1));
	matrix X = matPow(M, p / 2);
	return matMul(X, X);
}

void solve(){
            ll i,j,n,m,k;
            cin>>n>>m>>k;

            vv a(1,vi(n,0));
            input(a[0],0,n);
            vv adj(n,vector<ll>(n,0));

            vi deg(n,0);
            fo(i,0,m)
            {
				ll x,y;
				cin>>x>>y;
				x--,y--;
				adj[x][y] = 1;
				adj[y][x] = 1;
				deg[x]++;
				deg[y]++;
			}

			ll inv = modInverse(2*m,mod);

			vv M(n,vi(n,0));

			if(k == 0)
			{
				print(a[0],0,n);
				return ;
			}
			fo(i,0,n)
			{
				fo(j,0,n)
				{
					if(i == j)
					{
						M[i][j] = (1 - (deg[i]*inv)%mod + mod)%mod;
					}
					else
					{
						M[i][j] = inv*adj[i][j];
					}
				}
			}
			M = matPow(M, k);
			a = matMul(a,M);
			fo(i,0,n)
			{
				cout<<a[0][i]<<endl;
			}
}

int main()
{
     IO;
      ll t=1,i;
      //cin>>t;

      while(t--)
      {

          solve();
      }
    return 0;
}


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

#include<bits/stdc++.h>

using namespace std;

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 LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EPeddler {
public:

    vector<int> graph[200005];

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      vector<ll> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      vector<int> x(m), y(m);
      rep(i, m) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        graph[x[i]].push_back(y[i]);
      }

      vector<ll> dp(n, LLONG_MIN/2);
      vector<ll> lowest(n, LLONG_MAX/2);

      for(int i=0; i<n; i++) {
        for(auto e: graph[i]) {
          chmin(lowest[e], lowest[i]);
          chmin(lowest[e], a[i]);
        }
      }

      ll ret = LLONG_MIN/2;
      for(int i=0; i<n; i++) {
        chmax(ret, a[i] - lowest[i]);
      }

      cout << ret << endl;
    }
};

signed main() {
  EPeddler solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 100005;

int n, d;
int a[N], b[N];

int minu[N];

vector<int> v[N];

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

    a[n + 1] = b[n + 1] = d + 1;

    for (int i = 1; i <= n; ++i)
        minu[i] = N;

    map<int, int> mp;
    for (int i = 0; i <= n + 1; ++i)
    {
        mp[a[i] - i] = i;
        if (mp.find(b[i] - i) != mp.end())
        {
            if (mp[b[i] - i] != i)
                v[mp[b[i] - i]].push_back(i);
            minu[i] = min(minu[i], i - mp[b[i] - i]);
        }
    }

    mp.clear();
    for (int i = n + 1; i >= 0; --i)
    {
        mp[a[i] - i] = i;
        if (mp.find(b[i] - i) != mp.end())
        {
            if (mp[b[i] - i] != i)
                v[mp[b[i] - i]].push_back(i);
            minu[i] = min(minu[i], mp[b[i] - i] - i);
        }
    }

    for (int i = 0; i <= n + 1; ++i)
    {
        if (minu[i] == N)
        {
            printf("-1\n");
            return;
        }
    }

    ll ans = 0;
    for (int i = 0; i <= n + 1; ++i)
    {
        if (v[i].empty())
            continue;
        sort(all(v[i]));
        if (v[i][0] < i)
            ans += (i - v[i][0]);
        if (v[i].back() > i)
            ans += (v[i].back() - i);
    }

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

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <deque>
#include <iomanip>
#define ll long long
#define ld long double

using namespace std;

void solve() {
    ll L, R;
    cin >> L >> R;
    ll left = R - L;
    if (left < L) {
        cout << "0\n";
        return;
    }
    ll c = R - L - L + 1;
    ll ans = (c + 1) * c / 2;
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin >> t;
    for (int ij = 0; ij < t; ++ij) {
        solve();
    }
}
//*/

/*
Description
@authors Magneto
@date    2021-02-13 17:36:16
@version
*/
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long
#define l long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define pf pop.front()
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " = " << x << endl;
#define lcm(a,b) a*b/__gcd(a,b)
//__builtin_popcount = int
//__builtin_popcountl = long int
//__builtin_popcountll = long long

using namespace std;

void solve()
{
int a,b;
cin>>a>>b;

int left = a + a;
int right = b;
if(left > right){
cout<<0<<endl;
return;
}

ll n = right - left + 1;

ll ans = n*(n+1)/2;
cout<<ans<<endl;
}

int32_t main()
{
FAST
l T=1;
cin>>T;
while(T--)
{
solve();
}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define real long double
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pi M_PI
#define elif else if
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int INF = 2e18, MOD = 998244353, RANDOM = chrono::steady_clock::now().time_since_epoch().count();
const real EPS = 1e-12;
mt19937 rng(RANDOM);
struct chash {

    int operator() (int x) const { return (x ^ RANDOM) % MOD; }
};

int n;
vector<vector<int>> people;
vector<int> ind;
vector<pair<int, int>> answer;

int search(){
    int cnt = 0;
    for (int i=0; i<n - 1; ++i){
        if (people[i][2] == people[i][3]) continue;
        if (people[i][1] >= people[i][0]) return -1;
        int j = ind[people[i][3]];
        if (people[j][1] >= people[j][0]) return -1;
        ind[people[i][2]] = j;
        ind[people[i][3]] = people[i][3];
        swap(people[i][1], people[j][1]);
        swap(people[i][2], people[j][2]);
        answer.push_back({people[i][3], people[j][3]});
        ++cnt;
    }
    return cnt;
}

void debug(){
    cerr << "\n";

    cerr << "\n";
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // cout.precision(6);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n;
    people.assign(n, vector<int>(4, 0));
    ind.assign(n, 0);
    vector<int> b(n);
    for (int i=0; i<n; ++i) cin >> people[i][0];
    for (int i=0; i<n; ++i) cin >> b[i];
    for (int i=0; i<n; ++i){
        cin >> people[i][2];
        --people[i][2];
        people[i][1] = b[people[i][2]];
        people[i][3] = i;
    }
    sort(all(people));
    for (int i=0; i<n; ++i) ind[people[i][2]] = i;
    int res = search();
    cout << res << "\n";
    if (res != -1) for (auto i: answer) cout << i.f + 1 << " " << i.s + 1 << "\n";
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> b(N+1);
  vector<vector<int> > iap(N+1, vector<int>(3));
  vector<int> who_has(N+1);
  vector<int> who_is(N+1);
  vector<pair<int, int> > ans;
  for (int i = 1; i < 3; i++)
  {
    for (int j = 1; j < N+1; j++) cin >> iap.at(j).at(i);
    if (i == 1)
    {
      for (int j = 1; j < N+1; j++) cin >> b.at(j);
    }
  }
  for (int i = 1; i < N+1; i++) iap.at(i).at(0) = i;
  sort(iap.begin(),iap.end(),[](const vector<int> &alpha,const vector<int> &beta){return alpha[1] < beta[1];});
  for (int i = 1; i < N+1; i++)
  {
    who_has.at(iap.at(i).at(2)) = i;
    who_is.at(iap.at(i).at(0)) = i;
  }
  for (int i = 1; i < N+1; i++)
  {
    if (iap.at(i).at(0) == iap.at(i).at(2)) continue;
    if (iap.at(i).at(1) <= b.at( iap.at(i).at(2) ))
    {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(make_pair(iap.at(i).at(0), iap.at(who_has.at( iap.at(i).at(0) )).at(0)));
    iap.at(who_is.at( iap.at(who_has.at( iap.at(i).at(0) )).at(0) )).at(2) = iap.at(i).at(2);
    who_has.at( iap.at(i).at(2) ) = who_has.at( iap.at(i).at(0) );
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans.at(i).first << " " << ans.at(i).second << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
int binary_expo(int a,int b)
{
    int res=1;
    while(b>0)
    {
        if(b&1>0)
        {
            res=(((res%M)*(a%M))%M);
        }
        b=b>>1;
        a=(((a%M)*(a%M))%M);
    }
    return res;
}
int inv(int a,int b)
{
    a=(((a%M)*(binary_expo(b,M-2)))%M);
    return a;
}
int32_t main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;cin>>n;
        vector<int> a(n,0);
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        int p=0;
        int i=n-2;
        int s=0;
        while(i>=0)
        {
            s+=((a[i]*(binary_expo(2,p)))%M);
            s%=M;
            p++;
            i--;
        }
        int c=0;
        for(int i=n-1;i>0;i--)
        {
            int k=((s*a[i])%M);
            c+=k;
            c%=M;
            s=((s-a[i-1]+M)%M);
            s=(inv(s,(int)2)%M);
            s%=M;
        }
        for(int i=0;i<n;i++)
        {
            c+=((a[i]*a[i])%M);
            c%=M;
        }
        cout<<c<<endl;

    }
    return 0;
}

//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <inttypes.h>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// #include <atcoder/dsu>
// using namespace atcoder;
// using mint = modint1000000007;
// using mint = modint998244353;
// using mint = modint;

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template<typename T>
void chmin(T& x, T y) {
	x = min(x, y);
}

template<typename T>
void chmax(T& x, T y) {
	x = max(x, y);
}

ll csum(ll x, ll y) {
	if (x > 0 && y > 0 && x > LL_MAX - y) {
		return LL_MAX;
	}
	if (x < 0 && y < 0 && x < LL_MIN - y) {
		return LL_MIN;
	}
	return x + y;
}

ll readi() {
	ll ret;
	scanf("%" PRId64 "", &ret);
	return ret;
}

vector<ll> readvi(ll n) {
	vector<ll> ret(n);
	rep(i, 0, n) { ret[i] = readi(); }
	return ret;
}

double readf() {
	double ret;
	scanf("%lf", &ret);
	return ret;
}

string reads() {
	string s;
	cin >> s;
	return s;
}

void writei(ll x) {
	printf("%" PRId64 "\n", x);
}

void writevi(const vector<ll>& xs) {
    rep(i,0,xs.size()) {
        if (i < xs.size() - 1) {
            printf("%" PRId64 " ", xs[i]);
        } else {
            printf("%" PRId64 "\n", xs[i]);
        }
    }
}

void writes(const string& s) {
	cout << s.c_str() << endl;
}

void writef(double x) {
	printf("%.10f\n", x);
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N = readi();
	vector<ll> As(N);
	vector<ll> Ts(N);
	ll zero_pt = 0;
	rep(i,0,N) {
		As[i] = readi();
		Ts[i] = readi();
		if (Ts[i] == 1) {
			zero_pt += As[i];
		} else if (Ts[i] == 2) {
			zero_pt = max(zero_pt, As[i]);
		} else {
			zero_pt = min(zero_pt, As[i]);
		}
	}
	ll total = 0;
	rep(i,0,N) {
		if (Ts[i] == 1) {
			total += As[i];
		} else {
			As[i] -= total;
		}
	}
	ll lower = LL_MIN;
	ll upper = LL_MAX;
	rep(i,0,N) {
		if (Ts[i] == 1) {
			continue;
		} else if (Ts[i] == 2) {
			chmax(lower, As[i]);
		} else {
			chmin(upper, As[i]);
		}
	}
	ll Q = readi();
	vector<ll> ans(Q);
	rep(i,0,Q) {
		ll x = readi();
		if (lower <= upper) {
			ans[i] = min(upper, max(lower, x)) + total;
		} else {
			ans[i] = zero_pt;
		}
	}
	rep(i,0,Q) {
		writei(ans[i]);
	}
}


// E - Lamps
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define irep(i,s) for(int i=(int)(s);i>=0;--i)

int main(){
	int h, w; cin>>h>>w;
	int k = h * w;
	vector<string> S(h);
	rep(i, h){
		cin>>S[i];
		rep(j, w) if(S[i][j] == '#') --k;
	}

	vvi X(h, vi(w+1));
	rep(i, h){
		rep(j, w) if(S[i][j] == '.') X[i][j+1] += X[i][j] + 1;
		int mx = 0;
		irep(j, w) mx = X[i][j]? X[i][j] = max(mx, X[i][j]): 0;
	}

	vvi Y(h+1, vi(w));
	rep(j, w){
		rep(i, h) if(S[i][j] == '.') Y[i+1][j] += Y[i][j] + 1;
		int mx = 0;
		irep(i, h) mx = Y[i][j]? Y[i][j] = max(mx, Y[i][j]): 0;
	}

	int M = 1000000007;
	vector<int> pow2(k+1);
	pow2[0] = 1; rep(i, k) pow2[i+1] = pow2[i] * 2 % M;

	ll ans = (ll)k * pow2[k] % M;
	rep(i, h) rep(j, w){
		if(S[i][j] == '.'){
			ans -= pow2[k - (X[i][j+1] + Y[i+1][j] - 1)];
			ans %= M;
		}
	}
	cout<< (ans + M) % M <<endl;
}

#include<bits/stdc++.h>

using namespace std;

#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  2e3+5;
const ll   M     =  4e6+5;
const ll   mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll n, m, p[N][N][4], p2[M];
string s[N];

void solve(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> s[i]; s[i] = '#' + s[i] + '#';
	}
	s[0] = s[n+1] = string(m+2,'#');
	int no = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i][j] == '#') continue;
			no++;
		}
	}
	for(int i = 1; i <= n; i++){
		int prv = 0;
		for(int j = 1; j <= m; j++){
			if(s[i][j] == '#') prv = j;
			else {
				p[i][j][0] = prv;
			}
		}
		prv = m+1;
		for(int j = m; j >= 1; j--){
			if(s[i][j] == '#') prv = j;
			else {
				p[i][j][1] = prv;
			}
		}
	}
	for(int i = 1; i <= m; i++){
		int prv = 0;
		for(int j = 1; j <= n; j++){
			if(s[j][i] == '#') prv = j;
			else {
				p[j][i][2] = prv;
			}
		}
		prv = n+1;
		for(int j = n; j >= 1; j--){
			if(s[j][i] == '#') prv = j;
			else {
				p[j][i][3] = prv;
			}
		}
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i][j] == '#') continue;
			int tot = p[i][j][1] - p[i][j][0] + p[i][j][3] - p[i][j][2] - 3;
			ll res = (p2[no] - p2[no-tot] + mod) % mod;
			ans = (ans + res) % mod;
		}
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	p2[0] = 1;
	for(int i = 1; i < M; i++){
		p2[i] = p2[i-1] * 2 % mod;
	}
	int test = 1;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
}


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

const int N = 2000 + 5;

int gcd(int a, int b){
	while(b){
		a %= b;
		swap(a, b);
	}
	return a;
}

int n;
int a[N];

int solve(){
	map<int, int> G;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j * j <= a[i]; j++){
			if(a[i] % j == 0){
				if(G.count(j)) G[j] = gcd(G[j], a[i]);
				else G[j] = a[i];
				if(G.count(a[i] / j)) G[a[i] / j] = gcd(G[a[i] / j], a[i]);
				else G[a[i] / j] = a[i];
			}
		}
	}
	int ans = 0;
	int mini = *min_element(a + 1, a + n + 1);
	for(auto e : G){
		if(e.first < mini and e.second == e.first) ans++;
	}
	return ans + 1;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", a + i);
	printf("%d\n", solve());
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

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

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

    ll n; cin >> n;
    ll a[n]; zep(i, 0, n)cin >> a[i];

    ll mn = a[0]; zep(i, 0, n)mn = min(mn, a[i]);

    map<ll, ll> s;
    zep(i, 0, n){
        for(ll j = 1; j * j <= a[i]; j++){
            if(a[i] % j == 0){
                if(s.find(j) == s.end()){
                    s[j] = a[i];
                }else{
                    s[j] = gcd(s[j], a[i]);
                }

                ll k = a[i] / j;
                if(s.find(k) == s.end()){
                    s[k] = a[i];
                }else{
                    s[k] = gcd(s[k], a[i]);
                }
            }
        }
    }

    ll ans  = 0;
    for(auto it = s.begin(); it != s.end(); it++){
        if((*it).first <= mn && (*it).first == (*it).second)ans++;
    }
    print(ans)

    return 0;
}


#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert
#define nl "\n"

const ll MOD = 998244353;

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

template<typename T> T signum(T a) {
    return (a > 0) - (a < 0);
}

template<typename T> T cmp(T a, T b) {
    return signum(a-b);
}

template<typename T> bool mins(T& lhs , T& rhs) {
    if (rhs < lhs) {
        lhs = rhs;
        return true;
    }

    return false;
}

template<typename T> bool maxs(T& lhs , T& rhs) {
    if (rhs > lhs) {
        lhs = rhs;
        return true;
    }

    return false;
}

const int MAX = INT_MAX;

void gks(int tc) {
    printf("Case #%d: ", tc);
};

int main() {
    int n;
    cin>>n;
    cout<<n-1<<nl;
   return 0;
}

//in dp prefix suffix sum helps..
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include <iterator>
#include <map>
#include<list>
#include <fstream>
#include<unordered_map>
#include<set>
#include<queue>
#define int  long long
#define double long double
#define pb   push_back
#define mp   make_pair
#define pii  pair<int,int>
#define pip pair<int, pair<int, int> >
#define vip vector<pair<int, pii> >
#define vi vector<int>
#define vd vector<double>
#define mii  map<int, int>
#define qu queue<int>
#define set set<int>
#define multiset multiset<int>
#define rep(i, a, b) for(int i=a;i<b;i++)
#define rep1(i, a, b) for(int i=a;i>=b;i--)
#define viv vector<vi>
#define stack stack<int>
#define fi first
#define se second
#define reverse(s) reverse(s.begin(), s.end())
#define sort1(v) sort(v.begin(), v.end())
#define it iterator
#define pq priority_queue<int>
#define pq1 priority_queue <pii, vector<pii>, greater<pii> >
#define mem(x, y) memset(x, (int)y, sizeof(x))
#define ps(x,y) fixed<<setprecision(y)<<x
// author :: Anurag Anand.
using namespace std;
//int z=  1e9+7;
int z= 998244353;
int gcd(int a, int b){
    if(a==0)return b;
    if(b==0)return a;
    return gcd(b, a%b);
}
int power(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
		{
			res=(res*a)%z;
			b--;
		}
		a=(a*a)%z;
		b=b>>1;
	}
	return res;
}
vi sv;
// vi seg;
// void arrange(int i, int v, int x, int lx, int rx){
// 	if(rx-lx==1){
// 		seg[x] =v;
// 		return;
// 	}
// 	int m= (lx+rx)/2;
// 	if(i<m) arrange(i, v, 2*x+1, lx, m);
// 	else arrange(i, v, 2*x+2, m, rx);
// 	seg[x]=min(seg[2*x+1], seg[2*x+2]);
// }
// int calc(int l, int r, int x, int lx, int rx){
// 	    if(l>=rx||r<=lx) return 1e9;
// 	    if(lx>=l&&rx<=r) return seg[x];
// 	    int mid=(lx+rx)/2;
// 	    int sl= calc(l, r, 2*x+1, lx, mid), sr= calc(l, r, 2*x+2, mid, rx);
// 	    return min(sl, sr);
// }
// vi v[200001];
// int dist[200001], ans[200001]={0}, vis[200001]={0};
// void dijkstra(int root){
// 	int a, d;
// 	dist[root]=0;
// 	set s;
// 	s.insert(mp(0, root));
// 	while(!s.empty()){
// 		a= (*s.begin()).se, d= (*s.begin()).fi;
// 		s.erase(s.begin());
// 		for(int i=0;i<v[a].size();i++){
// 			if(dist[a]+1<dist[v[a][i]]){
// 				s.erase(mp(dist[v[a][i]], v[a][i]));
// 				dist[v[a][i]]=dist[a]+1;
// 				s.insert(mp(dist[v[a][i]], v[a][i]));
// 			}
// 		}
// 	}
// }
vi pp;
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
	pp.assign(1000001, 0);
	for(int i=2;i<1000;i++){
		if(!pp[i]){
			for(int j=i*i;j<=1000000;j+=i){
				pp[j]=1;
			}
		}
	}
	for(int i=2;i<=1000000;i++) if(!pp[i]) sv.pb(i);
	int t;
	t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		cout<<n-1<<"\n";
	}
}


#include <iostream>
#include <algorithm>

using namespace std;

const int kMaxN = 1e5 + 1;

struct E {
  int y, n;
} e[2 * kMaxN];

struct V {
  int c, et;
} a[kMaxN];

int n, p, v[kMaxN];
bool s[kMaxN];

void A(int i, int x, int y) {
  e[i] = {y, a[x].et};
  a[x].et = i;
}

void D(int x, int f) {
  s[x] = !v[a[x].c]++;
  for (int i = a[x].et; i; i = e[i].n) {
    if (e[i].y != f) {
      D(e[i].y, x);
    }
  }
  --v[a[x].c];
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].c;
  }
  for (int i = 1, x, y; i < n; ++i) {
    cin >> x >> y;
    A(i, x, y), A(i + n, y, x);
  }
  D(1, 0);
  for (int i = 1; i <= n; ++i) {
    if (s[i]) {
      cout << i << endl;
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define CASE(t) int t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vi vector<ll>
#define cs(ele) cout<<ele<<'\n'
const ll Mod=1e9 +7;const ll M1=998244353;
ll mod(ll n){return ((n%Mod)+Mod)%Mod;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=mod(res*x);x=mod(x*x);y=mod(y>>1);}return mod(res);}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

       int n,x;cin>>n>>x;
       vector<int> v;
       f(i,0,n){
           int a;cin>>a;
           if(a!=x)v.pb(a);
       }
       for(auto a:v)ce(a);cout<<endl;

}


#include<bits/stdc++.h>

using namespace std;
const int inf = 1e9;

bool mini(int &a, int b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt","r",stdin);
    int n, m; cin >> n >> m;
    vector<vector<int> > adj(n);
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int k; cin >> k;
    vector<int> c(k);
    for (int i = 0; i < k; i++) {
        cin >> c[i];
        --c[i];
    }
    auto bfs = [&](int s) {
        vector<int> cost(n, inf);
        cost[s] = 0;
        queue<int> q;
        q.push(s);
        while (q.size()) {
            int u = q.front();
            q.pop();
            for (int v: adj[u]) {
                if (mini(cost[v], cost[u] + 1)) q.push(v);
            }
        }
        for (int i = 0; i < k; i++) cost[i] = cost[c[i]];
        cost.resize(k);
        return cost;
    };
    vector<vector<int> > cost(k);
    for (int i = 0; i < k; i++) cost[i] = bfs(c[i]);
    vector<vector<int> > dp(1 << k, vector<int>(k, inf));
    for (int i = 0; i < k; i++) dp[1 << i][i] = 1;
    for (int mask = 1; mask < (1 << k); mask++) {
        for (int i = 0; i < k; i++) {
            if (mask & (1 << i)) {
                int mask2 = mask ^ (1 << i);
                for (int j = 0; j < k; j++) {
                    if (mask2 & (1 << j)) {
                        mini(dp[mask][i], dp[mask2][j] + cost[i][j]);
                    }
                }
            }
        }
    }
    int ans = *min_element(dp.back().begin(), dp.back().end());
    if (ans >= inf) ans = -1;
    cout << ans;
    return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using pii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define pi 3.14159265358979
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) int x;cin >> x
#define cci(x,y) int x,y;cin >> x >> y
#define co(x) cout << x << endl
void chmax(int &x,int y){x=max(x,y);}
void chmin(int &x,int y){x=min(x,y);}

int main(){
  cci(n,m);
  int inf=1001001001;
  vvi to(n,vi(0));

  rep(i,0,m){
    cci(a,b);
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  cii(r);
  vi v(r);
  rep(i,0,r)ci(v[i]),v[i]--;

  vvi dist(r,vi(r));
  // rep(i,0,n)dist[i][i]=0;
  rep(i,0,r){
    int now=v[i];
    vi dis(n,inf);
    dis[now]=0;
    queue<int> q;
    q.push(now);
    while(!q.empty()){
      int x=q.front();q.pop();
      for(int nx:to[x]){
        if(dis[nx]==inf){
          dis[nx]=dis[x]+1;
          q.push(nx);
        }
      }
    }
    rep(j,0,r)dist[i][j]=dis[v[j]];
  }

  // rep(k,0,r){
  //   rep(i,0,r){
  //     rep(j,0,r){
  //       int I=v[i],J=v[j],K=v[k];
  //       chmin(dist[I][J],dist[I][K]+dist[K][J]);
  //     }
  //   }
  // }

  int r2=1<<r;
  vvi dp(r2,vi(r,inf));
  rep(i,0,r)dp[1<<i][i]=0;
  rep(bn,0,r2){
    rep(i,0,r){
      if(~bn>>i&1)continue;
      rep(j,0,r){
        if(bn>>j&1)continue;
        chmin(dp[bn|1<<j][j],dp[bn][i]+dist[i][j]);
      }
    }
  }

  int ans=inf;
  rep(i,0,r)chmin(ans,dp[r2-1][i]);
  if(ans==inf)ans=-2;
  co(++ans);
}


/*************************************************************************
	> File Name: 2.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com
	> Blog: https://blog.csdn.net/Pig_cfbsl
	> Created Time: 2020/10/24 21:01:12
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=2e5+10,mod=998244353;
LL n,k,a[maxx][320],sum[320],ans[320],c[320][320];
void init(){
	For(i,0,300) c[0][i]=1;
	For(i,1,300) For(j,1,i)
		c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
}
LL qpow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	init();
	LL inv=qpow(2,mod-2);
	n=read(); k=read();
	For(i,1,n){
		a[i][1]=read();
		For(j,2,k) a[i][j]=a[i][j-1]*a[i][1]%mod;
	}
	For(i,1,k) For(j,1,n) (sum[i]+=a[j][i])%=mod;
	For(i,1,k)
		For(j,1,k-i){
			ans[i+j]=(ans[i+j]+c[i+j][i]*sum[i]%mod*sum[j]%mod)%mod;
		}
	For(i,2,k){
		(ans[i]-=(qpow(2,i)-2)*sum[i]%mod)%=mod;
		ans[i]=ans[i]*inv%mod;
	}
	For(i,1,k){
		(ans[i]+=sum[i]*(n-1)%mod)%=mod;
		printf("%lld\n",(ans[i]+mod)%mod);
	}

	return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2e5 + 8;
const int K = 301;
const int MOD = 998244353;

int add(int a, int b) {
    if (a + b < MOD) {
        return a + b;
    }
    return a + b - MOD;
}

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

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

int binpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b /= 2;
    }
    return res;
}

int divv(int a, int b) {
    return mul(a, binpow(b, MOD - 2));
}

int a[N];
int s[K];
int ans[K];
int C[K][K];

void init() {
    for (int i = 0; i < K; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
        }
    }
}

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

    init();

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        int c = 1;
        for (int j = 0; j < K; j++) {
            s[j] = add(s[j], c);
            c = mul(c, a[i]);
        }
    }
    for (int i = 0; i < K; i++) {
        for (int j = 0; i + j < K; j++) {
            int S = mul(s[i], s[j]);
            S = sub(S, s[i + j]);
            S = divv(S, 2);
            ans[i + j] = add(ans[i + j], mul(C[i + j][j], S));
        }
    }
    for (int i = 1; i <= k; i++) {
        cout << ans[i] << '\n';
    }
}


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

using ll=long long;
ll mod=1000000007;

int main(){
    ll N;
    cin >> N;
    set<ll> P;
    for(ll a=2;a*a<=N;a++){
        ll j=a*a;
        while(j<=N){
            P.insert(j);
            j*=a;
        }
    }
    cout << N-P.size() << endl;
}

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

#define int long long
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

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

	int ans = n;
	set<int> s;
	for(int i=2 ; i*i<=n ; i++){
		if(s.count(i)){
			continue;
		}
		int cnt = 0;
		int x = 1;
		while(x * i <= n){
			cnt++;
			x *= i;
			s.insert(x);
		}
		ans -= max(0LL, cnt - 1);
	}
	cout << ans << "\n";
}

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


#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define ll long long
#define INF 9999999999999999
#define rep(i,m,n) for(ll i = m;i < n;i++)
#define rrep(i,m,n) for(ll i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<ll,ll>
#define tint tuple<int, int, int>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000010
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, A, B;
    cin >> N >> A >> B;
    cout << N - A + B << endl;
}

#include<bits/stdc++.h>

using namespace std;

#define gc c=getchar()
#define r(x) read(x)
#define ll long long
#define db double

template<typename T>
inline void read(T&x){
    x=0;T k=1;char gc;
    while(!isdigit(c)){if(c=='-')k=-1;gc;}
    while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
}

ll n,k;

inline ll calc(ll x){
    if(x<2||x>2*n)return 0;
    return min(n,x-1)-max(1ll,x-n)+1;
}

int main(){
    // freopen(".in","r",stdin);
    // freopen(".out","w",stdout);
    r(n),r(k);
    ll ret=0;
    for(int i=2;i<=2*n;++i){
        ret+=calc(i)*calc(i-k);
    }
    printf("%lld\n",ret);
}


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

void solve()
{
    int a,b;
    cin >> a >> b;
    int mx=0;
    for (int k=1; k<=b; k++)
    {
      int z = (a+k-1)/k;
      int first = z*k;
      int second = (z+1)*k;
      if (first>=a && second<=b) mx = k;
    }
    cout << mx;
}

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

#if _local
#define _GLIBCXX_DEBUG
#endif

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

struct fastio{fastio(){cin.tie(nullptr);ios_base::sync_with_stdio(false);std::cout<<std::fixed<<setprecision(10);}}oitsaf;
#define rep(i,n) for(int i=0;i<int(n);++i)
using i64 = int64_t;
using pll = std::pair<int64_t,int64_t>;
constexpr char newl = '\n';
template<class T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U>std::istream&operator>>(std::istream&is,std::pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T,class U>std::ostream&operator<<(std::ostream&os,std::pair<T,U>const&p){os<<p.first<<" "<<p.second;return os;}
#if _local
struct debug_structure{template<class T>debug_structure&operator<<(const T&elm){std::cerr<<elm<<std::flush;return*this;}}dout;
#else
struct debug_structure{template<class T>debug_structure&operator<<(const T&elm){return*this;}}dout;
#endif

int main() {
  int n;
  cin >> n;
  vector<pll> a(n);
  cin >> a;
  i64 bsum = 0;
  for (auto [b, _] : a)
    bsum += b;
  auto cmp = [](pll a, pll b) {
    return a.first * 2 + a.second > b.first * 2 + b.second;
  };
  sort(begin(a), end(a), cmp);
  i64 asum = 0;
  int ans = 0;
  rep(i, n) {
    asum += a[i].first + a[i].second;
    bsum -= a[i].first;
    ans = i + 1;
    if (asum > bsum)
      break;
  }
  dout << asum << " " << bsum << newl;
  cout << (ans) << endl;
}


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

#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> ii;

const int N = 3e5;
const int INF = 1e9;
int n, k;
int st[4*N], lz[4*N];

void prop(int idx, int l, int r) {
    if (lz[idx] == 0) return;
    st[idx] += lz[idx];
    if (l < r) {
        lz[2*idx] += lz[idx];
        lz[2*idx+1] += lz[idx];
    }
    lz[idx] = 0;
}

void update(int idx, int l, int r, int x, int y, int val) {
    prop(idx,l,r);
    if (l > y || r < x) return;
    if (l >= x && r <= y) {
        lz[idx] += val;
        prop(idx,l,r);
        return;
    }
    int m = (l+r)/2;
    update(2*idx,l,m,x,y,val); update(2*idx+1,m+1,r,x,y,val);
    st[idx] = min(st[2*idx],st[2*idx+1]);
}

int minOf(int idx, int l, int r, int x, int y) {
    prop(idx,l,r);
    if (l > y || r < x) return INF;
    if (l >= x && r <= y) return st[idx];
    int m = (l+r)/2;
    return min(minOf(2*idx,l,m,x,y),minOf(2*idx+1,m+1,r,x,y));
}

int binser(int l, int r) {
    if (minOf(1,0,n,l,r) > 0) return r+1;
    if (l == r) return l;
    int m = (l+r)/2;
    if (l <= m && minOf(1,0,n,l,m) == 0) return binser(l,m);
    return binser(m+1,r);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int a; cin >> a;
        update(1,0,n,a,a,1);
    }
    ll ans = 0;
    while (k--) {
        int mex = binser(0,n);
        if (mex == 0) break;
        // cout << ">> " << mex << '\n';
        ans += mex;
        update(1,0,n,0,mex-1,-1);
    }
    cout << ans << '\n';
    return 0;
}

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = (ll)(a - 1); i >= (ll)(b); i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vl A(N);
    vl cnt(300001);
    rep(i,N){
        cin >> A[i];
        cnt[A[i]]++;
    }
    ll ans=0;
    ll now=K;
    rep(i,300001){
        chmin(now,cnt[i]);
        ans+=now;
    }
    cout << ans << endl;
}


/*
_/_/_/_/    _/_/_/_/_/  _/_/_/
_/      _/      _/    _/      _/
_/      _/      _/    _/      _/
_/      _/      _/    _/      _/
_/      _/      _/    _/  _/  _/
_/      _/  _/  _/    _/    _/_/
_/_/_/_/      _/_/     _/_/_/_/_/

_/_/_/_/    _/    _/  _/      _/
_/      _/   _/  _/   _/_/  _/_/
_/      _/    _/_/    _/ _/_/ _/
_/      _/     _/     _/  _/  _/
_/      _/    _/_/    _/      _/
_/      _/   _/  _/   _/      _/
_/_/_/_/    _/    _/  _/      _/

_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/         _/     _/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/     _/_/_/_/_/ _/_/_/_/_/

_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/         _/     _/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/     _/_/_/_/_/ _/_/_/_/_/
*/
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <iomanip>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int P = 998244353;

int norm(int x) { return x >= P ? (x - P) : x; }

void add(int &x, int y) { if ((x += y) >= P) x -= P; }

void sub(int &x, int y) { if ((x -= y) < 0) x += P; }

void exGcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  exGcd(b, a % b, y, x);
  y -= a / b * x;
}

int inv(int a) {
  int x, y;
  exGcd(a, P, x, y);
  return norm(x + P);
}

const int N = 3010, L = 15;

int A[L], B[L];
int f[L][N];
int ans[N], q[N];

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;

  for (int i = 1; i != L; ++i) {
    B[i] = (1 << i) - 1;
    A[i] = A[i - 1] + B[i];
  }

  f[0][0] = 1;
  for (int i = 0; i <= n; ++i) {
    for (int j = 1; A[j] <= i; ++j)
      sub(f[0][i], f[j][i - A[j]]);
    int j;
    for (j = 1; B[j] <= i; ++j)
      f[j][i] = norm(P - f[j - 1][i] + f[j][i - B[j]]);
    for (; B[j] <= n; ++j)
      f[j][i] = norm(P - f[j - 1][i]);
  }

  {
    int C = 0;
    for (int i = 0; C <= n; ++i, C = A[i]) {
      if (i)
        for (int j = B[i]; j <= n; ++j) add(f[0][j], f[0][j - B[i]]);
      memset(q, 0, sizeof(q));
      if (i & 1)
        for (int j = 0; j <= n - C; ++j) sub(q[j + C], f[0][j]);
      else for (int j = 0; j <= n - C; ++j) add(q[j + C], f[0][j]);
      for (int j = 1; j <= n >> i; ++j)
        add(ans[j], q[n - j * (1 << i)]);
    }
  }

  cout << ans[k] << '\n';

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
      -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}

# include <bits/stdc++.h>
# define ll long long
# define db double
# define ld long double
# define pb push_back
# define fir first
# define sec second
# define rep(i, l, r) for (int i = l; i <= r; i++)
# define per(i, r, l) for (int i = r; i >= l; i--)
using namespace std;
const int N = 200010;
typedef pair <int, int> P;

struct node {
    int to, next;
} ed[N * 2];

int sz, head[N], n, k;
set <P, greater <P> > ss;

void addEdge(int from, int to) {
    ed[++sz].next = head[from];
    ed[sz].to = to;
    head[from] = sz;
}

int read() {
    int x = 0; char c = getchar(), flag = '+';
    while (!isdigit(c)) flag = c, c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    return flag == '-' ? -x : x;
}
// void dfs2(int u, int dis) {
//     ss.erase(P(deep[u], u));
//     if (!dis) return;
//     for (int i = head[u]; i; i = ed[i].next) {
//         int v = ed[i].to;
//        // if (v == ff) continue;
//         dfs2(v, dis - 1);
//     }
// }
P dfs(int u, int ff, int x) {
    P ss = P(0, 0);
    for (int i = head[u]; i; i = ed[i].next) {
        int v = ed[i].to;
        if (v == ff) continue;
        P tt = dfs(v, u, x);
        tt.sec++;
        ss.fir += tt.fir;

        if (ss.sec + tt.sec < 0) ss.sec = min(ss.sec, tt.sec);
        else ss.sec = max(ss.sec, tt.sec);

    }
    if (ss.sec == x || u == 1 && ss.sec >= 0) ss.fir++, ss.sec = -x - 1;
    return ss;
}
bool check(int x){
    return dfs(1, 0, x).fir <= k;
}

// void dfs1(int u, int ff) {
//     deep[u] = deep[ff] + 1;
//     fa[u] = ff;
//     for (int i = head[u]; i; i = ed[i].next) {
//         int v = ed[i].to;
//         if (v == ff) continue;
//         dfs1(v, u);
//     }
// }
int main() {
    n = read(), k = read();
    rep (i, 1, n - 1) {
        int u = read(), v = read();
        addEdge(u, v);
        addEdge(v, u);
    }
    //dfs1(1, 0);

    int l = 0, r = n, ans = -1;
    while (l <= r) {
        int mid = l + r >> 1;
        if (check(mid)) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    cout << ans;
    return 0;
}
/* by DT_Kang */


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> v(n);
  for (auto &x : v) cin >> x;
  long long ans = 0;
  sort(v.begin(), v.end());
  for (long long i = 0; i < n; ++i) {
    ans += i * v[i] - (n - i - 1) * v[i];
  }
  cout << ans;
}

#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>

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'
 #define mod 1000000007
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    ll n;
    cin>>n;
    ll i,ar[n+2],br[n+3];
    ll sum=0;
    for(i=0;i<n;i++)cin>>ar[i];
    for(i=0;i<n;i++)
    {
        cin>>br[i];
        sum+=(ar[i]*br[i]);
    }
    if(sum==0)cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}


#include <bits/stdc++.h>

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int x;
	cin >> x;
	if(x <= 0) cout << 0;
	else cout << x;

	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const double pi = 3.14159265358979323846264;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main()
{
    ll x;
    cin >> x;
    cout << seinomi(x) << endl;
}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
int n,k;
char c[110];
signed main(){
    n=read(),k=read();
    cin>>(c+1);
	for(int i=1;i<=k;i++) {
	 	for(int j=n+1;j<=2*n;j++) c[j]=c[j-n];
		for(int j=1;j<=n;j++) {
			if(c[j*2-1]=='S'){
				if(c[j*2]=='R') c[j]=c[j*2];
				else c[j]=c[j*2-1];
			}
			if(c[j*2-1]=='R'){
				if(c[j*2]=='P') c[j]=c[j*2];
				else c[j]=c[j*2-1];
			}
			if(c[j*2-1]=='P'){
				if(c[j*2]=='S') c[j]=c[j*2];
				else c[j]=c[j*2-1];
			}
		}
	}
	cout<<c[1];
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    string s;
    bool winner[4][4] = {{true,false,true,false},{false,false,false,false},{false,false,true,true},{true,false,false,true}};
    string win;
    cin >> n >> k >> s;
    while(k--)
    {
        int len = s.size();
        if(len & 1)
        {
            len += len;
            s += s;
        }
        win.clear();
        for(int i = 0;i < len;i+=2)
        {
            win += winner[s[i] - 'P'][s[i+1]-'P']?s[i]:s[i+1];
        }
        s = win;
    }
    printf("%c\n",win[0]);
}


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

int main(){//main_program
  int H,W,X,Y;
  int count = 1;
  cin >> H >> W >> X >> Y;
  vector<vector<char>> data(H, vector<char>(W));

  for(int i = 1;i<=H;i++){
    for(int l = 1;l<=W;l++){
      cin >> data.at(i-1).at(l-1);
    }
  }

  for(int i = X-2 ;i >= 0 ; i--){
    if( data.at(i).at(Y-1) == '.'){
      count++;
    }else{
      break;
    }
  }
  //
  for(int i = X ;i < H ; i++){
    if( data.at(i).at(Y-1) == '.'){
      count++;
    }else{
      break;
    }
  }
  //
  //
    for(int i = Y-2 ;i >= 0 ; i--){
    if( data.at(X-1).at(i) == '.'){
      count++;
    }else{
      break;
    }
  }
  //
  for(int i = Y ;i < W ; i++){
    if( data.at(X-1).at(i) == '.'){
      count++;
    }else{
      break;
    }
  }
  cout << count << endl;
}

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 200005

struct Info{
	Info(){

		kei = value = 0;
	}
	Info(double arg_kei,double arg_value){
		kei = arg_kei;
		value = arg_value;
	}
	Info operator+(const struct Info& arg) const{

		return Info(kei+arg.kei,value+arg.value);
	}
	Info operator-(const struct Info& arg) const{

		return Info(kei-arg.kei,value-arg.value);
	}
	Info operator/(int div) const{

		return Info(kei/div,value/div);
	}

	double kei,value;
};

int N,M,K;
bool check[SIZE];
Info info[SIZE];

int main(){

	scanf("%d %d %d",&N,&M,&K);

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

		check[i] = true;
	}

	int tmp;
	for(int i = 0; i < K; i++){

		scanf("%d",&tmp);
		check[tmp] = false;
	}

	for(int i = 0; i < M; i++){

		info[N+i].kei = 0;
		info[N+i].value = 0;
	}

	Info sum;

	for(int i = N-1; i >= 0; i--){

		if(!check[i]){

			info[i].kei = 1;
			info[i].value = 0;

		}else{

			info[i] = sum/M + Info(0,1);
		}

		sum = sum+info[i];
		sum = sum-info[i+M];
	}

	double a = info[0].kei;
	double b = info[0].value;

	if(1-a < EPS){

		printf("-1\n");
	}else{

		printf("%.12lf\n",b/(1.0-a));
	}

	return 0;
}


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

long long rev(long long num)
{
    int digit, rev = 0;
    do
    {
        digit = num % 10;
        rev = (rev * 10) + digit;
        num = num / 10;
    } while (num != 0);

    return rev;
}

long long deleteTrail(long long num)
{
    num = rev(num);
    num = rev(num);
    return num;
}

bool palindrom(long long num)
{
    return rev(num) == num;
}

int main()
{
    long long s;
    cin >> s;

    if (palindrom(deleteTrail(s)))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int i,f=0,p=0;
    string s,s1;
    cin>>s;
    for(i=s.size()-1; i>=0; i--)
    {
        if(s[i]!='0')
            break;
         else if(s[i]=='0')
            p++;
    }
    for(i=1; i<=p; i++)
    {
        s1+='0';
    }
    //cout<<s1<<endl;
    for(i=0; i<s.size(); i++)
    {
        s1+=s[i];
    }
    //cout<<s1;
    for(i=0; i < s1.size() ; i++)
    {
        if(s1[i] != s1[s1.size()-i-1])
        {
            f = 1;
            break;
        }
    }
    if(f==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  long long L,S=1;cin>>L;
  for(int X=1;X<12;X++){
    S*=L-X;S/=X;
  }
  cout<<S<<endl;
}

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define mod 1000000007
#define one(x)   __builtin_popcountll(x)
#define zero(x)  __builtin_ctzll(x)
#define pp pair<ll,ll>
#define all(x) (x).begin(), (x).end()
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
typedef long long int ll;

const int mxn = 2e5 + 10;

/*
ll n,q;
ll ar[200001];
ll t[800004];

 void build(ll index,ll l, ll r){
     if(l==r){
         t[index]=ar[l];
         return ;
     }
     ll mid=(l+r)/2 ;
     build(index*2,l,mid);
     build(index*2+1,mid+1,r);
     t[index]=t[index*2]^t[index*2+1];
 }

 void update(ll index, ll l ,ll r, ll pos, ll val){
     if(pos<l || pos>r){
         return;
     }
     if(l==r){
         t[index]=val;
         ar[l]=val;
         return ;
     }
     ll mid=(l+r)/2 ;
     update(index*2,l,mid,pos,val);
     update(index*2+1,mid+1,r,pos,val);
     t[index]=min(t[index*2],t[index*2+1]);
 }

 ll query(ll index,ll l, ll r, ll lq, ll rq){
     if(rq<l || lq>r){
         return 0;
     }
     if(lq<=l && r<=rq){
         return t[index];
     }

     ll mid=(l+r)/2 ;
     return query(index*2,l,mid,lq,rq)^query(index*2+1,mid+1,r,lq,rq);
 }*/

//ll a[mxn];

ll dp[12];
void subMain(){
    ll n;
    cin >> n;
    dp[0] = 1;
    while(--n){
        for(ll i = 10; i >= 0; i--){
            dp[i+1]+=dp[i];
        }
    }
    cout << dp[11];
}

int main(){

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

    /*ll t, i = 0;
	cin >> t;
	while(t--){
        //cout << "Case #" << i+1 << ": ";
        subMain();
        //i++;
	}*/
	subMain();
	cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define irreps(i, m, n) for (int i = ((int)(n)-1); i > (int)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (int)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;
using ld = long double;

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

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
// const ll MOD = 1e9+7;
const ll MOD = 998244353;
const ll LINF = 1e18;

// 以下の操作が行える時、SをTに一致させられるか
// 011..1 :0が連続している区間から始めて登場する1とswap
// 11..10 :逆
// まずこの操作によってある0（1でもよい）は任意の場所に移動できると気付く
// 正確には、0001100みたいに先頭から0が3個、1が2個、0が2個みたいな情報が与えられたとき、0，1の個数が一致するなら必ずそれが作れるということ
// 以下は0，1の個数が一致する場合
// s,tの0のindexをリスト化する(a,bとする)
// a[i]!=b[i]なら、明らかにs[a[i]]はいずれかの1とswapする必要があるが、この時aの他の要素が変化することはない（swapするのは1なので）
// 上記から、少なくともa[i]!=b[i]の個数だけ操作する必要があるとわかる
// どのような場合でも最適に操作すれば、上の個数回だけの操作で一致させられるか？ => 可能
// 今いくつかa[i]!=b[i]であるようなiが存在するとする
// 今移動させられるiとswapできるs[x]==1 && s[x]!=t[x]なるindex xが存在するはずで、これを適切な組合せと順序でswapしていけば（端から処理するイメージ）よい
// s=10111001
// t=01011011
// 上の例なら、今a[0]=1を見ているなら、x=0(前方)となる
// a[i]!=b[i]なるiが存在していて、1手で操作できる範囲にxが存在しないということは有り得ない
// s=101
// t=?1?
// （a,bの長さが一致するなら、0,2のいずれかは0である）tの0,2いずれを0にするとしても必ず s,tは1手で一致させられる

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

  int n; cin>>n;
  string s,t; cin>>s>>t;

  vc<int> a,b;
  rep(i,n) {
    if(s[i]=='0') a.push_back(i);
    if(t[i]=='0') b.push_back(i);
  }

  if(a.size()!=b.size()) {
    cout<<-1<<endl;
    return 0;
  }

  int ans=0;
  rep(i,a.size()) if(a[i]!=b[i]) ans++;
  cout<<ans<<endl;
}

#include<bits/stdc++.h>

using namespace std;

const int maxn = 1e6+1;
long long st[maxn], tot;
long long ts[maxn], cnt;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i = 1; i <= n; ++ i) {
        if (s[i-1] == '0') st[++tot] = i;
        if (t[i-1] == '0') ts[++cnt] = i;
    }
    if (tot != cnt) {
        cout << "-1" << "\n";
    }
    else {
        long long ans = 0;
        for(int i = 1; i <= tot; ++ i) {
            if (st[i] != ts[i]) ans ++;
        }
        cout << ans << "\n";
    }
    return 0;
}


    #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 int mod=998244353;
    const int INF=1001001001;

    template<typename T>
    struct BIT {
      int n;
      vector<T> d;
      BIT(int n=0):n(n),d(n+1) {}
      void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
          d[i] += x;
        }
      }
      T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
          x += d[i];
        }
        return x;
      }
      T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
      }
    };

    int main() {
      int N;
      cin>>N;
      vector<int>a(N);
      rep(i,N){cin>>a[i];}
      BIT<int>d(N);
      ll sum=0;
      rep(i,N){
        sum+=d.sum(a[i]+1,N);
        d.add(a[i]);
      }
      rep(i,N){
        cout<<sum<<endl;
        sum=-a[i]+N-1-a[i]+sum;
      }

      return 0;
    }

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
int main()
{

    long long n;
    cin>>n;
    long long int a[n];
    long long int c[200];
    for (int i=0;i<200;i++)
        c[i]=0;
    for (int i=0;i<n;i++)
    {
          cin>>a[i];
          int m=a[i]%200;
             c[m]++;
    }
   long long int count=0;
    for (int i=0;i<200;i++)
    {
     count=count+(c[i]*(c[i]-1)/2);

    }
    cout<<count<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e3+9;
const int MAX=6e5+9;
const int MAX1=5e6+9;
const int INF=0x3f3f3f3f;
const double ep=1e-8;
const double ep1=1e-4;
const int mod=998244353;
const double inf=1e20;
const double pi=acos(-1);
#define debug1 puts("?");
#define debug(x) cout<<"##"<<(x)<<endl;
#define mk make_pair
#define PII pair<int,int>
#define PDI pair<double,int>
#define PIII pair<int,PII >
#define PIII1 pair<PII,int>
#define PIIII pair<PII,PII >
#define PIL pair<int,ll>
#define PLI pair<ll,int>
#define PLIII pair<PLI,PII >
#define PLL pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
#define plldk(x) printf("%lld ",(x))
#define pdd(x,y) printf("%d %d\n",(x),(y))
#define PR(x) printf("Case %d: ",(x))
#define INF 0x3f3f3f3f
typedef unsigned long long ull;
/*
*/
struct node{
	int to,nex;
	ll val;
}a[maxn];
int n,m;
int head[maxn],cnt;
void add(int fro,int to,ll val)
{
	a[++cnt].to=to;
	a[cnt].val=val;
	a[cnt].nex=head[fro];
	head[fro]=cnt;
}
ll d[maxn];
void bfs(int x)
{
	priority_queue<PLI,deque<PLI >,greater<PLI > >q;
	q.push(mk(0,x));
	bool ju=0;
	while(!q.empty())
	{
		PLI p=q.top();q.pop();
		int cur=p.se;
		ll val=p.fi;
		if(cur==x&&val)
		{
			plld(val);
			return;
		}
//		cout<<cur<<' '<<val<<endl;
		for(int i=head[cur];i;i=a[i].nex)
		{
			int to=a[i].to;
//			cout<<to<<' '<<a[i].val<<' '<<d[to]<<endl;
			if(val+a[i].val<d[to])
			{
				d[to]=val+a[i].val;
				q.push(mk(d[to],to));
//				if(to==x)ju=1;
			}
		}
	}
	puts("-1");
}
void solve()
{
	sdd(n,m);
	rep(i,1,m)
	{
		int u,v;
		ll w;
		sdd(u,v);
		slld(w);
		add(u,v,w);
	}
	rep(i,1,n)
	{
		memset(d,INF,sizeof d);
		bfs(i);
	}
}
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int T=1;
//    sd(T);
    while(T--)solve();
}

#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack>
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};

ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}

int main(){
    int n,m;
    cin >> n >> m;
    map<int,int> mp;

    REP(i,n){
        int x;
        cin >> x;

        mp[x]++;
    }

    REP(i,m){
        int x;
        cin >> x;

        mp[x]++;
    }

    for(auto x:mp){
        if(x.second != 2){
            cout << x.first << " ";
        }
    }
    cout << endl;
}

//500000500000
//963761198400
//4500001500000
//505013002500


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
typedef long long ll;
const ll mod = 1e9 + 7;
string s;
int k, a[N], n;

int work(int x) {
    int ans = 0;
    while (x) {
        if (x & 1) ans++;
        x = x / 2;
    }
    return ans;
}

ll dp[N][20];

ll dfs(int p, int stat, int limit) {
    int cnt = work(stat);
   // cout << p << " " << cnt << " " << stat  << endl;
    if (cnt > k) return 0;
    if (p == n) {
        if (cnt == k) return 1;
        return 0;
    }
    if (!limit && dp[p][cnt] != -1) return dp[p][cnt];
    int maxn = 15;
    if (limit) {
        maxn = a[p];
    }
    ll ans = 0;
    for (int i = 0; i <= maxn; i++) {
        ans += dfs(p + 1, stat | (1 << i), limit && i == maxn);
        ans = ans % mod;
    }
    if (!limit) dp[p][cnt] = ans;
    return ans;

}

void solve() {
    ll ans = 0;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; i++) {
        int maxn = 15;
        if (i == 0) {
            maxn = a[0];
        }
      //  cout << "Maxn " << maxn << endl;
        for (int j = 1; j <= maxn; j++) {

            ans += dfs(i + 1, (1 << j), i == 0 && j == maxn);
            ans = ans % mod;
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> s >> k;
    n = s.length();
    for (int i = 0; i < s.length(); i++) {
        if (s[i] >= '0' && s[i] <= '9') {
            a[i] = s[i] - '0';
        } else {
            a[i] = s[i] - 'A' + 10;
        }
    }
    solve();
}

#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll f[200010][17][2][2],ans;int k,n,a[200010];
char s[200010];
int num(int x)
{
    if(s[x]<='9'&&s[x]>='0') return s[x]-'0';
    return s[x]-'A'+10;
}
ll dfs(int pos,int st,int maxx,bool zero)
{
    int cnt=__builtin_popcount(st);
    if(pos>n) return cnt==k;
    if(cnt>k) return 0ll;
    if(pos>n) return cnt==k&&!zero;
    if(f[pos][cnt][maxx][zero]!=-1) return f[pos][cnt][maxx][zero];
    int to=maxx?a[pos]:15;
    ll ans=0;
    for(int i=0;i<=to;i++)
        if(!i&&zero) ans=(ans+dfs(pos+1,0,0,1))%mod;
        else ans=(ans+dfs(pos+1,st|(1<<i),maxx&&i==to,0))%mod;
    f[pos][cnt][maxx][zero]=ans;
    return ans;
}
int main()
{
    scanf("%s %d",s+1,&k);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
        a[i]=num(i);
    memset(f,-1,sizeof(f));
    printf("%lld",dfs(1,0,1,1));
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define al(a) a.begin(), a.end()
#define ral(a) a.rbegin(), a.rend()
#define sz(a) (int)a.size()

using C = complex<double>;
C inC() {
  double x, y;
  cin >> x >> y;
  return C(x, y);
}
int main() {
  int n;
  cin >> n;
  C s = inC();
  C t = inC();

  C o = (s + t) / 2.0; //原点
  double PI = acos(-1);
  double rad = 2 * PI / n; //ラジアン
  C r(cos(rad), sin(rad)); //距離1、偏角?

  //(s - o)逆ベクトル?、(*r)反時計回りの角度を足す(距離はそのまま)
  //(+o)出来たベクトルを原点に合わせる?
  C ans = (s - o) * r + o;

  cout << fixed << setprecision(11) << ans.real() << " ";
  cout << fixed << setprecision(11) << ans.imag() << endl;
  return 0;
}
//難しい! 複素数! ラジアン! それらのライブラリ! ベクトル!
// int main() {
//   int n;
//   cin >> n;

//   double x, y;
//   complex<double> a, b;
//   cin >> x >> y, a = {x, y}; //複素数オブジェクトの初期化
//   cin >> x >> y, b = {x, y};

//   auto m = (a + b) / 2.0;

//   auto res = m + (a - m) * polar(1.0, M_PI * 2.0 / n);
//   // polar(r, t)長さr,角度(ラジアン)tの複素数
//   // M_PIでPIが取れる!!
//   cout << fixed << setprecision(11) << res.real() << " " << res.imag() <<
//   endl;
// }

// using C = complex<double>; //複素数ライブラリ
// C inC() {
//   double x, y;
//   cin >> x >> y;
//   return C(x, y); // C(実部, 虚部)複素数オブジェクト
// }

// int main() {
//   int n;
//   cin >> n;
//   C s = inC();
//   C t = inC();

//   C o = (s + t) / 2.0;  //中心点を取る
//   double PI = acos(-1); //これでPIが取れる!!
//   // cout << PI << endl;
//   double rad = 2 * PI / n;
//   // cout << rad << endl;
//   // n=4 Π=90° rad=1.5708.. /n=6 Π=60° rad=1.0472..
//   C r(cos(rad), sin(rad));
//   // cout << "cos(rad) " << cos(rad) << ", sin(rad) " << sin(rad) << endl;
//   // n=4 r(6.123.. , 1) / n=6 r(0.5, 0.866..)
//   C ans = o + (s - o) * r;
//   //
//   s-oでoからsへ伸びるベクトルが得られ、それを2π/nだけ回転したベクトルを、mに足す
//   cout << fixed << setprecision(11) << ans.real() << " " << fixed
//        << setprecision(11) << ans.imag() << endl;
//   return 0;
// }

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LARGE_PRIME_NUM (1e9+7)
typedef long long ll;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

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