#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using P = pair<ll, int>;
const ll INF = 1e18;

struct Edge {
    int to, t, k;
    Edge(int to, int t, int k): to(to), t(t), k(k) {}
};

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    --x; --y;

    vector<vector<Edge>> g(n);
    REP(i, m){
        int a, b, t, k;
        cin >> a >> b >> t >> k;
        --a; --b;
        g[a].emplace_back(b, t, k);
        g[b].emplace_back(a, t, k);
    }

    vector<ll> dist(n, INF);
    priority_queue<P, vector<P>, greater<P>> pq;

    auto push = [&](int v, ll x){
        if(dist[v] <= x) return;
        dist[v] = x;
        pq.emplace(x, v);
    };

    push(x, 0);

    while(!pq.empty()){
        auto [x, v] = pq.top(); pq.pop();
        if(dist[v] != x) continue;
        for(Edge& e : g[v]) {
            ll nx = (x + e.k - 1)/e.k*e.k + e.t;
            push(e.to, nx);
        }
    }

    ll ans = dist[y];
    if(ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
typedef long long ll;

int n,s[N],t[N],from[N];
char str[N];
set<int> pos[2];
ll ans;

int main() {
#ifdef LOCAL
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>(str+1);
	for(int i=1;i<=n;i++) s[i]=str[i]-'0';
	cin>>(str+1);
	for(int i=1;i<=n;i++) t[i]=str[i]-'0';
	for(int i=1;i<=n;i++) s[i]^=s[i-1],t[i]^=t[i-1],pos[s[i]].insert(i);
	for(int i=1;i<=n;i++) {
		auto it=pos[t[i]].lower_bound(max(from[i-1],i));
		if(it==pos[t[i]].end()) return cout<<-1,0;
		from[i]=*it;
	}
	for(int i=1;i<=n;i++)
		if(from[i]!=from[i-1]) ans+=from[i]-i;
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>
#define NIL (-1)
#define ll long long
using namespace std;
const double PI = acos(-1.0);

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

	bitset<100001> dp;
	dp[0] = 1;
	int tot = 0;
	for (int i = 0; i < N; i++) {
		int T;
		cin >> T;
		tot += T;
		dp |= dp << T;
	}
	//cout << dp << endl;

	//cout << tot << endl;
	int ans = tot;
	for (int i = 0; i < dp.size(); i++) if (dp[i]) ans = min(ans, max(i, (tot - i)));
	cout << ans << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main() {

int n;
int sum=0;
cin>>n;
int a[n],b[n];
for (int i = 0; i <n; i++)
{
  cin>>a[i];
}
for (int i = 0; i <n; i++)
{
  cin>>b[i];
}
for (int i = 0; i <n; i++)
{
  if (a[0]<a[i])
  {
    a[0]=a[i];
  }

  if (b[0]>b[i])
  {
    b[0]=b[i];
  }

}

for (int i = a[0]; i <=b[0]; i++)
{
  sum++;
}

cout<<sum;

return 0;

}


#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double ld;

#define NN 60
constexpr ll M = 998244353;

vector<ll> edges[2][NN];
ll used[NN];
ll a[NN][NN];

ll f[NN];

ll dfs(ll u, bool t) {
    used[u] = 1;
    ll tot = 1;
    for (auto v:edges[t][u]) if (!used[v])tot+=dfs(v, t);
    return tot;
}

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

	f[0] = 1;
	for (ll i=1; i<NN; ++i) f[i] = f[i-1]*i%M;

	ll n, K;
	cin>>n>>K;
	for (ll i=0; i<n; ++i) for(ll j=0; j<n; ++j) cin>>a[i][j];
    for (ll x=0; x<n; ++x) {
        for (ll y=x+1; y<n; ++y) {
            for (ll i=0; i<n; ++i) {
                if (a[i][x]+a[i][y]>K) goto rfail;
            }
            edges[0][x].push_back(y);
            edges[0][y].push_back(x);

            rfail:;

            for (ll i=0; i<n; ++i) {
                if (a[x][i]+a[y][i]>K) goto cfail;
            }
            edges[1][x].push_back(y);
            edges[1][y].push_back(x);

            cfail:;
        }
    }

	ll ans = 1;
	for (ll i=0; i<n; ++i) if (!used[i]) ans = ans*f[dfs(i, 0)]%M;
	memset(used, 0, sizeof used);
	for (ll i=0; i<n; ++i) if (!used[i]) ans = ans*f[dfs(i, 1)]%M;
	cout<<ans<<endl;
}

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) {
    int ret = 1; while (b > 0) {
        if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1;
    } return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }
typedef vector<int> Vec;
typedef vector<Vec> Mat;
Vec mulMatVec(Mat a, Vec b)
{
    int n = b.size(); Vec ret(n, 0);
    rep(i, 0, n) rep(j, 0, n) ret[i] = add(ret[i], mul(a[i][j], b[j]));
    return ret;
}
Mat mulMatMat(Mat a, Mat b)
{
    int n = a.size(); Mat ret(n, Vec(n, 0));
    rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) ret[i][j] = add(ret[i][j], mul(a[i][k], b[k][j]));
    return ret;
}
Mat fastpow(Mat x, ll n)
{
    Mat ret(x.size(), Vec(x.size(), 0));
    rep(i, 0, x.size()) ret[i][i] = 1;
    while (0 < n) { if ((n % 2) == 0) { x = mulMatMat(x, x); n >>= 1; } else { ret = mulMatMat(ret, x); --n; } }
    return ret;
}
void printVec(Vec a) { cout << "[\t"; rep(i, 0, a.size()) cout << a[i] << "\t"; cout << "]" << endl; }
void printMat(Mat a) { rep(i, 0, a.size()) printVec(a[i]); }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, M, K, A[101];
int X[10101], Y[10101];
int cnt[101];
bool E[101][101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> K;
	rep(i, 0, N) cin >> A[i];
    rep(i, 0, M) cin >> X[i] >> Y[i], X[i]--, Y[i]--;

    Mat Ma(N, Vec(N));
	rep(i, 0, M) {
        cnt[X[i]]--;
        cnt[Y[i]]--;
        E[X[i]][Y[i]] = E[Y[i]][X[i]] = true;
	}

    rep(to, 0, N) {
        int cnt = M;
        rep(from, 0, N) if (to != from) {
            if (E[to][from]) {
                Ma[to][to] = add(Ma[to][to], mul(modinv(M), modinv(2)));
                Ma[to][from] = add(Ma[to][from], mul(modinv(M), modinv(2)));
                cnt--;
            }
        }
        Ma[to][to] = add(Ma[to][to], mul(cnt, modinv(M)));
    }

    Vec v(N, 0);
    rep(i, 0, N) v[i] = A[i];

    Ma = fastpow(Ma, K);
    v = mulMatVec(Ma, v);
    rep(i, 0, N) cout << v[i] << endl;
}


#include <iostream>
#include <cmath>
#include <iomanip>
typedef long long ll;
using namespace std;

int main() {
	int N, tmp;
	ll mand = 0, powsum = 0, chebid = 0;
	double eucd;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		mand += abs(tmp);
		powsum += pow(tmp, 2);
		if (chebid < abs(tmp)) {
			chebid = abs(tmp);
		}
	}
	eucd = sqrt(powsum);
	cout << mand << endl;
	cout << fixed << setprecision(10) <<eucd << endl;
	cout << chebid << endl;
	return 0;
}

#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <stack>
#include <queue>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	REP(i,n) cin >> x[i];

	ll m=0;
	ll eu=0;
	ll che=0;
	REP(i,n){
		m += abs(x[i]);
		eu  += (ll)x[i]*x[i];
		chmax(che, (ll)abs(x[i]));
	}
	long double ans = sqrt(eu);
	printf("%Ld\n%.12Lf\n%Ld\n", m, ans, che);

	return 0;
}


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

const int MAXN = 2e5 + 5;

int st[MAXN], ed[MAXN], idx;
vector<int> e[MAXN], h[MAXN];
void dfs(int u, int fa, int depth) {
    st[u] = idx++;
    h[depth].push_back(st[u]);
    for (int v: e[u]) {
        if (v == fa) continue;
        dfs(v, u, depth + 1);
    }
    ed[u] = idx;
}
signed main(int argc, char *argv[]) {
	int n;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        int fa;
        cin >> fa;
        e[fa].push_back(i);
    }
    dfs(1, -1, 0);
    int q;
    cin >> q;
    while (q--) {
        int u, d;
        cin >> u >> d;
        #define ALL(vec) vec.begin(), vec.end()
        cout << lower_bound(ALL(h[d]), ed[u]) - lower_bound(ALL(h[d]), st[u]) << '\n';
    }
	system("pause");
}

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pqi priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) vector<int> a(n+f);for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define printdecimal(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define mod (int)(1e9+7)
#define inf LLONG_MAX
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int exp(int x,int y){int val=1;x=x%mod;while(y>0){if(y&1)val=(val*x)%mod;y=y>>1;x=(x*x)%mod;}return val;}
int modinv(int x){return exp(x,mod-2);}
int add(int a,int b){a%=mod,b%=mod;a=((a+b)%mod+mod)%mod;return a;}
int sub(int a,int b){a%=mod,b%=mod;a=((a-b)%mod+mod)%mod;return a;}
int mul(int a,int b){a%=mod,b%=mod;a=((a*b)%mod+mod)%mod;return a;}

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

	int n,ans=0;
	cin>>n;
	inp(a,n,0);
	map<int, int> m;
	for(int i:a)
		ans+=m[i%200],m[i%200]++;
	cout<<ans;
	return 0;
}


