//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353

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

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	int m, t; cin >> m >> t;
	ll now = n;
	int ti = 0;
	bool ch = true;
	int a, b;
	REP(i, m){
		cin >> a >> b;
		now -= a-ti;
		if(now <= 0) ch = false;
		now += b - a;
		now = min(now, (ll)n);
		ti = b;
	}
	now -= t - ti;
	if(now <= 0) ch = false;
	if (ch) cout << "Yes" << endl;
	else cout << "No" << endl;

	//cout << ans << endl;
}

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

template<int M>
class ModInt {
   public:
    ll value;
    constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; }
    constexpr ModInt pow(ll n) const { if (!n) return 1; ModInt a = pow(n >> 1); a *= a; if (n & 1) a *= *this; return a; }
    constexpr ModInt inv() const { return this->pow(M - 2); }
    constexpr ModInt operator + (const ModInt &rhs) const { return ModInt(*this) += rhs; };
    constexpr ModInt operator - (const ModInt &rhs) const { return ModInt(*this) -= rhs; };
    constexpr ModInt operator * (const ModInt &rhs) const { return ModInt(*this) *= rhs; };
    constexpr ModInt operator / (const ModInt &rhs) const { return ModInt(*this) /= rhs; };
    constexpr ModInt &operator += (const ModInt &rhs) { value += rhs.value; if (value >= M) value -= M; return *this; };
    constexpr ModInt &operator -= (const ModInt &rhs) { value -= rhs.value; if (value <  0) value += M; return *this; };
    constexpr ModInt &operator *= (const ModInt &rhs) { value = value * rhs.value % M; return *this; };
    constexpr ModInt &operator /= (const ModInt &rhs) { return (*this) *= rhs.inv(); };
    constexpr bool operator == (const ModInt &rhs) { return value == rhs.value; }
    constexpr bool operator != (const ModInt &rhs) { return value != rhs.value; }
    friend ostream &operator << (ostream &os, const ModInt &rhs) { os << rhs.value; return os; }
};

using mint = ModInt<MOD>;

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

    ll S = accumulate(ALL(A), 0LL);
    mint ans = 1;
    REP(i, 0, N + S) {
        ans *= (N + M - i);
        ans /= (N + S - i);
    }
    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using prique = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

template<class T> class segtree {
	int n;
	vector<T> data;
	T id = 0;
	T operation(T a, T b) { return a ^ b; };
public:
	segtree(int _n) {
		n = 1;
		while (n < _n + 2) n <<= 1;
		data = vector<T>(2 * n, id);
	}
	segtree(vector<T> vec) {
		int _n = vec.size();
		n = 1;
		while (n < _n + 2) n <<= 1;
		data = vector<T>(2 * n, id);
		for (int i = 0; i < _n; i++) data[i + n] = vec[i];
		for (int i = n - 1; i >= 1; i--) data[i] = operation(data[i << 1], data[i << 1 | 1]);
	}
	void change(int i, T x) {
		i += n;
		data[i] = x;
		while (i > 1) {
			i >>= 1;
			data[i] = operation(data[i << 1], data[i << 1 | 1]);
		}
	}
	void add(int i, T x) { change(i, data[i + n] + x); }
	T get(int a, int b) {
		T left = id; T right = id;
		a += n; b += n;
		while (a < b) {
			if (a & 1) left = operation(left, data[a++]);
			if (b & 1) right = operation(data[--b], right);
			a >>= 1; b >>= 1;
		}
		return operation(left, right);
	}
	T get_all() { return data[1]; }
	T operator[](int i) { return data[i + n]; }
};

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	cin >> a;
	segtree<int> seg(a);
	while (q--) {
		int type;
		cin >> type;
		if (type == 1) {
			int x, y;
			cin >> x >> y;
			x--;
			seg.change(x, seg[x] ^ y);
		}
		else {
			int x, y;
			cin >> x >> y;
			x--;
			cout << seg.get(x, y) << '\n';
		}
	}
}

#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define sqr(x) ((x) * (x))
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 50;
const LL INF = 1e9;

int c[MX], vis[MX];
VI g[MX];

vector<int> vec;

void dfs(int u)
{
    vec.PB(u); vis[u] = 1;

    for(int v : g[u])
    {
        if(!vis[v]) dfs(v);
    }
}

LL rec(int i)
{
    if(i == vec.size()) return 1;

    int u = vec[i], f[3] = {0};
    for(int v : g[u]) if(c[v] != -1) f[c[v]] = 1;

    LL ret = 0;
    loop(j,0,3)
    {
        if(f[j] == 0)
        {
            c[u] = j;
            ret += rec(i+1);
        }
    }

    c[u] = -1;
    return ret;
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, m;
    cin>>n>>m;
    int u, v;
    loop(i,0,m)
    {
        cin>>u>>v;
        g[u].PB(v);
        g[v].PB(u);
    }

    LL ans = 1;
    mset(c,-1); mset(vis,0);

    loop(i,1,n+1)
    {
        if(vis[i] == 0)
        {
            dfs(i);
            LL ans1 = rec(0);
            if(ans1 == 0) {ans = 0; break;}
            ans *= ans1;
            vec.clear();
        }
    }

    cout<<ans<<'\n';

    return 0;
}


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

