#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
#define all(v) v.begin(), v.end()
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, b) for (ll i = a; i < b; ++i)
#define rep_down(i, a, b) for (ll i = a; i > b; --i)

#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second

#define vvvvll vector<vector<vector<vector<ll>>>>
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>

#define vvvvdo vector<vector<vector<vector<double>>>>
#define vvvdo vector<vector<vector<double>>>
#define vvdo vector<vector<double>>
#define vdo vector<double>

#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 62);
// constexpr ll mod = 998244353;
// constexpr ll mod = 67280421310721;
constexpr ll mod = 1000000007;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
void pt(T val) {
    cout << val << "\n";
}
template <typename T>
void pt_vll(vector<T> &v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];

        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}
template <typename T>
void pt_vvll(vector<vector<T>> &v) {
    ll vs = v.size();
    rep(i, vs) pt_vll(v[i]);
}

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

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

ll modpow(ll x, ll n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}
ll minv(ll a, ll m) { return modpow(a, m - 2); }

void make_prime(vector<ll> &ret, ll n) {
    ll x = n;
    for (ll i = 2; i * i <= x; i++) {
        while (n % i == 0) {
            n /= i;
            ret.push_back(i);
        }
    }
    if (n != 1) {
        ret.push_back(n);
    }

    return;
}

ll M;
ll mypow(ll a, ll n) {
    ll ret = 1;
    rep(i, n) {
        if (ret > M / a) return -1;
        ret *= a;
    }
    return ret;
}
using pp = pair<P, ll>;
map<pp, ll> mp;
void dijkstra(vector<vector<P>> &G, ll start, vector<ll> &dist) {
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    ll n = G.size();

    dist.assign(n, INF);
    dist[start] = 0;

    while (que.size()) {
        P now = que.top();
        que.pop();
        if (dist[now.se] < now.fi) continue;

        for (auto nx : G[now.se]) {
            ll D = mp[{{nx.fi, now.se}, nx.se}];
            ll d2 = (dist[now.se] + D - 1) / D * D;
            if (chmin(dist[nx.fi], d2 + nx.se))
                que.push(make_pair(dist[nx.fi], nx.fi));
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<vector<P>> G(N);
    rep(i, M) {
        ll a, b, t, k;
        cin >> a >> b >> t >> k;
        G[--a].push_back({--b, t});
        G[b].push_back({a, t});
        mp[{{a, b}, t}] = mp[{{b, a}, t}] = k;
    }

    vll dist;
    dijkstra(G, --X, dist);
    // pt_vll(dist);
    if (dist[--Y] < INF)
        pt(dist[Y]);
    else
        pt(-1);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
	T t=0;
	char k;
	bool vis=0;
	do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
	while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
	return vis?-t:t;
}
# define fre(k) freopen(k".in","r",stdin);freopen(k".out","w",stdout)
int s,a[505],b[505],pr[505*505];bool ty;
void Swap(int x,int y){b[a[x]]=y;b[a[y]]=x;swap(a[x],a[y]);pr[++*pr]=x;ty^=1;}
void Swap2(int x){Swap(x-1,x);Swap(x,x+1);Swap(x-1,x);Swap(x,x+1),Swap(x-1,x);}
int main(){
	for(int T=read;T--;){
		s=read;*pr=0;ty=1;
		for(int i=1;i<=s;++i)b[a[i]=read]=i;
		for(int i=1;i<s-1;++i){
			if(b[i]==i)continue;
			if((b[i]^ty)&1)
				for(int j=b[i]-1;j>=i;--j)Swap(j,j+1);
			else{
				int w=b[i]-1;
				if(w!=i)Swap(w-1,w);
				else if(w==s-3){
					Swap(w+1,w+2);
					Swap(w+2,w+3);
					Swap(w+1,w+2);
					w=s-1;
				}else if(w==s-2){Swap2(i);w=i-1;}
				else Swap(w+3,w+4);
				for(int j=w;j>=i;--j)Swap(j,j+1);
			}
		}if(a[s-1]>a[s])
			if((b[s-1]^ty)&1)Swap(b[s-1]-1,b[s-1]);
			else Swap2(s-1);
		printf("%d\n",*pr);
		for(int i=1;i<=*pr;++i)printf("%d ",pr[i]);
		putchar('\n');
	}
	return 0;
}/*

      x
1 3 2 5 4
a c b
c a b
c b a
b c a
b a c
a b c
*/


#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,val) memset(a,val,sizeof(a))
//#define int long long
using namespace std;

const int N=3e3+5;

int n,m,head[N],to[N],nxt[N],edge[N],tot;
int dis[N],ins[N];

void add(int x,int y,int w)
{
	nxt[++tot]=head[x];
	head[x]=tot;
	to[tot]=y;
	edge[tot]=w;
}

//void dfs(int u,int d)
//{
//	if(!ins[u]){
//		ins[u]=1;
//		if(dis[u]>d){
//			dis[u]=d;
//			for(int e=head[u];e;e=nxt[e]){
//				int v=to[e];
//				dfs(v,d+edge[e]);
//			}
//		}
//		ins[u]=0;
//	}
//	else{
//		assert(d>dis[u]);
//		ans[u]=min(ans[u],d-dis[u]);
//	}
//}

int cur,ans=1e9;

void dfs(int u)
{
	for(int e=head[u];e;e=nxt[e]){
		int v=to[e];
		if(v==cur){
			ans=min(ans,dis[u]+edge[e]);
			continue;
		}
		if(dis[v]>dis[u]+edge[e]){
			dis[v]=dis[u]+edge[e];
			dfs(v);
		}
	}
}

priority_queue< pair<int,int> > q;

int vis[N],cc[N];

signed main()
{
	cin>>n>>m;

	For(i,1,n) cc[i]=1e9;

	For(i,1,m){
		int x,y,w;
		cin>>x>>y>>w;
//		if(x==y) cc[i]=min(cc[i],w);
		add(x,y,w);
	}

//	For(i,1,n+1){
//		ans[i]=1e9;
//		dis[i]=1e9;
//	}

//	dis[n+1]=0;
//
//	q.push(make_pair(0,n+1));
//
//	while(q.size()){
//		int u=q.top().second;
//		q.pop();
//
//		if(vis[u]) continue;
//		vis[u]=1;
//
//		for(int e=head[u];e;e=nxt[e]){
//			int v=to[e];
//			if(dis[v]>dis[u]+edge[e]){
//				dis[v]=dis[u]+edge[e];
//				q.push(make_pair(-dis[v],v));
//			}
//		}
//	}
//
//	For(i,1,n) cout<<dis[i]<<endl;
//
//	dfs(n+1,0);

	For(i,1,n){
		clr(dis,0x3f);
		cur=i;
		dis[i]=0;
		ans=cc[i];
		dfs(i);
		if(ans<1e9) cout<<ans<<endl;
		else cout<<-1<<endl;
	}

	return 0;
}

#include <bits/stdc++.h>
#define inf 1e9
using namespace std;
const int N = 2e3 + 101;
struct Edge{
	int nex, to, dis;
}edge[N*2];
int tot, head[N], dis[N];
int dist[N][N], ans[N], vis[N];
struct node{
	int u, dis;
	bool operator < (const node &a) const{
	    return dis > a.dis;
	}
};
priority_queue<node>q;
int n, m;

void add(int from,int to,int dis)
{
	edge[++ tot].nex = head[from];
	edge[tot].to = to;
	edge[tot].dis = dis;
	head[from] = tot;
}

void dij(int s)
{
	for(int i = 1;i <= n; i++) dis[i] = inf, vis[i] = 0;
	dis[s] = 0;q.push((node){s,0});
	while(!q.empty())
	{
		int u = q.top().u;
		q.pop();
		if(vis[u]) continue;
		vis[u] = 1;
		for(int i = head[u];i;i = edge[i].nex)
		{
			int v = edge[i].to;
			if(dis[v] > dis[u] + edge[i].dis)
			{
				dis[v] = dis[u] + edge[i].dis;
				q.push((node){v,dis[v]});
			}
		}
	}
	for(int j = 1;j <= n; j++) dist[s][j] = dis[j];
}

signed main()
{
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n; i++)
	    for(int j = 1;j <= n; j++)
	        dist[i][j] = inf, ans[i] = inf;
	for(int i = 1;i <= m; i++)
	{
		int u, v, w;scanf("%d%d%d",&u,&v,&w);
		add(u,v,w);
		if(u == v) ans[u] = min(ans[u],w);
	}
	for(int i = 1;i <= n; i++) dij(i);
	for(int i = 1;i <= n; i++)
	for(int j = 1;j <= n; j++)
	    if(i != j) ans[i] = min(ans[i],dist[i][j] + dist[j][i]);
	for(int i = 1;i <= n; i++)
	    printf("%d\n",ans[i] == inf ? -1 : ans[i]);
}


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

#define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr))
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define iter(it, s) for (auto it = s.begin(); it != s.end(); it++)
#define fillc(a,b) memset(a,b,sizeof(a))
#define MOD 1000000007
#define INF 1e17

void solve()
{
	ll n,i,ans=0,num;
	cin>>n;
	map<ll,ll> mp;
	for(i=0;i<n;i++)
	{
		cin>>num;
		mp[num]++;
	}
	for(auto i:mp)
		ans+=i.ss*(i.ss-1)/2;
	cout<<n*(n-1)/2-ans<<endl;
}

int main()
{
    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
        solve();
}

#include<bits/stdc++.h>
using namespace std;
struct node{int n,i;node(int n,int i):n(n),i(i){}};
int n,t,a;
bool b[203];
vector<int>f[203];
vector<node>s;
map<int,vector<node> >all;
void dfs(int x){
	if(x==n){
		int ps=0;
		vector<node>y;
		for(int i=0;i<n;++i)if(b[i])y.push_back(s[i]),ps+=s[i].n;
		ps%=200;
		if(y.size()==0)return;
		if(all[ps].size()>0){
			printf("Yes\n%d ",all[ps].size());
			for(unsigned int i=0;i<all[ps].size();++i)printf("%d ",all[ps][i].i);
			printf("\n%d ",y.size());
			for(unsigned int i=0;i<y.size();++i)printf("%d ",y[i].i);
			exit(0);
		}
		all[ps]=y;
		return;
	}
	b[x]=false;
	dfs(x+1);
	b[x]=true;
	dfs(x+1);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&a);
		s.push_back(node(a%200,i+1));
		f[a%200].push_back(i+1);
		if(f[a%200].size()==2){
			printf("Yes\n1 %d\n1 %d",f[a%200][0],f[a%200][1]);
			return 0;
		}
	}
	n=s.size();
	dfs(0);
	puts("No");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
  long n,ans,k;
  cin>>n;
  ans=0;
  vector<long> vec(n);
  vector<long> fibo(n+2);
  for(long i=0; i<n; i++){
    cin>>vec.at(i);
    vec.at(i)=vec.at(i)%1000000007;
  }
  fibo.at(0)=0;
  fibo.at(1)=1;
  for(long i=2; i<n+2; i++){
    fibo.at(i)=fibo.at(i-1)+fibo.at(i-2);
    fibo.at(i)=fibo.at(i)%1000000007;
  }
  ans=fibo.at(n+1)*vec.at(0);
  for(int i=1; i<n; i++){
    k=(fibo.at(i-1)*fibo.at(n-i+1)+fibo.at(i)*fibo.at(n-i-1))%1000000007;
    ans=ans+vec.at(i)*k;
    ans=ans%1000000007;
  }
  cout<<ans;
}

