#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
#define ll long long
ll pwmd(ll a, ll n) {
    if(n == 0) return 1;
    ll tmp = pwmd(a, n / 2);
    tmp = (tmp * tmp) % MOD;
    return (n % 2 == 0 ? tmp : tmp * a % MOD);
}

int main() {
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> fact(n + m + 2, 1);
    for(int i = 1;i < n + m + 2;++i) fact[i] = (fact[i - 1] * i) % MOD;
    if(n > m + k) {
        cout << 0 << '\n';
        return 0;
    }
    ll ans = fact[m + n] * pwmd(fact[m] * fact[n] % MOD, MOD - 2) % MOD;
    if(n == k) {
        cout << ans << '\n';
        return 0;
    }
    ans -= fact[m + n] * pwmd(fact[m + k + 1] * fact[n - k - 1] % MOD, MOD - 2) % MOD;
    ans %= MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << '\n';
    return 0;
}

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

ll mod = 1000000007;

template< typename flow_t >
struct Dinic {
  const flow_t INF;

  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
    int idx;
  };

  vector< vector< edge > > graph;
  vector< int > min_cost, iter;

  Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}

  void add_edge(int from, int to, flow_t cap, int idx = -1) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
  }

  bool bfs(int s, int t) {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty() && min_cost[t] == -1) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return min_cost[t] != -1;
  }

  flow_t dfs(int idx, const int t, flow_t flow) {
    if(idx == t) return flow;
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        flow_t d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s, int t) {
    flow_t flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      flow_t f = 0;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};

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

//Combination2
//10^6くらいまで
//modはグローバルに定義しておく
vector<ll> fact;
vector<ll> invf;
ll comb(ll n,ll k){
    if(n<0||k<0||k>n) return 0LL;
    else{
        ll a = fact[n]*invf[k]%mod;
        a = a*invf[n-k]%mod;
        return a;
    }
}

int main() {

    ll B,W,K; cin >> W >> B >> K;
    if(W-B>=K+1){
        cout << 0 << endl; return 0;
    }
    //main関数内に以下ペースト
    //N:max
    ll N = B+W+2;
    fact.assign(N+1,1LL);
    invf.assign(N+1,1LL);
    rep(i,N) fact[i+1] = fact[i]*(i+1)%mod;
    rep(i,N+1) invf[i] = modinv(fact[i],mod);
    ll ans = (comb(B+W,B)+1000*mod-comb(B+W,B+K+1))%mod;
    if(K==W) ans = comb(B+W,B)%mod;

    cout << ans << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;

const int maxn = 1e6 + 5;

int n, k;
vector<int> g[maxn];

int limit;
int used;

// farthest needs, town reach
pair<int,int> dfs(int at, int p=0) {
    int needs = 0;
    int town = -1;

    if (at==1) {
	for (int to: g[at]) {
	    if (to==p) continue;
	    auto rec = dfs(to, at);
	    needs = max(needs, rec.first);
	    town = max(town, rec.second);
	}
	if (town < needs) {
	    used++;
	}
	return {needs, town};
    } else {
	for (int to: g[at]) {
	    if (to==p) continue;
	    auto rec = dfs(to, at);
	    needs = max(needs, rec.first);
	    town = max(town, rec.second);
	}

	if (town >= needs) {
	    needs = 0;
	} else {
	    if (needs == limit) {
		used++;
		needs = 0;
		town = limit;
	    } else {
		needs++;
	    }
	}
	town--;
	return {needs, town};
    }
}

bool test(int L) {
    limit = L;
    used = 0;

    dfs(1);

    return used <= k;
}

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

    cin>>n>>k;
    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }

    // for (int i=0; i<=n; i++) {
    // 	cout<<i<<": "<<dfs(1,0,i).second<<endl;
    // }

    int lo = -1;
    int hi = n+10;
    while (hi-lo>1) {
	int mid=(lo+hi)/2;
	if (test(mid)) {
	    hi = mid;
	} else {
	    lo = mid;
	}
    }

    out(hi);

    return 0;
}