int main(){
    int N = 3;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(), A.end());
    if((A[2]-A[1])==A[1]-A[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

#include <bits/stdc++.h>

using namespace std;

int main() {

  int A1,A2,A3;

  cin>>A1>>A2>>A3;

  if((max(A1,max(A2,A3))-max(A1,min(A2,A3)))==(max(A1,min(A2,A3))-min(A1,min(A2,A3))))

{cout<<"Yes"<<endl;}

  else if((max(A1,max(A2,A3))-min(A1,max(A2,A3)))==(min(A1,max(A2,A3))-min(A1,min(A2,A3))))

{cout<<"Yes"<<endl;}

  else{cout<<"No"<<endl;}

}


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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define pf push_front
#define sz(x) (int)(x).size()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef long double ld;
typedef map<int,int> mii;

const int MOD = 1e9+7;
const ld PI = acos((ld)-1);

void solve () {
	int x,y;
	cin >> x >> y;
	if (abs(x-y) < 3) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

int main () {

#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif

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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define ull unsigned long long
#define lson(x) x << 1
#define rson(x) x << 1 | 1
using namespace std;
void io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int MAXN = 5e5 + 5;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

ll fpow(ll base, ll t, ll p) {
    ll ans = 1;
    while (t) {
        if (t & 1) {
            ans = ans * base % p;
        }
        base = base * base % p;
        t >>= 1;
    }
    return ans;
}

int main() {
    io();
    ll n, m;
    cin >> n >> m;
    n = fpow(10, n, m * m);
    n /= m;
    cout << n;
}


#include<bits/stdc++.h>
typedef int LL;
typedef double dl;
#define opt operator
#define pb push_back
#define pii std::pair<LL,LL>
const LL maxn=1e6+9,mod=1e9+7,inf=0x3f3f3f3f;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
void Chkmin(LL &x,LL y){
	if(y<x) x=y;
}
void Chkmax(LL &x,LL y){
	if(y>x) x=y;
}
LL add(LL x,LL y){
	return x+=y,x>=mod?x-mod:x;
}
LL dec(LL x,LL y){
	return x-=y,x<0?x+mod:x;
}
LL mul(LL x,LL y){
	return 1ll*x*y%mod;
}
LL Pow(LL base,LL b){
	LL ret(1); while(b){
		if(b&1) ret=mul(ret,base); base=mul(base,base); b>>=1;
	}return ret;
}
LL n;
LL a[maxn];
int main(){
	n=Read();
	for(LL i=1;i<=n;++i) a[i]=Read();
	std::sort(a+1,a+1+n);
	LL ret(1);
	for(LL i=0;i<n;++i) ret=mul(ret,a[i+1]-a[i]+1);
	printf("%d\n",ret);
	return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

const int maxn = 4e5 + 50, INF = 0x3f3f3f3f;

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

int n, pos[maxn];

struct Node {
	int id, val;
	inline friend bool operator < (register const Node &a, register const Node &b) { return a.val < b.val; }
} a[maxn];

int main () {
	n = read() << 1;
	for (register int i = 1; i <= n; i ++) a[i].id = i, a[i].val = read();
	sort (a + 1, a + n + 1);
	for (register int i = 1; i <= n; i ++) pos[a[i].id] = i;
	register int res = 0;
	for (register int i = 1; i <= n; i ++) {
		if (pos[i] <= n >> 1) {
			if (res >= 0) putchar ('(');
			else putchar (')');
			res ++;
		} else {
			if (res <= 0) putchar ('(');
			else putchar (')');
			res --;
		}
	}
	return putchar ('\n'), 0;
}


// *** Though I am not John Snow, yet I know nothing ***
#include <bits/stdc++.h>
using namespace std;
#define F(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define range(a, b) substr(a, b - a + 1)
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define FIO                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

void solve()
{
    int n;
    cin >> n;
    int a[105];
    int t, p;
    cin >> t >> p;
    F(i, 0, n)
    {
        int st, pt;
        cin >> st >> pt;
        if (st < t && pt > p)
        {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}

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

    FIO;

    solve();

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <cstring>
#include <bitset>
#include <array>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	if(abs(m)>max(n-2, 0)){
		cout << -1 << '\n';
		return 0;
	}
	if(m<0){
		cout << -1 << '\n';
		return 0;
		m=abs(m)+1;
		cout << 1 << ' ' << m+2 << '\n';
		int pos=(m+1)*2;
		for(int i=0; i<m; i++){
			cout << i+2 << ' ' << pos << '\n';
			pos--;
		}
		pos=(m+1)*2+1;
		for(int i=0; i<n-m-1; i++){
			cout << pos << ' ' << pos+1 << '\n';
			pos+=2;
		}
	}
	else if(m>0){
		int pos=1;
		m++;
		for(int i=0; i<n-m-1; i++){
			cout << pos << ' ' << pos+1 << '\n';
			pos+=2;
		}
		cout << pos << ' ' << pos+(m+1)*2-1 << '\n';
		for(int i=0; i<m; i++){
			cout << pos+i*2+1 << ' ' << pos+(i+1)*2 << '\n';
		}
	}
	else{
		int pos=1;
		for(int i=0; i<n; i++){
			cout << pos << ' ' << pos+1 << '\n';
			pos+=2;
		}
	}

	return 0;
}


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

int main()
{
    ll n,i,x,y,ans=0;
    cin >> n;

    ll a[n],b[n];
    for(i=0;i<n;i++)
        cin >> a[i];

    for(i=0;i<n;i++)
        cin >> b[i];

    for(i=0;i<n;i++)
    {
        ans += a[i]*b[i];
    }
    if(ans == 0)
        std::cout << "Yes" << std::endl;
    else
        cout << "No" << "\n";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

void solve() {
	int n,x,s=0;
	cin>>n;
	int a[n];
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) {
		cin>>x;
		s+=a[i]*x;
	}
	if(s) cout<<"No";
	else cout<<"Yes";
}

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


/*#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll sum;
    int k;
    while(cin>>k){
            sum=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                if(a*b*c<=k)sum++;
            }
        }
    }
    cout<<sum<<endl;
}
}
*/
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll sum;
    int k;
    while(cin>>k){
            sum=0;
    for(int a=1;a<=k;a++){
        for(int b=a;b<=k/a;b++){
            for(int c=b;c<=k/a/b;c++){
                if(a*b*c<=k){
                    if(a==b&&b==c)sum+=1;
                    else if(a==b||b==c||a==c)sum+=3;
                    else sum+=6;
                }
            }
        }
    }
    cout<<sum<<endl;
}
}

#include <iostream>
using namespace std;
typedef long long ll;
ll n,N,M,ans;
int main(void){
    cin>>n;
    for(ll i=1LL;i<=n;i++){
        N=n/i;
        for(ll j=1LL;j<=N;j++){
            M=N/j;
            ans+=M;
        }
    }
    cout<<ans<<endl;
}


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

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define pf              push_front
#define mkp             make_pair
#define mkt             make_tuple
#define pii             pair<int,int>
#define tii             tuple<int,int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rall(v)         v.rbegin(),v.rend()
#define endl            "\n"
using cd = complex<double>;
const double PI = acos(-1);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int maxm(int a, int b)
{
    return (a >= b ? a : b);
}

int minm(int a, int b)
{
    return (a <= b ? a : b);
}

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    if (x == 0)
        return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

#define FMAX 2000005
vi fact(FMAX, 1);
vi fact_inv(FMAX, 1);
vi lp(FMAX);
vi pr;

int nCrmodp(int n, int r, int p)
{
    if (r > n)
        return 0;
    int pro = (fact[n] * fact_inv[r]) % p;
    pro = (pro * fact_inv[n - r]) % p;
    return pro;
}
void precompute()
{
    int x = 1;
    for (int i = 1; i < FMAX; ++i)
    {
        x *= i;
        x %= mod;
        fact[i] = x;
        fact_inv[i] = power(x, mod - 2, mod);
    }
}

void spf_calc()
{
    for (int i = 2; i < FMAX; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] < FMAX; ++j)
            lp[i * pr[j]] = pr[j];
    }
}

int next_smaller(vector<int>v, int val)
{
    int l = 0, r = v.size() - 1, ans = -1;
    while (l <= r)
    {
        int mid = (l + r) / 2;
        if (v[mid] <= val)
        {
            ans = mid;
            l = mid + 1;
        }
        else
            r = mid - 1;
    }
    return ans;
}

void c_p_c()
{
    precompute();
    //spf_calc();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

signed main()
{
    c_p_c();

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

    if (n > (m + k))
        cout << "0\n";
    else
    {
        int tot = nCrmodp(n + m, n, mod);
        tot -= nCrmodp(n + m, m + k + 1, mod);
        tot = (tot + mod) % mod;
        cout << tot << endl;
    }
    return 0;
}

#include <algorithm>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; ++i)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; }

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
const int INF = INT_MAX - 1;

class ModCalc
{
    LLONG m_mod;
    vector<LLONG> m_fac;
    vector<LLONG> m_ifac;

public:
    ModCalc(const LLONG mod)
    {
        m_mod = mod;
    }

    ModCalc(const int max, const LLONG mod)
    {
        m_mod = mod;
        m_fac = vector<LLONG>(max + 1);
        m_ifac = vector<LLONG>(max + 1);
        m_fac[0] = m_ifac[0] = 1;
        for (int i = 0; i < max; ++i)
        {
            m_fac[i + 1] = m_fac[i] * (i + 1) % mod;    // n! (mod M)
            m_ifac[i + 1] = m_ifac[i] * ModPow(i + 1, mod - 2) % mod;   // k!^(M-2) (mod M)
        }
    }

    const LLONG ModAdd(LLONG a, LLONG b) const
    {
        return (a + b) % m_mod;
    }

    const LLONG ModSubtract(LLONG a, LLONG b) const
    {
        LLONG diff = a - b;
        return diff >= 0 ? diff : diff + m_mod;
    }

    const LLONG ModMulti(LLONG a, LLONG b) const
    {
        LLONG prod = a * b % m_mod;
        return prod >= 0 ? prod : prod + m_mod;
    }

    const LLONG ModDiv(LLONG a, LLONG b) const
    {
        LLONG c = m_mod, u = 1, v = 0;
        while (c)
        {
            LLONG t = b / c;
            b -= t * c; swap(b, c);
            u -= t * v; swap(u, v);
        }
        u %= m_mod;
        if (u < 0) u += m_mod;
        return (a % m_mod) * u % m_mod;
    }

    const LLONG ModPow(LLONG x, LLONG n) const
    {
        LLONG ret = 1;
        while (n != 0)
        {
            if (n & 1) ret = ret * x % m_mod;
            x = x * x % m_mod;
            n = n >> 1;
        }
        return ret;
    }

    const LLONG ModComb(LLONG n, LLONG r) const
    {
        if (n == 0 && r == 0) return 1;
        if (n < r || n < 0) return 0;
        LLONG tmp = m_ifac[n - r] * m_ifac[r] % m_mod;
        return tmp * m_fac[n] % m_mod;
    }
};

int main()
{
    LLONG N, M, K; cin >> N >> M >> K;
    if (N > M + K)
    {
        cout << 0 << endl;
    }
    else
    {
        ModCalc m(2000001, MOD);
        cout << m.ModSubtract(m.ModComb(N + M, N), m.ModComb(N + M, M + K + 1)) << endl;
    }
}


#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::istream;
using std::ostream;
using std::vector;
using ll = long long;
using ull = unsigned long long;

// Mod int
const int mod = 1000000007;
struct mint {
  uint x;
  mint(): x(0) {}
  mint(ll x):x((x%mod+mod)%mod) {}
  mint operator-() const { return mint(0) - *this;}
  mint operator~() const { return mint(1) / *this;}
  mint& operator+=(const mint& a) { if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a) { if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a) { x=(ull)x*a.x%mod; return *this;}
  mint& operator/=(const mint& a) { x=(ull)x*a.pow(mod-2).x%mod; return *this;}
  mint operator+(const mint& a) const { return mint(*this) += a;}
  mint operator-(const mint& a) const { return mint(*this) -= a;}
  mint operator*(const mint& a) const { return mint(*this) *= a;}
  mint operator/(const mint& a) const { return mint(*this) /= a;}
  mint pow(ll t) const {
    if(!t) return 1;
    mint res = pow(t/2);
    res *= res;
    return (t&1)?res*x:res;
  }
  bool operator<(const mint& a) const { return x < a.x;}
  bool operator==(const mint& a) const { return x == a.x;}
  bool operator!=(const mint& a) const { return x != a.x;}
};
mint ex(mint x, ll t) { return x.pow(t);}
istream& operator>>(istream&i,mint&a) {i>>a.x;return i;}
//*
ostream& operator<<(ostream&o,const mint&a) {o<<a.x;return o;}

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

	vector<int> a(n);
	rep(i, n) cin >> a[i];

	vector<mint> fib(n + 2);
	fib[0] = fib[1] = 1;
	for (int i = 2; i <= n + 1; ++i)
	    fib[i] = fib[i - 1] + fib[i - 2];

	mint ans = fib[n] * a[0];
	for (int i = 1; i < n; ++i) {
		mint coeff = fib[i] * fib[n - i] - fib[i - 1] * fib[n - i - 1];
		ans += coeff * a[i];
	}

	cout << ans << '\n';

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define sfd(x) scanf("%d",&x)
#define sfd2(x,y) scanf("%d%d",&x,&y)
#define sfd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sfs(x) scanf("%s",x)
#define sfll(x) scanf("%lld",&x)
#define sfll2(x,y) scanf("%lld%lld",&x,&y)
#define pfd(x) printf("%d",x)
#define pfs(x) printf("%s",x)
#define pfll(x) printf("%lld",x)
#define nl printf("\n")
#define sp printf(" ")
#define pfyes printf("YES")
#define pfno printf("NO")
#define pf0 printf("0")
#define FOR(i,a,b,in) for(int i=a;i<=b;i+=in)
#define RFOR(i,a,b,de) for(int i=a;i>=b;i-=de)
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mkp make_pair
#define mod 1000000007
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
// ------------------------//
int main()
{
	int n;
	sfd(n);
	ll a[n];
	rep(i,n)
	sfll(a[i]);
	if(n==1)
	{
		pfll(a[0]);
		return 0;
	}
	ll dp[n][2];
	rep(i,n)
	{
		rep(j,2)
		dp[i][j]=0;
	}
	dp[1][0]=(a[0]+a[1])%mod;
	dp[1][1]=(a[0]-a[1])%mod;
	if(dp[1][1]<0)
	dp[1][1]+=mod;
	ll cp[n];
	ll cn[n];
	rep(i,n)
    {
      cp[i]=0;
      cn[i]=0;
    }
	cp[1]=1;
	cn[1]=1;
	for(int i=2;i<n;i++)
	{
		dp[i][0]=(dp[i-1][0]+dp[i-1][1]+(((a[i]*((cp[i-1]+cn[i-1])%mod))%mod)))%mod;
		dp[i][1]=(dp[i-1][0]-((a[i]*(cp[i-1])%mod)))%mod;
    	cp[i]=(cp[i-1]+cn[i-1])%mod;
    	cn[i]=cp[i-1];
		if(dp[i][0]<0)
		dp[i][0]+=mod;
		if(dp[i][1]<0)
		dp[i][1]+=mod;
	}
	pfll((dp[n-1][0]+dp[n-1][1])%mod);
	return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define eps 1e-7
#define equals(a,b) (fabs(a - b) < eps)
#define fi first
#define se second
using namespace std;
typedef long long ll;

const int maxn = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll rd(){
	ll x = 0;
	int f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-')  f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

struct PSegmentTree{
	struct Node{
		int l,r,d;
		Node *ls,*rs;
	};
	int a[maxn];
	Node pool[maxn * 30],*rt[maxn];
	int top;
	Node* build(int l,int r){
		Node *p = pool + (++top);
		p -> l = l,p -> r = r;
		if(l == r) {
			p -> d = a[l];
			return p;
		}
		int mid = l + r >> 1;
		p -> ls = build(l,mid);
		p -> rs = build(mid + 1,r);
		return p;
	}
	Node* copyNode(Node* rt){
		Node* p = pool + (++top);
		pool[top] = *rt;
		return p;
	}
	Node* change(Node* rt,int id,int x){
		Node* p = copyNode(rt);
		if(p -> l == p -> r) {
			p -> d = x;
			return p;
		}
		int mid = p -> l + p -> r >> 1;
		if(id <= mid) p -> ls = change(p -> ls,id,x);
		else p -> rs = change(p -> rs,id,x);
		return p;
	}
	int query(Node* rt,int id){
		if(rt -> l == rt -> r) {
			return rt -> d;
		}
		int mid = rt -> l + rt -> r >> 1;
		if(id <= mid) return query(rt -> ls,id);
		else return query(rt -> rs,id);
	}
};

int main(){
	int n = rd();
	vector<int> v(n + 1);
	ll x = rd();
	for(int i = 1;i <= n;i++)
		v[i] = rd();
	ll res = 1e18;
	for(int c = 1;c <= n;c++){
		int m = x % c;
		vector<vector<int>> dp(c + 1,vector<int>(c + 1,-1));
		dp[0][0] = 0;
		for(int k = 1;k <= n;k++)
			for(int i = min(k ,c) - 1;i >= 0;i--)
				for(int j = 0;j < c;j++)
					if(~dp[i][j])
						dp[i + 1][(j + v[k] % c) % c] = max(dp[i + 1][(j + v[k] % c)% c],dp[i][j] + v[k]);
		if(~dp[c][m])
		 	res = min(res,(ll)(x - (ll)dp[c][m]) / c);
	}
	cout << res;
}

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

int main() {
  int N;
  int64_t X;
  cin >> N >> X;
  vector<int64_t> w(N);
  for (int i = 0; i < N; ++i) cin >> w[i];

  // O(N^4)

  int64_t min_time = numeric_limits<int64_t>::max();
  // Brute force value for k.
  for (int k = 1; k <= N; ++k) {
    // dpv[i][j][m] = max value we can get when selecting j items from prefix [:i]
    // that sum up to value m, modulo k. (i is 1-based)
    vector<vector<vector<int64_t>>> dpv(N + 1, vector<vector<int64_t>>(k + 1, vector<int64_t>(k, -1e10)));
    dpv[0][0][0] = 0;  // Boundary condition.
    for (int i = 1; i <= N; ++i) {
      for (int j = 0; j <= k; ++j) {
        for (int m = 0; m < k; ++m) {
          if (j > 0) {
            // We take it.
            // new_mod = (old_mod + values[i - 1] % k) % k
            const int old_mod = (m - (w[i - 1] % k) + k) % k;
            dpv[i][j][m] = max(dpv[i][j][m], w[i - 1] + dpv[i - 1][j - 1][old_mod]);
          }

          // We don't take it.
          dpv[i][j][m] = max(dpv[i][j][m], dpv[i - 1][j][m]);
        }
      }
    }
    const int64_t max_val = dpv[N][k][X % k];

    if (max_val >= 0) {
      // Because of bounds (X > 10^9) max_val cannot be greater than X.
      assert(X >= max_val);
      min_time = min(min_time, (X - max_val) / k);
    }
  }
  cout << min_time << endl;
}


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

#define rep(i,s,e)                  for (ll i = s; i <= e; ++i)
#define rrep(i,s,e)                 for (ll i = s; i >= e; --i)
#define pb                          push_back
#define pf                          push_front
#define fi                          first
#define se                          second
#define all(a)                      a.begin(), a.end()
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vll;

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

    ll n, m, x, y; cin >> n >> m >> x >> y;
    vector<array<ll,3>> neibs[n+1];
    rep (i,0,m-1) {
        ll a, b, t, k; cin >> a >> b >> t >> k;
        neibs[a].pb({b,t,k});
        neibs[b].pb({a,t,k});
    }

    //basic dijkstra

    priority_queue<ii, vii, greater<ii>> pq;
    pq.push({0,x});
    ll dist[n+1];
    memset(dist, -1, (n+1)*sizeof(ll));
    dist[x] = 0;

    while (!pq.empty()) {
        ll T = pq.top().fi, city = pq.top().se;
        pq.pop();
        if (dist[city] < T) continue;
        if (city==y) {
            cout << T << "\n";
            return 0;
        }
        for (array<ll,3> v : neibs[city]) {
            ll b = v[0], t = v[1], k = v[2];
            if (dist[b]==-1 || (T+k-1)/k*k+t < dist[b]) {
                dist[b] = (T+k-1)/k*k+t;
                pq.push({dist[b], b});
            }
        }
    }
    cout << "-1\n";
    return 0;
}

#include "bits/stdc++.h"
#include<sstream>
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const long long inf = 1e18;
const ll INFL = 1e18;
const ll MOD = 1e9 + 7;

int digit(ll x) {
    int digits = 0;

    while(x > 0){
        x /= 10;
        digits++;
    }

    return digits;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;

    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}

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

double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}

long long modpow(long long a, long long b, long long m){
    long long ans = 1;
    while(b > 0){
        if (b % 2 == 1){
            ans *= a;
            ans %= m;
        }
        a *= a;
        a %= m;
        b /= 2;
    }
    return ans;
}

long long comb(long long x, long long y){
    int z;
    if (y == 0) return 1;
    else {
        z = modpow(x, y/2, MOD)*modpow(x, y/2, MOD)%MOD;
        if (y % 2 == 1) z = z*x%MOD;
        return z;
    }
}

vector<pair<long long, long long>> prime_fact(long long x){
    vector<pair<long long, long long>> res;
    for(int i = 2;i*i <= x;i++){
        if (x % i == 0){
            long long cnt = 0;
            while(x % i == 0){
                cnt++;
                x /= i;
            }
            res.push_back({i, cnt});
        }
    }
    if (x != 1){
        res.push_back({x, 1});
    }
    return res;
}

int64_t mod_inv(int64_t a, int64_t m){
    int64_t b = m, u = 1, v = 0;

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

    return u;
}

// {g, x, y}: ax + by = g
tuple<long long, long long, long long> extgcd(long long a, long long b){
    if (b == 0) return {a, 1, 0};
    long long g, x, y;
    tie(g, x, y) = extgcd(b, a % b);
    return {g, y, x - a/b*y};
}

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

//////////////////////////////////////////////////////////////

int main(){
    int n,m;
    long long x, y;
    cin >> n >> m >> x >> y;
    x--;
    y--;
    vector<vector<tuple<int, long long, long long>>> g(n + 1);
    for(int i = 0;i < m;i++){
        int a, b;
        long long t, k;
        cin >> a >> b >> t >> k;
        a--;
        b--;
        g[a].push_back(make_tuple(b, t, k));
        g[b].push_back(make_tuple(a, t, k));
    }

    vector<long long> dist(n + 1, 1e18);
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
    dist[x] = 0;
    q.push({0, x});
    long long ans = 1e18;
    while(!q.empty()){
        auto p = q.top();
        q.pop();
        for(auto nx : g[p.second]){
            if (dist[get<0>(nx)] > get<2>(nx)*((p.first + get<2>(nx) - 1) / get<2>(nx)) + get<1>(nx)){
                dist[get<0>(nx)] = get<2>(nx)*((p.first + get<2>(nx) - 1) / get<2>(nx)) + get<1>(nx);
                if(p.second == y){
                    ans = min(ans, dist[get<0>(nx)]);
                } else {
                    q.push({dist[get<0>(nx)], get<0>(nx)});
                }
            }
        }
    }

    if (dist[y] == 1e18){
        cout << -1 << endl;
    } else {
        cout << dist[y] << endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" "
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=998244353;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n,m,k;cin>>n>>m>>k;
    vector<vector<char>>grid(n,vector<char>(m,'.'));
    for (int i = 0; i < k; ++i)
    {
    	int h,w;char c;cin>>h>>w>>c;
    	h--;
    	w--;
    	grid[h][w]=c;
    }

    vv row(n+1,v(m+1,0)),col(n+1,v(m+1,0));
    for(int i=n-1;i>=0;i--)
    {
    	for(int j=m-1;j>=0;j--)
    	{
    		row[i][j]=row[i][j+1];
    		col[i][j]=col[i+1][j];
    		if(grid[i][j]=='.')
    		{
    			row[i][j]++;
    			col[i][j]++;
    		}
    	}
    }
    v powers(n+m+2,1);
    for(int i=1;i<=n+m+1;i++)
    	powers[i]=MOD(powers[i-1]*3);
    vv dp(n+1,v(m+1,0));
    dp[n-1][m-1]=1;
    if(grid[n-1][m-1]=='.')
    	dp[n-1][m-1]=3;
   	for(int i=n-1;i>=0;i--)
   	{
   		for(int j=m-1;j>=0;j--)
   		{
   			if(i==(n-1) && j==(m-1))
   				continue;
   			if(grid[i][j]=='R')
   			{
   				dp[i][j]=MOD(dp[i][j+1]*powers[col[i+1][j]]);
   			}
   			else if(grid[i][j]=='D')
   			{
   				dp[i][j]=MOD(dp[i+1][j]*powers[row[i][j+1]]);
   			}
   			else if(grid[i][j]=='X')
   			{
   				dp[i][j]=MOD(MOD(dp[i][j+1]*powers[col[i+1][j]])+MOD(dp[i+1][j]*powers[row[i][j+1]]));
   			}
   			else
   			{
   				dp[i][j]=MOD(2*MOD(dp[i][j+1]*powers[col[i+1][j]])+2*MOD(dp[i+1][j]*powers[row[i][j+1]]));
   			}
   		}
   	}
   	cout<<dp[0][0]<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const long long MOD = 998244353;
const long long INF = 9999999999999999;
using ll = long long;
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; }

long long pow(long long x, long long n, long long MM) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MM;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MM;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main(){
  ll H,W,K;
  cin>>H>>W>>K;
  char ban[H+2][W+2] = {};
  ll masu = 0;
  rep(i,H+1){
    rep(k,W+1){
      ban[i][k] = '.';
      masu++;
    }
  }
  ll kakeru = pow(3,(H*W-K),MOD);

  ll ans[H+2][W+2];
  rep(i,K){
    ll a,b;
    char c;
    cin>>a>>b>>c;
    ban[a][b] = c;
  }

  rep(i,H+1){
    rep(k,W+1){
      ans[i][k] = 0;
    }
  }
  ll waru = pow(3,(MOD-2),MOD);
  ans[1][1] = kakeru;
  for(ll i = 1;i<=H;i++){
    for(ll k = 1;k<=W;k++){
      if(ban[i][k] == 'D'){
        ans[i+1][k] += ans[i][k];
        ans[i+1][k]%=MOD;
      }
      if(ban[i][k] == 'R'){
        ans[i][k+1] += ans[i][k];
        ans[i][k+1]%=MOD;
      }
      if(ban[i][k] == 'X'){
        ans[i+1][k] += ans[i][k];
        ans[i][k+1] += ans[i][k];
        ans[i+1][k]%=MOD;
        ans[i][k+1]%=MOD;
      }
      if(ban[i][k] == '.'){
        ans[i+1][k] += ans[i][k]*2%MOD*waru%MOD;
        ans[i][k+1] += ans[i][k]*2%MOD*waru%MOD;
      }
    }
  }
  cout << ans[H][W]%MOD << endl;
  return 0;
}


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

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

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

	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;

	ll kotae = 0;
	queue<int> q;
	int jogai = -1;
	rep(i, N) {
		if (jogai >= 0 && S[i] == '1') {
			S[i] = '0';
			kotae += i - jogai;
			jogai = -1;
		}

		if (T[i] == '1') q.push(i);

		if (S[i] == '1') {
			if (q.size()) {
				int tmp = q.front();
				q.pop();
				kotae += i - tmp;
			}
			else {
				jogai = i;
			}
		}
	}

	if (jogai == -1 && q.empty()) {
		co(kotae);
	}
	else co(-1);

	Would you please return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <sstream>
#define INF 1000000009
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;

int h,w;

ll calc(vector<vector<int>> m,int a, int b, int x, int y){

    if(a<0||b<0) return 0;
    if(x==h-1&&y==w-1){
        if(m[x][y]==1&&a==0&&b==0) return 1;
        else if(m[x][y]==0&&a==0&&b==1) return 1;
        else return 0;
    }
    else{
        if(m[x][y]==0){
            m[x][y] = 1;
            vector<vector<int>> m1 = m;
            if(x==h-1){
                m1[x][y+1] = 1;
                return calc(m,a,b-1,0,y+1) + calc(m1,a-1,b,0,y+1);
            }else{
                vector<vector<int>> m2 = m;
                m1[x][y+1] = 1;
                m2[x+1][y] = 1;
                return calc(m,a,b-1,x+1,y) + calc(m1,a-1,b,x+1,y) + calc(m2,a-1,b,x+1,y);
            }
        }else{
            if(x==h-1) return calc(m,a,b,0,y+1);
            else return calc(m,a,b,x+1,y);
        }
    }
}

int main() {

    ll ans;
    int a,b;
    ans = 0;

    cin >> h>>w>>a>>b;
    vector<vector<int>> m(h+1,vector<int>(w+1,0));

    ans = calc(m,a,b,0,0);
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, c);
    vc<vc<int>> e(n);
    Rep(n-1){
        Cin(int, a, b); a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    unordered_set<int> cs;
    set<int> ans;
    auto f = [&](int i, int par, auto self) -> void {
        bool good = cs.count(c[i]) == 0;
        if(good){
            ans.insert(i+1);
            cs.insert(c[i]);
        }
        for(const int &j : e[i]) if(j != par) self(j, i, self);
        if(good) cs.erase(c[i]);
    };
    f(0, -1, f);
    Couts(ans);
}

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
template<class T>
class MS{
    public:
        set<T> st;
        map<T, int> cnt;
        int size = 0;
        MS(){}
        void insert(T x){
            st.insert(x);
            size++;
            cnt[x] += 1;
        }
        void remove(T x){
            if(cnt[x] == 0) return;
            cnt[x] -= 1;
            size--;
            if(cnt[x] == 0) st.erase(x);
        }
        bool find(T x){
            return (cnt[x] > 0);
        }
        T begin(){
            return *st.begin();
        }
        T rbegin(){
            return *st.rbegin();
        }
};
vector<vector<int>> adj;
int N;
vector<int> C;
MS<int> path;
vector<int> ans;

void DFS(int u, int p = -1){
    // cout << u << endl;
    if(!path.find(C[u])) ans.push_back(u);
    path.insert(C[u]);
    for(int v: adj[u]){
        if(v == p) continue;
        DFS(v, u);
        path.remove(C[v]);
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N;
    C.resize(N + 1);
    adj.resize(N + 1);
    for(int i = 1; i <= N; i++){
        cin >> C[i];
    }
    for(int i = 0, a, b; i < N - 1; i++){
        cin >> a >> b;
        // cout << a << " " << b << endl;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    DFS(1);
    sort(ans.begin(), ans.end());
    for(int i: ans) cout << i << "\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define _ <<' '<<
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 3000005
//<<fixed << setprecision(9)

int arr[space];
int n;
int ways(int x)
{
    x-=2;
    if(x>n-1)
    {
        int diff=x-(n-1);
        x-=2*diff;
    }
    return x+1;
}
int32_t main()
{
    int i,j,t;
    boost;
    // n=10;
    // cin>>i;
    // cout<<ways(i);
    int k;
    cin>>n>>k;

    int ab;
    rep(ab,2,2*n+1)
    {
        int w = ways(ab);
        arr[ab+1]+=w;
        arr[ab+n+1]-=w;
    }
    rep(i,1,3*n+1) arr[i]+=arr[i-1];

    rep(i,1,3*n+1)
    {
        if(arr[i]<k)k-=arr[i];
        else break;
    }
    int sum=i;
    int bea,tas;
    rep(bea,1,n+1)
    {
        if(bea+n+n<sum )continue;

        int jmin,jmax;
        int l=1,r=n,ans;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(bea+mid+n>=sum)
            {
                r=mid-1;
                ans=mid;
            }
            else l=mid+1;
        }
        jmin=ans;

        l=1,r=n,ans;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(bea+mid+1<=sum)
            {
                l=mid+1;
                ans=mid;
            }
            else r=mid-1;
        }
        jmax=ans;

        if(k>(jmax-jmin+1)) k-= (jmax-jmin+1);
        else
        {
            tas = jmin +k-1;
            break;
        }
    }
    cout<<bea _ tas _ sum-bea-tas;
    return 0;
}

#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define endl "\n"

using namespace std;

const int max_n = 1e6+100;
const int limit = 2e5+10;
const int max_k = 1e7+10;
const long long inf = 1e18;
const int off_set = 1e3+10;
const int Mod = 200;

int dp[3*max_n][4];
int p[3*max_n][4];

int intersection(pair<int,int> a,pair<int,int> b){
    if(a.x>b.y || a.y<b.x) return 0;
    pair<int,int> c(max(a.x,b.x),min(a.y,b.y));
    return c.y-c.x+1;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n,k;cin>>n>>k;
    k--;

    dp[0][0]=1;
    for(int s=0;s<=3*n;s++) p[s][0]=1;

    for(int j=1;j<=3;j++){
        for(int s=1;s<=3*n;s++){
            dp[s][j]=p[s-1][j-1];
            if(s-n-1>=0){
                dp[s][j]-=p[s-n-1][j-1];
            }

            p[s][j]=dp[s][j];
            p[s][j]+=p[s-1][j];
        }
    }

    int S;
    for(int s=1;s<=3*n;s++){
        if(dp[s][3]>k){
            S = s;
            break;
        }else{
            k-=dp[s][3];
        }
    }

    for(int i=1;i<=n;i++){
        pair<int,int> I1(1,n);
        pair<int,int> I2(S-i-n,S-i-1);

        int c = intersection(I1,I2);

        if(c<=k){
            k-=c;
        }else{
            for(int j=1;j<=n;j++) if(S-i-j>=1 && S-i-j<=n){
                if(k==0){
                    cout<<i<<" "<<j<<" "<<S-i-j<<endl;
                    return 0;
                }else{
                    k--;
                }
            }
            assert(false);
        }

    }

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstdlib>
#include<numeric>
#include<set>
#include<utility>
#include<limits>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;

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

const int MOD = 1000000007;

int main(){
	string s;cin >> s;
	if(s.size() == 1){
		if(s[0] == '8'){
			cout << "Yes" << endl;
			return 0;
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
	vector<int> exist(10);
	for(int i=0;i<s.size();i++){
		int n = (int)(s[i] - '0');
		exist[n]++;
	}
	//rep(i,exist.size()){
	//	cout << "exist[" << i << "]は" << exist[i] << endl;
	//}
	bool flag = false;
	int i_start,i_end;
	if(s.size()==2){
		i_start=16;i_end=100;
	}else{
		i_start=104;i_end=1000;
	}
	for(int i=i_start;i<i_end;i+=8){
		int a,b,c;
		int i_copy = i;
		a = i_copy%10;i_copy/=10;
		b = i_copy%10;i_copy/=10;
		c = i_copy%10;i_copy/=10;
		//cout << "a b cは" << a << ' ' << b << ' ' << c << endl;
		vector<int> e_copy(exist.size());
		copy(exist.begin(),exist.end(),e_copy.begin());
		if(e_copy[a]>0){
			e_copy[a]--;
			if(e_copy[b]>0){
				e_copy[b]--;
				if(s.size() == 2){
					flag = true;
					break;
				}
				if(e_copy[c]>0){
					flag = true;
					break;
				}
			}
		}
	}
	if(flag) cout << "Yes" << endl; else cout << "No" << endl;
}

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

int main(){
    string S;
    int num;
    cin>>S;
    vector<int> count(10,0);
    vector<int> comp(10,0);
    for(int i=0;i<S.size();i++){
        count.at(S.at(i)-48)++;
    }
    if(S.size()==1){
        if(S.at(0)-48==8){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    else if(S.size()==2){
        if(((S.at(0)-48)*10+S.at(1)-48)%8==0||((S.at(1)-48)*10+S.at(0)-48)%8==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    else{
        for(int i=1;i<10;i++){
            comp.at(i)++;
            for(int j=1;j<10;j++){
                comp.at(j)++;
                for(int k=1;k<10;k++){
                    comp.at(k)++;
                    if(comp.at(k)>count.at(k)||comp.at(i)>count.at(i)||comp.at(j)>count.at(j)){
                        comp.at(k)--;
                        continue;
                    }
                    if((100*i+10*j+k)%8==0){
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                    comp.at(k)--;
                }
                comp.at(j)--;
            }
            comp.at(i)--;
        }
    }
    cout<<"No"<<endl;
}


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

int n,k,ans=0;

int w(int x,int t)//和为x,在t以内
{
	if (x<2)  return 0;
	if (x==2)  return 1;
	if (x<=t)  return x-1;
	if (x>2*t)  return 0;

	int l=t;
	int r=x-t;
	if (l>r)  swap(l,r);
	return r-l+1;
}

signed main()
{
	cin>>n>>k;
	for (int i=0;i<=n*2;i++)//3 2
	{
		int x=i,y=i-k;
		ans+=w(x,n)*w(y,n);
	}
	cout<<ans<<endl;

	return 0;
}

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define w(x)  int x; cin>>x; while(x--)
using namespace std;
const long long N=100005, INF=2000000000000000000;
vi g[N];
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vi prime;
bool isprime[N];
void pre()
{
    for(int i=2;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<N;j+=i)
            isprime[j]=false;
            prime.pb(i);
        }
    }
    return;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;

        // If the element is present at the middle
        // itself
        if (arr[mid] == x)
            return mid;

        // If element is smaller than mid, then
        // it can only be present in left subarray
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);

        // Else the element can only be present
        // in right subarray
        return binarySearch(arr, mid + 1, r, x);
    }

    // We reach here when element is not
    // present in array
    return -1;
}
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int gcd(int a, int b)
{
    if(a < b)
        return gcd(b, a);
    else if(a%b == 0)
        return b;
    else return gcd(b, a%b);
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

int spf[N+1];
void spfFun(){
    for(int i=0;i<=N;i++) spf[i]=i;
    for(int i=2;i*i<=N;i++){
        if(spf[i]==i){
            for(int j=i*i;j<=N;j+=i){
                spf[j] = min(spf[j],i);
            }
        }
    }
}

bool isPerfectSquare(long double x)
{
  // Find floating point value of
  // square root of x.
  long double sr = sqrt(x);

  // If square root is an integer
  return ((sr - floor(sr)) == 0);
}
void print(bool n){
    if(n){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
}

int n,k;
int cal(int a){
    if(a>n){
        return 2*n - a + 1;
    }
    return a-1;
}

int32_t main()
{
    IOS;
    // pre();
    // fill(isprime,true);
    cin>>n>>k;
    unsigned int ans=0;
    for(int i=2;i<=2*n;i++){
        int other = i-k;
        // cout<<i<<" "<<cal(i)<<"\n";
        if(other<=1 || other>2*n) continue;
        ans+=cal(i)*cal(other);
    }
    cout<<ans;
}


#include <iostream>
#include <cstdio>
using namespace std;
string s;
int read(){
	int x = 0;
	char c = getchar();
	while(c < '0' || c > '9') c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + (c ^ 48),c = getchar();
	return x;
}
int main(){
	cin >> s;
	for(int i = 0; i < s.size(); i ++){
		if(i % 2 && s[i] > 'Z' || (i % 2 == 0) && s[i] <= 'Z'){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

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

bool has_seven(int x, int b) {
    while (x > 0) {
        if (x % b == 7) return true;
        x /= b;
    }
    return false;
}

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

    int cnt = 0;
    for (int n = 1; n <= N; n++) {
        if (has_seven(n, 10) || has_seven(n, 8)) {
            cnt++;
        }
    }
    cout << N - cnt << endl;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 10;

int a[N], b[N], c[N], sum[N], n, m;

vector<int> vt[N];

inline int lowbit(int x) {
  return x & (-x);
}

void update(int x, int v) {
  while (x <= n) {
    sum[x] += v;
    x += lowbit(x);
  }
}

int query(int x) {
  int ans = 0;
  while (x) {
    ans += sum[x];
    x -= lowbit(x);
  }
  return ans;
}

int query(int l, int r) {
  return query(r) - query(l - 1);
}

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    c[i] = a[i] + i;
  }
  sort(c + 1, c + 1 + n);
  m = unique(c + 1, c + 1 + n) - (c + 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    int pos = lower_bound(c + 1, c + 1 + m, b[i] + i) - c;
    if (c[pos] != b[i] + i) {
      puts("-1");
      return 0;
    }
    b[i] = pos;
  }
  for (int i = n; i >= 1; i--) {
    vt[lower_bound(c + 1, c + 1 + m, a[i] + i) - c].push_back(i);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vt[b[i]].size()) {
      puts("-1");
      return 0;
    }
    int cur = vt[b[i]].back();
    ans += cur + query(cur + 1, n) - i;
    vt[b[i]].pop_back();
    update(cur, 1);
  }
  printf("%lld\n", ans);
  return 0;
}

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

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

P crt(const vector<ll> &b, const vector<ll> &m){
  ll r=0,M=1;
  rep(i,(int)b.size()){
    ll p,q;
    ll d = ext_gcd(M,m[i],p,q);
    if((b[i]-r)%d != 0) return P(0,-1);
    ll tmp = (b[i]-r)/d * p %(m[i]/d);
    r += M * tmp;
    M *= m[i]/d;
  }
  return P((r+M)%M,M);
}

int main(){
  int t; cin>>t;
  ll x,y,p,q;
  rep(i,t){
    ll ans=LLONG_MAX;
    cin>>x>>y>>p>>q;
    for(ll t1=x; t1<x+y; t1++){
      for(ll t2=p; t2<p+q; t2++){
        ll r,mod;
        vector<ll> b(2),m(2);
        b[0]=t1; b[1]=t2;
        m[0]=2*x+2*y; m[1]=p+q;
        tie(r,mod)=crt(b,m);
        if(mod!=-1) chmin(ans,r);
      }
    }
    if(ans==LLONG_MAX) cout<<"infinity"<<endl;
    else cout<<ans<<endl;
  }
}


#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  vector<i64> x(N), y(N);
  rep(i,0,N) {
    cin >> x[i] >> y[i];
  }

  rep(i,0,N) rep(j,0,N) rep(k,0,N) {
    if(i == j || j == k || k == i) continue;
    i64 a = (x[i] - x[k]) * (y[j] - y[k]) - (x[j] - x[k]) * (y[i] - y[k]);
    if(a == 0) {
      cout  << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ull unsigned long long
#define lld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define f first
#define s second
#define mk make_pair

/*----------------------DEBUGGER---------------------------*/
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.f); cerr << ","; _print(p.s); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
/*----------------------DEBUGGER---------------------------*/

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
  int t = 1;
  //cin >> t;
  while (t--)
  {
    int n;
    cin>>n;
    vector<pair<int,string>> v;
    for(int i=0;i<n;i++)
    {
      pair<int,string> p;
      cin>>p.s;
      cin>>p.f;
      v.pb(p);
    }
    sort(v.begin(),v.end());
    cout<<v[v.size()-2].s<<"\n";
  }//while
}//main


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

#define f first
#define s second
#define pb push_back
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define db(x) cout << '>' << #x << ':' << x << endl;
#define sz(x) ((int)(x).size())
#define newl cout << "\n"

#define ll long long int
#define vi vector<int>
#define vll vector<long long>
#define vvll vector<vll>
#define pll pair<long long, long long>

#define fast_io()                                                              \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

ll tc, n, m, k;

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

  cin>>n>>k;
  vll start(n), end(n), amount(n);
  rep(i, 0, n) cin>>start[i]>>end[i]>>amount[i];

  auto solve = [&]() {
    vector<pair<pair<int, int>, int>> events;
    rep(i, 0, n) {
      events.pb({{start[i], 1}, amount[i]});
      events.pb({{end[i], -1}, amount[i]});
    }
    sort(events.begin(), events.end());
    ll curr = 0;
    rep(i, 0, sz(events)) {
      auto id = events[i].f.s;
      if(id == 1) {
        curr += events[i].s;
      } else {
        curr -= events[i].s;
      }
      if(curr > k) return false;
    }

    return true;
  };

  if(solve()) {
    cout<<"Yes";
  } else {
    cout<<"No";
  }

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n);i++)
void out(string s){cout<<s<<endl;}
void outInt(int n){cout<<n<<endl;}
void outLl(long long ll){cout<<ll<<endl;}

int main(){
	int a,b,c;
  cin>>a>>b>>c;
  if(a*a+b*b < c*c){
  	out("Yes");
  }else{
  	out("No");
  }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1E5+5;
int n;
double a[N],r,ans,p=1E-7;
double f(double x){
	double s=0;
	for(int i=1;i<=n;i++){
		s=s+min(a[i],2*x);
	}
	return s-x*n;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lf",&a[i]),ans+=a[i],r=max(r,a[i]);
	r/=2.0;
	double l=0;
	while(l+p<r){
		double lmid=l+(r-l)/3;
		double rmid=r-(r-l)/3;
		if(f(lmid)>f(rmid)){r=rmid;}
		else{l=lmid;}
	}
	printf("%.7lf",(ans-f(l))/(n*1.0));
}

#include <bits/stdc++.h>

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

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

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

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<double> A(N);
	REP(i, N)cin >> A[i];
	so(A);
	double X = A[N / 2] / 2.0;
	double ans = 0;
	REP(i, N) {
		ans += X + max(0.0, A[i] - 2 * X);
	}
	ans /= N;
	printf("%.10f\n", ans);
	return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using ll = long long;
using namespace std;
using Graph = vector<vector<int>>;

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

    int diff;
    if (a <= b) diff = abs(a - b);
    else diff = abs(a - b) - 1;
    int up = min(x * 2, y);

    int res = diff * up + x;

    cout << res;

}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template <class T>
void read(T &);
template <class T>
void write(const T &);

typedef long long ll;
typedef unsigned long long ull;
typedef const long long &cll;
typedef const int &ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::abs;
using std::max;
using std::min;

int main() {
  int n, k;
  read(n), read(k);
  ll ans = 0;
  for (int i = max(2, k + 2); i <= 2 * n; ++i) {
    if (i - 2 * n > k) {
      break;
    }
    int na, nb;
    if (i <= n) {
      na = i - 1;
    } else {
      na = 2 * n - i + 1;
    }
    if (i - k <= n) {
      nb = i - k - 1;
    } else {
      nb = 2 * n - (i - k) + 1;
    }
    ans += na * 1ll * nb;
  }
  write(ans), EL;
  return 0;
}

template <class T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template <class T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}


#include<stdio.h>

int main()
{
	long int n,x;

	scanf("%ld %ld",&n,&x);
	int i=1,flag=0;
	double r=0;

	while(i<=n)
	{
		double v,p;

		scanf("%lf %lf",&v,&p);

		r= r+ v*p;

		if(r>x*100)
		{
			flag=1;
			break;
		}
		i++;
	}

	if(flag)
	{
		printf("%d\n",i );
	}
	else
	{
		printf("-1\n");
	}
}

#include <bits/stdc++.h>
using namespace std;
using int128  = __int128_t;
using int64   = long long;
using int32   = int;
using uint128 = __uint128_t;
using uint64  = unsigned long long;
using uint32  = unsigned int;

#define ALL(obj) (obj).begin(),(obj).end()
template<class T> using priority_queue_reverse = priority_queue<T,vector<T>,greater<T>>;

constexpr int64 MOD = 1'000'000'000LL + 7; //'
constexpr int64 MOD2 = 998244353;
constexpr int64 HIGHINF = 1'000'000'000'000'000'000LL;
constexpr int64 LOWINF = 1'000'000'000'000'000LL; //'
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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;}
template <class T>ostream &operator<<(ostream &o, const deque<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
vector<string> split(const string &str, const char delemiter) {vector<string> res;stringstream ss(str);string buffer; while( getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
inline constexpr int msb(int x) {return x?31-__builtin_clz(x):-1;}
inline constexpr int64 ceil_div(const int64 a,const int64 b) {return (a+(b-1))/b;}// return ceil(a/b)
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

/**
 * @url
 * @est
 */
int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int N;
    int64 X; cin >> N >> X;
    vector<int64> V(N),P(N);
    for(int i=0;i<N;++i) cin >> V[i] >> P[i];
    X *= 100;
    for(int i=0;i<N;++i) {
        V[i] *= P[i];
        X -= V[i];
        corner(X < 0,i+1);
    }
    cout << -1 << endl;
    return 0;
}


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

// int getRandom(int l, int r)
// {
// 	return l + rand()%(r-l+1);
// }

// int32_t main()
// {
// 	#ifndef ONLINE_JUDGE
//     // For getting input from input.txt file
//     // freopen("input.txt", "r", stdin);
//     // Printing the Output to output.txt file
//     freopen("input.txt", "w", stdout);
// 	#endif

//     srand(time(0));

//  	int t = 10;
//  	cout << t << "\n";
//  	while(t--)
//  	{
//  		int n = getRandom(199, 200);
//  		int m = getRandom(199, 200);
//  		cout << n << "\n";
//  		cout << m << "\n";
//  		for(int i = 0; i < n; i++)
//  		{
//  			for(int j = 0; j < m; j++)
//  			{
//  				cout << 0 << " ";
//  			}
//  		}
//  		cout << "\n~\n";
//  	}

//     return 0;
// }

// ---------------------------- DIVIDER ---------------------------- //

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

// class Solution {
//   public:
//     bool ValidCorner(const vector<vector<int> >& matrix) {
//         int rows = matrix.size();
//         if (rows == 0)
//             return false;

//         int columns = matrix[0].size();
//         unordered_map<int, unordered_set<int> > ump;
//         for (int i = 0; i < rows; ++i)
//         {
//             for (int j = 0; j < columns - 1; ++j)
//             {
//                 for (int k = j + 1; k < columns; ++k)
//                 {
//                     if (matrix[i][j] == 1 && matrix[i][k] == 1)
//                     {
//                         if (ump.find(j) != ump.end() && ump[j].find(k) != ump[j].end())
//                             return true;
//                         if (ump.find(k) != ump.end() && ump[k].find(j) != ump[k].end())
//                             return true;
//                         ump[j].insert(k);
//                         ump[k].insert(j);
//                     }
//                 }
//             }
//         }
//        return false;
//     }
// };

// int32_t main()
// {
// 	#ifndef ONLINE_JUDGE
//     // For getting input from input.txt file
//     freopen("input.txt", "r", stdin);
//     // Printing the Output to output.txt file
//     freopen("output.txt", "w", stdout);
// 	#endif

//     ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
//     cout.tie(NULL);

//  	int t;
//  	cin >> t;
//  	while(t--)
//  	{
//  		int row, col;
//         cin>> row>> col;

//         vector<vector<int> > matrix(row);

//         for(int i=0; i<row; i++)
//         {
//             matrix[i].assign(col, 0);
//             for( int j=0; j<col; j++)
//             {
//                 cin>>matrix[i][j];
//             }
//         }

//         char ch;
//         cin >> ch;

//         Solution ob;

//         if (ob.ValidCorner(matrix))
//             cout << "Yes";
//         else
//             cout << "No";
//         cout << "\n~\n";
//  	}

//     return 0;
// }

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(1e16)
#define N 105

int32_t main()
{

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

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

    int ans = 9999999999;
    for(int i = 0; i < n; i++)
    {
    	for(int j = 0; j < n; j++)
    	{
    		if(i!=j)
    			ans = min(ans, max(a[i][0], a[j][1]));
    		else
    			ans = min(ans, a[i][0] + a[j][1]);
    	}
    }

    cout << ans;

    return 0;
}

#include<bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define vp vector<pair<int,int>>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

      int n;
      cin>>n;

      int a,b;
      vp v1,v2;
      f(i,0,n)
      {
          cin>>a>>b;
          v1.pb(mp(a,i));
          v2.pb(mp(b,i));
      }

      sort(v1.begin(),v1.end());
      sort(v2.begin(),v2.end());

      int mn=INT_MAX;

      f(i,0,n-1)
      f(j,i,i+2)
      if(v1[i].second!=v2[j].second && mn>max(v1[i].first,v2[j].first))
      mn=max(v1[i].first,v2[j].first);
      else if(mn>v1[i].first+v2[j].first)
      mn=v1[i].first+v2[j].first;

      cout<<mn;
	cout<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define deb(k) cerr << #k << ": " << k << "\n";
#define size(a) (int)a.size()
#define fastcin cin.tie(0)->sync_with_stdio(0);
#define st first
#define nd second
#define pb push_back
#define mk make_pair
#define int long long
typedef long double ldbl;
typedef double dbl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef vector<int> vint;
#define MAXN 300100
#define MAXLG 20
const int inf = 0x3f3f3f3f;
//const ll mod = 1000000007;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const int N = 300100;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k, mod;
int dp[110][1000010];
void solve(){
	cin>>n>>k>>mod;
	dp[0][0] = 1;
	int s = 0;
	for(int i=1;i<=n;i++){
		vint cnt(i);
		s += i;
		for(int j=0;j<=s*k;j++){
			int r = j % i;
			cnt[r] += dp[i-1][j];
			if(j - i*(k+1) >= 0) cnt[r] -= dp[i-1][j - i*(k+1)];
			cnt[r] = (cnt[r]%mod + mod)%mod;
			dp[i][j] = cnt[r];
		}
	}
	s = 0;
	for(int i=1;i<=n;i++){
		s += i;
		int ans = 0;
		for(int j=0;j<=s*k;j++){
			ans += dp[i-1][j] * dp[n-i][j];
			ans %= mod;
		}
		ans = ans * (k+1) + mod - 1;
		ans %= mod;
		cout<<ans<<"\n";
	}

	// Have you read the problem again?
	// Maybe you understood the wrong problem
}

int32_t main(){
	fastcin;
	int t_ = 1;
	//cin>>t_;
	while(t_--)
		solve();
	return 0;
}

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

int main(){
  vector<vector<vector<long double>>> DP(101,vector<vector<long double>>(101,vector<long double>(101,0)));
  cout << fixed << setprecision(10);
  long double A,B,C;
  cin >> A >> B >> C;
  for(long double i=99;i>=A;i--){
    for(long double j=99;j>=B;j--){
      for(long double k=99;k>=C;k--){
        DP[i][j][k] += (DP[i+1][j][k]+1)*(i/(i+j+k));
        DP[i][j][k] += (DP[i][j+1][k]+1)*(j/(i+j+k));
        DP[i][j][k] += (DP[i][j][k+1]+1)*(k/(i+j+k));
      }
    }
  }
  cout << DP[A][B][C] << endl;
}


#include <algorithm>
#include <array>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
#define int long long
#define ll long long
#define pii std::pair<int, int>
#define pdd std::pair<double, double>
#define INF (1LL << 33)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define SHOW(p) \
    if (test)   \
        cout << #p " : " << p << endl;
bool test = false;
template <class T>
[[maybe_unused]] T ext_gcd(T a, T b, T& x, T& y) {
    // returns gcd(a,b)
    // ax + by = gcd(a,b)
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    T d = ext_gcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
};
int T, N, S, K, x, y, gcd;
signed main()
{
    // test = true;
    cin >> T;
    REP(i, T)
    {
        x = y = 0;
        cin >> N >> S >> K;
        gcd = ext_gcd(N, K, x, y);
        SHOW(gcd);
        y *= -1;
        if (test)
            cout << "x: " << x << " y: " << y << endl;
        if (S % gcd == 0) {
            y *= (S / gcd);
            if (test)
                cout << y << " " << N / gcd << endl;

            y %= (N / gcd);
            if (y < 0) {
                y += N / gcd;
            }
            cout << y << endl;
        } else {
            // NO
            cout << -1 << endl;
        }
        if (test)
            cout << endl;
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

typedef long long ll;

ll exgcd(ll a,ll b,ll &x,ll &y)//扩展欧几里得算法
{
    if(b==0)
    {
        x=1;y=0;
        return a;  //到达递归边界开始向上一层返回
    }
    ll r=exgcd(b,a%b,x,y);
    ll temp=y;    //把x y变成上一层的
    y=x-(a/b)*y;
    x=temp;
    return r;     //得到a b的最大公因数
}

int main()
{
    int t; cin >> t;
    while(t--) {
        ll n, s, k;
        cin >> n >> s >> k;
        ll x, y;
        ll r = exgcd(n, -k, x, y);
        // cout << r << " " << x << " " << y << endl;
        y = y * s / r;
        ll t = n / r;
        if(t < 0) t = -t;
        if(s % r != 0) cout << -1 << endl;
        else cout << (y % t + t) % t << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\n\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n;
pair<ll, ll> p[N];
bool check(int i, int j, int k)
{
    pair<ll, ll> v1 = mp(p[i].first - p[j].first, p[i].second - p[j].second);
    pair<ll, ll> v2 = mp(p[j].first - p[k].first, p[j].second - p[k].second);
    if(v1.first * v2.second - v1.second * v2.first == 0)
        return 1;
    return 0;
}

inline void solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> p[i].first >> p[i].second;
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j)
            for (int k = j + 1; k <= n; ++k)
            {
                if(check(i,j,k))
                    return puts("Yes"), void();
            }
    puts("No");
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
    {
        solve();
        // if (Test)
        //     putchar('\n');
    }
    TIME__END = clock();
    program_end();
    return 0;
}

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

set<int> returnSet(vector<vector<int>> &v, int x) {
  set<int> st;
  for (int i = 0; i < v.size(); i++) {
    int val = 0;
    int pow = 1;
    for (int j = 0; j < 5; j++) {
      if (v[i][j] >= x) val += pow;
      pow *= 2;
    }
    st.insert(val);
  }
  return st;
}

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

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

  int l = 0, r = INT_MAX;
  int res = 0;
  while(r - l > 1) {
    int mid = (l + r) / 2;
    set<int> st = returnSet(v, mid);

//    for (auto it : st) cout << it << " ";
//    cout << '\n';

    bool ok = false;
    for (auto v1 : st) {
      for (auto v2: st) {
        for (auto v3: st) {
          if ((v1 | v2 | v3) == (1 << 5) - 1) ok = true;
        }
      }
    }

    if (ok) l = mid;
    else r = mid;
  }
  cout << l << '\n';
}


#include <iostream>
#include <string>

int main() {
  int N, M;
  long long odd = 0, even = 0;
  std::cin >> N >> M;
  for (int i = 0; i < N; i++) {
    std::string S;
    std::cin >> S;
    bool f = false;
    for (char c : S)
      f ^= (c == '1');
    (f ? odd : even)++;
  }

  std::cout << 1LL * odd * even << "\n";
}

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

signed main() {
    int n, m;
    cin >> n >> m;
    string s[n];
    rep(i, n) {
        cin >> s[i];
    }
    ll ans = 0;
    int even = 0, odd = 0;
    rep(i, n) {
        int cnt = 0;
        rep(j, m) {
            if (s[i][j] == '1') cnt++;
        }
        if (cnt % 2 == 0) {
            ans += odd;
            even++;
        } else {
            ans += even;
            odd++;
        }
    }
    cout << ans << endl;
    return 0;
}


#include<cstdio>
#include<malloc.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<cassert>
using namespace std;
typedef long long ll;
const int MAXN = 200005;
const int INF = 0x7fffffff;
inline int read()//
{
    int x = 0, f = 1; char ch = getchar();
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    return x * f;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    double a, b;
    cin >> a >> b;
    printf("%.8lf", 100-(b / a)*100);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+10;
const int mod=998244353;
#define ll long long
#define ull unsigned long long
#define pi pair<int,int>
#define fi first
#define sc second
#define pb push_back

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double a,b;
    cin>>a>>b;
    double ans=(a-b)*100.0/a;
    cout<<fixed<<setprecision(6)<<ans<<'\n';

}


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

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

using namespace __gnu_pbds;
using namespace std;
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gcd(ll a, ll b)
{
	if (b==0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
ll 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;
}
struct node{
    ll x,t,k;
};
const int N=1e5+5;
vec d(N,(ll)1e18);
vec v[N];
vector<node> g[N];
ll dis(ll x,ll y)
{
    ll p=x/y;
    if(x%y!=0)p++;
    p*=y;
    return p;
}
void solve(ll n,ll u)
{
    multiset<pll> q;
    d[u]=0;
    q.insert({0,u});
    while(!q.empty())
    {
        pll p=*q.begin();
        q.erase(q.begin());
        trav(it,g[p.sc])
        {
            ll c=dis(p.f,it.k);

            if(d[it.x]>c+it.t)
            {
                d[it.x]=c+it.t;
                q.insert({d[it.x],it.x});
            }
        }
    }

}
int main()
{
	fast
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	FOR(i,1,m)
	{
	    ll a,b,c,d;
	    cin>>a>>b>>c>>d;
	    node temp;
	    temp.x=b;temp.t=c;temp.k=d;
	    g[a].pb(temp);
	    node kemp;
	    kemp.x=a;kemp.t=c;kemp.k=d;
	    g[b].pb(kemp);
	}
    solve(n,x);
    if(d[y]==(ll)1e18)cut(-1)
	//FOR(i,1,n)cout<<d[i]<<' ';
    cut(d[y])

}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll ;
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define pb push_back

vector<vector<int> > adj ;
vector<ll> val,m ;
vector<bool> vis ;
ll ans ;

ll dfs(int x)
{
	if(vis[x]) return m[x] ;
	ll ma=-1e9 ;
	vis[x]=1 ;
	rep(i,0,adj[x].size())
	{
		ma=max(ma,dfs(adj[x][i])) ;
	}
	ans=max(ans,ma-val[x]) ;
	ma=max(ma,val[x]) ;
	m[x]=ma ;
	return m[x] ;
}

int main()
{
	int T=1;
	// cin >> T ;

	while(T--)
	{
		int n,me ;
		cin>>n>>me ;
		adj.resize(0) ;
		adj.resize(n) ;
		val.resize(n) ;
		rep(i,0,n) cin>>val[i] ;
		m.resize(n) ;
		rep(i,0,n) m[i]=val[i] ;
		int x,y ;
		rep(i,0,me)
		{
			cin>>x>>y ; x-- ; y-- ;
			adj[x].pb(y) ;
		}
		vis.resize(0) ;
		vis.resize(n) ;
		rep(i,0,n) vis[i]=0 ;
		ans=-1e9 ;
		rep(i,0,n)
		{
			if(!vis[i])
			{
				dfs(i) ;

			}
		}

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


#include <bits/stdc++.h>

using namespace std;

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

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}

// ----------------- Output ------------------

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ',' << p.second;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &e : v) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------ End of template --------------

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<int> fib(N + 1, 0);
  vector<int> pow(N + 1, 0);
  fib[0] = 1, fib[1] = 2;
  pow[0] = 1, pow[1] = 2;
  for (int i = 2; i <= N; i++) {
    fib[i] = (fib[i - 1] + fib[i - 2]) % 1000000007;
    pow[i] = (pow[i - 1] * 2) % 1000000007;
  }
  char AA, AB, BA, BB;
  cin >> AA >> AB >> BA >> BB;
  if (N <= 3) {
    cout << 1 << endl;
    return;
  }
  if (AB == 'A') {
    if (AA == 'A') {
      cout << 1 << endl;
      return;
    }
    if (BA == 'B') {
      cout << pow[N - 3] << endl;
      return;
    }
    cout << fib[N - 3] << endl;
  }
  if (AB == 'B') {
    if (BB == 'B') {
      cout << 1 << endl;
      return;
    }
    if (BA == 'A') {
      cout << pow[N - 3] << endl;
      return;
    }
    cout << fib[N - 3] << endl;
  }
  return;
}

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

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}

using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 1005
#define ll long long
#define mo 1000000007
ll qpow(ll x,ll y=mo-2){
	ll r=1;
	for (;y;y>>=1,x=x*x%mo)
		if (y&1)
			r=r*x%mo;
	return r;
}
ll fac[N],ifac[N];
void initC(int n){
	fac[0]=1;
	for (int i=1;i<=n;++i)
		fac[i]=fac[i-1]*i%mo;
	ifac[n]=qpow(fac[n]);
	for (int i=n-1;i>=0;--i)
		ifac[i]=ifac[i+1]*(i+1)%mo;
}
ll C(int m,int n){
	if (m<n) return 0;
	return fac[m]*ifac[n]%mo*ifac[m-n]%mo;
}
int n;
int c[2][2];
void case1(){
	printf("1\n");
}
void case2(){
	ll ans=0;
	for (int i=1;i<=n-1;++i)
		ans+=C(i-1,n-1-i);
	printf("%lld\n",ans%mo);
}
void case3(){
	printf("%lld\n",qpow(2,n-3));
}
int main(){
	scanf("%d",&n);
	initC(n);
	for (int i=0;i<2;++i)
		for (int j=0;j<2;++j){
			char str[2];
			scanf("%s",str);
			c[i][j]=*str-'A';
		}
	if (n==2){
		printf("1\n");
		return 0;
	}
	if (c[0][1]==0){
		if (c[0][0]==0)
			case1();
		else{
			if (c[1][0]==0)
				case2();
			else
				case3();
		}
	}
	else{
		if (c[1][1]==1)
			case1();
		else{
			if (c[1][0]==1)
				case2();
			else
				case3();
		}
	}
	return 0;
}


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

using ll = long long;
using que_type = tuple<int, pair<int, int>, vector<int>>;

void solve(long long si, long long sj, std::vector<std::vector<long long>> t, std::vector<std::vector<long long>> p){
    priority_queue<que_type, vector<que_type>, greater<que_type>> que;
    que.push(make_tuple(p[si][sj], make_pair(si, sj), vector<int>{(int)t[si][sj]}));

    int times = 1e9;
    int beam = 1000;

    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    int ans = 0;
    vector<int> ansv;

    while(times--){
        priority_queue<que_type, vector<que_type>, greater<que_type>> next_que;

        while(!que.empty()){
            que_type q = que.top();
            int score;
            pair<int, int> pos;
            vector<int> tiles;
            tie(score, pos, tiles) = q;

            que.pop();

            for(int i = 0;i < 4;i++){
                int nx = dx[i] + pos.first;
                int ny = dy[i] + pos.second;
                if(0 <= dx[i] + pos.first && dx[i] + pos.first < 50 && 0 <= dy[i] + pos.second && dy[i] + pos.second < 50){
                    bool f = false;
                    for(int x : tiles){
                        if(x == t[nx][ny]){
                            f = true;
                            break;
                        }
                    }
                    if(f == false){
                        tiles.push_back(t[nx][ny]);
                        next_que.push(make_tuple(score + p[nx][ny], make_pair(nx, ny), tiles));
                        tiles.pop_back();
                        if(score + p[nx][ny] > ans){
                            ans = score + p[nx][ny];
                            ansv = tiles;
                        }
                    }
                }
            }
        }
        while(next_que.size() > beam)
            next_que.pop();
        que = next_que;
        //cout<<que.size()<<endl;
        //cout<<ans<<endl;
        if(que.size() == 0){
            break;
        }
    }

    int pi = si;
    int pj = sj;
    string ans_str;
    for(int i = 1;i < ansv.size();i++){
        bool f = false;
        //cout<<ansv[i]<<" ";
        for(int idx = 0;idx < 4;idx++){
            int nx = pi + dx[idx];
            int ny = pj + dy[idx];

            if(0 <= nx && nx < 50 && 0 <= ny && ny < 50){
                if(t[nx][ny] == ansv[i]){
                    //cout<<idx<<" ";
                    if(idx == 0){
                        ans_str.push_back('D');
                    }else
                    if(idx == 1){
                        ans_str.push_back('R');
                    }else
                    if(idx == 2){
                        ans_str.push_back('U');
                    }else
                    if(idx == 3){
                        ans_str.push_back('L');
                    }
                    f = true;
                }
            }
            if(f){
                pi = nx;
                pj = ny;
                break;
            }
        }
    }
    cout<<ans_str<<endl;
}

int main(){
    long long si;
    scanf("%lld",&si);
    long long sj;
    scanf("%lld",&sj);
    std::vector<std::vector<long long>> t(49+1, std::vector<long long>(49+1));
    for(int i = 0 ; i < 49+1 ; i++){
        for(int j = 0 ; j < 49+1 ; j++){
            scanf("%lld",&t[i][j]);
        }
    }
    std::vector<std::vector<long long>> p(49+1, std::vector<long long>(49+1));
    for(int i = 0 ; i < 49+1 ; i++){
        for(int j = 0 ; j < 49+1 ; j++){
            scanf("%lld",&p[i][j]);
        }
    }
    solve(si, sj, std::move(t), std::move(p));
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define mii map<int, int>
#define pii pair<int, int>
#define qii priority_que<int, vector<int>, greater<int>>
#define For(i, n) for(int i = 0; i < n; ++i)
#define For1(i, n) for(int i = 1; i <= n; ++i)
#define Forlr(i, l, r) for(int i = l; i <= r; ++i)
#define Forrl(i, r, l) for(int i = r; i >= l; --i)
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) {For(i, a.size()) cout << a[i] <<" ";}
#define ovv(a) {For(i, a.size()) {For(j, a[i].size()) cout << a[i][j] <<" ";cout <<"\n";}}
using ll = long long;
int n, m, k, q;
const int INF = 1e9 + 5;
const int nax = 1e5 + 5;
string s[2005];
ll dp[2005][2005];
const ll mod = 1e9 + 7;
ll x[2000][2000], y[2000][2000], z[2000][2000];

int main()
{
	cin >> n >> m;
	For(i, n){
		cin >> s[i];
	}
	dp[0][0] = 1;
	For(i, n){
		For(j, m){
			//o(s[i][j])
			if(i == 0 && j == 0) continue;
			if(s[i][j] =='#') continue;
			if(i > 0) {
				x[i][j] = (x[i - 1][j] + dp[i - 1][j]) % mod;
			}
			if(j > 0){
				y[i][j] = (y[i][j - 1] + dp[i][j - 1]) % mod;
			}
			if(i > 0 && j > 0){
				z[i][j] = (z[i - 1][j - 1] + dp[i - 1][j - 1]) % mod;
			}
			dp[i][j] = (x[i][j] + y[i][j] + z[i][j]) % mod;
		}
	}
	// For(i, n) {
	// 	For(j, m){
	// 		cout << dp[i][j] << " " ;
	// 	}
	// 	cout <<"\n";
	// }
	cout << dp[n - 1][m - 1];
	//cout << dp[n - 1][m - 1];
}