#include <cstdio>

typedef long long LL;
const int Mod = 1000000007;
int N;

int main() {
	int A = 0, B = 0, C = 0, D = 0;
	scanf("%d%d", &N, &A);
	C = 1;
	for (int i = 2; i <= N; ++i) {
		int x;
		scanf("%d", &x);
		int nA = (int)(((LL)(C + D) * x + A + B) % Mod);
		int nB = (int)(((LL)(Mod - C) * x + A) % Mod);
		int nC = (C + D) % Mod;
		int nD = C;
		A = nA, B = nB, C = nC, D = nD;
	}
	printf("%d\n", (A + B) % Mod);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans = 0;
void Main(){
    int n;
    cin >> n;
    vector<int> p(n+1), place(n+1, 0), v;
    vector<bool> used(n, false);
    For(i,0,n) {
        cin >> p[i+1];
        place[p[i+1]] = i+1;
    }
    For(i,1,n+1){
        while(place[i] > i){
            int r = i;
            int l = p[place[i] - 1];
            swap(p[place[i]], p[place[i] - 1]);
            swap(place[r], place[l]);
            v.push_back(place[i]);
            if(used[place[i]]){
                cout << -1 << endl;
                return;
            }
            used[place[i]] = true;
            /*cout << v.back() << endl;
            for(auto i:p) cout << i << " ";
            cout << endl;*/
        }
    }
    if(v.size() != n-1) cout << -1 << endl;
    else for(auto i:v) cout << i << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define pb push_back
#define mp make_pair
unordered_map<ll,int> um;

ll binpow(ll a, ll n){
    if(n==0) return 1;
    ll res = binpow(a, n/2);
    if(n%2 != 0) return res*res*a;
    else return res*res;
}
void solve(){
    ll n; cin>>n;
    for(int i=1;i<64;i++){
        ll x = binpow(5, i);
        if(x>=n){
            cout<<"-1"; return;
        }
        for(int j=1;j<64;j++){
            ll y = binpow(3, j);
            // if(y>=n){
            //     cout<<"-1"; return;
            // }
            if(x+y == n){
                cout<<j<<" "<<i;
                return;
            }
            if(x+y >= n) break;
        }
        // ll z = binpow(3, i);
        // if(z > n) break;
        // // if(z < n){
        //     ll x = n - z;
        //     // cout<<x<<" ";
        //     if(um.find(x)!=um.end()){
        //         cout<<i<<" "<<um[x]<<endl;
        //         return;
        //     }
        // }
    }
    cout<<"-1\n";
}
int main(){

    // for(int i=1;i<64;i++){
    //     ll z = binpow(5, i);
    //     um.insert({z, i});
    // }
    // while(t--){
        solve();
    // }
}


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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define test int TEST;cin>>TEST;while(TEST--)
#define all(x) x.begin(),x.end()
#define vrevsort(x) sort(x.rbegin(),x.rend())
#define opy cout<<"Yes\n"
#define opn cout<<"No\n"
#define NL cout<<'\n'
#define SP cout<<' '

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}
#define deb(x) cerr << #x << " = " << x << endl;

void solve(){
	int x,y;
	cin>>x>>y;
	if(abs(x-y)<3) opy;
	else opn;

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    //test{solve();cout<<'\n';}
	solve();

}

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

int main(){
    long int N;
    cin >> N;
    set<long int> s;
    rep(i, 2*sqrt(N))
        if(N % (i+1) == 0){
            s.insert(i+1);
            s.insert(N / (i+1));
        }
    for(auto x : s) cout << x << endl;
}


#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 h,w;
char grid[15][15];
int di[]={0,1,0,1};
int dj[]={0,0,1,1};

int main(){
  cin>>h>>w;
  rep(i,h)rep(j,w)cin>>grid[i][j];
  int ans=0;
  rep(i,h)rep(j,w){
    int cnt=0;
    rep(ind,4){
      if(grid[i+di[ind]][j+dj[ind]]=='#') cnt++;
    }
    ans += cnt%2;
  }
  cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std ;
int main()
{
    std::ios::sync_with_stdio(false) , cin.tie(0) ;
    // [n - i + 1 , n + i]
    int n ;
    cin >> n ;
    vector<int> a(2 * n + 1) ;
    for(int i = 1 ; i <= 2 * n ; i ++)  cin >> a[i] ;
    long long ans = 0 ;
    for(int i = 1 ; i <= 2 * n ; i ++)  ans += a[i] ;
    priority_queue<int> q ;
    for(int i = 1 ; i <= n ; i ++)
    {
        q.push(-a[n - i + 1]) ;
        q.push(-a[n + i]) ;
        ans -= abs(q.top()) ;
        q.pop() ;
    }
    cout << ans << '\n' ;
    return 0 ;
}

// Author: Vinay Khilwani
// Language: C++

// @vok8: Codeforces, AtCoder, LeetCode, HackerEarth, TopCoder, Google, FB, CSES, Spoj, GitHub
// @vok_8: CodeChef, GFG
// @vok8_khilwani: HackerRank

// Never Stop Trying.
// Trying to be Better than Myself.

// while(true)
// {
//     if(AC)
//     {
//         break;
//     }
//     else if(Contest Over)
//     {
//         Try.
//         Check out Editorial.
//         Understand.
//         Find out your Mistake.
//         Learn the topic (if new).
//         Solve Problems on that topic (if new).
//         Upsolve that problem.
//         break;
//     }
//     else
//     {
//         Try.
//         Use Pen-Paper.
//         Find errors, edge cases, etc.
//         continue;
//     }
// }

// Optimizations
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")

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

// Debugging
#define dbg(a) cerr<<a<<"\n";
#define debug_a(a) for(auto x:a) {cerr<<x<<" ";} cerr<<"\n";
#define debug_b(a) for(auto x:a) {cerr<<"["<<x.first<<", "<<x.second<<"]"<<"\n";} cerr<<"\n";
#define debug_c(a) for(auto x:a) {debug_a(x)} cerr<<"\n";
#define debug_d(a) for(auto x:a) {debug_b(x)} cerr<<"\n";
#define debug_e(a) cerr<<"["<<a.first<<", "<<a.second<<"]"<<"\n";

// Defines
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define fr(i,a,n,b) for(int i=a; i<n; i+=b)
#define rfr(i,a,n,b) for(int i=a; i>=n; i-=b)
#define IN cin>>
#define OUT cout<<
#define nl "\n"
#define sz(a) int(a.size())
#define all(a) (a).begin(),(a).end()
#define each(a,b) for(auto &a:b)
#define pb push_back
#define set_bits(a) __builtin_popcountll(a)
#define ar array
#define write(a) for(auto x:a) {OUT x<<" ";} OUT nl;
#define read(a) for(auto &x:a) {IN x;}
// #define oset tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
using ll=long long int;
using ld=long double;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vi=vector<int>;
const ll mod=(ll)(1e9)+7LL;
const ll M=998244353LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ld pi=acos(-1);

// General Functions
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo) //Fast Power
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    fast
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}