//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
//#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <random>
#include <cassert>
#include <cstring>
#include <sstream>
#include <complex>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <unordered_map>

using namespace std;
//int input........
template <typename T> inline void readline(T &n) {n = 0; int f = 1; register int ch = getchar();
 for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;for (; isdigit(ch);
ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
// long long input........
template <typename T> inline void readlinel(T &n) {n = 0; long long f = 1; register long long ch = getchar();
 for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;for (; isdigit(ch);
ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readlinel(T &n, TT &m) { readlinel(n); readlinel(m); }
template <typename T, typename TT, typename TTT> inline void readlinel(T &n, TT &m, TTT &l) { readlinel(n, m); readlinel(l);}
//debug..........
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
int dx[8]= {1,0,-1,0,-1,-1,1,1};int dy[8]= {0,1,0,-1,-1,1,-1,1}; int tc = 1;
#define F first
#define S second
#define pb  push_back
#define mp make_pair
#define Pi atan(1)*4
#define ll  long long int
#define happy cin.tie(0);
#define point(x) setprecision(x)
#define coding ios::sync_with_stdio(false);
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;
void print(int n){printf("%d\n", n);}
void Print(int n){printf("%d ", n);}
void print(int n,int m){printf("%d ",n);printf("%d ",m);}
void print(int n,int m,int k){printf("%d ",n);printf("%d ",m);printf("%d ",k);}
void print(ll n){printf("%I64d\n", n);}
void Print(ll n){printf("%I64d ", n);}
void print(ll n,ll m){printf("%I64d ",n);printf("%I64d ",m);}
void print(ll n,ll m,ll k){printf("%I64d ",n);printf("%I64d ",m);printf("%I64d ",k);}
int length(long long x){int l = 0;for(long long i=x;i;i/=10)l++;return l;}
int length(string s){return s.size();}
const int M           	= 1e9 + 7;
long long pow(long long a,long long n){ll res = 1;while(n){if(n&1) res = ((res%M)*(a%M))%M;a = ((a%M)*(a%M))%M;n>>=1;}return res%M;}

#define   pr 	pair<int, int>
#define   vpr 	vector<pr>
#define   vi   	std::vector<int>
#define   vll  	std::vector<ll>
#define   all(n) n.begin(),n.end()

const int Inf           = (int)2e9 + 5;
const ll  Lnf           = (ll)2e18 + 5;
const int N             = 4e5 + 5;
const int NN            = 1e6 + 5;

int solve()
{
	//happy coding

	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}

	int mn = 0;
	map<int,int>vis;

	for(int i=0;i<n;i++){
		vis[a[i]] = 1;
		if(vis[mn] == 0){
			cout<<mn<<endl;
		}else{
			while(vis[mn])mn++;
			cout<<mn<<endl;
		}
	}

	return 0;
	//error();
}
int main(){
	int test = 1;
	//readline(test);//(void)getchar();
	while (test--)solve();return 0;
}

#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long

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

    vector<ll int> a(N);

    for( ll int i = 0; i < N; i++){
        cin >> a.at(i);
    }

    vector<ll int> sum_each_step(N);

    ll int max_at_each_step = 0;
    ll int max_point = 0;

    // 1 ステップ目について
    sum_each_step.at(0) = a.at(0);

    if( sum_each_step.at(0) > 0){
        max_at_each_step = sum_each_step.at(0);
        max_point += max_at_each_step;
    }

    ll int last_point_pre_step = 0;

    for( ll int i = 1; i < N; i++){
        // 1 個前までのステップで進んだ点
        last_point_pre_step += sum_each_step.at(i-1);

        // i = 1 なら 0（１ステップ）までの進行　+ 1 （２ステップ）での進行
        sum_each_step.at(i) = sum_each_step.at(i-1) + a.at(i);

        if( sum_each_step.at(i) > max_at_each_step ){
            max_at_each_step = sum_each_step.at(i);
        }

        if( last_point_pre_step + max_at_each_step > max_point ){
            max_point = last_point_pre_step + max_at_each_step;
        }
    }

    cout << max_point;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double Lf;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;
const int maxk = 305;
const int INF = 998244353;

class Number{
public:
	int dat;
	Number(){}
	Number(int dat_): dat(dat_){}
	inline Number&operator += (const Number &oth){ (dat += oth.dat) -= (dat >= INF ? INF : 0); return *this; }
	inline Number&operator -= (const Number &oth){ (dat -= oth.dat) += (dat < 0 ? INF : 0); return *this; }
	inline Number&operator *= (const Number &oth){ dat = 1ll * dat * oth.dat % INF; return *this; }
	inline Number operator + (const Number &oth)const{ Number ret = *this; ret += oth; return ret; }
	inline Number operator - (const Number &oth)const{ Number ret = *this; ret -= oth; return ret; }
	inline Number operator * (const Number &oth)const{ Number ret = *this; ret *= oth; return ret; }
}a[maxn], binom[maxk][maxk], pw[2][maxn], s[maxk];

const Number inv2 = (INF + 1) / 2;

int n, k;

inline void precalc(){
	int p = 0, q = 1;
	REP(i, 0, k){
		binom[i][0] = 1;
		REP(j, 1, i)
			binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
		FOR(j, 0, n){
			pw[q][j] = (!i ? 1 : pw[p][j] * a[j]);
			s[i] += pw[q][j];
		}
		swap(p, q);
	}
	return;
}

int main(){
	scanf("%d%d", &n, &k);
	FOR(i, 0, n)
		scanf("%d", &a[i].dat);

	precalc();

	REP(x, 1, k){
		Number ans = 0;
		REP(i, 0, x){
			Number res = s[i] * s[x - i] - s[x];
			ans += res * binom[x][i];
		}
		printf("%d\n", (ans * inv2).dat);
	}
	return 0;
}

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
// clang-format on

const ll MODULO = 998244353;
ll mod_minus(ll x, ll modval) {
    if (x >= 0) {
        return x % modval;
    } else {
        ll mm = ((-x) % modval);
        if (mm == 0) {
            return 0;
        } else {
            return modval - mm;
        }
    }
}
ll mod(ll x) {
    return mod_minus(x, MODULO);
}

const ll COMBMAX = 212345;
ll fac[COMBMAX], finv[COMBMAX], inv[COMBMAX];
void combination_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < COMBMAX; i++) {
        fac[i] = fac[i - 1] * i % MODULO;
        inv[i] = MODULO - inv[MODULO % i] * (MODULO / i) % MODULO;
        finv[i] = finv[i - 1] * inv[i] % MODULO;
    }
}
ll combination(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MODULO) % MODULO;
}

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

    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    vector<ll> apow(N, 1);
    vector<ll> powsum(K + 1, 0);
    powsum[0] = N;
    for (ll k = 1; k <= K; k++) {
        for (ll i = 0; i < N; i++) {
            apow[i] = (apow[i] * a[i]) % MODULO;
            powsum[k] = (powsum[k] + apow[i]) % MODULO;
        }
    }

    combination_init();
    for (ll k = 1; k <= K; k++) {
        ll result = 0;
        for (ll m = 0; m <= k; m++) {
            ll v = 0;
            v = mod(powsum[m] * powsum[k - m]);
            v = mod(v - powsum[k]);
            v = mod(combination(k, k - m) * v);
            result = mod(v + result);
        }
        result = mod(finv[2] * result);
        print(result);
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main()
{
	int n, q;
	cin >> n >> q;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	ll k;
	rep(i, q) {
		cin >> k;
		ll ans;
		ll l = k - 2;
		ll r = k + n + 2;
		ll c;
		while (l + 1 < r) {
			c = (l + r) / 2;
			auto itr = upper_bound(all(a), c);
			if (c - ll(itr - a.begin())>= k)r = c;
			else l = c;
		}
		ans = r;
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int n, q;
  cin >> n >> q;
  vector<ll> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  a.push_back(2e18);
  vector<ll> s(n + 2);
  rep(i, n + 1) {
    s[i + 1] = s[i] + a[i + 1] - a[i] - 1;
  }
  rep(i, q) {
    ll k;
    cin >> k;
    auto itr = lower_bound(s.begin(), s.end(), k) - s.begin();
    itr--;
    k -= s[itr];
    ll ans = a[itr] + k;
    cout << ans << endl;
    //cout << s[itr] << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	long long int n = s.length();
	long long int one = 0, two = 0, sum = 0;
	for (long long int i = 0; i < n; i++)
	{
		int num = s[i] - 48;
		if (num % 3 == 1)
			one++;
		else if (num % 3 == 2)
			two++;
		sum += num;
	}
	int res = -2;
	if (sum % 3 == 0)
		res = 0;
	else {
		if (abs(two - one) < n)
		{
			res = abs(two - one);
		}
		two = two % 3;
		one = one % 3;
		if (abs(two - one) < n)
				res = abs(two - one) > res ? res : abs(two - one);
	}

	if (res == -2)
		res = -1;

	cout << res << endl;

}

#include<bits/stdc++.h>
#define pu push
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=1;i<=x;i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define BITSC(x,v) (binary_search(x.begin(),x.end(),v)
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
const double eps =1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main(){
    string n;cin>>n;
    int ans=2000;
    srep(i,1,(1<<n.size())){
        int temp=0;
        int count=0;
        rep(j,n.size()){
            if((1<<j)&i){
                temp+=n[j];
                count++;
            }
        }
        if(temp%3==0&&ans>n.size()-count)ans=n.size()-count;
    }

    if(ans==2000)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<ll,ll> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

ll solve1(VL& g, VL& b){
    int ng = g.size(), nb = b.size(), pos = 0;
    ll ret = LINF;
    REP(i,nb){
        while(pos<ng-1 && abs(b[i]-g[pos]) > abs(b[i]-g[pos+1])) pos++;
        chmin(ret, abs(b[i]-g[pos]));
    }
    return ret;
}

VL f(VL& b, VL& v){
    int n = b.size(), m = v.size(), pos = 0;
    VL ret(n);
    REP(i,n){
        while(pos<m-1 && abs(v[pos]-b[i]) > abs(v[pos+1]-b[i])) pos++;
        ret[i] = abs(v[pos]-b[i]);
    }
    return ret;
}

ll solve2(VL& r, VL& g, VL& b){
    int n = b.size(), nr = r.size(), ng = g.size();

    if(n==0) return LINF;

    VL dr = f(b,r), dg = f(b,g);
    VI pr(n), pg(n); REP(i,n) pr[i] = pg[i] = i;
    auto cr = [&](int i, int j){return dr[i]<dr[j];};
    auto cg = [&](int i, int j){return dg[i]<dg[j];};
    sort(ALL(pr), cr); sort(ALL(pg), cg);

    ll ret = LINF;
    if(pr[0] != pg[0]) chmin(ret, dr[pr[0]] + dg[pg[0]]);
    else chmin(ret, min(dr[pr[0]]+dg[pg[1]], dr[pr[1]]+dg[pg[0]]));
    return ret;
}

void Main(){
    int N; cin >> N;
    int M = N<<1, nr=0, ng=0, nb=0;
    VL r,g,b; vector<char> c(M);
    REP(i,M){
        ll a; char c;
        cin >> a >> c;
        if(c=='R') nr++, r.push_back(a);
        else if(c=='G') ng++, g.push_back(a);
        else nb++, b.push_back(a);
    }

    if(nr%2 + ng%2 + nb%2 == 0){
        cout << 0 << en;
        return;
    }

    SORT(r); SORT(g); SORT(b);
    if(nr%2 == 0) swap(r,b);
    else if(ng%2 == 0) swap(g,b);

    ll ans = solve1(r,g);
    chmin(ans, solve2(r,g,b));
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    while(t--) Main();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD int(1e9+7)
#define INF int(1e9+7)
#define LINF ll(1e18+7)
#define PI acos(-1)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<ll,ll>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int n;
int Mat[550][550];

int main(){
  cin>>n;
  rep(i,n)rep(j,n) cin>>Mat[i][j];
  vector<int> a(n),b(n);
  a[0]=0;
  b[0]=Mat[0][0]-a[0];
  bool ok=1;
  rep(i,n) a[i]=Mat[i][0]-b[0];
  rep(j,n) b[j]=Mat[0][j]-a[0];
  rep(i,n)rep(j,n){
    if(a[i]+b[j]!=Mat[i][j]) ok=0;
  }
  int amin=INT_MAX, bmin=INT_MAX;
  rep(i,n) chmin(amin,a[i]);
  rep(i,n) chmin(bmin,b[i]);
  if(amin<0 && bmin<0) ok=0;
  else if(amin<0){
    rep(i,n) a[i]+=abs(amin);
    rep(i,n){
      b[i]-=abs(amin);
      if(b[i]<0) ok=0;
    }
  }else if(bmin<0){
    rep(i,n) b[i]+=abs(bmin);
    rep(i,n){
      a[i]-=abs(bmin);
      if(a[i]<0) ok=0;
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
    rep(i,n) cout<<a[i]<<" "; cout<<endl;
    rep(i,n) cout<<b[i]<<" "; cout<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

bool solve() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(m), b(m);
    int bat = n;
    int time = 0;
    rep(i, m) {
        cin >> a[i] >> b[i];
        bat -= (a[i] - time);
        if (bat <= 0) return false;
        bat = min(bat + b[i] - a[i], n);
        time = b[i];
    }
    bat -= t - time;
    if (bat <= 0) return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int n,m,t;
    string ans = "Yes";
    cin >> n >> m >> t;
    int power = n;
    int nt = 0;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        power -= (a -nt);
        if(power <= 0){
            ans = "No";
            break;
        }
        //cout << power << endl;
        power = min(n,power + (b-a));
        //cout << power << endl;
        nt = b;
    }
    if(power -(t -nt) <=0){
        ans = "No";
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, int> P;
struct edge{
    int to;
    long long cost;
    long long time;
};
int main(){
    int N, M, X , Y;
    cin >> N >> M >> X >> Y;
    X--;
    Y--;
    vector<vector<edge>> G(N);
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        long long T, K;
        cin >> T >> K;
        G[A].push_back({B, T, K});
        G[B].push_back({A, T, K});
    }
    long long INF = 1e18;
    priority_queue<P, vector<P>, greater<P>> q;
    vector<long long> d(N, INF);
    d[X] = 0;
    q.push(P(0, X));
    while(!q.empty()){
        P v = q.top();
        q.pop();
        if(d[v.second] < v.first) continue;
        for(edge e: G[v.second]){
            long long t = (v.first + e.time - 1) / e.time * e.time;
            if(d[e.to] > t + e.cost){
                d[e.to] = t + e.cost;
                q.push(P(d[e.to], e.to));
            }
        }
    }
    if(d[Y] == INF) cout << -1 << endl;
    else cout << d[Y] << endl;
}

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

int main() {

	ll n,m,x,y;
	cin>>n>>m>>x>>y;
	vector<ll> adj[n+1],dis[n+1],tim[n+1],ans(n+1);
	for(ll i=0;i<m;i++){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		adj[a].push_back(b);
		adj[b].push_back(a);
		dis[a].push_back(c);
		dis[b].push_back(c);
		tim[a].push_back(d);
		tim[b].push_back(d);
	}
	for(ll i=1;i<n+1;i++)
	ans[i]=-1;
	ans[x]=0;
	queue<ll> q;
	q.push(x);
	while(!q.empty()){
		ll x1=q.front();
		q.pop();
		for(ll i=0;i<adj[x1].size();i++){
			ll x2=ans[x1];
			if(x2%tim[x1][i]!=0){
				x2+=tim[x1][i]-(x2%tim[x1][i]);
			}
			if((ans[adj[x1][i]]==-1)||(x2+dis[x1][i]<ans[adj[x1][i]])){
				ans[adj[x1][i]]=x2+dis[x1][i];
				q.push(adj[x1][i]);
			}
		}
	}
	cout<<ans[y];
	return 0;
}


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

int main(){
	string s;
	cin>>s;
	for(int i=s.size()-1;0<=i;i--){
		if(s[i]=='6'){
			cout<<'9';
		}else if(s[i]=='9'){
			cout<<'6';
		}else{
			cout<<s[i];
		}
	}

	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> S;

    reverse(S.begin(), S.end());

    REP(i,S.size()){
        if(S.at(i)=='6'){
            cout << '9';
        }
        else if (S.at(i) == '9'){
            cout << '6';
        }
        else{
            cout << S.at(i);
        }

    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define MP make_pair
#define PB push_back
#define REP(i, L, R) for (int i = L; i < (R); ++i)
#define SZ(x) (int)x.size()

using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

template <typename T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <typename T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

vector<int> compress(vector<int> &y)
{
    vector<int> v(y);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (int i = 0; i < SZ(y); ++i)
    {
        y[i] = lower_bound(v.begin(), v.end(), y[i]) - v.begin();
    }

    return v;
}

struct bit
{
    int n;
    vector<ll> v;

    void init(int sz)
    {
        n = sz;
        v.assign(n + 1, 0);
    }

    // sum([0..i])
    ll prefix_sum(int i)
    {
        // internally we use 1-based index
        int _i = i + 1;
        ll s = 0LL;
        while (_i)
        {
            s += v[_i];
            _i -= (_i & -_i);
        }
        return s;
    }

    // sum([i..end])
    ll suffix_sum(int i)
    {
        if (i == 0)
        {
            return prefix_sum(n - 1);
        }

        return prefix_sum(n - 1) - prefix_sum(i - 1);
    }

    void incr(int i, ll a)
    {
        // internally we use 1-based indexing
        int _i = i + 1;
        while (_i <= n)
        {
            v[_i] += a;
            _i += (_i & -_i);
        }
    }
};

const int MAXN = 200005;
void solve()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> t(q + 1), x(q + 1), y(q + 1, 0);
    vector<int> a(n, 0), b(m, 0);
    REP(i, 1, q + 1)
    {
        cin >> t[i] >> x[i] >> y[i];
        --x[i]; // 0-based index
    }

    auto vy = compress(y);
    // NOTE 1(coordinate compression): after compression, y is compressed to [0, q] and vy maps from a compressed y in [0,q] to its original value.

    // r1[i] = #i in b; r2[i] = sum of all i's in b.
    // c1[i] = #i in a; c2[i] = sum of all i's in a.
    bit r1, r2, c1, c2;
    r1.init(MAXN);
    r2.init(MAXN);
    c1.init(MAXN);
    c2.init(MAXN);
    // Initially, all b are 0
    r1.incr(0, m);
    // Initially, all a are 0
    c1.incr(0, n);

    ll ans = 0LL;
    REP(i, 1, q + 1)
    {
        if (t[i] == 1)
        {
            // a[x[i]] = y[i]
            int v = a[x[i]];
            ans -= vy[v] * r1.prefix_sum(v);
            ans -= r2.suffix_sum(v + 1);
            c1.incr(v, -1);
            c2.incr(v, -vy[v]);

            a[x[i]] = y[i];
            c1.incr(y[i], 1);
            c2.incr(y[i], vy[y[i]]);
            ans += vy[y[i]] * r1.prefix_sum(y[i]);
            ans += r2.suffix_sum(y[i] + 1);
        }
        else
        {
            // b[x[i]] = y[i]
            int v = b[x[i]];
            ans -= vy[v] * c1.prefix_sum(v);
            ans -= c2.suffix_sum(v + 1);
            r1.incr(v, -1);
            r2.incr(v, -vy[v]);

            b[x[i]] = y[i];
            r1.incr(y[i], 1);
            r2.incr(y[i], vy[y[i]]);
            ans += vy[y[i]] * c1.prefix_sum(y[i]);
            ans += c2.suffix_sum(y[i] + 1);
        }
        cout << ans << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x){
	x=0;char ch=getchar();bool f=false;
	while(!isdigit(ch)){if(ch=='-'){f=true;}ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=f?-x:x;
	return ;
}
template <typename T>
inline void write(T x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10^48);
	return ;
}
#define ll long long
const int N=2e5+5,M=1e8;
int n,m,q;
ll a[N],b[N];
struct SGTree{
	int cur,root;
	ll sum[N*80];
	int num[N*80],ls[N*80],rs[N*80];
	void Modify(int &x,int l,int r,int pos,int v,int tp){
		if(!x) x=++cur;
		int mid=l+r>>1;sum[x]+=v*tp;num[x]+=tp;
		if(l==r) return ;
		if(pos<=mid) Modify(ls[x],l,mid,pos,v,tp);
		else Modify(rs[x],mid+1,r,pos,v,tp);
		return ;
	}
	ll QuerySum(int x,int l,int r,int ql,int qr){
		if(ql>qr||!x) return 0;
		if(ql<=l&&r<=qr) return sum[x];
		int mid=l+r>>1;ll res=0;
		if(ql<=mid) res+=QuerySum(ls[x],l,mid,ql,qr);
		if(qr>mid) res+=QuerySum(rs[x],mid+1,r,ql,qr);
		return res;
	}
	int QueryNum(int x,int l,int r,int ql,int qr){
		if(ql>qr||!x) return 0;
		if(ql<=l&&r<=qr) return num[x];
		int mid=l+r>>1,res=0;
		if(ql<=mid) res+=QueryNum(ls[x],l,mid,ql,qr);
		if(qr>mid) res+=QueryNum(rs[x],mid+1,r,ql,qr);
		return res;
	}
}t1,t2;
ll Ans;
int main(){
	read(n),read(m),read(q);
	for(int i=1;i<=n;i++) t1.Modify(t1.root,0,M,a[i],a[i],1);
	for(int i=1;i<=m;i++) t2.Modify(t2.root,0,M,b[i],b[i],1);
//	for(int i=1;i<=n;i++){
//		Ans+=1ll*t2.QueryNum(t2.root,0,M,1,a[i])*a[i];
//		Ans+=1ll*t2.QuerySum(t2.root,0,M,a[i]+1,M);
//	}
	for(int i=1;i<=q;i++){
		int op,pos;ll v;
		read(op),read(pos),read(v);
		if(op==1){
			Ans-=1ll*t2.QueryNum(t2.root,0,M,0,a[pos])*a[pos];
			Ans-=1ll*t2.QuerySum(t2.root,0,M,a[pos]+1,M);
			t1.Modify(t1.root,0,M,a[pos],a[pos],-1);

			a[pos]=v;
			Ans+=1ll*t2.QueryNum(t2.root,0,M,0,a[pos])*a[pos];
			Ans+=1ll*t2.QuerySum(t2.root,0,M,a[pos]+1,M);
			t1.Modify(t1.root,0,M,a[pos],a[pos],1);
		}
		else{
			Ans-=1ll*t1.QueryNum(t1.root,0,M,0,b[pos])*b[pos];
			Ans-=1ll*t1.QuerySum(t1.root,0,M,b[pos]+1,M);
			t2.Modify(t2.root,0,M,b[pos],b[pos],-1);
			b[pos]=v;
			Ans+=1ll*t1.QueryNum(t1.root,0,M,0,b[pos])*b[pos];
			Ans+=1ll*t1.QuerySum(t1.root,0,M,b[pos]+1,M);
			t2.Modify(t2.root,0,M,b[pos],b[pos],1);
		}
		write(Ans),putchar('\n');
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int H,W;
vector<vector<char>> A;
vector<vector<ll>> dp(2000,vector<ll>(2000));
int f(int y,int x){
  int p;
  if(A[y][x] == '+') p=1;
  else p=-1;
  if((x+y)%2==0) p*=-1;
  return p;
}
int main(){
  cin>>H>>W;
  A.resize(H);
  for(int i=0;i<H;i++) A[i].resize(W);
  for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin>>A[i][j];
  for(int i=H-1;i>=0;i--){
    for(int j=W-1;j>=0;j--){

      if(i==H-1&&j==W-1) dp[i][j] = 0;
      else if(i==H-1) dp[i][j] = dp[i][j+1]+f(i,j+1);
      else if(j==W-1) dp[i][j] = dp[i+1][j]+f(i+1,j);
      else{
        if((i+j)%2==0) dp[i][j] = max(dp[i][j+1]+f(i,j+1),dp[i+1][j]+f(i+1,j));
        else dp[i][j] = min(dp[i][j+1]+f(i,j+1),dp[i+1][j]+f(i+1,j));
      }
    }
  }/*
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      printf("%3d",dp[i][j]);
    }
    cout<<"\n";
  }
  */
  if(dp[0][0] > 0) cout<<"Takahashi";
  else if(dp[0][0] < 0) cout<<"Aoki";
  else cout<<"Draw";
}


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

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

  int n = s.length();

  string result = "";

  for (int j = 0; j < n; j++) {
    int i = n - 1 - j;
    if (s[i] == '0')
      result += "0";
    if (s[i] == '1')
      result += "1";
    if (s[i] == '6')
      result += "9";
    if (s[i] == '8')
      result += "8";
    if (s[i] == '9')
      result += "6";
  }
  cout << result << endl;
}

#include <bits/stdc++.h>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}
template<class T> bool chmax(T& a, const T& b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T> bool chmin(T& a, const T& b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X;
	cin >> X;
	cout << 100 - (X % 100) << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int arr[N];
vi a;
int n, m, k;
//=======================

void solve() {
  int i, j, sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  double ans = 1.0 * sy * gx;
  ans += 1.0*gy*sx;
  ans = ans / (1.0*(sy + gy));
  cout << setprecision(10) << fixed;
  cout << ans << endl;
}

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

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for (int i = 0; i < (int)(n) ; i++)
#define rep2(i,a,b) for (int i = (a); i < (int)(b); i++)
#define Rrep(i,n) for (int i = (n); i >= 0; i--)
#define ENDL '\n'
#define SZ(a) (int)(a.size())
#define all(a) a.begin(),a.end()

ll powi(ll x,ll y) { //繰り返し二乗法
    if(y==0) return 1;
    if(y==1) return x;
    if(y%2==1) return x*pow(x,y-1);
    ll rt = pow(x,y/2);
    return rt*rt;
}

ll score(string s, ll n) {
    n++;
    s.at(4) = to_string(n).at(0);
    vector<ll> ci(9,0);
    rep(i,5) ci.at(s.at(i)-'0'-1)++;
    ll ret=0;
    rep(i,9) {
        ret+=(i+1)*powi(10,ci.at(i));
    }
    return ret;
}

int main() {
    cout << fixed << setprecision(20);
    ll k; cin >> k;
    string s, t; cin >> s >> t;

    vector<ll> cards(9,k);
    rep(i,4) cards.at(s.at(i)-'0'-1)--;
    rep(i,4) cards.at(t.at(i)-'0'-1)--;

/*
    ld all = 0;
    rep(i,9) {
        rep(j,9) {
            if (i==j) {
                if(cards.at(i) <2) continue;
                all += cards.at(i)*(cards.at(i)-1);
            }
           else all += cards.at(i)*cards.at(j);
        }
    }
*/
    ld win = 0;

    rep(i,9) {
        rep(j,9) {
            if(cards.at(i) && cards.at(j)) {
                if(score(s,i)>score(t,j)) {
                    win+=cards.at(i)*(cards.at(j)-(i==j));
/*
                    if (i==j) {
                    if(cards.at(i)<2) continue;
                    win += cards.at(i)*(cards.at(i)-1);
                    }
                    else win += cards.at(i)*cards.at(j);
*/
                }
            }
        }
    }

    ll rem=9*k-8;

    cout << win/rem/(rem-1) << endl;
}


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

int main() {
  int n, s, d;
  cin >> n >> s >> d;
  vector<int>x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];
  bool OK = false;
  rep(i,n){
    if(x[i] < s && y[i] > d) OK = true;
  }
  if(OK) puts("Yes");
  else puts("No");
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n,s,d;
    cin >>n >>s>>d;
    for(int i=0;i<n;i++){
        ll a,b;
        cin >>a>>b;
        if(a<s&&b>d){cout<<"Yes"<<endl;return 0 ;}
    }
    cout<<"No"<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int modd=998244353;
int a,b,c;
cin>>a>>b>>c;
a=a*(a+1);
a=a/2;
b=b*(b+1);
b=b/2;
c=c*(c+1);
c=c/2;
	a=a%modd;
	b=b%modd;
	c=c%modd;
	a=(a*b)%modd;
	a=(a*c)%modd;
	cout<<a;
}

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(x) cout<<x<<endl
#define printyes print("Yes")
#define printno print("No")
#define printYES print("YES")
#define printNO print("NO")
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
// const ll mod=1000000007;
const ll mod=998244353;
const ll inf=1LL<<60;
const double PI=acos(-1);
const double eps=1e-9;
template<class T,class E> ostream& operator<<(ostream& os,pair<T,E>& p){return os<<"{"<<p.first<<","<<p.second<<"}";}
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;}
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;}

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a,ll m=mod) {
  ll b=m,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+m)%m;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
ll N,M,K,H,W,A,B,C,D;
string s,t;
ll ans;
int main(){
  startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j;
  cin>>A>>B>>C;
  A=(1+A)*A/2%mod;
  B=(1+B)*B/2%mod;
  C=(1+C)*C/2%mod;
  print(A*B%mod*C%mod);
// }
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define llrep(i,n) for(ll i=0; i<(ll)n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define kiriage(x,y) (((x)+(y)-1)/(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vp;

int main(){
	int n; cin>>n;
	vector<pair<int, int>> x(n), y(n);
	rep(i,n){
		cin>>x[i].first>>y[i].first;
		x[i].second = i;
		y[i].second = i;
	}
	//fiが座標、seは何個目の組か
	sort(x.rbegin(), x.rend());
	sort(y.rbegin(), y.rend());
	//座標で降順ソート
	vector<tuple<ll, int, int>> t;
	vi one = {0,0,1};
	vi two = {n-1,n-2,n-1};
	llrep(i,3){
		ll nowx = abs(x[one[i]].first-x[two[i]].first);
		ll nowy = abs(y[one[i]].first-y[two[i]].first);
		t.emplace_back(nowx, x[one[i]].second, x[two[i]].second);
		t.emplace_back(nowy, y[one[i]].second, y[two[i]].second);
	}
	sort(rbegin(t), rend(t));
	int cnt = 0;
	int pre_x, pre_y;
	for (auto tmp:t){
		cnt++;
		if (cnt >= 2){
			if (get<1>(tmp) == pre_x && get<2>(tmp) == pre_y){
				continue;
			}
			else cout << get<0>(tmp) << endl;
			return 0;
		}
		pre_x = get<1>(tmp);
		pre_y = get<2>(tmp);
	}
}

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

const int maxn=100000+10;

int main()
{
    vector <P> vec,vecx,vecy;
    int n; cin>>n;
    for(int i=0;i<n;i++)
    {
        P a; cin>>a.first>>a.second;
        vec.push_back(a);
    }
    vecx=vec;
    vecy=vec;
    sort(vecx.begin(),vecx.end(),[](P a,P b){return a.first>b.first;});
    sort(vecy.begin(),vecy.end(),[](P a,P b){return a.second>b.second;});
    vector <ll> ans;
    /*ans.push_back(abs(vecx[0].first-vecx[n-1].first));
    ans.push_back(abs(vecx[0].first-vecx[n-2].first));
    ans.push_back(abs(vecx[1].first-vecx[n-1].first));
    ans.push_back(abs(vecy[0].second-vecy[n-1].second));
    ans.push_back(abs(vecy[0].second-vecy[n-2].second));
    ans.push_back(abs(vecy[1].second-vecy[n-1].second));
    sort(ans.begin(),ans.end(),[](ll a,ll b){return a>b;});
    cout<<ans[1]<<endl;*/
    for(int i=n-1;i>0;i--)
    {
        if(abs(vecx[0].first-vecx[i].first)>abs(vecx[0].second-vecx[i].second))
            ans.push_back(abs(vecx[0].first-vecx[i].first));
    }
    for(int i=1;i<n-1;i++)
    {
        if(abs(vecx[n-1].first-vecx[i].first)>abs(vecx[n-1].second-vecx[i].second))
            ans.push_back(abs(vecx[n-1].first-vecx[i].first));
    }
    for(int i=n-1;i>0;i--)
    {
        if(abs(vecy[0].second-vecy[i].second)>=abs(vecy[0].first-vecy[i].first))
            ans.push_back(abs(vecy[0].second-vecy[i].second));
    }
    for(int i=1;i<n-1;i++)
    {
        if(abs(vecy[n-1].second-vecy[i].second)>=abs(vecy[n-1].first-vecy[i].first))
            ans.push_back(abs(vecy[n-1].second-vecy[i].second));
    }
    sort(ans.begin(),ans.end(),[](ll a,ll b) {return a>b;});
    cout<<ans[1]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long pow(int k){
    if(k==0) return 1;
    else{
        long long a = 2*pow(k-1);
        a %= 998244353;
        return a;
    }
}
int main(){
    int h,w;
    cin >> h >> w;
    vector<int> red(h+w-1),blue(h+w-1),white(h+w-1);
    for(int i = 0 ; i < h ; i++ ) {
        for(int j = 0 ; j < w ; j++ ) {
            char c;
            cin >> c;
            if(c=='R') red.at(i+j)++;
            else if(c=='B') blue.at(i+j)++;
            else white.at(i+j)++;
        }
    }
    int k=0;
    bool flag = true;
    for(int i = 0 ; i < h+w-1 ; i++ ) {
        if(red.at(i)*blue.at(i)==0){
            if(red.at(i)==0&&blue.at(i)==0&&white.at(i)!=0)k++;
        }
        else {
            flag = false;
            break;
        }
    }

    if(flag) {
        cout << pow(k) << endl;
    }
    else {
        cout << 0 << endl;
    }

}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, m = 0, n = 0, p = 0, q = 0, mod = 1000000007, pi = 3.1415926535;
    string s1, s2;
    char moji;

    cin >> a >> b;
    vector<string> v(a);
    for(int i=0;i<a;i++)
    {
        cin >> v.at(i);
    }
    n=1;
    for(int i=0;i<=a+b-2;i++)
    {
        int nanika=0;
        for(int j=max(0LL,i-a+1);j<=i&&i-j<a&&j<b;j++)
        {
            if(v.at(i-j).at(j)=='R')
            {
                if(nanika==2||nanika==3)
                {
                    nanika=3;
                }
                else
                {
                nanika=1;
                }
            }
            else if(v.at(i-j).at(j)=='B')
            {
                if(nanika==1||nanika==3)
                {
                    nanika=3;
                }
                else
                {
                    nanika=2;
                }
            }
        }
        if(nanika==0)
        n*=2;
        if(nanika==3)
        n*=0;
      n%=998244353;
    }
    cout << n << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000;
constexpr ll llINF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
ll modpow(ll a,ll b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    ll memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<ll>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(ll i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
/*
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}*/
ll comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
ll inv(ll x){
    x=modpow(x,mod-2);
    return x;
}
struct BIT{
    int n,beki=1;
    vector<int>bit;
    BIT(int x){
        bit.resize(x+1,0);
        n=x;
        while(beki*2<=n)beki*=2;
    }
    int sum(int i){
        int res=0;
        while(i>0){
            res+=bit[i];
            i-=i&-i;
        }
        return res;
    }
    int sum(int l,int r){
        //[l,r]
        return sum(r)-(l==0?0:sum(l-1));
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
    void add(int l,int r,int x){
        //[l,r]+=x
        add(l,x);
        if(r<n)add(r+1,-x);
    }
    int lowerbound(int w){
        if(w<=0)return 0;
        int x=0;
        for(int k=beki;k>0;k>>=1){
            if(x+k<=n&&bit[x+k]<w){
                w-=bit[x+k];
                x+=k;
            }
        }
        return x+1;
    }
};
int h,w,m;
vector<int>G[200010];
int main(){
    cin>>h>>w>>m;
    int mi=h-1,mj=w;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;
        if(x==0)chmin(mj,y-1);
        else{
            if(y==1)chmin(mi,x-1);
            G[x].pb(y);
        }
    }
    BIT bit(w);
    ll ans=0;
    rep(i,h){
        if(i==0){
            ans+=mj;
            continue;
        }
        for(int j:G[i]){
            if(bit.sum(j,j)==0)bit.add(j,1);
        }
        if(i<=mi){
            int mjn=w;
            for(int j:G[i]){
                chmin(mjn,j-1);
            }
            ans+=mjn;
            if(mjn+1<=mj)ans+=(mj-mjn)-bit.sum(mjn+1,mj);
        }
        else{
            ans+=mj-bit.sum(1,mj);
        }
    }
    cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
char *fs,*ft,buf[1<<20];
#define gc() (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<20,stdin),fs==ft))?0:*fs++;
inline int read()
{
    int x=0,f=1;
    char ch=gc();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=gc();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=gc();
    }
    return x*f;
}
using namespace std;
#define int long long
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 2e5+10;

string a="0123456789ABCDEF",s;
int k,f[N][17];
int dfs(int pos,int st,int lim,int pre,int cnt)
{
    if(pos==sz(s)) return (cnt==k);
    if(!lim&&f[pos][cnt]!=-1&&!st) return f[pos][cnt];
    char high = lim?s[pos]:'F';
    int res=0;
    for(int i=0;i<sz(a);i++)
    {
        if(st&&i==0)
            res = (res+dfs(pos+1,st&&i==0,lim&&a[i]==high,pre,cnt))%mod;
        else
            res = (res+dfs(pos+1,st&&i==0,lim&&a[i]==high,pre|(1<<i),cnt+(pre!=(pre|(1<<i)))))%mod;
        if(a[i]==high) break;
    }
    if(!lim&&!st) f[pos][cnt] = res;
    return res;
}
signed main()
{
    cin>>s>>k;
    mem(f,-1);
    cout<<dfs(0,1,1,0,0)<<endl;
}


///////////////////////Loading Payloads.......////////////////////////////
#include<bits/stdc++.h>
#define f(i,a,b) for(int i = a; i < b; i++)
#define fd(i,a,b) for(int i = a; i > b;i--)
#define ll long long
#define fl(i,a,b) for(ll i = a; i < b; i++)
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VS vector<string>
#define VL vector<long long>
#define VC vector<char>
#define VF vector<float>
#define VD vector<double>
#define VB vector<bool>
#define PB push_back
#define F first
#define S second
#define fa(i,skill) for(auto i : skill)
#define fr(i,skill) for(VI :: reverse_iterator i = skill.rbegin(); i != skill.rend(); i++)
#define PI pair<int,int>
#define mi map<int,int>
#define mci map<char,int>
#define all(x) x.begin(),x.end()
#define MAX 1000000007
#define debug(x) cout<<"This side    ----> "<<#x<<" -> "<<x<<endl
using namespace std;

///////////////////////Engine Check.......////////////////////////////
void edit(VI &skill,int n)
{
    f(i,0,n)
        {
            int x;
            cin >> x;
            skill.PB(x);
        }
}
void editl(VL &skill,ll n)
{
    fl(i,0,n)
        {
            ll x;
            cin >> x;
            skill.PB(x);
        }
}

void achilles(int w)
{

    string s;cin >> s;
    s += s[0];
    cout << s[1]<<s[2]<<s[3] << "\n";

}

///////////////////////3....2....1...Ignition////////////////////////////

int main()
{
    ios :: sync_with_stdio(0);
    cin.tie(0);
    //freopen("out.txt","r",stdin);
    int x = 1;
    /*int t;cin >>t ;
    while(t--)*/
    {achilles(x);x++;}
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
    ll n;
    cin >> n;

    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cout << i << "\n";
            if (i * i != n)v.push_back(n / i);
        }
    }
    reverse(v.begin(), v.end());

    for (auto &x:v)cout << x << "\n";
    cout << flush;
    return 0;
}


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

signed main()
{
	int n;
	cin>>n;
	for(int i=1;i<=1000000;++i)
	{
		int k=log10(i);
		int tmp=pow(10,k+1);
		//cout<<i*tmp+i<<'\n';
		if(i*tmp+i>n)
		{
			cout<<i-1<<'\n';
			break;
		}
	}
   return 0;
}

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

int main(void){
  long long n;

  cin >> n;
  long long m = 1;
  long long k = 10;
  long long ans = 0;

  for(int i=1;i<1000000;i++){
    if(k <= i) k*=10;
    if(i*k+i <= n){
      ans++;
    }
    if(i*k+i > n) break;
  }

  cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7
const long long MOD = 998244353;

long powInt(long x, int n) {
    long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x;
        x = x * x;
        n >>= 1;
    }
    return ret;
}

// mod. m での a の逆元 a^{-1} を計算する
long modinv(long a, long m) {
    long b = m, u = 1, v = 0;
    while (b) {
        long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    int x;
    cin >> x;
    if(x>=0){
        out(x);
    }else
    {
        out(0);
    }
}

#include <stdio.h>

int main(void) {
  int in;
  scanf("%d", &in);
  printf("%d", (in > 0) ? in : 0);
}


#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

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

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

int main()
{
	ios_base::sync_with_stdio(false);

	int n;
	string t;

	string p = "110";
	ll len = 300000LL * 100000LL;

	cin >> n >> t;

	bool ok[3] = { true, true, true };
	for(int i = 0; i < n; ++i) {
		if(t[i] != p[i % 3]) ok[0] = false;
		if(t[i] != p[(i + 1) % 3]) ok[1] = false;
		if(t[i] != p[(i + 2) % 3]) ok[2] = false;
	}

	ll ans = 0;
	if(ok[0]) ans += (len - n) / 3 + 1;
	if(ok[1]) ans += (len - n - 1) / 3 + 1;
	if(ok[2]) ans += (len - n - 2) / 3 + 1;

	cout << ans << '\n';

	return 0;
}


#pragma clang optimize on
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
#define shift 30

inline int get_digit() {
    int x = 0, f = 1;
    char c = getchar();
    while(c > '9' || c < '0') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        x = (x * 10) + (c ^ 48);
        c = getchar();
    }
    return x * f;
}

int main() {
    int R = get_digit(), C = get_digit();
    int A[250000], B[250000];
    int dist[500000], cost, pt, to_hide = R * C;
    vector<ll> s;
    s.reserve(2 * R * C);
    priority_queue<ll, vector<ll>, greater<ll>> queue(s.begin(), s.end());
    for(int i = 0; i < R * C; ++i) {
        if(i % C != C - 1) A[i] = get_digit();
        dist[i] = 0;
    }
    for(int i = 0; i < (R - 1) * C; ++i) B[i] = get_digit();
    dist[0] = -10000000;
    queue.push((ll)(-10000000) << shift);
    while(queue.size()) {
        pt = queue.top() & ((1 << shift) - 1);
        if(pt == to_hide - 1) break;
        cost = queue.top() >> shift;
        queue.pop();
        if(pt < to_hide) {
            if(pt % C != C - 1 & cost + A[pt] < dist[pt + 1]) {
                dist[pt + 1] = cost + A[pt];
                queue.push(((ll)dist[pt + 1] << shift) | (pt + 1));
            }
            if(pt % C != 0 & cost + A[pt - 1] < dist[pt - 1]) {
                dist[pt - 1] = cost + A[pt - 1];
                queue.push(((ll)dist[pt - 1] << shift) | (pt - 1));
            }
            if(pt < to_hide - C & cost + B[pt] < dist[pt + C]) {
                dist[pt + C] = cost + B[pt];
                queue.push(((ll)dist[pt + C] << shift) | (pt + C));
            }
            if(cost + 1 < dist[pt + to_hide]) {
                dist[pt + to_hide] = cost + 1;
                queue.push(((ll)dist[pt + to_hide] << shift) | (pt + to_hide));
            }
        } else {
            if(to_hide < pt - C && cost + 1 < dist[pt - C]) {
                dist[pt - C] = cost + 1;
                queue.push(((ll)(cost + 1) << shift) | (pt - C));
            }
            if(cost < dist[pt - to_hide]) {
                dist[pt - to_hide] = cost;
                queue.push(((ll)cost << shift) | (pt - to_hide));
            }
        }
    }
    printf("%d\n", dist[to_hide - 1] - dist[0]);
}

//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int T;
	T=1;
	// cin.ignore(); must be there when using getline(cin, s)
	while(T--)
	{
		int n,m,i,j;
		cin>>n>>m;
		int ar[n+1][m+1],ar2[n+1][m+1],ar3[m+1],pos[m+1];
		for(i=1;i<=n;++i)
		{
			for(j=1;j<=m-1;++j)
			{
				cin>>ar[i][j];
			}
		}
		for(i=1;i<=n-1;++i)
		{
			for(j=1;j<=m;++j)
			{
				cin>>ar2[i][j];
			}
		}
		int ans[n+1][m+1],flag=0;
		for(i=1;i<=n;++i)
		{
			for(j=1;j<=m;++j)
			{
				ans[i][j]=1e9;
			}
		}
		ans[n][m]=0;
		start:
		for(j=m-1;j>0;--j)
		{
			ans[n][j]=min(ans[n][j],ans[n][j+1]+ar[n][j]);
		}

		for(i=n-1;i>=1;--i)
		{
			for(j=m;j>=1;--j)
			{
				ans[i][j]=min(ans[i][j],ans[i+1][j]+ar2[i][j]);
			}
			for(j=m-1;j>=1;--j)
			{
				ans[i][j]=min(ans[i][j],ans[i][j+1]+ar[i][j]);
			}
			for(j=2;j<=m;++j)
			{
				ans[i][j]=min(ans[i][j],ans[i][j-1]+ar[i][j-1]);
			}
		}
		++flag;
		if(flag<=max(n,m)+10)
		{
			for(j=1;j<=m;++j)
			{
				ar3[j]=ans[1][j];
				pos[j]=1;
			}
			for(i=2;i<=n;++i)
			{
				for(j=1;j<=m;++j)
				{
					ans[i][j]=min(ans[i][j],ar3[j]+1+(i-pos[j]));
					if(ans[i][j]<=ar3[j]+(i-pos[j]))
					{
						ar3[j]=ans[i][j];
						pos[j]=i;
					}
				}
			}
			goto start;
		}
		cout<<ans[1][1]<<endl;
	}
	return 0;
}


#define IOS ios::sync_with_stdio(false);
#define rep(i, a, n) for(ll i=a;i<=n;i++)

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double lb;
#define endl "\n"
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
ll n, m, t, k, ans, cnt, sum, flag;
ll arr[N], vis[N];
char s[N];

int main() {
    IOS;
    cin >> n;
    cnt = 1, ans = 1;
    while(n--) {
        cin >> s;
        cnt <<= 1;
        if (s[0] == 'O') ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

#pragma GCC target ("avx2")
//#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
using namespace std;
const ll mod = 1000000007;
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.push_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ll n;
    cin>>n;
    string s[n];
    for(ll i=0;i<n;i++)
    {
    	cin>>s[i];
    }
    ll dp[n+1];
    if(s[0]=="OR")
    	dp[0]=3;
    else
    	dp[0]=1;
    for(ll i=1;i<n;i++)
    {
    	if(s[i]=="AND")
    		dp[i]=dp[i-1];
    	else
    		dp[i]=dp[i-1]+(1LL<<(i+1));
    }
    cout<<dp[n-1];
    return 0;
}


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

int main()
{

	  int i,j,n,k,m,l=0;

     cin>>n>>k>>m;
     int ara[n];
     for(i=0;i<n-1;i++)
     {
     	cin>>ara[i];
     	l+=ara[i];
	 }
	 if(l/n>=m)
	 {
	 	cout<<"0";
	 	return 0;
	  }
	 else
	 {
	 	for(i=1;i<=k;i++)
	 	{
	 		l+=i;
	 		if(l/n>=m)
			 {
			 	cout<<i<<endl;
			 	return 0;
			 }
			 l-=i;
		 }
	 }
     cout<<"-1"<<endl;

    return 0;
}

# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 2000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
std::vector<bool> IsPrime;

int main() {
	long long ans = 0, counter = 0, maxi = -1, mini = INF, pass = 0;
	//new
	ll n, k, m;
	ll poi[10000];
	cin >> n >> k >> m;
	ll want = m * n;
	rep(i, n-1) {
		cin >> poi[i];
		counter += poi[i];
	}
	if (want-counter<=k){
		cout << max((ll)0,want - counter) << endl;;
	}
	else {
		cout << -1 << endl;
	}
}


    #include <bits/stdc++.h>
    #define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    #define ll long long
    #define endl '\n'
    using namespace std;
     ll n , t , k  , m;
      bool nud(int n)
    {
        int a[100];
 int c= 0 ;
        // counter for octal number array
        int i = 0;
        while (n != 0) {
            // storing remainder in octal array
            a[i] = n % 8;
            n = n / 8;
            i++;
        }

        for (int i  =  0 ; i < 100; i++)
        if (a[i] == 7 )c++;
        return c;
    }
    bool num (int x)
    {
        int c= 0 ;
        while (x)
        {
            if (x%10 == 7)c++;
            x/=10;
        }
        return c;
    }

    int main(){
     SpeeD;
      int n;
      cin >> n;
      long long sum =  0 ;
     // cout << nud(15);
      for (int i =  1 ; i <=n ;  i++)
      {
       // cout << i <<" " << num(i) <<" " << nud(i) << endl;
          sum = sum +  ( num(i) | nud(i));

      }
      cout << n-  sum;

}

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;
int X;

int main(){
  cin >> X;

  cout << 100-X%100;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const int inf = 1e9 + 7;
int a[807][807],b[807][807];
int n,k;

bool check(int m){
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if(a[i][j] > m) b[i][j] = b[i-1][j]-1;
			else b[i][j] = b[i-1][j]+1;
		}
	}
	for(int i = 1;i <= n+1-k;i++){
		int st = i+k-1,ans = 0;
		for(int j = 1;j < k;j++){
			ans = ans + b[st][j] - b[i-1][j];
		}
		for(int j = k;j <= n;j++){
			ans += b[st][j] - b[i-1][j];
			if(ans >= 0) return 0;
			ans -= b[st][j+1-k] - b[i-1][j+1-k];
		}
	}
	return 1;
}
int main(){

	scanf("%d %d",&n,&k);

	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	int l = 0,r = inf;
	while(l < r){
		int m = (l + r) / 2;
		if(check(m)){
			l = m + 1;
		}else r = m;
	}
	printf("%d\n",l);
	return 0;
}

#include <bits/stdc++.h>

#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define P pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>
#define mp make_pair
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rev(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define revs(i, n) for (int i = ((int)(n)); i > 0; --i)
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
// template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

// template <class T> void plus_mod(T &a, const T &b) {a = (a + b) % MOD;}

ll N, K;

ll grid[999][999];

class Cumu {
 private:
  vector<ll> _sum;

 public:
  Cumu(vector<ll> &source) {
    _sum = vector<ll>(source.size() + 1);
    for (ll i = 1; i < source.size() + 1; i++) {
      _sum[i] = _sum[i - 1] + source[i - 1];
    }
  }
  ll sum(ll left, ll right) {
    //
    return _sum[right + 1] - _sum[left];
  }
};

ll count_equal_or_less_than(ll th) {
  // return 0;

  ll start_y = 0;

  ll max_count = 0;

  // 前計算
  vector<Cumu> cumu_list;
  rep(x, N) {
    vll zo_list;
    rep(y, N) {
      ll v = grid[y][x];

      zo_list.emplace_back(v <= th);
    }

    cumu_list.emplace_back(Cumu(zo_list));
  }

  // 本計算
  ll count = 0;

  for (;;) {
    ll end_y = start_y + K - 1;
    if (end_y >= N) break;

    // 最初の四角のカウント
    count = 0;
    rep(x, K) {
      ll c = cumu_list[x].sum(start_y, end_y);
      count += c;
    }
    chmax(max_count, count);

    // 右まで移動
    ll start_x = 0;
    for (;;) {
      ll end_x = start_x + K - 1;
      if (end_x == N - 1) break;  // 右端

      count -= cumu_list[start_x].sum(start_y, end_y);
      count += cumu_list[end_x + 1].sum(start_y, end_y);

      chmax(max_count, count);

      start_x += 1;
    }

    // 下に移動
    start_y += 1;
  }

  return max_count;
}

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  scanf("%lld %lld", &N, &K);

  rep(y, N) {
    rep(x, N) {
      ll v;
      scanf("%lld", &v);
      grid[y][x] = v;
    }
  }

  ll nth = (K * K / 2) + 1;
  ll count_th = (K * K) - nth + 1;

  // leftが条件を満たしていないケースに注意
  ll left = -100;
  ll right = 2000000000LL;  // ■TODO

  for (;;) {
    // cout << "left:" << (left) << ",right:" << (right) << endl;

    if (1 >= right - left) {
      break;
    }
    ll center = (left + right) / 2;
    ll count = count_equal_or_less_than(center);

    if (count < count_th) {
      left = center;
    } else {
      right = center;
    }
  }

  // cout << "left:" << (left) << ",right:" << (right) << endl;

  ll ans = right;
  cout << (ans) << endl;

  // // [1, 3, 5, 6] -> 2
  // ll searchInsert(vector<ll>& nums, ll target) {
  //   ll left = 0;
  //   ll right = nums.size();
  //   for (;;) {
  //     if (1 == right - left) {
  //       if (nums[left] < target) {
  //         left = right;
  //       } else {
  //         right = left;
  //       }
  //       break;
  //     }
  //     if (0 >= right - left) {
  //       break;
  //     }
  //     ll center = (left + right) / 2;
  //     ll n = nums[center];
  //     if (n < target) {
  //       left = center;
  //     }
  //     if (n >= target) {
  //       right = center;
  //     }
  //   }
  //   return left;
  // }

  // ll ans = 0;

  // cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...)
#endif

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
string s;
inline void input(){
    fast_io();
    cin >> N;
    cin >> s;
}

void fox(string &t){
    if(t.length() < 3) return;
    int n = t.length();
    if(t[n-1] == 'x' && t[n-2] == 'o' && t[n-3] == 'f'){
        t.pop_back();
        t.pop_back();
        t.pop_back();
    }
    return ;
}

inline int solve(){
    string t = "";
    for (int i = 0; i < N; i++)
    {
        t.push_back(s[i]);
        fox(t);
    }

    cout << t.length() << endl;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define     pb         push_back
#define     ff             first
#define     ss            second
#define     ll         long long
#define   rep(n) for(int i=0;i<n;i++)
void fastInOut() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);
#endif
}

void solve()
{
    int a , b; // a = solid , b = fat
    cin >> a >> b;
    a = a + b;
    if (a >= 15 && b >= 8)
    {
        cout << 1 ;
    }
    else if (a >= 10 && b >= 3)
    {
        cout << 2 ;
    }
    else if (a >= 3)
    {
        cout << 3;
    }
    else
    {
        cout << 4;
    }

}
int main(int argc, char const * argv[]) {
    fastInOut();
    int tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve(); cout << endl;
    }
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

ll n, k;

ll c2(ll x) {
    if(x < 2) {
        return 0LL;
    }
    return x * (x - 1) / 2;
}

ll f(ll x) {
    return c2(x - 1) - 3 * c2(x - n - 1) + 3 * c2(x - 2*n - 1) - c2(x - 3*n - 1);
}

ll g(ll x) {
    ll L = max(1LL, x - n);
    ll R = min(n, x - 1);
    if(L > R) {
        return 0LL;
    }
    return R - L + 1;
}

int main() {

    cin >> n >> k;

    exrep(s, 3, 3*n) {
        ll x = f(s);
        if(k <= x) {
            exrep(a, 1, n) {
                x = g(s - a);
                if(k <= x) {
                    exrep(b, 1, n) {
                        ll c = s - a - b;
                        if(c <= 0 || n < c) {
                            continue;
                        }
                        if(k == 1) {
                            cout << a << " " << b << " " << c << endl;
                            re0;
                        }
                        k--;
                    }
                }
                k -= x;
            }
        }
        k -= x;
    }

    re0;
}

#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include <chrono>
#include <random>
#include <iterator>
#include <map>
#include<list>
#include<sstream>
#include <algorithm>
#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,pii>
#define vip vector<pii>
#define vi vector<int>
#define vs vector<string>
#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, b, a) for(int i=b;i>=a;i--)
#define viv vector<vi>
#define stack stack<char>
#define fi first
#define se second
#define all(v) (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;
int fact[1000001];
int ncr(int n, int r){
	int p=fact[n];
	p*=power(fact[r], z-2);
	p%=z;
	p*=power(fact[n-r], z-2);
	p%=z;
	return p;
}
int inv(int x){
	return power(x, z-2);
}
int dsu(int x, int par[]){
	if(x==par[x]) return x;
	return dsu(par[x], par);
}
// vi seg;
// void arrange(int i, int v, int x, int lx, int rx){
// 	if(rx-lx==1){
// 		seg[x]=v;
// 		return;
// 	}
// 	int mid=(lx+rx)/2;
// 	if(i<mid) arrange(i, v, 2*x+1, lx, mid);
// 	else arrange(i, v, 2*x+2, mid, 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(lx>=r||l>=rx) return 1e9;
// 	if(lx>=l&&rx<=r) return seg[x];
// 	int mid=(lx+rx)/2;
// 	int k1=calc(l, r, 2*x+1, lx, mid), k2=calc(l, r, 2*x+2, mid, rx);
// 	return min(k1, k2);
// }
vi pp;
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	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;
			}
		}
	}
	fact[0]=1;
	rep(i,1,1000001) fact[i]=i*fact[i-1], fact[i]%=z;
	for(int i=2;i<=1000000;i++) if(!pp[i]) sv.pb(i);
	int t;
	t=1;
	//cin>>t;
	while(t--){
		int n, q;
		cin>>n>>q;
		vip v;
		int ar[n];
		rep(i,0,n) cin>>ar[i];
		if(ar[0]>1){
			v.pb(mp(ar[0]-1, 1));
		}
		rep(i,1,n){
			if(ar[i]-ar[i-1]>1){
				v.pb(mp(ar[i]-ar[i-1]-1, ar[i-1]+1));
			}
		}
		v.pb(mp(1e18+1e10-ar[n-1], ar[n-1]+1));
		rep(i,1,v.size()){
			v[i].fi+=v[i-1].fi;
		}
		while(q--){
			int k;
			cin>>k;
			int l=0, r=v.size()-1, ans=-1;
			while(l<=r){
				int mid=(l+r)/2;
				if(v[mid].fi>=k){
					ans=mid;
					r= mid-1;
				}
				else l=mid+1;
			}
			if(ans!=-1){
				if(ans>0) k-=v[ans-1].fi;
				cout<<v[ans].se+k-1<<"\n";
			}
		}
	}
}


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

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,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(int i=cc;i>=n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

const vector<int> dx = {1, 0, -1,  0};
const vector<int> dy = {0, 1,  0, -1};

const vector<int> dx2 = {1, 1,  1, 0,  0, 0, -1, -1, -1};
const vector<int> dy2 = {1, 0, -1, 1, -1, 0,  1,  0, -1};

const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
const ll mod2 = 998244353;

const ll MAX = 1000000;
const int MOD = 1000000007;
const ll big = (1ll<<60);

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<ll>a(n),b(m);
  vector<vector<ll>>dp(n+1,vector<ll>(m+1,0));
  rep(i, 0, n)cin >> a[i];
  rep(i, 0, m)cin >> b[i];
  rep(i, 0, n+1)dp[i][0] = i;
  rep(i, 0, m+1)dp[0][i] = i;
  rep(i, 1, n+1){
    rep(j, 1, m+1){
      if(a[i-1]==b[j-1])dp[i][j] = min({dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]});
      else dp[i][j] = min({dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+1});
    }
  }
  /*
  rep(i, 0, n+1){
    rep(j, 0, m+1){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  cout << dp[n][m] << endl;
}

/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

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

ll n,m;
ll dp[1005][1005];
ll a[1005],b[1005];

ll solve(ll i,ll j)
{
    if(dp[i][j]!=-1) return dp[i][j];
    if(i>=n && j>=m) return 0;
    if(i>=n) return (m-j);
    if(j>=m) return (n-i);
    ll ans = inf;
    if(a[i]==b[j])
    {
        ans = min(ans,solve(i+1,j+1));
    }
    ans=min(ans,1+solve(i+1,j));
    ans=min(ans,1+solve(i,j+1));
    ans=min(ans,1+solve(i+1,j+1));
    return dp[i][j] = ans;

}

void eff()
{
    memset(dp,-1,sizeof(dp));
    sffl(n,m);
    for(ll i=0;i<n;i++) sfl(a[i]);
    for(ll i=0;i<m;i++) sfl(b[i]);
    printf("%lld\n",solve(0,0));

}

int main()
{
    // fastio
    // ll test ;
    // sfl(test);
    // for(ll i=0;i<test;i++)
    // {
        // printf("Case %lld: ",i+1);
        eff();
    // }
//    cout<<check(81);
    return 0;
}


// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(ll i=(ll)s; i<(ll)(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define pss pair<string, string>
#define ull unsigned long long int
#define lld long double
#define F first
#define S second
#define PI 3.141592653589793238
#define prec(n) fixed<<setprecision(n)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    itval(++it, args...);
}
const ll MOD = 1e9 + 7;
template <typename T>
inline void print(T x) {cout << x << "\n";}
template <typename T>
inline void printvec(T x) {for (auto a : x)cout << a << ' '; cout << '\n';}
// -----------------------------------------------------------------------

struct custom {
    bool operator()(const pll &p1, const pll &p2)const {
        return p1.F > p2.F;
    }
};

// Calculate a^b % MOD -------------------------------------------------
ll get_pow(ll a, ll b, ll M = MOD) {
    ll res = 1;
    while (b) {
        if (b & 1) res = (res * a) % M;
        a = (a * a) % M;
        b >>= 1;
    }
    return res;
}
// ---------------------------------------------------------------------
const ll N = 2e5 + 5, inf = 4e18;
ll dp[N][2];
void solve()
{
    ll n;
    cin >> n;
    vll mx(n + 1, -inf), mi(n + 1, inf);
    ll x, c;
    forn(i, 0, n)
    {
        cin >> x >> c;
        c--;
        mi[c] = min(mi[c], x);
        mx[c] = max(mx[c], x);
    }
    mx[n] = mi[n] = 0;
    ll ans = 0, p = 0;

    for (int j = n - 1; j >= 0; j--)
    {
        // dono mi
        if (mi[j] == inf)
        {
            dp[j][0] = dp[j + 1][0];
            dp[j][1] = dp[j + 1][1];
            mx[j] = mx[j + 1];
            mi[j] = mi[j + 1];
            continue;
        }
        dp[j][0] = abs(mi[j + 1] - mx[j]) + mx[j] - mi[j] + dp[j + 1][0];
        dp[j][0] = min(dp[j][0], abs(mx[j + 1] - mx[j]) + mx[j] - mi[j] + dp[j + 1][1]);
        dp[j][1] = abs(mx[j + 1] - mi[j]) + mx[j] - mi[j] + dp[j + 1][1];
        dp[j][1] = min(dp[j][1], abs(mi[j + 1] - mi[j]) + mx[j] - mi[j] + dp[j + 1][0]);
    }
    ans = min(dp[0][0] + abs(mi[0]), dp[0][1] + abs(mx[0]));
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int test = 1;
    clock_t z = clock();
    // cin >> test;

    forn(tes, 0, test)
    {
        solve();
    }
    debug("Total Time:%.4f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
    return 0;
}

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <chrono>
#include <functional>
#define _crt_secure_no_warnings
#define JH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F
#define MAXLL 1000000000000000000LL
#define MOD ll(1e9 + 7)
#define LOGMAX 21
#define ALPHABET 2
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define all1(v) v.begin() + 1, v.end()
#define F first
#define S second
#define EPS 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef unordered_set<int> usi;
typedef unordered_multiset<int> usmi;
//main exec

int main(){
    JH
    lld a, b; cin >> a >> b;
    cout << fixed << setprecision(9) << (b / 100) * a << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 2e5+5;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int check(string a,int n)
{
    int i,j;
    for(i=0;i<n;i++)
    {
        if(a[i]!=a[n-1-i])
            return 0;
    }
    return 1;
}

int main()
{
    int n,i,j,k,l,p,q,x,y;
    cin >> l;
    string a = to_string(l);n = a.size();
    if(check(a,n)==1)
    {
        cout << "Yes";
        return 0;
    }
    string b;p = 0;
    for(i=n-1;i>=0;i--)
    {
        if(p==0)
        {
            if(a[i]!='0')
            {
                p++;
                b+=a[i];
            }
        }
        else
            b+=a[i];
    }
    reverse(b.begin(),b.end());
    if(check(b,b.size())==1)
    {
        cout << "Yes";
        return 0;
    }
    else
        cout << "No";
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100010
#define MOD 1000000007
#define INF 1e15
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define endl "\n"
#define coutflg if(flg){cout << "Yes\n";}else{cout << "No\n";}
#define coutyes cout << "Yes\n";
#define coutno cout << "No\n";
#define flush fflush(stdout);
#define fixedprec cout << fixed << setprecision(18);

void solve(){
    string a;
    cin >> a;
    int flg = 1;
    ll n = a.size();
    ll l = 0;
    ll r = a.size()-1;
    while(l<n && a[l]=='0'){
        l++;
    }
    while(r>=0 && a[r]=='0'){
        r--;
    }
    while(l<=r){
        if(a[l]!=a[r]){
            flg = 0;
            break;
        }
        else{
            l++;
            r--;
        }
    }
    coutflg;
}

int main(){

    fast
    ll t,q;
    q = 1;
    // cin >> q;
    for(t=1;t<=q;t++){
        // cout << "Case #" << t << ": ";
        solve();
    }
}