/*  **    ** ******    ****** ****** **     ******    ***
    **    ** **  **    **  ** **  ** **     **  ** *********
    **\../** ******    ****** **  ** ****** **  **    ***
    **    ** ** **     ** **  **  ** **  ** **  **    *****
    **    ** **  ** ** **  ** ****** ****** ******    *****
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define vt vector
#define sz(v) ((int)((v).size()))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e6;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	for(auto& a:x)
		read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
	for(auto& a:x)
		read(a);
}
vector<pair<int,int>>adj[N];
int label[N],vis[N];
void dfs(int u,int l){
	label[u]=l;
	vis[u]=1;
	for(auto child:adj[u]){
		int v = child.fr,c = child.sc;
		if(!vis[v]){
			if(label[u]==c){
				if(label[u]==1){
					dfs(v,2);
				}else{
					dfs(v,1);
				}
			}else{
				dfs(v,c);
			}
		}
	}
}
void _run(){
	int n,m;
	read(n,m);
	lp(i,m){
		int x,y,c;
		read(x,y,c);
		adj[x].pb({y,c});
		adj[y].pb({x,c});
	}
	dfs(1,1);
	range(i,1,n){
		cout<<label[i]<<endl;
	}
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
	init();
    int t=1;
    // read(t);
    while(t--)_run();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll minimum = min(a,b);
  minimum = min(minimum,c);
  minimum = min(minimum,d);
  cout<<minimum<<'\n';
}

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

long long pow(long long x,long long n){
    long long ans = 1;
    while(n != 0){
        long long a = x;
        long long z = 1;
        while(z*2 <= n){
            a *=a;
            a=a%mod1;
            z*=2;
        }
        ans*=a;
        ans=ans%mod1;
        n-=z;
    }
    return ans;
}//累乗 x^n

template<typename T>
void input_vec(vector<T> &A,long long N){
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    return;
}//入力を配列で受け取る

template<typename T>
void output_vec(vector<T> &A,long long N){
    for(int i = 0; i < N; i++){
        if(i != 0){
            cout << " ";
        }
        cout << A.at(i);
    }
    cout << endl;
    return;
}//配列を出力

template<typename T>
long long count_vec(vector<T> &A,T x){
    long long counter = 0;
    for(int i = 0; i < (int)A.size(); i++){
        if(A.at(i) == x){
            counter++;
        }
    }
    return counter;
}//配列内のxの個数をreturn

vector<char> change_vec(string s,int n){
    vector<char> ans(n);
    for(int i = 0; i < n; i++){
        ans.at(i) = s.at(i);
    }
    return ans;
}//文字列を配列に変換

int main(){
    vector<ll> a(4);
    for(int i = 0; i < 4; i++){
        cin >> a.at(i);
    }
    ll small = mod1;
    for(int i = 0; i < 4; i++){
        small = min(small,a.at(i));
    }

    cout << small << endl;
}


#include <bits/stdc++.h>

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1e18+7;

ll ceildiv(ll a, ll b) { return (a+b-1)/b; } // 切り上げ
ll floordiv(ll a, ll b) { return a/b; } // 切り下げ

int show_matrix(vector<vector<int>> &dp) {
  loop(0, dp.size(), i) {
    loop(0, dp[i].size(), j) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

  ll N;
  cin >> N;

  vector<ll> A(N);
  ll cmax = -1;
  loop(0, N, i) {
    cin >> A[i];
  }

  vector<ll> C(N+1);
  vector<ll> M(N+1);
  loop(0, N, i) {
    C[i+1] = C[i] + A[i];
    M[i+1] = max(M[i], A[i]);
  }

  ll sum = 0;
  loop(0, N, i) {
    ll res = sum + C[i+1] + M[i+1] * (i+1);
    print(res)
    sum = sum + C[i+1];
  }
}

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

const string a = "atcoder";

void solve(){
    string s;
    cin >> s;
    if(s > a){
        cout << 0 << endl;
        return;
    }
    string t = s;
    sort(t.rbegin(), t.rend());
    if(t <= a){
        cout << -1 << endl;
        return;
    }
    int ans = 0, i = 0;
    while(s[i] == 'a') i++;
    while(s <= a){
        swap(s[i], s[i-1]);
        i--;
        ans++;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    rep(i,t) solve();
}


#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
#define deb(x) cout << #x": " << (x) << endl;

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}
lli lcm(lli a, lli b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
int popcount(lli x) { return __builtin_popcountll(x); }

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

lli poww(lli a, lli b){
	lli res =1;
	while(b){ if(b&1) res = res * a; a = a*a; b/=2; }
	return res;
}

vvc<int> graph(int n, int m, bool dir=1){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		if(dir)v[b].pb(a);
	}
	return v;
}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
// ---- コーディングはここから！ ('-')7

void solve(){
	int n,m; cin>>n>>m;
	vv(int,v,n,n,inf<int>);
	fore(i,0,m){
		int a,b,c; cin>>a>>b>>c;a--,b--;
		v[a][b]=min(v[a][b],c);
	}
	vv(ii,g,n+1);
	fore(i,0,n)fore(j,0,n)if(v[i][j]!=inf<int>)g[i].pb({j,v[i][j]});

	auto dij=[&](int a){
		using pp  = pair<int,lli>;
		priority_queue<pp>q;
		q.push({0,n});
		g[n]=g[a];
		vc<lli>dp(n+1,inf<lli>);
		dp[n]=0;
		while(!q.empty()){
			auto p=q.top(); q.pop();
			auto [y,x]=p;
			y*=-1;
			if(y!=dp[x])continue;
			if(x==a)return y;
			for(auto [i,j]:g[x])if(dp[i]>y+j){
				dp[i]=y+j;
				q.push({-dp[i],i});
			}
		}
		return -1;
	};
	fore(i,0,n)cout<<dij(i)<<ENDL;

}

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

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, x;
	cin>>n>>x;
	string s;
	cin>>s;

	for(char c : s){
		if(c == 'o'){
			x++;
		}
		else{
			x = max(0, x-1);
		}
	}

	cout<<x;

 	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)
inline void RI(i64 &i) {scanf("%lld", &(i));}
inline void RVI(vi &v) { for(i64 i=0;i<sz(v);++i) { RI(v[i]); } }
inline void RVVI(vvi &vv) { for(i64 i=0;i<sz(vv);++i) { RVI(vv[i]); } }
inline void WI(const i64 &i) {printf("%lld\n", i);}
inline void WVI(const vi &v, char sep=' ') { for(i64 i=0;i<sz(v);++i) { if(i != 0){ printf("%c", sep); } printf("%lld", v[i]);} printf("\n"); }
inline void WS(const string &s) { printf("%s\n", s.c_str()); }
inline void WB(bool b, const string &yes, const string &no) { if(b){ WS(yes);} else { WS(no);} }
inline void YESNO(bool b) { WB(b, "YES", "NO"); }
inline void YesNo(bool b) { WB(b, "Yes", "No"); }
#define BUF_LENGTH 1000000
inline void RS(string &s) {static char buf[BUF_LENGTH]; scanf("%s", buf); s = buf;}
template<typename T> inline bool IN(T &S, const typename T::key_type &key) {
  return S.find(key) != S.end();
}
template<typename T> inline bool ON(const T &b, i64 idx) {
  return ((T(1) << idx) & b) != 0;
}

double sq(double d) {
  return d * d;
}

int main(int argc, char *argv[]) {
  i64 i, j, k;
  i64 N; RI(N);
  i64 Ma, Mb, Mc, Md;
  Ma = Mb = Mc = Md = 0;
  using ppi = pair<pi, pi>;
  vector<ppi> P(N);
  REP(0, N, i) {
    i64 a, b; RI(a); RI(b);
    a *= N;
    b *= N;
    Ma += a;
    Mb += b;
    P[i].first = {a, b};
  }
  REP(0, N, i) {
    i64 c, d; RI(c); RI(d);
    c *= N;
    d *= N;
    Mc += c;
    Md += d;
    P[i].second = {c, d};
  }
  Ma /= N;
  Mb /= N;
  Mc /= N;
  Md /= N;
  REP(0, N, i) {
    P[i].first.first -= Ma;
    P[i].first.second -= Mb;
    P[i].second.first -= Mc;
    P[i].second.second -= Md;
  }

  const double eps = 1e-3;

  if(N == 1) {
    WS("Yes");
    return 0;
  }

  i64 i0;
  REP(0, N, i0) {
    i64 a = P[i0].first.first;
    i64 b = P[i0].first.second;
    i64 n1 = a * a + b * b;
    if(n1 > 0) {
      break;
    }
  }
  assert(i0 != N);
  i64 a = P[i0].first.first;
  i64 b = P[i0].first.second;
  i64 n1 = a * a + b * b;
  REP(0, N, i) {
    i64 c = P[i].second.first;
    i64 d = P[i].second.second;

    i64 n2 = c * c + d * d;
    // cerr << n1 << " "<< n2 << endl;
    if(n1 != n2) {
      continue;
    }

    // cerr << a << " " << b << " " << c << " " << d << " " << endl;
    double r1 = atan2(b, a);
    double r2 = atan2(d, c);
    double delta = r2 - r1;
    double cd = cos(delta), sd = sin(delta);
    bool valid = true;
    // cerr << i << " " << delta << endl;
    REP(0, N, j) {
      i64 aa = P[j].first.first;
      i64 bb = P[j].first.second;
      double d_min = 1e10;
      double a2c = aa * cd - bb * sd;
      double b2d = bb * cd + aa * sd;
      REP(0, N, k) {
        i64 cc = P[k].second.first;
        i64 dd = P[k].second.second;
        double d = sq(cc - a2c) + sq(dd - b2d);
        d_min = min(d, d_min);
      }
      if(d_min > eps) {
        valid = false;
      }
    }
    if(valid) {
      WS("Yes");
      return 0;
    }
  }
  WS("No");
  return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include <bitset>
// #include <atcoder/all>
#include <fstream>
#include <random>
#include <cassert>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = 3.1415926535897932;

using Graph = vector<vector<ll>>;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll m, h;
	cin >> m >> h;

	if (h % m == 0) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <utility>
#include <vector>

#define DEBUG_PRINT(n) \
    (cout << "L" << __LINE__ << " " << #n << " = " << n << endl)

#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using std::map;
using std::vector;

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

    return 0;
}

#include <bits/stdc++.h>

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

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n, a, b;
	cin >> n >> a >> b;
	cout << (n - a) + b;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100006];
int main ()
{
	int n,m,k;
	cin>>n>>m>>k;
	for (int i=1;i<=2*m;i++)
		cin>>a[i];
	sort(a+1,a+2*m+1);
	a[0]=0,a[2*m+1]=k;
	int t=2*m+1;
	int ans=n;
	for (int i=1;i<=t;i++){
		if(i%2) ans-=a[i]-a[i-1];
		else ans=min(n,ans+a[i]-a[i-1]) ;
		if (ans<=0) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
 }

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

int main() {
  double N, D, H;  //Nこ　D離れてHの高さ
  cin >> N >> D >> H;
  vector<pair<int, int>> dh(N);
  for(int i = 0; i < N; i++)
    cin >> dh.at(i).first >> dh.at(i).second;  //fin
  double ans=0;
  for(int i = 0;i < N; i++) {
    double k;
    k = H-((H-dh.at(i).second)/(D-dh.at(i).first))*D;
    ans = max(k, ans); }
  cout << fixed << setprecision(15) << ans << endl;

}


#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;
map<string ,int> chk;
int main()
{
    ll tc;

    cin>>tc;
    int flg=0;
      string s,ans;
    while(tc--){

    cin>>s;
    if(s[0]=='!'){
            s.erase(0, 1);
        if(chk[s]==1){
            flg=1;

            ans=s;}
        else{
        chk[s]=2;
        }

    }
    else{
        if(chk[s]==2){
            flg=1;

            ans=s;
    }
        else{
        chk[s]=1;
        }

    }

    }

if(flg) {cout<<ans<<endl;}
else {cout<<"satisfiable"<<endl;}

}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    set<int> a;
    rep(i,n) {
        int p;
        cin >> p;
        a.insert(p);
    }
    while(1){
        int max = *a.rbegin();
        int min = *a.begin();
        if(max == min) break;
        a.erase(max);
        a.insert(max - min);
        /*
        cout << " " << endl;
        cout << max << endl;
        cout << min << endl;
        */
    }
    cout << *a.begin() << endl;
}


/*/
     Author: _Math.man
     "Everything in this world is magic, except to the magician"
/*/
#include<bits/stdc++.h>
using namespace std;

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast")
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n; i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
// for all eight directions
int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
// for all 4 directions
//int dx[4]={-1,1,0,0};
//int dy[4]={0,0,-1,1};
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
  vector<string> v; stringstream ss(s); string x;
  while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
  stringstream s; s << "[";
  for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
  if(n>0)
  s << arr[n - 1] ;
  s<< "]";
  return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
  __trace_out_var(a);
  cerr << "; ";
  __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];
bool ok(int n){
  int m = n;
  while(n){
    if(n%10==7)return 0;
    n/=10;
  }
  n = m;
  while(n){
    if(n%8==7)return 0;
    n/=8;
  }
  return 1;
}
signed main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n;
    cin >> n ;
   int ans=0;
    fn1{
      ans+=ok(i);
    }
   cout << ans <<'\n';

  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define sorts(s) sort(s.begin(), s.end())
#define sortu(s) sort(s.begin(), s.end(), greater<>())
typedef long long int ll;
using Graph = vector<vector<int>>;