// Global Variables
const int mxN=int(1e5)+100;

// Solver Function(s)
void solve()
{
    int a,b;
    IN a>>b;
    int x=a+b;
    x/=2;
    int y=a-x;
    OUT x<<" "<<y<<nl;
}

// Main Function
int main()
{
    vok();
    int t=1;
    // IN t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;

ll n,x,y,ans,sum;
string s;

int main(){

	ios::sync_with_stdio(0);

	cin>>n;
	cin>>s;

	for(int i=0;i<n;i++){
		x=y=0;
		for(int j=i;j<n;j++){
			if(s[j]=='A')x++;
			if(s[j]=='T')x--;
			if(s[j]=='G')y++;
			if(s[j]=='C')y--;
			if(x==y && x==0)ans++;
		}
	}

	cout<<ans<<endl;

	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}
#ifdef LOCAL
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cerr<<(*i)<<" ";cerr<<endl;}
#else
template<class T>void pv(T a,T b){}
#endif

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 5010;
int c[4][MAX_N];

int main2() {
  CLR(c, 0);

  int N = nextLong();
  string S; cin >> S;

  REP(i, N) {
    c[0][i+1] = c[0][i] + (S[i] == 'A');
    c[1][i+1] = c[1][i] + (S[i] == 'T');
    c[2][i+1] = c[2][i] + (S[i] == 'G');
    c[3][i+1] = c[3][i] + (S[i] == 'C');
  }

  ll ans = 0;
  REP(i, N) {
    for (int j = i + 1; j <= N; j++) {
      int d[4] = {0};
      REP(k, 4) d[k] = c[k][j] - c[k][i];

      if (d[0] == d[1] && d[2] == d[3]) ans++;

    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
// sort(ALL(v), [](auto const& lhs, auto const& rhs) { return lhs > rhs; /* 左の方が大きい...というイメージ。*/ });
// --------------------------------------------------------------------------------------------- //

static const int MAX = 100001;
static const ll MOD = 1000000007;

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N; cin >> N;
	ll ans1=0, ans2=0, ans3=0;
	rep(i, N){
		ll x; cin >> x;
		ans1 += abs(x);
		ans2 += x * x;
		ans3 = max(ans3, abs(x));
	}
	double ans2_d = sqrt((double)ans2);
	cout << ans1 << endl;
	cout << ans2_d << endl;
	cout << ans3 << endl;

	return 0;
}

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

int main(){
  int n;cin>>n;
  vector<int> a(n),b(n);
  int ans=1e10;
  rep(i,n)cin>>a[i]>>b[i];
  rep(i,n){
    rep(j,n){
      if(i==j)ans=min(ans,a[i]+b[j]);
      else ans=min(ans,max(a[i],b[j]));
    }
  }
  cout<<ans;
}


#include <iostream>
#include <cmath>

using namespace std;

int main() {

    int N, X0, Y0, XN2, YN2;
    cin >> N >> X0 >> Y0 >> XN2 >> YN2;

    double xo, yo;
    xo = (double)(X0 + XN2) / 2;
    yo = (double)(Y0 + YN2) / 2;

    double X0d, Y0d;
    X0d = X0 - xo;
    Y0d = Y0 - yo;

    double pi = 3.1415926535;
    double p = pi / (N / 2);

    double x1d, y1d;
    x1d = X0d * cos(p) - Y0d * sin(p);
    y1d = X0d * sin(p) + Y0d * cos(p);

    double x1, y1;
    x1 = x1d + xo;
    y1 = y1d + yo;

    cout << x1 << " " << y1 << endl;

    return 0;
}

#line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Graph/dijkstra.hpp"

#line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Tools/heap_alias.hpp"

#include <queue>

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
#line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Graph/graph.hpp"

#include <vector>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;

    Edge() = default;
    Edge(int src, int dst, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return cost > e.cost; }
};

template <class Cost = int>
struct Graph : public std::vector<std::vector<Edge<Cost>>> {
    using std::vector<std::vector<Edge<Cost>>>::vector;

    void span(bool direct, int src, int dst, Cost cost = 1) {
        (*this)[src].emplace_back(src, dst, cost);
        if (!direct) (*this)[dst].emplace_back(dst, src, cost);
    }
};
#line 5 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Graph/dijkstra.hpp"

template <class Cost>
std::vector<Cost> dijkstra(const Graph<Cost>& graph, int s) {
    std::vector<Cost> dist(graph.size(), -1);
    dist[s] = 0;
    MinHeap<std::pair<Cost, int>> que;
    que.emplace(0, s);

    while (!que.empty()) {
        auto [d, v] = que.top();
        que.pop();
        if (d > dist[v]) continue;

        for (const auto& e : graph[v]) {
            if (dist[e.dst] != -1 &&
                dist[e.dst] <= dist[v] + e.cost) continue;
            dist[e.dst] = dist[v] + e.cost;
            que.emplace(dist[e.dst], e.dst);
        }
    }

    return dist;
}
#line 2 "main.cpp"
#include <iostream>

using namespace std;
constexpr int N = 100;

int enc(int x, int t) { return x + t * N; }

void solve() {
    int a, b, x, y;
    cin >> a >> b >> x >> y;
    int s = enc(--a, 0), g = enc(--b, 1);

    Graph<int> graph(N * 2);
    for (int i = 0; i < N; ++i) {
        graph.span(false, enc(i, 0), enc(i, 1), x);

        if (i + 1 < N) {
            graph.span(false, enc(i + 1, 0), enc(i, 1), x);
            for (int t = 0; t < 2; ++t) {
                graph.span(false, enc(i, t), enc(i + 1, t), y);
            }
        }
    }

    cout << dijkstra(graph, s)[g] << "\n";
}

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

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define all(n) n.begin(),n.end()
#define forn(i,a,b) for(i=a;i<b;i++)
ll mul(ll x,ll y){  return (x*y)%mod;}
ll power(ll x, ll y) {ll res = 1; x %= mod;
 while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}
ll fact(ll n) {ll res = 1; for (ll i = 2; i <= n; i++) res = mul(res , i); return res; }
ll nCr(ll n, ll r) { return mul(fact(n),mod_inv(mul(fact(r),fact(n - r))));}
const int mxn =100000;
vli v[mxn];
ll c[mxn]={};
bool ans[mxn]={},vis[mxn]={};
map<int,int> m;

void dfs(ll x){
	if(m[c[x]]) ans[x]=1;
	m[c[x]]++;;
	vis[x]=1;
	ll i;
	for(i=0;i<v[x].size();i++){
       if(vis[v[x][i]]==0){
       	dfs(v[x][i]);
       }
	}
	m[c[x]]--;
}

int main() {
  fast;
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  ll t=1;
  // cin>>t;
  while(t--){
    ll n;
    cin>>n;
    scan(c,n);
    ll x,y,i;
    for(i=0;i<n-1;i++){
    	cin>>x>>y;
    	x--;y--;
    	v[x].pb(y);
    	v[y].pb(x);

    }
    dfs(0);
    for(i=0;i<n;i++){
    	if(!ans[i]) cout<<i+1<<endl;
    }

  }
return 0;
 }

//author : ainunsy1
#include <bits/stdc++.h>
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
vector<ll>v[100005];
ll n,c[100005];
bool lewat[100005],ans[100005];
int udh[100005];
void dfs(ll b){
	lewat[b]=true;
	if(udh[c[b]])ans[b]=true;
	udh[c[b]]++;
	for(auto d:v[b]){
		if(!lewat[d]) dfs(d);
	}
	udh[c[b]]--;
}
void solve(){
	cin>>n;
	forn(i,1,n) cin>>c[i];
	forn(i,1,n-1){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(1);
	forn(i,1,n){
		if(!ans[i]) cout<<i<<endl;
	}
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t=1;
	// cin>>t;
	forn(i,1,t){
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   double x1,x2,y1,y2;
   cin>>x1>>y1>>x2>>y2;
   if(x1>x2)swap(x1,x2),swap(y1,y2);
   double ans=(y1*(x2-x1))/(y1+y2);
   cout<<fixed<<setprecision(10);
   cout<<x1+ans<<"\n";
   return 0;
}

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

int solve() {
  int n;
  string s;
  cin >> n >> s >> s >> s;
  cout << string(n, '0') << string(n, '1') << "0\n";
  return 0;
}

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


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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

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

ld const PI = 4*atan((ld)1);

int main()
{
	fastio;

	int n;
	cin >> n;

	vector<ll> a(n), b(n);
	for (ll &x : a)
		cin >> x;

	for (ll &x : b)
		cin >> x;

	ll ma = 0, res = 0;
	for (int i = 0; i < n; ++i)
	{
		ma = max(ma, a[i]);
		res = max(res, ma * b[i]);

		cout << res << '\n';
	}

	return 0;
}

// Artur Kraska, II UWr

#include <bits/stdc++.h>

#define forr(i, n)                  for(int i=0; i<n; i++)
#define FOREACH(iter, coll)         for(auto iter = coll.begin(); iter != coll.end(); ++iter)
#define FOREACHR(iter, coll)        for(auto iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,R,PRED)            ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;})
#define testy()                     int _tests; scanf("%d", &_tests); FOR(_test, 1, _tests)
#define CLEAR(tab)                  memset(tab, 0, sizeof(tab))
#define CONTAIN(el, coll)           (coll.find(el) != coll.end())
#define FOR(i, a, b)                for(int i=a; i<=b; i++)
#define FORD(i, a, b)               for(int i=a; i>=b; i--)
#define MP                          make_pair
#define PB                          push_back
#define ff                          first
#define ss                          second
#define deb(X)                      X;

#define M 1000000007
#define INF 1000000007LL

using namespace std;

int n, m, a;
long long t1[1000007], t2[1000007], m1[1000007];

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n)
    {
        scanf("%lld", &t1[i]);
        m1[i] = max(m1[i-1], t1[i]);
    }
    long long res = 0;
    FOR(i, 1, n)
    {
        scanf("%lld", &t2[i]);
        res = max(res, t2[i]*m1[i]);
        printf("%lld\n", res);
    }

    return 0;
}


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

struct cond {
	int X, Y, Z;
};

bool IsOneBit(long long bits, int i) {
	return (bits & (1ll << i)) > 0;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<cond> Cond(M);
	for (auto& [X, Y, Z] : Cond) cin >> X >> Y >> Z;
	int PN = 1 << N;
	vector<long long> DP(PN);
	DP[0] = 1;
	for (int bit = 0; bit < PN; bit++) {
		int one = 0;
		for (int i = 0; i < N; i++) one += IsOneBit(bit, i);
		bool isOK = true;
		for (auto& [X, Y, Z] : Cond) {
			if (one > X) continue;
			int sum = 0;
			for (int j = 0; j < Y; j++) sum += IsOneBit(bit, j);
			if (sum > Z) isOK = false;
		}
		if (isOK) {
			for (int i = 0; i < N; i++) {
				if (IsOneBit(bit, i)) DP[bit] += DP[bit ^ (1 << i)];
			}
		}
		else DP[bit] = 0;
	}
	cout << DP[PN - 1] << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<int> X(m), Y(m), Z(m);
  vector<vector<pair<int, int>>> A(n+1);
  rep(i, m) {
    cin >> X[i] >> Y[i] >> Z[i];
    Y[i]--;
    A[X[i]].push_back({Y[i], Z[i]});
  }
  vector<ll> dp(1<<n);
  dp[0] = 1;
  rep(i, 1<<n) {
    rep(j, n) {
      if((i>>j)&1) continue;
      vector<int> cnt(n);
      int ne = i^(1<<j);
      rep(k, n) {
        if((ne>>k)&1) cnt[k]++;
      }
      rep(k, n) if(k) cnt[k] += cnt[k-1];
      bool ok = true;
      int sz = __builtin_popcount(ne);
      for(auto [y, z]: A[sz]) {
        if(cnt[y] > z) ok = false;
      }
      if(ok) dp[ne] += dp[i];
    }
  }
  cout << dp[(1<<n)-1] << endk;
  return 0;
}


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

#define FASTIO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define int long long
#define mod ((int)1e9 + 7)

void solve(){
        int n , ans = 0 ; cin >> n ;
        vector<int> a(n) ;
        for(int& i : a) cin >> i ;
        for(int i = 0 ; i < n ; ++i){
                int x ; cin >> x ;
                ans += a[i] * x ;
        }
        cout << ((ans == 0) ? "Yes" : "No") << "\n" ;
}

signed main(){
        FASTIO
        int T = 1 ;
       // cin >> T ;
        while(T--) solve() ;
        return 0 ;
}

#include <bits/stdc++.h>
using namespace std;
using i64 = unsigned long long;
#define rep(i, n) for (i64 i = 0; i < (n); i++)
#define IN_i64(n) \
    i64 n; \
    cin >> n;
#define IN_veci64(a, n) \
    vector<i64> a((n)); \
    rep(i, n) cin >> a[i];
constexpr i64 INF64 = 1LL << 62LL;
inline i64 modpow(i64, i64, i64 = INF64);
inline i64 gcd(i64, i64);
template <class T> inline bool chmax(T &a, T b);
template <class T> inline bool chmin(T &a, T b);

int main()
{
    IN_i64(N);
    IN_i64(K);
    rep(i,K){
        if (N%200==0) N/=200;
        else{
            N*=1000;
            N+=200;
        }
    }
    cout<<N<<endl;
}

i64 modpow(i64 base, i64 exp, i64 mod)
{
    i64 ans = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
        {
            ans *= base;
            ans %= mod;
        }
        exp /= 2;
        base *= base;
        base %= mod;
    }
    return ans;
}

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

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

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


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

#define sp(y) fixed<<setprecision(y)
#define w(t) int t;cin>>t;while(t--)
//#define pi 2*acos(0.0)
#define bg begin()
#define en end()
#define all(x) x.begin(),x.end()
#define sortarr(x) sort(x,x+arrsize(x))
#define arrsize(x) sizeof(x)/sizeof(x[0])
#define sortall(x) sort(all(x))
#define formn(m,n) for(m;m<=n;m++)
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define REP(i,a,b) for (auto i=a;i<=b;i++)
#define sq(a) (a)*(a)
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
//fast I/o;
void fastIO(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);

}
void init_code(){
    fastIO();

}

//solution
#define mx 1000005
#define m7 1000000007
int prime[mx];
int arr[mx];
void seive(){
    prime[0]=1;
    prime[1]=1;
    for(ll i=2;i<mx;i++){
        if(prime[i]==0){
            for(ll j=i*i;j<mx;j+=i){
                prime[j]=1;
            }
        }

    }
}

int solve(){
    ll a,b,c,d;
    ll blue,red;
    cin>>a>>b>>c>>d;
    red = 0;
    blue =a;

    if((c*d - b) <=0){
       cout<<-1<<endl;
    }else{
         REP(i,1,a){
               blue+=b;
               red+=c;
               if(blue<=d*red){
                    cout<<i<<endl;
                    return 0;
               }

         }

    }

return 0;
}
//end solution
int main(){

     init_code();
    solve();
}

#include <iostream>

#include <cmath>
#include <iostream>

namespace {

int solve(const int a, const int b, const int c, const int d) {
  int tmp = c * d - b;
  if (tmp > 0) {
    return static_cast<int>(std::ceil(static_cast<double>(a) / tmp));
  }
  return -1;
}
}  // namespace

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;

  std::cout << solve(a, b, c, d) << std::endl;
  return EXIT_SUCCESS;
}