int main(void) {
    int i, j, k;
    int N;
    cin >> N;
    vector<int> T(N); int sum = 0;
    rep(i, N) {
        cin >> T[i];
        sum += T[i];
    }
    int half = (sum / 2);
    vector<vector<int>> dp(N+1, vector<int>(half+1, 0));
    rep(i, N) {
        for (j = 0; j <= half; ++j) {
            if (j >= T[i]) {
                dp[i+1][j] = max(dp[i][j-T[i]] + T[i], dp[i][j]);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    int ans = sum - dp[N][half];
    cout << ans << endl;
    //cout << fixed << setprecision(3) << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
const double PI=acos(-1);
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
    if(x>y)return x;
    else return y;
}
ll min(ll x,ll y){
    if(x<y)return x;
    else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,m;cin >> n >> m;
    if(n==1 && m==0){
        cout << "1 2" << endl;return 0;
    }
    if(m==n || m<0 || m+1==n){
        cout << -1 << endl;
        return 0;
    }
    if(m==0){
        rep(i,n)cout << 3*i+1 << ' ' << 3*i+2 << endl;
        return 0;
    }

    int l=m+1;
    int k=n-l-1;
    rep(i,k){
        cout << 3*i+1+1 << ' ' << 3*i+1+1+1 << endl;
    }
    rep(i,l){
        cout << 3*k+3*i+1+1 << ' ' << 3*k+3*i+1+1+1 << endl;
    }
    cout << 3*k+1 << ' ' << 100000000 << endl;
}

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(vec) vec.begin(), vec.end()
#define allr(vec) vec.rbegin(), vec.rend()
#define CST(x) cout << fixed << setprecision(x)
using namespace std;

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

using ll = long long;

const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;

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

using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vi = vector<int>;
using vll = vector<ll>;

//------

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

  if (a + b >= 15 && b >= 8) {
    cout << 1 << endl;
  } else if (a + b >= 10 && b >= 3) {
    cout << 2 << endl;
  } else if (a + b >= 3) {
    cout << 3 << endl;
  } else {
    cout << 4 << endl;
  }
}


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

const int INF = 2e9;

int main(){
    ll n,x;
    cin >> n >> x;
    vector<pair<ll,ll>> events;
    rep(i,n){
        ll a,b,c;
        cin >> a >> b >> c;
        events.emplace_back(a,c);
        events.emplace_back(b+1,-c);
    }
    sort(events.begin(),events.end());
    ll ans = 0,s = 0,pre = 0;
    for(auto event : events){
        ans += min(x,s)*(event.first - pre);
        s += event.second;
        pre = event.first;
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
#define con(typ) const typ
typedef long long ll;
template<typename T>void sf(T &x){x=0;T f=0;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')f=1;for(;c>='0'&&c<='9';c=getchar())x=(x<<3)+(x<<1)+(c^'0');if(f)x=-x;}
template<typename T>void pf(T x,char l='\n'){static int s[100],t;if(x<0)putchar('-'),x=-x;do s[++t]=x%10,x/=10;while(x);while(t)putchar(s[t--]^'0');putchar(l);}
int main()
{
	int a,b,c;
	sf(a),sf(b),sf(c);
	pf(3*7-a-b-c);
	return 0;
}


#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

constexpr ll MOD = 998244353;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
ostream &operator<<(ostream &o, const string &obj) {o << "\""; o << obj.c_str(); o << "\""; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif

template <typename... Ts>
std::istream& IN(Ts&... xs){ return (std::cin >> ... >> xs); }

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

#define Rrepr(i, a, b) for (int i = b; i >= a; i--)
#define Rrep(i, n) for (int i = n-1; i >= 0; i--)

bool dfs(ll p, vector<vector<ll>>& v,vector<ll>& fin_list, vector<ll>& cv,ll c, ll depth){
    bool closed = false;
    if(fin_list[p]){
        if(depth >= 3) return true;
        else           return false;
    }
    cv[p] = c;
    fin_list[p] = 1;
    rep(i, v[p].size()){
        if(v[p][i]){
            closed |= dfs(i, v, fin_list, cv, c, depth+1);
        }
    }
    return closed;
}

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

    ll n;
    IN(n);

    vector<ll> t(n);
    ll tm_sum = 0;

    rep(i,n){
        IN(t[i]);
        tm_sum += t[i];
    }

    vector<vector<ll>> dp(n+1,vector<ll>(tm_sum/2+1,0));

    rep(i,n){
        rep(j,tm_sum/2+1){
            if(j >= t[i]) dp[i+1][j] = max(dp[i][j-t[i]]+t[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    ll ans = tm_sum - dp[n][tm_sum/2];
    //print(dp)

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
#define int long long
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define endl "\n"
#define vmin *min_element
#define vmax *max_element
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define mp make_pair
#define yy cout<<"YES"<<endl
#define nn cout<<"NO"<<endl
#define nores cout<<"-1"<<endl
#define vi vector<int>
#define all(x)   x.begin(),x.end()
#define prec(x)  fixed<<setprecision(x)
#define ppb  pop_back
#define gcd(a,b) __gcd(a,b)
#define si set<int>
#define maxh priority_queue<int>
#define minh priority_queue<int,vector<int>,greater<int> >

signed main(){
   Fastio ;

 //  int t ; cin>>t;
 // while(t--)
 // {

 int n; cin>>n;
 vi v(n);
 int s=0;
 for(int i=0;i<n;i++){

 cin>>v[i];
 s=s+v[i];
}

 bool dp[n+1][s+1];
 for(int i=0;i<=n;i++)
 {
 	for(int j=0;j<=s;j++)
 	{
 		if(i==0) dp[i][j]=false;
 		else if(j==0) dp[i][j]=true;

	 }
 }
 dp[0][0]=true;
 for(int i=1;i<=n;i++)
 {
 	for(int j=1;j<=s;j++)
 	{
 		if(j>=v[i-1])
 		dp[i][j]=(dp[i-1][j-v[i-1]] or dp[i-1][j]);
 		else
 		dp[i][j]=dp[i-1][j];
	 }
 }
 int ans;
 if(s%2==0)
 {

 for(int j=s/2;j<=s;j++)
 {
 	if(dp[n][j])
 	{
 		ans=j;
 		break;
	 }
 }
}
else
{
for(int j=(s/2)+1;j<=s;j++)
 {
 	if(dp[n][j])
 	{
 		ans=j;
 		break;
	 }
 }

}
 cout<<ans<<endl;
}


#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int TIME = 2*100000+10;
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n,w;

  cin >> n >> w;

  vector<int> s(n),t(n),p(n);

  for(ii=0;ii<n;ii++){
    cin >> s[ii] >> t[ii] >> p[ii];
  }
  vector<lll> preCal(TIME);
  vector<lll> waste(TIME);

  //cout << "calc waste" << endl;
  for(ii=0;ii<n;ii++){
    preCal[s[ii]] += p[ii];
    preCal[t[ii]] -= p[ii];
  }
  lll calCost = 0;
  for(ii=0;ii<TIME;ii++){
    calCost+=preCal[ii];
    waste[ii] = calCost;
  }
  bool flg = true;
  //cout << "check waste" << endl;
  for(ii=0;ii<TIME;ii++){
    if(waste[ii] > w){
      flg = false;
    }
  }

  if(flg){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9+7; //998244353;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = modint1000000007;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll w;
	cin >>n >>w;

	VL dp(200200);
	int mx =0;
	rep(i, n){
		int s,t, p;
		cin >>s >>t >>p;
		dp[s] += p;
		dp[t] -=p;
		mx = max(mx, t);
	}
	rep(i, 200001){
		dp[i+1] +=dp[i];
	}
	//rep(i, mx+1) cerr<<dp[i]<<" ";dbg();
	bool ok=1;
	rep(i, 200001) if(dp[i] > w) ok=0;
	puts(ok? "Yes":"No");
	return 0;
}


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

#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;

// Euclides Estendido
ll gcd(ll A, ll B, ll &X, ll &Y) {
	if(B == 0) {
		X = 1; Y = 0;
		return A;
	}
	ll x1, y1;
	ll G = gcd(B, A % B, x1, y1);
	X = y1; Y = x1 - (A / B) * y1;
	return G;
}

// Acha a primeira vez que dois eventos ocorrem ao mesmo tempo
// Os eventos acontecem a cada:
// A * T1 + Z1 e B * T2 + Z2
ll solve(ll A, ll B, ll Z1, ll Z2) {
	if(Z2 > Z1) swap(A, B), swap(Z1, Z2);
	ll X, Y, ans = 0;
	ll G = gcd(A, B, X, Y), C = Z2-Z1;
	if(C%G) return 1LL << 62;	// impossivel
	C /= G; X *= C; Y *= C;
	// Acho o primeiro X positivo
	if(X >= 0) {
		ll K = (X * G) / B;
		ans = A * (X - K * (B / G)) + Z1;
	} else {
		ll K = (-X * G + B - 1) / B;
		ans = A * (X + K * (B / G)) + Z1;
	}
	// retorna um par na forma (A, Z)
	// A -> novo tamanho do ciclo
	// Z -> primeira vez que acontece
	// return mk(A * (B / G), ans);
	return ans;
}

// Anotação importante, Há duas formas de alterar as soluções:
// (1) -> X = X + K * (B / G) e Y = Y - K * (A / G)
// (2) -> X = X - K * (B / G) e Y = Y + K * (A / G)

int main(int argc, char** argv) {
	int T, X, Y, P, Q;
	scanf("%d", &T);
	rep(t, 0, T) {
		ll ans = (1LL <<62);
		scanf("%d%d", &X, &Y);
		scanf("%d%d", &P, &Q);
		rep(y, 0, Y) rep(q, 0, Q)
			ans = min(ans, solve(2*X+2*Y, P+Q, X + y, P + q));
		if(ans != (1LL << 62))
			printf("%lld\n", ans);
		else puts("infinity");
	}
	return 0;
}

#include<bits/stdc++.h>
#include<bits/extc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t){
	while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<": "; for(auto i:x) cerr<<i<<" "; cerr<<endl;}}
#define debugr(l,r,x) {{cerr<<#x<<": "; for(int i=l;i<=r;i++) cerr<<x<<" "; cerr<<endl;}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debugr(l,r,x)
#define cerr while(0) cerr
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define priority_queue std::priority_queue
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll euclid(ll a, ll b, ll &x, ll &y) {
	if (!b) return x = 1, y = 0, a;
	ll d = euclid(b, a % b, y, x);
	return y -= a/b * x, d;
}

ll crt(ll a, ll m, ll b, ll n){
	if(n>m) swap(a, b), swap(m, n);
	ll x, y, g=euclid(m, n, x, y);
	if((a-b)%g!=0) return LONG_LONG_MAX;
	x=(b-a)%n*x%n/g*m+a;
	return x<0 ? x+m*n/g : x;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T;
	cin>>T;
	while(T--){
		ll x, y, p, q;
		cin>>x>>y>>p>>q;
		ll ans=LONG_LONG_MAX;
		for(ll i=x;i<x+y;i++){
			for(ll j=p;j<p+q;j++){
				ans=min(ans, crt(i, 2*(x+y), j, (p+q)));
			}
		}
		if(ans==LONG_LONG_MAX) cout<<"infinity\n";
		else cout<<ans<<"\n";
	}
}


#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
const int N = 1e6 + 50;

char s[N];

int main(){
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    bool ok = 1;
    for(int i = 1; i <= len; i += 2) if(!(s[i] >= 'a' && s[i] <= 'z'))  ok = 0;
    for(int i = 2; i <= len; i += 2) if(!(s[i] >= 'A' && s[i] <= 'Z'))  ok = 0;
    puts(ok ? "Yes" : "No");
}

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

        using namespace std;
        typedef long long ll;
        typedef unsigned long long ull;
        # define M_PI  3.14159265358979323846

        const int M=998244353;
        long long mod(long long x){
            return ((x%M + M)%M);
        }
        long long add(long long a, long long b){
            return mod(mod(a)+mod(b));
        }
        long long mul(long long a, long long b){
            return mod(mod(a)*mod(b));
        }

        ll modPow(ll a, ll b){
            if(b==0)
                return 1LL;
            if(b==1)
                return a%M;
            ll res=1;
            while(b){
                if(b%2==1)
                    res=mul(res,a);
                a=mul(a,a);
                b=b/2;
            }
            return res;
        }

        void solve(){
            string s;
            cin>>s;
            int nb=0;
            int cnt[3]={0};
            int sum=0;
            int n=s.size();
            for(int i=0;i<n;i++){
                int k=s[i]-'0';
                cnt[k%3]++;
                sum+=k;
            }
            sum=sum%3;
            if(sum==0){
                cout<<0;
                return;
            }
            else if(sum==1){
                if(cnt[1]>0 && n>1) cout<<1;
                else if(cnt[2]>1 && n>2) cout<<2;
                else cout<<-1;
            }
            else{
                if(cnt[2]>0 && n>1) cout<<1;
                else if(cnt[1]>1 && n>2) cout<<2;
                else cout<<-1;
            }
        }
        int main(){
            ios::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            cout<<fixed;
            cout<<setprecision(10);
    //        freopen("timber_input.txt", "r", stdin);
    //        freopen("timber_output.txt", "w", stdout);
            int t=1;
            // cin>>t;
            for(int i=1;i<=t;i++){
            //    cout<<"Case #"<<i<<": ";
                solve();
            }
            return 0;
        }


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

int h, w;
bool field[16][16];

long long dfs(int x, int y, int a, int b)
{
    //畳が足りない時。
    if(a < 0 || b < 0)return 0;

    //端まで行きついたら
    if(y == h) y = 0, x++;//左上に移動
    if(x == w)return 1;//右下端まで来たのでこれが一つ

    //もう使われてたら
    if(field[x][y] == true)return dfs(x, y + 1, a, b);

    //流れ
    /*
        一回おいてから、もっと深くまで探索する。
        探索が終わって帰ってきたら、外す。
    */

    long long ret = 0;
    //横に置く
    if(x + 1 < w && field[x + 1][y] == false)
    {
        field[x][y] = true;
        field[x + 1][y] = true;
        ret += dfs(x, y + 1, a - 1, b);
        field[x][y] = false;
        field[x + 1][y] = false;
    }
    //縦に置く
    if(y + 1 < h && field[x][y + 1] == false)
    {
        field[x][y] = true;
        field[x][y + 1] = true;
        ret += dfs(x, y + 1, a - 1, b);
        field[x][y] = false;
        field[x][y + 1] = false;
    }
    //半畳を置く
    field[x][y] = true;
    ret += dfs(x, y + 1, a, b - 1);
    field[x][y] = false;

    return ret;
}

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

    //横に置く、縦に置く、半畳を置く
    cout << dfs(0, 0, a, b) << endl;
}

// I SELL YOU...!
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 998244353;
const ll MAX = 5100;
bool can[MAX][MAX][3];
ll dp[MAX][MAX]={};
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;
}
signed main(){
  init_io();
  ll H,W,K,fi=1,mv;
  cin >> H >> W >> K;
  mv = modinv(3,MOD);
  vector<ll> h(K),w(K);
  vector<char> c(K);
  for(int i=0;i<MAX;i++){
    for(int j=0;j<MAX;j++){
      for(int k=0;k<3;k++){
        can[i][j][k] = true;
      }
    }
  }
  for(ll i=0;i<H*W-K;i++){
    fi *= 3;
    fi %= MOD;
  }
  for(int i=0;i<K;i++){
    cin >> h[i] >> w[i] >> c[i];
    h[i]--;
    w[i]--;
    for(int j=0;j<3;j++){
      can[h[i]][w[i]][j] = false;
    }
    if(c[i]=='R') can[h[i]][w[i]][0] = true;
    if(c[i]=='D') can[h[i]][w[i]][1] = true;
    if(c[i]=='X') can[h[i]][w[i]][2] = true;
  }
  dp[0][0] = 1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ll nv = dp[i][j];
      if(can[i][j][0]&&can[i][j][1]&&can[i][j][2]){
        nv = (nv*2*mv);
        nv %= MOD;
        dp[i][j+1] = (dp[i][j+1]+nv)%MOD;
        dp[i+1][j] = (dp[i+1][j]+nv)%MOD;
      }else if(can[i][j][0]){
        dp[i][j+1] = (dp[i][j+1]+nv)%MOD;
      }else if(can[i][j][1]){
        dp[i+1][j] = (dp[i+1][j]+nv)%MOD;
      }else if(can[i][j][2]){
        dp[i][j+1] = (dp[i][j+1]+nv)%MOD;
        dp[i+1][j] = (dp[i+1][j]+nv)%MOD;
      }
    }
  }
  cout << (dp[H-1][W-1]*fi)%MOD << endl;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int mod = 998244353;

#define int __int128
const int inf = (1LL << 60);
const int INF = inf * inf;
template< typename T > inline void get_min(T &x, T y) {if(y < x) x = y;}
template< typename T > inline void get_max(T &x, T y) {if(x < y) x = y;}
inline int read() {
  int x = 0, f = 0; char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
  return f ? -x : x;
}
template<typename T> inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

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

void solve() {
  int x, y, p, q;
  x = read(), y = read(), p = read(), q = read();
  int ans = INF;
  //print(ans);
  for (int i = x; i < x + y; i++) {
    for (int j = p; j < p + q; j++) {
      int a = 2 * x + 2 * y, b = -(p + q), l, r;
      int c = j - i;
      int d = __gcd(a, b);
      if (c % d) continue; // 无解
      extend_gcd(a, b, l, r);
      int e = a * b / d; //  最小公倍数
      if (e < 0) {
          e = -e;
      }
      l = c / d * l % e;
      r = c / d * r % e;
      int mem = (a * l + i) % e;
      if (mem < 0) mem += e;
      //cout << l << ' ' << r << '\n';
      ans = min(ans, mem);
    }
  }
  if (ans == INF) {
    cout << "infinity\n";
  } else {
    print(ans);
    puts("");
  }
}

signed main() {
  //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int T = 1; T = read();
  while (T--) {
    solve();
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) { cerr << #a << ':' << a << endl; }
#define endl '\n'
#define fi first
#define se second
using lint = long long;
using P = pair<int,int>;
template<class T> using V = vector<T>;
template<class T> using priq     = priority_queue<T>;
template<class T> using priq_inv = priority_queue<T, vector<T>, greater<T>>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
template<class T> T ceil(const T &a, const T &b) { return (a+b-1)/b; }
template<class T> bool chmin(T &a, T b) { if(a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax(T &a, T b) { if(a < b) { a = b; return 1; } return 0; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;

template<class T, class U> istream& operator>>(istream &in, pair<T,U> &p) {
    return in >> p.first >> p.second;
}
template<class T, class U> ostream& operator<<(ostream &out, const pair<T,U> &p) {
    return out << p.first << ' ' << p.second;
}
template<class T> istream& operator>>(istream &in, vector<T> &v) {
    for(auto &&e: v) in >> e;
    return in;
}
template<class T> ostream& operator<<(ostream &out, const vector<T> &v) {
    for(const auto &e: v) out << e << ' ';
    return out;
}

/*----------------------------------------------------------------------------------------------------*/

template<class T>
vector<T> Dijkstra(int s, const vector<vector<pair<T,int>>> &g, vector<int> prev = {}) {

    using pi = pair<T,int>;
    const T inf = numeric_limits<T>::max()/2;
    vector<T> dist(g.size(), inf);
    dist[s] = 0;

    prev.assign(dist.size(), -1);

    priority_queue<pi, vector<pi>, greater<pi>> que;
    que.emplace(0,s);

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int now = p.second;
        if(dist[now] < p.first) continue;
        for(P np : g[now]) {
            int next = np.second;
            if(dist[next] > dist[now] + np.first) {
                prev[next] = now;
                dist[next] = dist[now] + np.first;
                que.emplace(dist[next], next);
            }
        }
    }
    return dist;
}

int main() {
    int h, w;
    cin >> h >> w;
    V<V<int>> a(h,V<int>(w-1)), b(h-1,V<int>(w));
    cin >> a >> b;

    auto makeId = [&](int y, int x) {
        if(h > w) return x*h+y;
        else return y*w+x;
    };
    auto retPoint = [&](int id) {
        if(h > w) return make_pair(id/h, id%w);
        else return make_pair(id/w, id%h);
    };

    V<V<P>> g(h*w);
    rep(i,h)rep(j,w) {
        int id = makeId(i,j);
        if(j+1 < w) g[id].emplace_back(a[i][j], makeId(i,j+1));
        if(j > 0) g[id].emplace_back(a[i][j-1], makeId(i,j-1));
        if(i+1 < h) g[id].emplace_back(b[i][j], makeId(i+1,j));
        Rep(k,i) g[id].emplace_back(k+1, makeId(i-k,j));
    }

    auto dist = Dijkstra(makeId(0,0), g);
    int ans = dist[makeId(h-1,w-1)];
    cout << ans << endl;
}


// Problem: D - Powers
// Contest: AtCoder - AtCoder Regular Contest 106
// URL: https://atcoder.jp/contests/arc106/tasks/arc106_d
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

const int N = 2e5+7,M = 305,MOD = 998244353;
ll fx[M],fc[M],fsa[M],fsb[M];
int a[N],b[N];
ll fa[N][M],fb[N][M];
ll qmul(ll a, ll b, ll P)
{
  	ll L = a * (b >> 25LL) % P * (1LL << 25) % P;
  	ll R = a * (b & ((1LL << 25) - 1)) % P;
  	return (L + R) % P;
}
ll qpow(ll a,ll b,ll p)
{
	ll res = 1 % p;
	while(b)
	{
		if(b & 1)	res = res * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return res;
}
ll fact[N],infact[N];
void init()
{
    fact[0] = infact[0] = 1;
    for (int i = 1; i < N; i ++ )
    {
        fact[i] = ((ll)fact[i - 1] * i) % MOD;
        infact[i] = ((ll)infact[i - 1] * qpow(i, MOD - 2, MOD)) % MOD;
    }
}
ll C(int a,int b)
{
    return (ll)fact[a]*infact[b]%MOD*infact[a-b]%MOD;
}
int main()
{
	init();
	int n,k,rev2 = qpow(2,MOD - 2,MOD);scanf("%d%d",&n,&k);
    forn(i,1,n)	scanf("%d",&a[i]),b[i] = 2 * a[i];
	fsa[0] = n,fsb[0] = n;
	forn(i,1,n)
	{
		ll _a = 1,_b = 1;
		forn(j,1,k)
		{
			_a = _a * a[i] % MOD,_b = _b * b[i] % MOD;
			fsa[j] = (fsa[j] + _a) % MOD,fsb[j] = (fsb[j] + _b) % MOD;
		}
	}

    forn(x,1,k)
    {
		ll lf = 0;
		forn(i,0,x)
		{
			ll t = fsa[i] * fsa[x - i] % MOD;
			t = t * C(x,i) % MOD;
			lf = (lf + t) % MOD;
		}
		// cout << lf << endl;
		lf = ((lf - fsb[x]) % MOD + MOD) % MOD;
		printf("%lld\n",rev2 * lf % MOD);
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n , k , a [200005] , fact [303] , sum [303] , mn [303] , pww [200005][303] , pwww [200005][303];
long long pw ( long long x , long long y )
{
    if ( y == 0 ) return 1;
    long long ans = pw ( x , y / 2 );
    ans = ( ans * ans ) % mod;
    if ( y % 2 ) ans = ( ans * x ) % mod;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin >> n >> k;
    for ( int i = 0 ; i < n ; i ++ ) cin >> a [i];
    fact [0] = 1;
    for ( int i = 0 ; i < n ; i ++ )
    {
        pww [i][0] = 1;
        pwww [i][0] = 1;
    }
    for ( int i = 1 ; i <= k ; i ++ )
    {
        fact [i] = ( fact [ i - 1 ] * i ) % mod;
        for ( int j = 0 ; j < n ; j ++ )
        {
            pww [j][i] = ( pww [j][ i - 1 ] * a [j] ) % mod;
            pwww [j][i] = ( pwww [j][ i - 1 ] * ( a [j] + a [j] ) ) % mod;
            mn [i] += pwww [j][i];
        }
        mn [i] %= mod;
    }
    for ( int i = 0 ; i < n ; i ++ )
    {
        for ( int j = 0 ; j <= k ; j ++ ) sum [j] += pww [i][j];
    }
    for ( int i = 0 ; i <= k ; i ++ )
    {
        sum [i] %= mod;
        sum [i] = ( sum [i] * pw ( fact [i] , mod - 2 ) ) % mod;
    }
    for ( int i = 1 ; i <= k ; i ++ )
    {
        long long ans = 0;
        for ( int j = 0 ; j <= i ; j ++ ) ans += ( sum [j] * sum [ i - j ] ) % mod;
        ans %= mod;
        ans = ( ans * fact [i] ) % mod;
        ans = ( ans - mn [i] + mod ) % mod;
        cout << ( ans * pw ( 2 , mod - 2 ) ) % mod << endl;
    }
}


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

#define endl '\n'
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define FordE(i, l, r) for (int i = l; i >= r; i--)
#define Fora(v, a) for (auto v: a)
#define bend(a) a.begin(), a.end()
#define isz(a) ((signed)a.size())

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

const int N = 2e5 + 5;
const ll infll = (ld)1e18 + 7;

int n, q;

ll l = -infll, r = infll;
ll delta = 0;
// x <= l -> l, x >= r -> r, l < x < r -> x

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    ForE(i, 1, n){
        int a, t; cin >> a >> t;
        if (t == 1){
            delta += a;
        }
        else if (t == 2){
            if (a <= l + delta){
                continue;
            }
            if (a < r + delta){
                l = a - delta;
            }
            else{
                l = r = a - delta;
            }
        }
        else{
            if (a >= r + delta){
                continue;
            }
            if (a > l + delta){
                r = a - delta;
            }
            else{
                l = r = a - delta;
            }
        }
    }
    cin >> q;
    while (q--){
        int x; cin >> x;
        if (x <= l) cout << l + delta << endl;
        else if (x >= r) cout << r + delta << endl;
        else cout << x + delta << endl;
    }
}

/*
==================================================+
INPUT:                                            |
--------------------------------------------------|

--------------------------------------------------|
==================================================+
OUTPUT:                                           |
--------------------------------------------------|

--------------------------------------------------|
==================================================+
*/

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

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

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

int main()
{
	fast
	ll n;
	cin>>n;
	ll p=n+1;
	ll k=(-1+sqrt(1+8*p))/2;
	k+=10;
	while(true)
    {
        ll fun=k*(k+1)/2;
        if(fun<=p){break;}
        k--;
    }
    cout<<n-k+1;
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i  =  a; i < (int)(b); ++i)
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  int N, M; cin >> N >> M;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<pair<int, int>> ps(M);
  REP(i, M) cin >> ps[i].first >> ps[i].second;
  sort(ps.begin(), ps.end());

  vector<pair<int, int>> nodes(N);
  for (auto [a, b] : ps) {
    --a, --b;
    int x = A[a];
    if (nodes[a].second > 0) {
      x = min(A[a], nodes[a].second);
    }
    if (nodes[b].second == 0) {
      nodes[b] = {A[b], x};
    } else {
      nodes[b].second = min(nodes[b].second, x);
    }
  }

  int vmax = -1e18;
  for (auto [a, b] : nodes) {
    if (a == 0 && b == 0) continue;
    vmax = max(vmax, a - b);
  }
  cout << vmax << endl;

  return 0;
}

#include <bits/stdc++.h>

// ====================================================================
// clang-format off
namespace std {
template <class Fun>
class y_combinator_result {
    Fun fun_;
public:
    template <class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
    template <class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); }
};
template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); }
} // namespace std
// clang-format on
// ====================================================================

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

    int64_t x, y;
    std::cin >> x >> y;

    std::map<int64_t, int64_t> map;

    auto ans = std::y_combinator([&](auto self, int64_t t) -> int64_t {
        if (map.find(t) != end(map)) {
            return map[t];
        }
        else if (t == 1) {
            return map[t] = std::abs(x - t);
        }
        else if (t & 1) {
            return map[t] = std::min({
                std::abs(x - t),
                self((t + 1) / 2) + 2,
                self((t - 1) / 2) + 2
            });
        }
        else {
            return map[t] = std::min(std::abs(x - t), self(t / 2) + 1);
        }
    })(y);

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

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi (3.141592653589)
#define mod 1000000007
#define float double
#define pb push_back
// #define mp make_pair
#define ff first
#define ss second
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
const int N = 1e6+9;
int fact[N], invfact[N];
inline int add(int x, int y) { x += y; return x % mod;}
inline int sub(int x, int y) { x -= y; x %= mod; x += mod; return x % mod;}
inline int mul(int x, int y) { return  (x * y) % mod;}
inline int powr(int a, int b) {
	int x = 1 % mod;
	b %= (mod - 1);
	while (b) {
		if (b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a) { return powr(a, mod - 2);}
void pre() {
	fact[0] = invfact[0] = 1;
	for (int i = 1; i < N; i++) fact[i] = mul(i, fact[i - 1]);
	invfact[N - 1] = inv(fact[N - 1]);
	for (int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);
	assert(invfact[1] == 1);
}

inline int C(int n, int k) {
    if(k == 0)
        return 1;
	if (n < k || k < 0) return 0;
	return mul(fact[n], mul(invfact[k], invfact[n - k]));
}

int power(int x, int y, int m)
{
    if(y == 0)
        return 1;
    int temp = power(x,y/2,m);
    temp = ((temp%m) * (temp%m))%m;
    if(y%2 == 1)
        temp =  ((x%m) * (temp%m))%m;
    return temp;
}
// int dp[5009][5009];
bool isPalindrome(string str) {
  int i = 0, j = str.size() - 1;

  // traversing from both the ends
  while (i < j)

    // not palindrome
    if (str[i++] != str[j--])
      return false;

  // palindrome
  return true;
}

// function to remove all the palindromic words
// from the given sentence
string removePalinWords(string str) {

  // 'final_str' to store the final string and
  // 'word' to one by one store each word of 'str'
  string final_str = "", word = "";

  // add space at the end of 'str'
  str = str + " ";
  int n = str.size();

  // traversing 'str'
  for (int i = 0; i < n; i++) {

    // accumulating characters of the current word
    if (str[i] != ' ')
      word = word + str[i];

    else {

      // if 'word' is not palindrome then a
      // add it to 'final_str'
      if (!(isPalindrome(word)))
        final_str += word + " ";

      // reset
      word = "";
    }
  }

  // required final string
  return final_str;
}

void solve()
{
    int t = 1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
        string s;
        cin>>s;
        int n = s.size();
        deque<char> que;
        int c = 0;

        for(int i=0;i<n;i++)
        {
            if(s[i] == 'R')
                c = (c+1)%2;
            else
            {
                if(c == 0)
                {
                    if(que.size() != 0)
                    {
                        char ch = *que.rbegin();
                        if(ch == s[i])
                            que.erase(que.end());
                        else
                            que.push_back(s[i]);
                    }
                    else
                        que.push_back(s[i]);
                }
                else
                {
                    if(que.size() != 0)
                    {
                        char ch = *que.begin();
                        if(ch == s[i])
                            que.erase(que.begin());
                        else
                            que.push_front(s[i]);
                    }
                    else
                        que.push_front(s[i]);
                }
            }

        }

        string temp = "";
        for(auto it : que)
            temp.push_back(it);

        if(c == 1)
            reverse(temp.begin(),temp.end());

        cout<<temp;
    }

}

int32_t main(){

    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    solve();
    return 0;
}


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

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

  double ans = 0.0;
  for (int i = n - 1; i > 0; i--) {
    double p = (double)n / i;
    ans += p;
  }

  printf("%.10f\n", 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++)

// 最大公約数
ll gcd(ll a, ll b) { return (a % b)? gcd(b, a % b): b; }
ll gcd(ll a, ll b, ll c){ return gcd(a, gcd(b,c)); }

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

    ll result = 0;
    rep(i,N){
        int temp;
        cin >> temp;

        if(temp>10){
            result += temp-10;
        }
    }

    cout << result << endl;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long int;
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }

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

  unordered_map<string, int> mp;

  rep(i, N) {
    string S;
    cin >> S;

    if (S[0] == '!') {
      if (mp.find(S.substr(1, S.size() - 1)) != mp.end()) {
        cout << S.substr(1, S.size() - 1) << endl;
        return 0;
      } else {
        mp[S] = i;
      }
    } else {
      if (mp.find("!" + S) != mp.end()) {
        cout << S << endl;
        return 0;
      } else {
        mp[S] = i;
      }
    }
  }
  cout << "satisfiable" << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int N = 105;
const ll mod = 998244353;

int n;
string str[maxn], res;
unordered_map<string, int>o;

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	res = "()";
	for (int i = 1; i <= n; ++i) {
		cin >> str[i];
		if (res != "()")continue;
		if (str[i][0] == '!') {
			string cur = "";
			int sz = str[i].size();
			for (int j = 1; j < sz; ++j) {
				cur += str[i][j];
			}
			if (o[cur] == 1) {
				res = cur;
			} else {
				o[cur] = 2;
			}
		} else {
			if (o[str[i]] == 2) {
				res = str[i];
			} else {
				o[str[i]] = 1;
			}
		}
	}
	if (res == "()")cout << "satisfiable" << endl;
	else cout << res << endl;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Mod=998244353;
int n,m,k,ans;
inline int qpow(int a,int b,int m=Mod) {
	if (!a) return 0;
	int r=1;
	while (b) {
		if (b&1) r=1ll*r*a%m;
		a=1ll*a*a%m,b>>=1;
	}
	return r;
}

signed main() {
	cin>>n>>m>>k;
	if (n==1||m==1) cout<<qpow(k,n+m-1);
	else {
		for (int amax=1; amax<=k; ++amax)
			ans=(ans+(amax==1?1ll:(1ll*qpow(amax,n)-qpow(amax-1,n))%Mod)*qpow(k-amax+1,m))%Mod;
		cout<<(ans+Mod)%Mod;
	}
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define each(e, v) for(auto &e: v)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
//const int MOD = 1000000007;
const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct io_setup{
    io_setup(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

template<int mod>
struct Mod_Int{
    int x;

    Mod_Int() : x(0) {}

    Mod_Int(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    Mod_Int &operator += (const Mod_Int &p){
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p){
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p){
        *this *= p.inverse();
        return *this;
    }

    Mod_Int &operator ++ () {return *this += Mod_Int(1);}

    Mod_Int operator ++ (int){
        Mod_Int tmp = *this;
        ++*this;
        return tmp;
    }

    Mod_Int &operator -- () {return *this -= Mod_Int(1);}

    Mod_Int operator -- (int){
        Mod_Int tmp = *this;
        --*this;
        return tmp;
    }

    Mod_Int operator - () const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int inverse() const {
        assert(*this != Mod_Int(0));
        return pow(mod-2);
    }

    Mod_Int pow(long long k) const{
        Mod_Int now = *this, ret = 1;
        for(; k > 0; k >>= 1, now *= now){
            if(k&1) ret *= now;
        }
        return ret;
    }

    friend ostream &operator << (ostream &os, const Mod_Int &p){
        return os << p.x;
    }

    friend istream &operator >> (istream &is, Mod_Int &p){
        long long a;
        is >> a;
        p = Mod_Int<mod>(a);
        return is;
    }
};

using mint = Mod_Int<MOD>;

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

    if(N == 1) {cout << mint(K).pow(M) << '\n'; return 0;}

    if(M == 1) {cout << mint(K).pow(N) << '\n'; return 0;}

    vector<mint> S(K+1, 0);
    rep2(i, 1, K) S[i] = S[i-1]+mint(i).pow(M)-mint(i-1).pow(M);

    mint ans = 0;
    rep2(i, 1, K){
        mint tmp = mint(i).pow(N)-mint(i-1).pow(N);
        ans += tmp*S[K+1-i];
        //cout << tmp << ' ' << S[K-i] << '\n';
    }

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


#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
    ll res = 1;
    while (n) {
        if (n & 1)res = res * x % m;
        x = x * x % m; n >>= 1;
    }
    return res;
}
struct modint {
    ll n;
    modint() :n(0) { ; }
    modint(ll m) :n(m) {
        if (n >= mod)n %= mod;
        else if (n < 0)n = (n % mod + mod) % mod;
    }
    operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
    if (n == 0)return modint(1);
    modint res = (a * a) ^ (n / 2);
    if (n % 2)res = res * a;
    return res;
}

ll inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 10;
modint fact[max_n], factinv[max_n];
void init_f() {
    fact[0] = modint(1);
    for (int i = 0; i < max_n - 1; i++) {
        fact[i + 1] = fact[i] * modint(i + 1);
    }
    factinv[max_n - 1] = modint(1) / fact[max_n - 1];
    for (int i = max_n - 2; i >= 0; i--) {
        factinv[i] = factinv[i + 1] * modint(i + 1);
    }
}
modint comb(int a, int b) {
    if (a < 0 || b < 0 || a < b)return 0;
    return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vector<vector<modint>> rsum(k + 1, vector<modint>(n + 1));
    rep(i, n) {
        modint p = 1;
        rep(j, k + 1) {
            rsum[j][i + 1] += rsum[j][i] + p;
            p *= a[i];
        }
    }
    rep1(x, k) {
        modint ans = 0;
        rep(j, x + 1) {
            ans += comb(x, j) * rsum[j][n] * rsum[x - j][n];
            ans -= comb(x, j) * rsum[x][n];
        }
        ans *= (1 + mod) / 2;
        cout << ans << "\n";
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(15);
    init_f();
    //init();
    //expr();
    //int t; cin >> t; rep(i, t)
    solve();
    return 0;
}

/*

Konnichiwaa!!!!

*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define REP(i, k, n) for(ll i = k; i < n; ++i)
#define REPI(i, k, n) for(ll i = k; i >= n; --i)
#define vi vector<int>
#define vch vector<char>
#define vstr vector<string>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vpl vector<pair<ll, ll>>
#define vpi vector<pair<int, int>>
#define F first
#define S second
#define el "\n"
#define sz(x) x.size()
#define ld long double
#define sortar(v) sort(v.begin(),v.end())
#define rsort(v) sort(v.rbegin(),v.rend())
#define all(x) x.begin(), x.end()
#define div 1000000007
#define div2 998244353
#define pi 3.14159265358979323846
#define inf 1000000000000000000
#define blk 455
#define pb push_back
#define ppb pop_back
#define print(x) for(auto p:x) cout<<p<<' '; cout<<el;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 998244353
#define N 1000005
bool isPrime[N] = {false};
vll prm;
vll SPF(N);

void sieve()
{
    isPrime[1] = isPrime[0] = 0;
    ll i;

    for(i=2;i<N;++i) isPrime[i] = 1;

    for(i=2;i*i<N;++i)
    {
        if(isPrime[i])
        {
            for(ll j = i*i; j<N; j += i)
                isPrime[j] = 0;
        }
    }

    if(!prm.empty())
        prm.clear();

    REP(i,2,N)
    {
        if(isPrime[i])
            prm.pb(i);
    }

}

bool flip(bool f)
{
    if(f) return 0;
    return 1;
}
ll fastPower(ll a, ll b)
{
    if(b == 0) return 1;
    ll prod = 1;
    while(b > 0)
    {
        if(b & 1)
            prod = prod * a;
        b = b >> 1;
        a = a * a;
    }
    return prod;
}

ll fact(ll n) {
    ll res = 1;
    for(ll i=2;i<=n;i++) {
        res*=i;
    }
    return res;
}

ll nCr(ll n,ll r) {
    return (ld)fact(n)/(ld)(fact(r)*fact(n-r));
}

void printa(bool f){
    if(f) cout<<"YES"<<el;
    else cout<<"NO"<<el;
}

ll value(ll n){
    return (n*(n+1))/2;
}

void solve(){
    ll n, i;
    cin>>n;
    vector<pair<ll, ll>> a;
    REP(i,0,n){
        ll x, y;
        cin>>x>>y;
        a.pb(make_pair(x, y));
    }
    sort(all(a));

    ll j, k;

    REP(i,0,n){
        REP(j,i+1, n){
            REP(k,j+1,n){
                if(a[j].F != a[i].F && a[k].F != a[i].F){
                    double m1 = 1.0*(a[j].S - a[i].S)/(a[j].F - a[i].F);
                    double m2 = 1.0*(a[k].S - a[i].S)/(a[k].F - a[i].F);
                    if(m1==m2){
                        cout<<"Yes"<<el;
                        return;
                    }
                } else if(a[j].F == a[i].F && a[k].F == a[i].F){
                    cout<<"Yes"<<el;
                    return;
                }
            }
        }
    }
    cout<<"No"<<el;
}

int main()
{
    // fastio();
    #ifndef ONLINE_JUDGE
    freopen("C:/Users/Lenovo/Desktop/inpOut/input.txt", "r", stdin);
    freopen("C:/Users/Lenovo/Desktop/inpOut/output.txt", "w", stdout);
    #endif

    // ios_base::sync_with_stdio(0);
    // cin.tie(0);

    int tc = 1, i = 1;
    // scanf("%d", &tc);
    while(tc--)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
        // ++i;
    }
    return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <algorithm>
#include<bits/stdc++.h>
#include <cstdarg>
#include <cstdint>
#include <cstring>
#include <iomanip>
#include <math.h>
#include <vector>

// @author : sam000013

#define int long long
#define PI 3.14159265
#define pb(x) push_back(x)
#define all(v) v.begin(), v.end()
#define dbg(x) cout<<#x<<" "<<x<<endl;
#define bye cout<<endl;return
#define uni 1.000000
#define ld long double
using namespace std;

const int mod = 1000000007;
const int hashMod = 29996224275833;
template <typename T>

void show(vector<T> x)
{
    for (auto e : x){
        cout<<e<<" ";
    }
    cout<<endl;
}
template <typename T1>
void showPair(vector<pair<T1, T1>> x) {
    for(auto e:x){
        cout<<e.first<<" "<<e.second<<endl;
    }
}
template <typename T2>
void showSet(set<T2> x) {
    for(auto e:x){
        cout<<e<<" ";
    }
    cout<<endl;
}
template <typename T3>
void showMultiSet(multiset<T3> x) {
    for(auto e:x){
        cout<<e<<" ";
    }
    cout<<endl;
}

/*
for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){

    }
}
*/
void solve(){
    int n;
    cin>>n;
    vector<vector<int>> v(n, vector<int>(n));
    for(int i=0; i<n; i++){
        for(int j=0;j<n;j++){
            cin>>v[i][j];
        }
    }
    for(int i=0; i<n; i++){

        vector<int> canbe;
        for(int j=0; j<n; j++){
            int diff;
            bool ok = 1;
            for(int k=0; k<n; k++){
                if(k == 0){
                    if(v[j][k] - v[i][k] >= 0){
                        diff = v[j][k] - v[i][k];
                    }else{
                        ok = 0;
                        break;
                    }
                }else{
                    if(v[j][k] - v[i][k] != diff){
                        ok = 0;
                        break;
                    }
                }
            }
            if(ok){
                canbe.push_back(diff);
            }else{
                break;
            }
        }
        if(canbe.size() == n){
            cout<<"Yes\n";
            for(int j=0; j<n; j++){
                cout<<canbe[j]<<" ";
            }cout<<"\n";
            for(int j=0; j<n; j++){
                cout<<v[i][j]<<" ";
            }cout<<"\n";

            return;
        }
    }
    cout<<"No";bye;
}
signed main(){
    ios::sync_with_stdio(false);cin.tie(NULL);
    int t   = 1;
    // cin >> t;
    for(int i=1; i<=t; i++){
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define   NeedForSpeed  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(x)        (x).begin(), (x).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   len           length()
#define   sz            size()
#define   mod           1000000007
#define   elif          else if
#define   filein(x)     ifstream fin (x);
#define   fileout(x)    ofstream fout (x);

int32_t main(){
    NeedForSpeed

    int n;cin>>n;
    int ans=1;
    for(int i=n;i>=2;i--){
        if(__gcd(i,ans)==1){ans*=i;}
        else{
            ans*=i/(__gcd(ans,i));
        }
    }
    cout<<(ans+1)<<endl;
}


#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define all(a)  (a).begin(),(a).end()
#define rall(a)  (a).rbegin(),(a).rend()
typedef long long ll;
typedef pair<ll,ll> pl;
typedef tuple<ll,ll,ll> tupl;

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll sum=a,tot=0;
    ll cnt=0;
    if(b/c>=d) {
        cout << -1 << endl;
        return 0;
    }
    while(true) {
        sum+=b;
        tot+=c;
        cnt++;
        if(sum<=tot*d) break;
    }
    cout << cnt << endl;
    return 0;
}

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

#define LSOne(S) ((S) & -(S))

typedef vector<long double> vld;
using ld = long double;

class FenwickTree {
private:
  vld ft;
public:
  FenwickTree(int m) { ft.assign(m+1, 0); }

  ld rsq(int j) {
    ld sum = 0;
    for (; j; j -= LSOne(j))
      sum += ft[j];
    return sum;
  }

  ld rsq(int i, int j) { return rsq(j) - rsq(i-1); }

  void update(int i, ld v) {
    for (; i < (int)ft.size(); i += LSOne(i))
      ft[i] += v;
  }

};

class RUPQ {
private:
  FenwickTree ft;
public:
  RUPQ(int m) : ft(FenwickTree(m)) {}
  void range_update(int ui, int uj, ld v) {
    ft.update(ui, v);
    ft.update(uj+1, -v);
  }
  ld point_query(int i) { return ft.rsq(i); }
};

const ld MOD = 1000000007;
const int MAXN = 100005;

int n, m, k;

bool go_back[MAXN];
double ans[MAXN];

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

	cout << fixed << setprecision(5) << "\n";

	cin >> n >> m >> k;

	int consec = 0;
	bool good = true;
	for (int i = 0; i < k; i++) {
		int x;
		cin >> x;
		go_back[x]=true;
		if (good) {
			if(go_back[x-1]){
				consec++;
			} else {
				consec=1;
			}
			if (consec==m) {
				good = false;
			}
		}
	}

	if (!good) {
		cout << "-1\n";
		return 0;
	}

	RUPQ ft(n);

	ld coef0 = m;
	ld scalar0 = m;

	int limit = n-1;

	ft.range_update(1, min(m,limit), -1);

	for (int i = 1; i < n; i++) {
		ld val = ft.point_query(i);
		if (go_back[i]) {
			coef0+=val;
		} else {
			scalar0-=val;
			ft.range_update(i+1,min(limit, i+m),val/m);
		}
	}

	cout << (scalar0/coef0) << "\n";

}


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

#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define pb          push_back
#define all(v)      v.begin(),v.end()
#define ya          cout<<"Yes"<<endl;
#define no          cout<<"No"<<endl;
#define ff          first
#define sc          second
#define inf         999999999
#define pi          3.14159265359
#define printv(v)   for(auto x:v)cout<<x<<' ';cout<<endl;
#define takev(v)    for(auto &x:v)cin>>x;
inline  int         random(int a=1,int b=10)
{
    return a+rand()%(b-a+1);
}
typedef long long ll;
inline ll           lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
//#define see(x)  cout<<endl<<#x<<" : "<<(x)<<endl;
#define see(args...) \
{ \
    string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);\
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr<< *it << " = " << a <<",\n"[++it==istream_iterator<string>()];
    err(it, args...);
}
#define scc(n) scanf("%lld",&n);
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int N=3e6+9,mod=998244353;
ll a[N];
int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(NULL);
//    cout.tie(NULL);

    for(int i=1;i<=2e5;i++)
    {
        for(int j=1;j<=2e5;j++)
        {
            if(i*j>2e5)break;
            for(int k=1;k<=2e5;k++)
            {
                if(i*j*k>2e5)break;
                a[i*j*k]++;
            }
        }
    }

    for(int i=1;i<=2e5;i++)a[i]+=a[i-1];
    int p;
    cin>>p;
    cout<<a[p]<<endl;

    return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define mydeb(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
//#define mydeb(fmt, ...)

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

	double sum=0;

	for (int i=n-1;i>0;--i)
	{
		sum+=(double)1/i;
	}
	cout << setprecision(16) << sum*n << endl;
}


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

const char nl = '\n';
const double eps = 1e-6;
const int N = 110;

int n, D, H;
int d[N], h[N];

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

    priority_queue<double, vector<double>, greater<double>> q;

    cin >> n >> D >> H;
    for (int i = 0; i < n; ++i) {
        cin >> d[i] >> h[i];
        double t = (double)(H - h[i]) / (D - d[i]);
        q.push(t);
    }

    double k = q.top();
    double b = H - k * D;
    if (b > 0) cout << b << nl;
    else cout << "0.0" << nl;
    return 0;
}

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

int main() {
  cout << fixed << setprecision(20);
  int n,D,H;
  cin >> n >> D >> H;
  vector<int> d(n);
  vector<int> h(n);
  rep(i,n){
    cin >> d[i] >> h[i];
  }
  double ans = 0;
  rep(i,n){
    double tmpAns = H - D * (double(H-h[i])/double(D-d[i]));
    ans = max(ans, tmpAns);
  }
  cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <random>
#include <chrono>
#include <queue>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <limits>

#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define showv(v) for(int i : v) cout << i << ' '; cout << '\n';
#define show(begin, end) for(auto it = begin; it != end; it++) cout << *it << ' '; cout << '\n';
#define MAXN 300005

using namespace std;
using namespace std::chrono;
typedef long long   ll;
typedef long double ld;

int inf = 1e9 + 9;
int mod = 1e9 + 7;

vector<ll> sieve(ll n) {
    vector<bool> prime(n, true);
    prime[0] = prime[1] = false;
    for(int i = 2;i < n;i++)
        if(prime[i])
            for(int j = 2 * i;j < n;j += i)
                prime[j] = false;

    vector<ll> primes;
    for(ll i = 0;i < n;i++)
        if(prime[i]) primes.push_back(i);
    return primes;
}

ll bpow(ll a, ll n, ll m) {
    if(n == 0)
        return 1;
    if(n & 1) {
        ll res = bpow(a, n - 1, m);
        res = (res * a) % m;
        return res;
    } else {
        ll res = bpow(a, n / 2, m);
        res = (res * res) % m;
        return res;
    }
}

void solve() {
    ll n, m; cin >> n >> m;
    ll mm = m * m;
    // (10 ^ n) % m = a
    // 10 ^ n = p * m * m + b * m + a
    // (10 ^ n( % mm =
    ll a = bpow(10, n, m);
    ll c = bpow(10, n, mm);
    ll b = (c - a) / m;
    cout << b << endl;
}

int main() {
    faster
    auto start = high_resolution_clock::now();
    int test; test = 1;
    while(test--) {
        solve();
    }
    auto stop = high_resolution_clock::now();
    double duration = duration_cast<milliseconds>( stop - start ).count() * 1.0;
    // cout << "Time taken by function: " << duration << " ms " << endl;
    return 0;
}

#include "iostream"
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>

using namespace:: std;

long long int pow (long long int n, long int k, long int m)
    {

    if (k == 1)
        return n;

    else if (k % 2 == 0)
        return ((pow (n, k / 2, m) % m * pow (n, k / 2, m) % m) % m);
    else
        return ((pow (n, k - 1, m) % m * (n % m)) % m);
    }

int main()
    {

    long long int n, m;
    cin>>n>>m;

    cout<<(pow (10, n, m * m) / m) % m;

    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 998244353
#define INF 1000000007LL

using namespace std;

int n, m, a, b, k, ilep[5005][5005], iled[5005][5005];
long long pot[5005];
char z[5005][5005];
long long tab[5005][5005];

int main()
{
    pot[0] = 1;
    FOR(i, 1, 5003)
        pot[i] = (pot[i-1]*3)%M;

    scanf("%d %d %d", &n, &m, &k);
    forr(i, k)
    {
        scanf("%d %d", &a, &b);
        scanf(" %c", &z[a][b]);
    }
    FORD(i, n, 1)
        FORD(j, m, 1)
        {
            ilep[i][j] = ilep[i][j+1] + (z[i][j] == 0 ? 1 : 0);
            iled[i][j] = iled[i+1][j] + (z[i][j] == 0 ? 1 : 0);
        }

    FORD(i, n, 1)
        FORD(j, m, 1)
        {
            if(i == n && j == m)
            {
                tab[i][j] = (z[i][j] == 0 ? 3 : 1);
                continue;
            }
            long long d = (z[i][j] == 0 ? 2 : z[i][j] == 'R' ? 0 : 1);
            long long r = (z[i][j] == 0 ? 2 : z[i][j] == 'D' ? 0 : 1);
            d = d * pot[ilep[i][j+1]] % M;
            r = r * pot[iled[i+1][j]] % M;
            tab[i][j] = (d * tab[i+1][j] + r * tab[i][j+1]) % M;
            //cout << i << ", " << j << " daje " << tab[i][j] << endl;
        }

    printf("%lld\n", tab[1][1]);

    return 0;
}

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

constexpr int M = 998244353;

int main() {
    int h, w, k; cin >> h >> w >> k;
    long long dp[2][w][3];
    int cur = 0, prev = 1;
    unordered_map<int, unordered_map<int, char> > f;
    auto get = [&f](int i, int j) -> char {
        if (f.find(i) == f.end()) return 0;
        if (f[i].find(j) == f[i].end()) return 0;
        return f[i][j];
    };
    while (k--) {
        int h, w; char c; cin >> h >> w >> c;
        f[h-1][w-1] = c;
    }
    vector<long long> vcount(w, 1);
    for (int i = 0; i < h; i++) {
        long long hcount = 1;
        for (int j = 0; j < w; j++) {
            long long val = 0;
            if (i > 0) val += (dp[prev][j][1] + dp[prev][j][2]) * hcount % M;
            if (j > 0) val += (dp[cur][j-1][0] + dp[cur][j-1][2]) * vcount[j] % M;
            if (i == 0 && j == 0) val = 1;
            char c = get(i, j);
            // c == 'R' ? 0 : c == 'D' ? 1 : 2
            if (c == 'R') {
                dp[cur][j][0] = val;
                dp[cur][j][1] = dp[cur][j][2] = 0;
            } else if (c == 'D') {
                dp[cur][j][1] = val;
                dp[cur][j][0] = dp[cur][j][2] = 0;
            } else if (c == 'X') {
                dp[cur][j][2] = val;
                dp[cur][j][0] = dp[cur][j][1] = 0;
            } else {
                dp[cur][j][0] = dp[cur][j][1] = dp[cur][j][2] = val;
            }
            if (c == 0) {
                hcount = hcount * 3 % M;
                vcount[j] = vcount[j] * 3 % M;
            }
            // cerr << i << ' ' << j << ' ' << c << ' ' << dp[cur][j][0] << ' ' << dp[cur][j][1] << ' ' << dp[cur][j][2] << endl;
        }
        swap(cur, prev);
    }
    cout << accumulate(dp[prev][w-1], dp[prev][w-1]+3, 0LL) % M << endl;
}


#include<cstdio>
#define MOD 1000000007
#define MAX_X 2000000

int f[2000006];
int inv_f[2000006];

int pow(int x, int y) {
  if (y == 0) {
    return 1;
  }
  if (y % 2 == 0) {
    return pow(1ll * x * x % MOD, y / 2);
  } else {
    return 1ll * x * pow(x, y - 1) % MOD;
  }
}

int inv(int x) {
  return pow(x, MOD - 2);
}

int nCr(int n, int r) {
  if (n < r) {
    return 0;
  }
  return (1ll * f[n] * inv_f[r] % MOD) * inv_f[n - r] % MOD;
}

int n, m, k;

int main() {
  f[0] = 1;
  for (int i = 1; i <= MAX_X; i++) {
    f[i] = 1ll * i * f[i - 1] % MOD;
  }
  inv_f[MAX_X] = inv(f[MAX_X]);
  for (int i = MAX_X; i > 0; i--) {
    inv_f[i - 1] = 1ll * i * inv_f[i] % MOD;
  }
  scanf("%d %d %d", &n, &m, &k);
  if (n - m >= k + 1) {
    printf("0\n");
    return 0;
  }
  int ans = ((nCr(m + n, n) - nCr(m + n, k + m + 1) % MOD) + MOD) % MOD;
  printf("%d\n", ans);
  return 0;
}

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

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

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

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

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

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

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

const ll maxf = 10000000;
ll fact[maxf+5];
ll ifact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++) fact[i] = (fact[i-1] * i) % MOD;
  ifact[maxf]=modpow(fact[maxf],MOD-2);
  for(ll i=maxf; i>=1; i--) ifact[i-1] = (ifact[i] * i) % MOD;
}

ll comb(ll n, ll r){
  if(n<r || n<0 || r<0) return 0;
  if(fact[0] == 0) fact_init();
  return ((fact[n] * ifact[n-r]) % MOD * ifact[r]) % MOD;
}

ll naive_comb(ll n, ll r){
  ll res = 1;
  for (ll i = n; i > n - r; i--) res = res * i % MOD;
  for (ll i = 1; i <= r; i++) res = (res * modpow(i, MOD-2)) % MOD;
  return res;
}

// 考えたこと
// sumがmで、xorが0
// bitの重複はない？ => 重複なかったら0にならない
// mのあるbitが立っている => その直前のbitが2個立っている そのbitはsumでは桁上がり and xorでは0になる
// => mの下一桁が1なら作れない
// 16を作りたい
// 8 8 でも良いが 4 4 4 4 でも良い 2 2 2 2 2 2 2 2
// n=4として、24を作ることを考える
// 16を作るのに4を4個にすると、8を作るための4が足りなくなる => 2を4個でも事足りる
// 28を考える
// 4を4個、2を4個、1を4個
// 16を作る 4を2個、2を4個
// あるビットをxorが0にして立たせようとすると二分木っぽくなる
// 各bitを偶数個に分割
// あるbitは

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

  int n,m; cin>>n>>m;

  int logM=0;
  int M=m;
  vc<int> a;
  while(M){
    logM++;
    a.push_back(M&1);
    M>>=1;
  }
  // cout<<logM<<endl;
  // rep(i,a.size()) cout<<a[i]<<' ';
  // cout<<endl;
  vc<vc<ll>> dp(logM+1, vc<ll>(n+1));

  if(a[0]==1){
    cout<<0<<endl;
    return 0;
  }

  dp[0][0]=1;
  rep(i,logM-1){
    for(int j=0; j<=n; j++){
      for(int k=0; k<=n; k+=2){
        if((j+k)/2%2==a[i+1])
        (dp[i+1][(j+k)/2]+=dp[i][j]*comb(n,k)%MOD)%=MOD;
      }
    }
  }

  // rep(i,n+1) cout<<dp[logM-1][i]<<' ';
  // cout<<endl;
  cout<<dp[logM-1][1]<<endl;
}


//kapi kapi spaghetti
#include <iostream>
#include <iomanip> //setprecision(12)
#include <algorithm>
#include <functional>
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <set>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

using pll=pair<ll,ll>;
int main()
{
    ll N;
    cin>>N;
    vector<vector<ll>> edge(N);
    for(ll i=1; i<N; i++)
    {
        ll p;
        cin>>p;
        --p;
        edge[p].push_back(i);
    }

    auto solve=[&](auto& solve, pll now)->pll//( vertex, turn(1:first,-1:second) )
    {

        ll from=now.first, turn=now.second;
        pll res;
        res.first=1*turn;
        turn*=-1;
        res.second=turn;

        vector<pll> w,d,l;
        for(auto to:edge[now.first])
        {
            pll temp=solve(solve,pll(to,-turn));
            if(temp.first>0&&temp.second==turn) w.push_back(temp);
            else if(temp.first<=0&&temp.second==turn) l.push_back(temp);
            else d.push_back(temp);
        }

        if(turn==1)
        {
            for(auto a:w) res.first+=a.first;
            sort(d.begin(), d.end(), [](pll a, pll b)
            {
                return a.first>b.first;
            });
            for(ll i=0; i<d.size(); i++)
            {
                res.first+=d[i].first*turn;
                turn*=-1;
            }
            res.second=turn;
            for(auto a:l) res.first+=a.first*turn;
            res.second*=-1;
        }
        else
        {
            for(auto a:l) res.first+=a.first;
            sort(d.begin(), d.end(), [](pll a, pll b)
            {
                return a.first<b.first;
            });
            for(ll i=0; i<d.size(); i++)
            {
                res.first+=d[i].first*(-turn);
                turn*=-1;
            }
            res.second=turn;
            for(auto a:w) res.first+=a.first*(-turn);
            res.second*=-1;
        }

        //cout<<from<<": "<<res.first<<" "<<res.second<<endl;
        return res;
    };

    pll res=solve(solve,pll(0,1));
    //cout<<res.first<<" "<<res.second<<endl;
    cout<<(N+res.first)/2<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0, i##_len=(n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())

void _cin() {} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail) { cin >> head; _cin(forward<Tail>(tail)...); }
#define cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
#define cinv(Type, xs, n) vector<Type> xs(n); rep(i, n) cin >> xs[i]
#define cinv2(Type, xs, ys, n) vector<Type> xs(n), ys(n); rep(i, n) cin >> xs[i] >> ys[i]
#define cinv3(Type, xs, ys, zs, n) vector<Type> xs(n), ys(n), zs(n); rep(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define cinvv(Type, xs, h, w) vector<vector<Type>> xs(h, vector<Type>(w)); rep(i, h) rep(j, w) cin >> xs[i][j]

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); }
template <class Type> void print(vector<Type> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class Type> void print(vector<vector<Type>> &df) { for (auto& vec : df) { print(vec); } }

void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void yesno(bool b) { cout << (b ? "yes" : "no") << endl; }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a < b) { a = b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;

vector<vector<int>> ch(110000);

int calc(int &T, int &A, int p=0) {
	T = 1;
	A = 0;
	int N = 1;
	if (len(ch[p]) == 0) return N;

	vector<tuple<int, int, int, int>> st;
	for (auto c : ch[p]) {
		int t, a;
		int n = calc(t, a, c);
		N += n;
		st.emplace_back((n % 2) ? 1 : (a - t > 0) ? 0 : 2, t - a, t, a);
	}
	sort(all(st));
	int i = 0;
	for (auto [o, s, t, a] : st) {
		if (o) {
			if (i % 2) swap(t, a);
			if (o == 1) i++;
		}
		T += t;
		A += a;
	}
	return N;
}

void Main() {
	cin(int, n);
	for (int i = 1; i < n; i++) {
		cin(int, p);
		p--;
		ch[p].emplace_back(i);
	}
	int t, a;
	calc(t,a);
	print(t);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(16);
	//int t; cin >> t; while (t--)
	Main();
}