// #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<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 res = 1;
    while (b) {
        if (b & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}
// ---------------------------------------------------------------------
const ll N = 2e5 + 5, inf = 2e18;

void solve()
{
    ll n, q;
    cin >> n >> q;
    vll v(n);
    forn(i, 0, n) cin >> v[i];
    ll x;
    forn(i, 0, q)
    {
        cin >> x;
        ll lo = 0, hi = inf, mid, d;
        while (lo + 1 < hi)
        {
            mid = (lo + hi) >> 1;
            d = upper_bound(all(v), mid) - v.begin();
            if (mid - d > x - 1)
                hi = mid;
            else
                lo = mid;
        }
        cout << hi << '\n';
    }
}

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

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

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

typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 1e6, M = 1e9+7, inf = -2e9;
// #define runcase LOL
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ull> vul;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<array<int, 2>> var2;
typedef vector<array<int, 3>> var3;
typedef pair<ll, ll> pl;
typedef vector<pl> vpl;

#define FOR(j, V) for(int j = 0; j < V; j++)
#define DOR(tt, X) for(int tt = X; tt >= 0; --tt)
#define pb push_back
#define all(X) X.begin(),X.end()
#define sz(X) int(X.size())
// template insertion spaces

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iterator>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, std::less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve(int test_case = 0)
{
    int N, Q;
    cin >> N >> Q;
    vector<int64_t> A(N);
    for(int64_t &i : A) {
        cin >> i;
    }
    for(int qq = 0; qq < Q; qq++) {
        int64_t K; cin >> K;
        int64_t l = 1, r = 2e18;

        while(l < r) {
            int64_t mid = l + (r - l) / 2;
            int64_t below = lower_bound(A.begin(), A.end(), mid) - A.begin();
            below++;
            if(!binary_search(A.begin(), A.end(), mid)) --below;

            if(mid - below >= K) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }

        cout << l << "\n";
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    // precalc();
    int T = 1;
#ifdef runcase
    cin >> T;
#endif

    for(int nt = 0, i; nt < T; nt++) {
        solve(nt);
        ++i;
    }
}


// RAKSHIT KADAM

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// find_by_order returns iterator to  element present at that index...
// order_of_key returns no. of elements having value stricktly less than that given in the order_of_key();
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :

#define inf 1000000003
#define MOD  1000000007
#define newMOD  998244353
#define MAX 200006
#define pi 3.1415926535897932384626433832795
#define ld long double
#define ll long long
#define int long long
#define INF 1000000000000000008
#define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define satisfy cerr<<"\n\n---------------Running on multiple test cases--------------"<<endl;ll t; cin>> t; while(t--)
#define mp make_pair
#define pb push_back
#define endl "\n"
#define x first
#define y second
#define Endl endl
#define pii pair<ll,ll>
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500004;
//ll fact[300007] = {0};
//void facto() {fact[0] = 1; fact[1] = 1; for(int i = 2; i < 300005; i++){fact[i] = (fact[i-1]*i)%MOD;}}
//ll ncr(ll n, ll r)
//{
//    if(r>n)return 0;
//    ll res = 1;
//    res = fact[n];
//    res*=modInverse(fact[r],MOD);
//    res%=MOD;
//    res*=modInverse(fact[n-r],MOD);
//    res%=MOD;
//    return res;
//}

//vector<ll>primes;

void solve()
{
    double x,y,z;
    cin>>x>>y>>z;
    ll i=0;
    while(y/x>(double(i))/z)i++;
    cout<<--i<<endl;
}

signed main()
{

    Need_for_speed(activated);

//    satisfy
//    { solve();
//    }

    solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define BE(x) x.begin(), x.end()

int main() {
    double x, y, z;
    cin >> x >> y >> z;
    double a = y*z / x;
    a -= 0.001;
    int ans = a;
    cout << ans << endl;
}


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

typedef long long ll;

#define F0R(i, x, y) for (int i = x; i < y; i++)
#define FOR(i, n) F0R(i, 0, n)
#define F0RD(i, x, y) for (int i = y - 1; i >= x; i--)
#define FORD(i, n) F0RD(i, 0, n)

#define F first
#define S second

int mp(int x, int c) {
    return 1000 * c + x;
}

vector<int> adj[2005];
bool vis[2005];

void dfs(int v) {
    vis[v] = true;
    for (int to : adj[v]) {
        if (!vis[to]) dfs(to);
    }
}

int main() {
#ifdef mikey
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin >> n >> m;
    auto ad = [&] (int a, int b, int c, int d) {
        adj[mp(a, b)].push_back(mp(c, d));
        adj[mp(c, d)].push_back(mp(a, b));
    };
    ad(0, 0, 0, 1);
    ad(0, 0, m - 1, 1);
    ad(n - 1, 0, 0, 1);
    ad(n - 1, 0, m - 1, 1);
    FOR(i, n) {
        string s; cin >> s;
        FOR(j, m) {
            if (s[j] == '#') {
                ad(i, 0, j , 1);
            }
        }
    }
    int rcc = 0;
    FOR(i, n) {
        if (!vis[mp(i, 0)]) {
            dfs(mp(i, 0));
            ++rcc;
        }
    }
    memset(vis, false, sizeof(vis));
    int ccc = 0;
    FOR(i, m) {
        if (!vis[mp(i, 1)]) {
            dfs(mp(i, 1));
            ++ccc;
        }
    }
    cout << min(rcc - 1, ccc - 1) << '\n';
}

#include <bits/stdc++.h>
using namespace std;
int h,w;
string s[1003];
int f[2003];
int F(int x){
	return f[x]==x?x:f[x]=F(f[x]);
}
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	s[0][0]=s[0][w-1]=s[h-1][0]=s[h-1][w-1]='#';
	for(int i=0;i<h+w;i++)f[i]=i;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)
		if(s[i][j]=='#'){
			int x=F(i),y=F(j+h);
			if(x!=y)f[x]=y;
		}
	unordered_map<int,bool>R,C;
	for(int i=0;i<h;i++)R[F(i)]=1;
	for(int i=0;i<w;i++)C[F(i+h)]=1;
	cout<<min((int)R.size(),(int)C.size())-1;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n,m,ans;
vector<int> adj[400001];
vector<int> cur;
bool vis[400001];
void dfs(int x){
    vis[x]=true;
    cur.pb(x);
    for (auto i:adj[x]){
        if (vis[i]) continue;
        dfs(i);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>m;
    n=400000;
    for (int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=n;i++){
        if (vis[i] || adj[i].empty()) continue;
        cur.clear();
        dfs(i);
        int curnum=cur.size(),edges=0;
        for (auto j:cur){
            edges+=adj[j].size();
        }
        edges/=2;
        ans+=min(curnum,edges);
    }
    cout<<ans;
}

/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define isSet(n, i) bool(n & (1LL << i))
#define Set(n, i) (n | (1LL << i))
#define unSet(n, i) (n & !(1LL << i))
#define PI 2 * acos(0.0)
#define all(r) (r).begin(), (r).end()
#define dbg(a) cout << #a << " ->->->-> " << a << "\n"
#define inf 100000000000000000
#define mod 1000000007
#define N 100009

int dirx[] = {1, -1, 0, 0, 1, 1, -1, -1}, diry[] = {0, 0, 1, -1, 1, -1, 1, -1};

//=============================================ASIFAZAD==============================================//

int n, ans[N], colors[N], cur[N];
vi adj[N];

void dfs(int nod, int par)
{
    if (cur[colors[nod]])
        ans[nod] = -1;
    else
        ans[nod] = 1;
    cur[colors[nod]]++;
    for (auto x : adj[nod])
        if (x != par)
            dfs(x, nod);
    cur[colors[nod]]--;
}

int main()
{
    io;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &colors[i]);
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        u--;
        v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(0, -1);
    for (int i = 0; i < n; i++)
        if (ans[i] == 1)
            printf("%d\n", i + 1);
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

lint powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

int main(void){
    int N;
    cin >> N;
    if(N%2) cout << "Black" << endl;
    else cout << "White" << endl;
}

#include <bits/stdc++.h>

using namespace std;

#define N 100005
#define MOD 1000000007
#define fo(i, b, n) for (long i = b; i < n; ++i)
#define rfo(i, b, n) for (long i = b; i >= n; --i)
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define mem(ar, val) memset(ar, val, sizeof(ar))
#define fi first
#define se second
#define pb push_back
#define fastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.precision(12);

typedef long long ll;
typedef pair<long, long> pll;
typedef pair<ll, ll> plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vl> vvl;
typedef vector<vll> vvll;

const double PI = 3.141592653589793238;
const ll oo = 1e18;

void solve()
{
    ll n;
    string s;
    cin >> n >> s;
    if (s[0] != s[n - 1])
    {
        cout << "1";
        return;
    }
    for (long i = 2; i < n - 1; ++i)
    {
        if (s[i] != s[n - 1] && s[i - 1] != s[0])
        {
            cout << "2";
            return;
        }
    }
    cout << "-1";
}

signed main()
{
    fastIO;
    solve();
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}
template<typename T, typename U> static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

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

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;}

int solve(){

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

    return 0;
}
signed main(){
    asdf
    // freopen("inputf.in", "w", stdout);

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

#pragma GCC optimize("Ofast")
#if 1
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using ll = int64_t;
using db = double;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define show(x) cerr << #x << " = " << (x) << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo(x) cout<<((x)?"Yes":"No")<<newl;
#define YESNO(x) cout<<((x)?"YES":"NO")<<newl;
#define v(T) vector<T>
#define vv(T) vector<vector<T>>

template<class A, class B> using umap = unordered_map<A, B>;
template<class A> using uset = unordered_set<A>;

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const pair<T, T>& v) {
  o << "(" << v.first << "," << v.second << ")";
  return o;
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  for (auto e : v) {
    o << e << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

struct P {
  int x, y;
  int dist(const P& v) {
    return max(abs(v.x - x), abs(v.y - y));
  }
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  v(P) as(N);
  vpii xs(N), ys(N);
  F0R(i, N) {
    cin >> as[i].x>>as[i].y;
    xs[i] = { as[i].x,i };
    ys[i] = { as[i].y,i };
  }
  sort(rng(xs));
  sort(rng(ys));
  uset<int> vs;
  auto F = [&](int i) {
    vs.insert(xs[i].second);
    vs.insert(ys[i].second);
  };
  F(0); F(1); F(N - 2); F(N - 1);
  vi bs;
  for (auto v : vs) {
    bs.push_back(v);
  }
  vi rs;
  F0R(i, sz(bs)) {
    FOR(j, i + 1, sz(bs)) {
      rs.push_back(as[bs[i]].dist(as[bs[j]]));
    }
  }
  sort(rrng(rs));
  cout << rs[1];
}
#endif


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

#include <iostream>
#include <cassert>

template<long long mod>
class modint{
private:
  using T = long long;
  T a;
public:
  constexpr modint(const long long x = 0) noexcept : a((x%mod+mod)%mod) {}
  constexpr T& value() noexcept { return a; }
  constexpr const T& value() const noexcept { return a; }
  constexpr modint operator-() const noexcept {
    return modint(0) -= *this;
  }
  constexpr modint operator+(const modint& rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint& rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint& rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint& rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint& rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint& rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint& rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(const modint& rhs) noexcept {
    return *this *= rhs.inv();
  }
  constexpr bool operator==(const modint& rhs) const noexcept {
    return a == rhs.a;
  }
  constexpr bool operator!=(const modint& rhs) const noexcept {
    return not (*this == rhs);
  }
  constexpr modint pow(long long k) const noexcept {
    modint ret(1);
    modint x = k > 0 ? *this : this->inv();
    k = abs(k);
    while(k > 0){
      if(k&1) ret *= x;
      x *= x;
      k >>= 1;
    }
    return ret;
  }
  constexpr modint inv() const noexcept {
    return pow(mod-2);
  }
  friend std::ostream& operator<<(std::ostream &os, const modint &X) noexcept {
    return os << X.a;
  }
  friend std::istream& operator>>(std::istream &is, modint &X) noexcept {
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

template<typename T>
T power(T x, long long k){
  T ret{1};
  while(k > 0){
    if(k&1) ret *= x;
    x *= x;
    k /= 2;
  }
  return ret;
}

int main(){
  using mint = modint<998244353>;
  int n, m;
  cin >> n >> m;
  mint ans = 0;
  vector<mint> pow_m(n+1);
  pow_m[0] = 1;
  for(int i = 0; i < n; ++i)
    pow_m[i+1] = pow_m[i]*m;
  for(int i = 1; i <= m; ++i){
    ans += power<mint>(m-i+1,n) - power<mint>(m-i,n);
    mint a = 1, b = 1;
    for(int j = 1; j+1 <= n; ++j){
      a *= m-i+1, b *= m-i;
      if(j+2 <= n){
        mint p = a - b;// i が 1 回以上使われる
        p *= n-j-1;// 長さ j+2 の区間の取り方
        p *= (i-1)*(i-1);//両端
        p *= pow_m[n-j-2];//残り
        ans += p;
      }
      mint q = a - b;
      q *= 2;
      q *= i-1;//両端
      q *= pow_m[n-j-1];//残り
      ans += q;
    }
  }
  cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define db double
#define rep(i,be,en) for(int i=be;i<=en;i++)
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
//const double pi=acos(-1);
const int mod=1e9+7;
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)
using namespace std;
const int N=1e5+7;
const int M=1e6+7;

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

int T,n,m,fl;

signed main(){
	n=read();
	int x=1,a=0,b=0,c=0,ans,aa,bb,cc;
	a=n/x;
	ans=a;aa=a;bb=0;cc=0;
	while(x*2<=n){
		b++;
		x*=2;
		a=n/x;
		c=n%x;
		if(a+b+c<ans){
			ans=a+b+c;
			aa=a;bb=b;cc=c;
		}
	}

	printf("%lld\n",ans,aa,bb,cc);

}


#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define FOR(i,a,b)  for(ll i=a;i<=b;i++)
#define FORR(i,a,b)  for(ll i=a;i>=b;i--)
#define vl vector<ll>
#define ld long double
#define vld vector<ld>
#define vvl vector<vector<long long>>
#define vvld vector<vector<ld>>
#define pll pair<long,long>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.14159265358979323846264338327950288419716939937510
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define mset(a,val) memset(a,val,sizeof(a));
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M = 1000000007;
const ll MM = 998244353;
#define endl "\n"
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T, typename F>
void chmax( T &a, F b) {
  if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
  if (b < a)a = b;
}

ll powM(ll a, ll b, ll m) {
  if (b < 0 || a <= 0)return 0;
  a %= m;
  ll ans = 1LL;
  while (b) {
    if (b & 1)ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}

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

const ll N = 3e5 + 5;

//ll dp[105][105][105];

//ll allowed[105][105][105];

int main() {

  IOS;

#ifndef ONLINE_JUDGE

  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);

#endif

  ll n, x;
  cin >> n >> x;
  vl a(n + 1);
  FOR(i, 1, n) {
    cin >> a[i];
  }

  /*

  let us say we choose q elements.

  x%q == (sum)%q;

  so basically what is the max sum from q elements

  st sum%q==x%q;

  dp[i][j][mod]. (sum%q==mod)  mod:[0,q-1];

  dp[i-1][j][mod],dp[i-1][j-1][(mod-a[i]%q)]+a[i]

  and last me dp[n][q][x%q]  (for a fixed q).

  so ans=(x-dp)/q;

  */

  ll ans = x;

  FOR(q, 1, n) {
    vector<vvl>dp(n + 1, vvl(n + 1, vl(n + 1, -1e18)));

    dp[0][0][0] = 0;

    for (ll i = 0; i < n; i++) {
      for (ll j = 0; j <= i; j++) {
        for (ll mod = 0; mod < q; mod++) {
          chmax(dp[i + 1][j][mod], dp[i][j][mod]);
          chmax(dp[i + 1][j + 1][(mod + a[i + 1]) % q], dp[i][j][mod] + a[i + 1]);
        }
      }
    }

    ll blah = x % q;
    //d2(q, dp[n][q][blah]);
    if (dp[n][q][blah] > 0) chmin(ans, (x - dp[n][q][blah]) / q);
  }
  cout << ans << endl;

  return 0;
}

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

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

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

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

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

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

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

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

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

const int h = 1000000007;

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

	int n;
	cin >> n;
	ll x;
	cin >> x;
	vl v(n);
	cin >> v;
	ll ans = LLONG_MAX;
	rep(num,1,n+1)
	{
		vvl dp(num + 1, vl(num, -1));
		dp[0][0] = 0;
		for(ll x : v)
			per(i,num-1,-1)
				rep(j,0,num)
					if(dp[i][j] != -1)
						dp[i + 1][(j + x) % num] = max(dp[i + 1][(j + x) % num], dp[i][j] + x);
		if(dp.back()[x % num] != -1)
			ans = min(ans, (x - dp.back()[x % num]) / num);
	}
	cout << (ans == LLONG_MAX ? -1 : ans);
}


#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;
typedef	long long ll;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

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

ll modinv(ll a) {
	ll m = mod, y = 0, x = 1;
	while (a > 1) {
		ll q = a / m, t = m;
		m = a % m;
		a = t;
		t = y;
		y = x - q * y;
		x = t;
	}
	return x < 0 ? x + mod : x;
}

int main() {
	fio;
	ll n, m;
	cin >> n >> m;
	ll dp[n][m];
	for (int i = 0;i < m;i++)
		dp[0][i] = 1;
	vl s(n), minv(m + 1), mpm1j(m, 1);
	s[0] = m;
	mpm1j[0] = 0;
	ll mpmi = 1;
	for (int j = 1;j <= m;j++)
		minv[j] = modinv(j);
	for (int i = 1;i < n;i++) {
		mpmi = mpmi * m % mod;
		for (int j = 0;j < m;j++) {
			mpm1j[m - 1 - j] = mpm1j[m - 1 - j] * (m - 1 - j) % mod;
			dp[i][j] = (s[i - 1] + (mpmi * j + mpm1j[m - 1 - j]) % mod * minv[j + 1]) % mod;
		}
		for (int j = 0;j < m;j++)
			s[i] = (s[i] + dp[i][j]) % mod;
	}
	cout << s[n - 1] << '\n';
}

#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3+5,mod = 998244353;
int n,m,powm[maxn][maxn],ans;
int main(){
	scanf("%d %d",&n,&m);
	powm[0][0] = 1;
	for(int i=1;i<=m;++i){
		powm[i][0] = 1;
		for(int j=1;j<=n;++j)powm[i][j] = 1ll*powm[i][j-1]*i%mod;
	}
	ans = 1ll*n*powm[m][n]%mod;
	for(int i=1;i<n;++i)
		for(int j=1;j<=m;++j)
			ans -= 1ll*(n-i)*powm[m-j][i-1]%mod*powm[m][n-i-1]%mod,ans = (ans+mod)%mod;
	printf("%d",ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std ;

#define i64 int64_t // typecast using i64(x)
#define int int64_t
#define ld long double
#define endl "\n"
#define f(i,a,b) for(int i=int(a);i<int(b);++i)

#define pr pair
#define ar array
#define fr first
#define sc second
#define vt vector
#define pb push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue

#define sz(x) ((int)(x).size())
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))

template<class A> void rd(vt<A>& v);
template<class T> void rd(T& x){ cin >> x; }
template<class H, class... T> void rd(H& h, T&... t) { rd(h) ; rd(t...) ;}
template<class A> void rd(vt<A>& x) { for(auto& a : x) rd(a) ;}

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

template<typename T>
void __p(T a) {
  cout<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cout<<"{";
  __p(a.first);
  cout<<",";
  __p(a.second);
  cout<<"}\n";
}
template<typename T>
void __p(std::vector<T> a) {
  cout<<"{";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cout<<",}\n"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout<<name<<" : ";
  __p(arg1);
  cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cout.write(names,comma-names)<<" : ";
  __p(arg1);
  cout<<" | ";
  __f(comma+1,args...);
}

void setIO(string s = "") {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin.exceptions(cin.failbit);
  if(sz(s)){
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
  }
}
template<int MOD> struct mint {
  static const int mod = MOD ;
  int v; explicit operator int() const { return v; }
  mint() { v = 0; }
  mint(long long _v) { v = int((-MOD < _v && _v < MOD) ? _v : _v % MOD);
    if (v < 0) v += MOD; }
  friend bool operator==(const mint& a, const mint& b) {
    return a.v == b.v; }
  friend bool operator!=(const mint& a, const mint& b) {
    return !(a == b); }
  friend bool operator<(const mint& a, const mint& b) {
    return a.v < b.v; }

  mint& operator+=(const mint& m) {
    if ((v += m.v) >= MOD) v -= MOD;
    return *this; }
  mint& operator-=(const mint& m) {
    if ((v -= m.v) < 0) v += MOD;
    return *this; }
  mint& operator*=(const mint& m) {
    v = int((long long)v*m.v%MOD); return *this; }
  mint& operator/=(const mint& m) { return (*this) *= inv(m); }
  friend mint power(mint a, long long p) {
    mint ans = 1; assert(p >= 0);
    for (; p; p /= 2, a *= a) if (p&1) ans *= a;
    return ans; }
  friend mint inv(const mint& a) { assert(a.v != 0);
    return power(a,MOD-2); }

  mint operator-() const { return mint(-v); }
  mint& operator++() { return *this += 1; }
  mint& operator--() { return *this -= 1; }
  friend mint operator+(mint a, const mint& b) { return a += b; }
  friend mint operator-(mint a, const mint& b) { return a -= b; }
  friend mint operator*(mint a, const mint& b) { return a *= b; }
  friend mint operator/(mint a, const mint& b) { return a /= b; }
};
const int MOD = 998244353 ;
typedef mint<MOD> mi;
signed main(){
  setIO() ;
  int N, M, K;
  rd(N,M,K);
  mi ans ;
  if(N == 1){
  	ans = power(mi(K),M);
  }else if(M == 1){
  	ans = power(mi(K),N);
  }else{
  	for(int x=1; x<=K; x++){
  		mi countB =  power(mi(K-x+1),M);
  		mi countA =  power(mi(x),N) - power(mi(x-1),N) ;
  		ans += countA * countB;
  	}
  }
  cout << ans.v ;
}

// Skyqwq
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long LL;

const int N = 2e5 + 5, P = 998244353;

int n, m, K;

int inline power(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = (LL)res * a % P;
		a = (LL)a * a % P;
		b >>= 1;
	}
	return res;
}

int ans;

int main() {
	scanf("%d%d%d", &n, &m, &K);
	if (n > 1 && m > 1) {
		for (int i = 1; i <= K; i++) {
			ans = (ans + ((LL)power(i, n) - power(i - 1, n) + P) * power(K - i + 1, m)) % P;
		}
	} else if (n == 1 && m == 1) {
		ans = K;
	} else if (n == 1) {
		for (int i = 1; i <= K; i++) {
			ans = (ans + (LL)power(K - i + 1, m) - power(K - i, m) + P) % P;
		}
	} else if (m == 1) {
		for (int i = 1; i <= K; i++) {
			ans = (ans + (LL)power(i, n) - power(i - 1, n) + P) % P;
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<cstring>
#define ll long long
using namespace std;
ll x,y,a,b,g;
int main(){

	cin>>x>>y>>a>>b;

    while((double)a*x<=x+b && a*x<y){
       x*=a;
       g++;
    }

    cout<<g + (y-1-x)/b<<endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); (i)++)
#define per(i, n) for (ll i = n - 1; i >= 0; (i)--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define ROF(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define ALL(x) std::begin(x), std::end(x)

typedef long long ll;

int main(){
    //input, initialize
    ll A, B, K; cin >> A >> B >> K;
    //solve
    vector<vector<ll>> combi(A+B+1, (vector<ll>(A+B+1, 0)));
    rep(i, A+B+1) combi[i][0] = 1;
            // combi[i][j] := iCjを表す
    FOR(i, 1, A+B+1)FOR(j, 1, i+1){
        combi[i][j] = combi[i][j-1] * (i - j + 1) / j;
    }
    vector<bool> Bspot(A+B+1); //Bspot[i] := ひだりからi番目(1-based)のBの位置
    ROF(i, 1, B+1)FOR(j, i, A+B+1){
        if(combi[j][i] >= K){
            Bspot[j] = true;
            K -= combi[j-1][i]; // j == i のときは0が引かれてそのまま
            break;
        }
    }

    //output
    ROF(i, 1, A+B+1){
        if(Bspot[i]) cout << 'b';
        else cout << 'a';
    }
    cout << '\n';
}


#include <bits/stdc++.h>
using namespace std;
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 DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define repl(i, a, b) for(int i = a; i < int(b); i++)
#define rep(i, n) repl(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    double ans = sx;
    ans += (double)(gx - sx) * (double)sy / (double)(sy + gy);
    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double x1,x2,y1,y2,d;
     cin>>x1>>y1>>x2>>y2;
     d=(y1*x2+y2*x1);
     d=d/(y2+y1)*1.00;
     cout<<fixed<<setprecision(10);
     cout<<d<<endl;
}


#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define rep(i,n) repi(i,0,n)
#define repi(i,a,n) for(ll i=a;i<(ll)n;++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
void YN(bool a) { cout << (a ? "Yes" : "No") << endl; }
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; }
void show(){ cout << endl; }
template <class Head, class... Tail>
void show(Head&& head, Tail&&... tail){ cout << head << " "; show(std::forward<Tail>(tail)...); }
template<class T> inline void showall(T& a) { for(auto v:a) cout<<v<<" "; cout<<endl; }

vector<ll> sz;
vector<vector<ll>> child;

int dfs(int idx)
{
  sz[idx] = 1;
  for(auto to : child[idx])
  {
    sz[idx] += dfs(to);
  }
  return sz[idx];
}

int count(int idx) // idxの頂点に来た時に手番のある人が、また戻ってきたときの相対スコア
{
  vector<ll> odd;
  vector<ll> even;
  ll score = -1;
  for(auto to : child[idx]) ((sz[to] & 1) ? odd : even).emplace_back(count(to));

  sort(RALL(odd));
  int sign = 1;
  for(auto v : odd)
  {
    score += sign * v;
    sign *= -1;
  }

  for(auto v : even)
  {
    if (v >= 0) score += v;
    else score += v * ((odd.size() & 1) ? -1 : 1);
  }
  return score;
}

void solve()
{
  ll n;
  cin >> n;
  sz.resize(n, 0);
  child.resize(n, vector<ll>());
  repi(i, 1, n)
  {
    ll p;
    cin >> p;
    p--;
    child[p].emplace_back(i);
  }

  dfs(0);
  show((n - count(0)) / 2);
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

const int N = 100000 + 1;

int coins[N], sub[N];
vector<int> adj[N];

void dfs(int u) {
  sub[u] = 1;
  for (auto c : adj[u]) {
    dfs(c);
    sub[u] += sub[c];
  }

  coins[u] = 1;
  vector<array<int, 2>> children;
  for (auto c : adj[u]) {
    if (sub[c] % 2 == 0) {
      if (coins[c] <= sub[c] - coins[c]) {
        coins[u] += coins[c];
      }
    } else {
      children.push_back({sub[c] - 2 * coins[c], c});
    }
  }
  sort(children.rbegin(), children.rend());

  for (int i = 0; i < (int) children.size(); ++i) {
    int c = children[i][1];
    if (i % 2 == 0) {
      coins[u] += coins[c];
    } else {
      coins[u] += sub[c] - coins[c];
    }
  }

  for (auto c : adj[u]) {
    if (sub[c] % 2 == 0 && coins[c] > sub[c] - coins[c]) {
      if (children.size() % 2 == 0) {
        coins[u] += coins[c];
      } else {
        coins[u] += sub[c] - coins[c];
      }
    }
  }
}

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

  int n;
  cin >> n;

  for (int i = 2; i <= n; ++i) {
    int p;
    cin >> p;
    adj[p].push_back(i);
  }

  dfs(1);

  cout << coins[1] << "\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

bool isPrime(ll n){
  if(n<=1) return false;
  if(n<=3) return true;

  if(n%2==0 || n%3==0) return false;
  for(ll i=5; i*i<=n; i++){
      if(n%i==0 || n%(i+2)==0){
        return false;
      }
  }
  return true;
}

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

  string s;
  cin>>s;
  string ans = "";
  for(ll i=0;i<s.length();i++)
  {
    if(s[i]=='.'){
      break;
    }
    ans+=s[i];
  }
  cout<<ans<<endl;
}

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

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


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;

long long const mod = 998244353;
struct mint{
	long long val;
	mint(long long val = 0): val(val % mod) {}
	mint& operator += (const mint n){
		val += n.val;
		if(val >= mod) val -= mod;
		return *this;
	}
	mint& operator -= (const mint n){
		val -= n.val;
		if(val < 0) val += mod;
		return *this;
	}
	mint& operator *= (const mint n){
		val *= n.val;
		val %= mod;
		if(val < 0) val += mod;
		return *this;
	}
	mint operator + (const mint n) const{
		mint res(*this);
		return res += n;
	}
	mint operator - (const mint n) const{
		mint res(*this);
		return res -= n;
	}
	mint operator * (const mint n) const{
		mint res(*this);
		return res *= n;
	}
	mint pow(long long n) const{
		if(n == 0) return 1;
		mint m = pow(n >> 1);
		m *= m;
		if(n & 1) m *= *this;
		return m;
	}
	// mint division for prime mod
	mint inv() const{
		return pow(mod - 2);
	}
	mint& operator /= (const mint n){
		return (*this) *= n.inv();
	}
	mint operator / (const mint n) const{
		mint res(*this);
		return res /= n;
	}
};

long long modpow(long long x, long long n){
	long long r = 1;
	while(n){
		if(n & 1) r = r * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return r;
}

int main(){
	LL N, M, K;
	cin >> N >> M >> K;
	if(N == 1){
		cout << modpow(K, M) << endl;
		return 0;
	}
	if(M == 1){
		cout << modpow(K, N) << endl;
		return 0;
	}
	mint ans = 0;
	for(LL i = 1; i <= K; i++){
		mint A = modpow(i, N) - modpow(i - 1, N);
		mint B = modpow(K - i + 1, M);
		mint res = A * B;
		ans += res;
	}
	cout << ans.val << endl;

	return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define int long long
#define sz(x) (ll)(x.size())
using namespace std;

const int mod = 1e9+7;

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

ll add()
{
    return 0;
}

template <typename T, typename... Types>
T add(T var1, Types... var2){
    return (((((ll)(var1)) % mod + (ll)(add(var2...))) % mod) + mod) % mod;
}

ll mul(){
    return 1;
}

template <typename T, typename... Types>
T mul(T var1, Types... var2){
    return (((ll)(var1)) % mod * (ll)(mul(var2...))) % mod;
}

void solve(){
  int n;
  cin >> n;
  if (n == 2 or n == 3) {
    cout << "1\n";
    return;
  }

  int fib[n];
  fib[0] = 1;
  fib[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fib[i] = add(fib[i-1],fib[i-2]);
  }

  char caa,cab,cba,cbb;
  cin >> caa >> cab >> cba >> cbb;

  if (cab == 'A') {
    if (caa == 'A') {
      cout << "1\n";
      return;
    }
    if (cba == 'A') {
      cout << fib[n-2] << "\n";
      return ;
    }
    else {
      cout << expo_pow(2,n-3) << "\n";
      return ;
    }
  }
  if (cab == 'B') {
    if (cbb == 'B') {
      cout << "1\n";
      return;
    }
    if (cba == 'B') {
      cout << fib[n-2] << "\n";
      return ;
    }
    else {
      cout << expo_pow(2,n-3) << "\n";
      return ;
    }
  }

}

signed main(){
  fast;
  int test = 1;
  int i=1;
  while(test--){
    solve();
  }
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

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

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, m; cin >> n >> m;
    vector<int> a(n), b(m);
    vector<int> cnt(1001);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
        cnt[b[i]]++;
    }
    for(int i = 1; i <= 1000; i++) {
        if(cnt[i] == 1) cout << i << ' ';
    }
    cout << endl;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> cnt(1e3 + 1, 0);
    rep(i, n) {
        ll a;
        cin >> a;
        cnt[a]++;
    }
    rep(i, m) {
        ll b;
        cin >> b;
        cnt[b]++;
    }
    rep(i, sz(cnt)) {
        if (cnt[i] == 1) {
            cout << i << endl;
        }
    }
    return 0;
}


//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <memory>
#include <random>
#include <functional>
#include <complex>
#include <immintrin.h>
#ifdef DEBUG
#include "./CompetitiveProgrammingCpp/debug_VC.hpp"
#include "./CompetitiveProgrammingCpp/Timer.hpp"
#include "./CompetitiveProgrammingCpp/sample.hpp"
#else
#define dump(...)
#endif

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
template<class T>
inline auto sort(T& t) { std::sort(ALL(t)); }
template<class T>
inline auto rsort(T& t) { std::sort((t).rbegin(), (t).rend()); }
template<class T>
inline auto unique(T& t) { (t).erase(unique((t).begin(), (t).end()), (t).end()); }
template<class T, class S>
inline auto chmax(T& t, const S& s) { if (s > t) { t = s; return true; } return false; }
template<class T, class S>
inline auto chmin(T& t, const S& s) { if (s < t) { t = s; return true; } return false; }
inline auto BR() { std::cout << "\n"; }

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std {
template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } };
}

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

//=============================================================================================

signed main() {
	ll n, q;
	cin >> n >> q;
	VL a(n);
	cin >> a;

	VL v(n);
	RREP(i, n) {
		v[i] = a[i] - i;
	}
	dump(v);

	REP(_, q) {
		ll k;
		cin >> k;
		auto it = std::upper_bound(ALL(v), k) - v.begin();
		--it;
		if (it == -1) {
			cout << k << endl;
		} else {
			cout << a[it] + k - v[it] + 1 << endl;
		}
	}
}

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define vll vector<ll>
#define vvl vector<vll>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MOD 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt","r",stdin);
	ll T=1;
	//cin >> T;
	ll t;
	while(t++<T){
		ll n,k;
		cin>>n>>k;
		vll a(n,0);
		fo(i,n){
			ll z;
			cin>>z;
			a[z]++;
		}
		ll cnt=0,ans=0;
		fo(i,n){
			ll lft=k-cnt;
			if(a[i]<lft){
				ans+=i*(lft-a[i]);
				cnt+=(lft-a[i]);
			}
			if(cnt>=k)break;
		}
		cout<<ans<<endl;
	}
return 0;
}


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

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
        return false;
    }
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

template<typename...args>inline bool read(int &a,args&...x){
    return (read(a),read(x...));
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

int h,w,x,y;
char m[110][110];

bool in(int x,int y){
    return x>=1&&x<=h&&y>=1&&y<=w;
}

int ans=1;

signed main(){
    read(h,w,x,y);

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>m[i][j];
        }
    }

    for(int i=1;i<=h;i++){
        if(in(x+i,y)&&m[x+i][y]!='#'){
            ans++;
        }
        else{
            break;
        }
    }

    for(int i=1;i<=h;i++){
        if(in(x-i,y)&&m[x-i][y]!='#'){
            ans++;
        }
        else{
            break;
        }
    }

    for(int i=1;i<=w;i++){
        if(in(x,y+i)&&m[x][y+i]!='#'){
            ans++;
        }
        else{
            break;
        }
    }

    for(int i=1;i<=w;i++){
        if(in(x,y-i)&&m[x][y-i]!='#'){
            ans++;
        }
        else{
            break;
        }
    }

    writeln(ans);

    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<ll,ll>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 61;
const ll mod =998244353;

vector<int> dx = { 1,-1, 0, 0, 1,-1,-1, 1 };
vector<int> dy = { 0, 0, 1,-1, 1,-1, 1,-1 };
int h, w;
bool isinside(int i, int j) {
	if (0 <= i && i < h && 0 <= j && j < w) {
		return true;
	}
	return false;
}

int main() {

	cin >> h >> w;
	int i, j;
	cin >> i >> j;
	i--, j--;
	VS v(h);
	REP(i, h)cin >> v[i];

	int cnt = 0;

	REP(k, 4) {
		int a = 0;
		while (true) {
			int ny = i + dy[k] * a;
			int nx = j + dx[k] * a;
			if (!isinside(ny, nx))break;
			if (v[ny][nx] == '#')break;
			a++;
		}
		cnt += a;
	}
	cout << cnt-3 << endl;

}


#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<int MOD>
class ModInt {
public:
    ModInt() :value(0) {}
    ModInt(long long val) :value((int)(val<0 ? MOD + val % MOD : val % MOD)) { }

    ModInt& operator+=(ModInt that) {
        value = value + that.value;
        if (value >= MOD)value -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        value -= that.value;
        if (value<0)value += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        value = (int)((long long)value * that.value % MOD);
        return *this;
    }
    ModInt &operator/=(ModInt that) {
        return *this *= that.inverse();
    }
    ModInt operator+(ModInt that) const {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) const {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) const {
        return ModInt(*this) *= that;
    }
    ModInt operator/(ModInt that) const {
        return ModInt(*this) /= that;
    }
    ModInt pow(long long k) const {
        ModInt n = *this, res = 1;
        if (k < 0) {
            k = -k;
            n = n.inverse();
        }
        while (k) {
            if (k & 1)res *= n;
            n *= n;
            k >>= 1;
        }
        return res;
    }
    ModInt inverse() const {
        long long a = value, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
    int toi() const { return value; }

private:
    int value;
};
typedef ModInt<998244353> mint;
ostream& operator<<(ostream& os, const mint& x) {
    os << x.toi();
    return os;
}

mint dp[3002][3002];
bool vis[3002][3002];

mint f(int n, int k) {
    mint &res = dp[n][k];
    if (vis[n][k])return res;
    vis[n][k] = true;
    if (n == 0 && k == 0) {
        res = 1;
    } else if (n == 0 || k == 0) {
        res = 0;
    } else {
        res = f(n - 1, k - 1);
        if (k * 2 <= n) {
            res += f(n, k * 2);
        }
    }
    return res;
}

void solve() {
    int N, K;
    cin >> N >> K;

    cout << f(N, K) << endl;
}

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

#include<bits/stdc++.h>
#define X first
#define Y second
#define ll long long
#define sz(a) (int)a.size()
using namespace std;
const int maxn =2e5 + 100;
const int mod = 998244353;
signed main()
{
   // ifstream cin("rt.txt.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector <vector <int> > dp(n + 1, vector <int> (n + 1, 0));
    dp[0][0] = 1;
    for(int n1 = 1; n1 <= n; n1++)
    {
        for(int k1 = n; k1 >= 1; k1--)
        {
            if(k1 * 2 <= n)
            {
                dp[n1][k1] = (dp[n1][k1] + dp[n1][k1 * 2]) % mod;
            }
            dp[n1][k1] = (dp[n1][k1] + dp[n1 - 1][k1 - 1]) % mod;
        }
    }
   // cout << dp[1][1] << " ";
    cout << dp[n][k];
    return 0;
}