#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b

using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

const int N = 1000001;

int factorialNumInverse[N + 1];
int naturalNumInverse[N + 1];
int fact[N + 1];

void InverseofNumber(int p)
{
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (int i = 2; i <= N; i++)
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}
void InverseofFactorial(int p)
{
    factorialNumInverse[0] = factorialNumInverse[1] = 1;

    for (int i = 2; i <= N; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}

void factorial(int p)
{
    fact[0] = 1;

    for (int i = 1; i <= N; i++)
    {
        fact[i] = (fact[i - 1] * i) % p;
    }
}

int Binomial(int N, int R, int p)
{
    int ans = ((fact[N] * factorialNumInverse[R])
              % p * factorialNumInverse[N - R])
             % p;
    return ans;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    InverseofNumber(mod);
    InverseofFactorial(mod);
    factorial(mod);
    int b = Binomial(n*m-2,k-2,mod)%mod;
    int x = 0;
    rep(i,1,n){
        int coef = (n-i);
        coef %= mod;
        coef *= m;
        coef %= mod;
        coef *= m;
        coef %= mod;
        coef *= i;
        coef %= mod;
        x += coef;
        x %= mod;
    }
    int y = 0;
    rep(j,1,m){
        int coef = (m-j);
        coef %= mod;
        coef *= n;
        coef %= mod;
        coef *= n;
        coef %= mod;
        coef *= j;
        coef %= mod;
        y += coef;
        y %= mod;
    }

    cout<<(((x+y)%mod)*b)%mod<<endl;

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

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

int moveX(vector<char>& str, int posX, int targetX)
{
    while(posX < targetX)
    {
        posX += 1;
        str.push_back('R');
    }
    while(targetX < posX)
    {
        posX -= 1;
        str.push_back('L');
    }

    return posX;
}

int moveY(vector<char>& str, int posY, int targetY)
{
    while(posY < targetY)
    {
        posY += 1;
        str.push_back('U');
    }
    while(targetY < posY)
    {
        posY -= 1;
        str.push_back('D');
    }

    return posY;
}

int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int posX=sx;
    int posY=sy;
    vector<char> str;

    // step1
    posX = moveX(str, posX, tx);
    posY = moveY(str, posY, ty);

    // step2
    posX = moveX(str, posX, sx);
    posY = moveY(str, posY, sy);

    // final step
    if(sx < tx && sy < ty)
    {
        posX -= 1;
        str.push_back('L');
        posY = moveY(str, posY, ty+1);
        posX = moveX(str, posX, tx);
        posY = moveY(str, posY, ty);

        posX += 1;
        str.push_back('R');
        posY = moveY(str, posY, sy-1);
        posX = moveX(str, posX, sx);
        posY = moveY(str, posY, sy);
    }else if(tx < sx && sy < ty)
    {
        posX += 1;
        str.push_back('R');
        posY = moveY(str, posY, ty+1);
        posX = moveX(str, posX, tx);
        posY = moveY(str, posY, ty);

        posX -= 1;
        str.push_back('L');
        posY = moveY(str, posY, sy-1);
        posX = moveX(str, posX, sx);
        posY = moveY(str, posY, sy);
    }else if(tx < sx && ty < sx)
    {
        posX += 1;
        str.push_back('R');
        posY = moveY(str, posY, ty-1);
        posX = moveX(str, posX, tx);
        posY = moveY(str, posY, ty);

        posX -= 1;
        str.push_back('L');
        posY = moveY(str, posY, sy+1);
        posX = moveX(str, posX, sx);
        posY = moveY(str, posY, sy);
    }else
    {
        posX -= 1;
        str.push_back('L');
        posY = moveY(str, posY, ty-1);
        posX = moveX(str, posX, tx);
        posY = moveY(str, posY, ty);

        posX += 1;
        str.push_back('R');
        posY = moveY(str, posY, sy+1);
        posX = moveX(str, posX, sx);
        posY = moveY(str, posY, sy);
    }

    for(int i=0; i<str.size(); i++) cout << str[i];
    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

uint64_t kRem = 998244353;

int64_t pow_rem(int64_t val, int64_t mul, int64_t rem)
{
	if (mul == 1) return val;

	int64_t ret = pow_rem(val, mul / 2, rem);
	ret *= ret;
	ret %= rem;

	if (mul & 1) {
		ret *= val;
		ret %= rem;
	}

	return ret;
}

int main()
{
	int n; cin >> n;
	vector<int> ns(n);
	int m = 0;
	for (auto& elem : ns) {
		cin >> elem;
		m += elem;
	}

	vector<vector<int64_t>> dp_r(n, vector<int64_t> (m + 1));

	dp_r[0][0] = 2;
	dp_r[0][ns[0]] = 1;

	FOR_LT(i, 0, n - 1) {
		FOR_LE(v, 0, m) {
			if (dp_r[i][v] != 0) {
				dp_r[i + 1][v] += dp_r[i][v] * 2;
				dp_r[i + 1][v + ns[i + 1]] += dp_r[i][v];
			}
		}

		FOR_LE(v, 0, m) {
			if (dp_r[i + 1][v] != 0) {
				dp_r[i + 1][v] %= kRem;
			}
		}
	}

	vector<vector<int64_t>> dp_rb(n, vector<int64_t>(m + 1));
	dp_rb[0][0] = 1;
	dp_rb[0][ns[0]] = 1;

	FOR_LT(i, 0, n - 1) {
		FOR_LE(v, 0, m) {
			if (dp_rb[i][v] != 0) {
				dp_rb[i + 1][v] += dp_rb[i][v];
				dp_rb[i + 1][v + ns[i + 1]] += dp_rb[i][v];
			}
		}

		FOR_LE(v, 0, m) {
			if (dp_rb[i + 1][v] != 0) {
				dp_rb[i + 1][v] %= kRem;
			}
		}
	}

	int64_t ng_cases = 0;
	FOR_LE(v, ((m + 1) / 2), m) {
		ng_cases += dp_r[n - 1][v];
		ng_cases %= kRem;
	}
	if ((m & 1) == 0) {
		ng_cases -= dp_rb[n - 1][m / 2];
		if (ng_cases < 0) ng_cases += kRem;
	}
	ng_cases *= 3;
	ng_cases %= kRem;

	int64_t all_cases = 0;
	all_cases = pow_rem(3, n, kRem);

	int64_t ans = (all_cases - ng_cases);
	if (ans < 0) ans += kRem;

	cout << ans << endl;
}

#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
ll ans[1010][1010],n;
bool vis[10101];
int tot,p[10101];
inline void init(int n){
	for (int i=2;i<=n;i++){
		if (!vis[i]) p[++tot]=i;
		for (int j=1;j<=tot;j++){
			if (1ll*i*p[j]>n) break;
			vis[i*p[j]]=1;
			if (i%p[j]==0) break;
		}
	}
}
inline ll lcm(ll a,ll b){
	if (a*b==0) return a+b;
	return a/__gcd(a,b)*b;
}
signed main(){
	n=read();
	if (n==2){
		printf("4 7\n23 10\n");
		return 0;
	}
	init(10000);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if ((i+j)%2==0){
				ans[i][j]=1ll*p[(i+j)/2]*p[1+(i-j)/2+n];
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if ((i+j)%2){
				ans[i][j]=1+lcm(ans[i-1][j],lcm(ans[i][j-1],lcm(ans[i+1][j],ans[i][j+1])));
			}
			printf("%lld ",ans[i][j]);
		}
		puts("");
	}
	return 0;
}


#include<iostream>
using namespace std;
int main (void)
{
  int r;
  cin>>r;
  r=r*2*3141592;
  cout<<r/1000000<<"."<<r%1000000;
}

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

int main() {
  const double PI = 3.14159265358979;
  double R;
  cin >> R;
  cout << R*2*PI << endl;

  return 0;

    }


#include<stdio.h>
#include<string.h>
int main(void)
{
	char str[20];
	int len,i;
	scanf("%s",str);
	len=strlen(str);
	for(i=len-1;i>=0;i--){
		printf("%c",str[i]);
	}
	printf("\n");
	return 0;
}

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

using namespace std;
// cin >>
// cin <<
int main(){
	string a;
	getline(cin,a);
		reverse( a.begin() , a.end() );
		cout <<a<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define MAX_N 100
#define INF 1000000000

int N;
int r[MAX_N],c[MAX_N];
int memo[MAX_N][MAX_N];
int saiki(int i ,int j){
    if(memo[i][j] > -1)
        return memo[i][j];
    if(i == j)
        return 0;
    int mini = INF;
    FOR(k,i,j){
        mini = min(mini,saiki(i,k) + saiki(k + 1,j) + r[i] * c[k] * c[j]);
    }
    return memo[i][j] = mini;
}

int main(){
    scanf("%d",&N);
    REP(i,N){
        scanf("%d%d",&r[i],&c[i]);
    }
    REP(i,N)REP(j,N)memo[i][j] = -1;
    printf("%d\n",saiki(0,N-1));
    return 0;
}

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

using namespace std;
int INF = 100000000;

struct Matrix { int row, col; };

int getMinMCM(const vector<Matrix>& matVec) {
	const size_t n = matVec.size();
	//table(i,num)は、与えられた行列積のindex=i(0始まり）の行列から、num個先の行列までの積についてのMCM最小値を記録する
	//（ table.at(0).at(n - 1) が求まると、与えられた行列積全体のMCMが求まる ）
	vector< vector<int> > table(n, vector<int>(n, 0));
	for (size_t num = 1; num != n; ++num) {
		const size_t end = n - num;
		for (size_t i = 0; i != end; ++i) {
			const Matrix& matI = matVec.at(i);
			const Matrix& matNum = matVec.at(i+num);
			int& target = table.at(i).at(num);
			target = INF;
			int end2 = i + num;
			for (int j = i; j != end2; ++j) {
				const Matrix& matJ = matVec.at(j);
				target = min(target, matI.row * matJ.col * matNum.col + table.at(i).at(j - i) + table.at(j + 1).at(num+i-j-1));
			}

		}
	}
	return table.at(0).at(n - 1);
}

template<typename T>
void execute(T& cin) {
	int n;
	cin >> n;
	vector<Matrix> m(n);
	for (auto& matrix : m)cin >> matrix.row >> matrix.col;
	cout << getMinMCM(m) << endl;

}

int main()
{
	execute(cin);

	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main(int argc, char* argv[])
{
    int n = 0, n2 = 0;
    cin >> n;
    //n = atoi(argv[1]);
    if(n < 1 || n > 100) {
        return 1;
    }
    n2 = pow(n, 3.0);
    cout << n2 << endl;
}

    #include <cstdio>

    int main() {
    	int a, b;
    	scanf("%d", &a);
    	b=a*a*a;
    	printf("%d\n",b);

    	return 0;
    }


#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int sum = max(a, b);
    if (max(a, b) - min(a, b) >= 2) {
        sum += max(a,b) - 1;
    }
    else {
        sum += min(a,b);
    }
    cout << sum;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[5];
  int ans;
  for(int i=0;i<2;i++){
    cin>>a[i];
  }
  sort(a,a+2);
  ans=a[1];
  a[1]--;
  sort(a,a+2);
  ans+=a[1];
  cout<<ans<<"\n";
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int main(){
    int n;cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);

    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

#include <iostream>
//#include<stack>
#include<set>
#include<bits/stdc++.h>
using namespace std;
//int f[10005];
//int chazhao(int x)
//{
//	if(x==f[x])
//	return x;
//	else
//	return f[x]=chazhao(f[x]);
//}

int main()
{
	set<int >ss;
	int n,x;
	cin>>n>>x;
	ss.insert(x);
	for(int i=1;i<n;i++)
	{
		cin>>x;
	  if(ss.count(x)==0)
	  ss.insert(x);
	  else
	  continue;
	}
   int k=ss.size();
   if(k==n)
   cout<<"YES"<<endl;
   else
   cout<<"NO"<<endl;
 return 0;
}


#include <bits/stdc++.h>

using namespace std;

int N,a[500010],s[500010];
vector<int>pos[1<<20];
int sum0[500010];
const int MOD = 1e9 + 7;

int main() {
	scanf("%d",&N);
	for (int i=1;i<=N;i++) {
		scanf("%d",&a[i]);
		s[i] = s[i - 1] ^ a[i];
		pos[s[i]].push_back(i);
		sum0[i] = sum0[i - 1] + (s[i] == 0);
	}
	if (s[N] != 0) {
		int X = s[N];
		int s0 = 1, s1 = 0;
		for (int i=1;i<=N;i++) {
			if (s[i] == X) {
				int F = s0;
				s1 = (s1 + F) % MOD;
				if (i == N) {
					printf("%d\n",F);
					return 0;
				}
			} else if (s[i] == 0) {
				int F = s1;
				s0 = (s0 + F) % MOD;
			}
		}
	}
	int ans = 0;
	int p2 = 1;
	for (int i=1;i<=sum0[N-1];i++) {
		p2 = p2 * 2 % MOD;
	}
	ans = p2;
	for (int v=1;v<(1<<20);v++) {
		if (pos[v].size() == 0) {
			continue;
		}
		if (pos[v].size() == 1) {
			ans++;
			continue;
		}
		int lastF = 1, s0 = 1, s1 = 1;
		for (int i=1;i<pos[v].size();i++) {
			int bz = sum0[pos[v][i]] - sum0[pos[v][i-1]];
			s0 = (1LL * bz * s1 + s0) % MOD;
			int F = s0;
			s1 = (s1 + F) % MOD;
		}
		ans = (ans + s1) % MOD;
	}
	printf("%d\n",ans);
}

//Only the Creator has given me strength!🖤
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
#define pi 3.1415926535897931159979635
#define pb push_back
#define vctr vector<int>
#define vvtr vector<vctr>
int mod=1e9+7;
using namespace std;
void fastio() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
    fastio();
    int s;
    ll g=0;
    string a;
    cin>>s>>a;
    ll r=0,gr=0,b=0,k,l;
    for(int i=0; i<s; i++) {
        if(a[i]=='R') r++;
        else if(a[i]=='G') gr++;
        else b++;
        for(int j=0; j<s; j++) {
            k=2*j+i;
            l=j+i;
            if(k>=s) break;
            if(a[i]!=a[l] && a[i]!=a[k] && a[l]!=a[k])
                g++;
        }
    }
    ll ans=r*gr*b-g;
    cout<<ans<<"\n";
    return 0;
}


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set

    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
	int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 5e5+5;
const int mod = 1e9+7;
using namespace std;

int block, curl, curr, res;
struct qry {
	int id, l, r;
} q[maxn];
int ans[maxn], a[maxn], mp[maxn];

void add(int pos) {
	if (mp[a[pos]]==0) {
		res++;
		mp[a[pos]]=1;
	} else {
		mp[a[pos]]++;
	}
}

void del(int pos) {
	if (mp[a[pos]]-1==0) {
		mp[a[pos]]=0;
		res--;
	} else {
		mp[a[pos]]--;
	}
}

void solve() {
	ll n,m; cin >> n >> m;
	block = sqrt(n);
	rep(i,1,n+1) cin >> a[i];
	rep(i,1,m+1) cin >> q[i].l >> q[i].r, q[i].id=i;
	sort(q+1, q+m+1, [](qry x, qry y) {
		if (x.l/block == y.l/block)
			return x.r < y.r;
		return x.l/block < y.l/block;
	});
	curl = curr = res = 0;
	for (int i=1; i<=m; i++) {
		while(curr > q[i].r)
			del(curr--);
		while(curr < q[i].r)
			add(++curr);
		while(curl > q[i].l)
			add(--curl);
		while(curl < q[i].l)
			del(curl++);
		ans[q[i].id]=res;
	}
	for(int i=1; i<=m; i++)
		cout << ans[i] << '\n';
}

int main(int argc, char * argv[])
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

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

    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  rep(i, m) cin >> p[i] >> s[i];
  rep(i, m) --p[i];

  vector<int> ac(n, 0), wa(n, 0);
  rep(i, m) {
    if (s[i] == "AC") ++ac[p[i]];
    else if (ac[p[i]] == 0) ++wa[p[i]];
  }

  int co = 0, pe = 0;
  rep(i, n) if (ac[i] > 0) {
    ++co;
    pe += wa[i];
  }
  printf("%d %d\n", co, pe);
  return 0;
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<vector<string>> v(n);
    rep(i, m){
        int a; cin >> a;
        string s; cin >> s;
        v.at(a-1).push_back(s);
    }
    int ac = 0, wa = 0;
    vector<int> v_wa(n);
    rep(i, n){
        bool flag = true;
        for(auto j : v.at(i)){
            if(j == "AC") {
                ac++;
                flag = false;
                break;
            }
            wa++;
        }
        if(flag) wa = 0;
        v_wa.at(i) = wa;
        wa = 0;
    }
    int sum = 0;
    for(auto a : v_wa) sum += a;
    cout << ac << ' ' << sum << endl;
    return 0;
}


#include <stdio.h>
int main(){
	int X,Y,Z;
	int *px,*py,*pz;
	scanf("%d",&X);
	scanf("%d",&Y);
	scanf("%d",&Z);
	px = &Z;
	py = &X;
	pz = &Y;
	printf("%d %d %d",*px,*py,*pz);
}

#include <cmath>

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int a;
int b;
int c;

void input() {
  cin >> a >> b >> c;
}

void solve() {
  swap(a, b);
  swap(a, c);

  cout << a << ' ' << b << ' ' << c << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, H, W;
	cin >> N >> H >> W;
	int ans = 0;

	cout << (N - H + 1)*(N - W + 1) << endl;

	return 0;
}

using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int CtoI(char c){
	if(c=='I')return 1;
	else if(c=='V')return 5;
	else if(c=='X')return 10;
	else if(c=='L')return 50;
	else if(c=='C')return 100;
	else if(c=='D')return 500;
	else if(c=='M')return 1000;
}
int main()
{
	string s;
	while(getline(cin,s)){
		int ans=0;
		for(int i=1;i<(int)s.length();i++){
			int x=CtoI(s[i-1]);
			if(x<CtoI(s[i]))ans-=x;
			else ans+=x;
		}
		ans+=CtoI(s[(int)s.length()-1]);
		cout<<ans<<endl;
	}
    return 0;
}


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

ll tens[32];

ll dp(const int digit, const ll D, bool zero) {
  if (digit == 1) return (D == 0 ? 10 : 0);
  if (digit == 0) return (D == 0 ? 1 : 0);
  if (abs(D) > tens[digit]) return 0;
  ll res = 0;
  for (int diff = -9; diff <= 9; ++diff) {
    int count = 10 - abs(diff) - (zero ? 1 : 0);
    ll nD = D - diff * (tens[digit - 1] - 1);
    if (nD % 10 == 0) res += dp(digit - 2, nD / 10, false) * count;
  }
  return res;
}

void solve(const ll D) {
  tens[0] = 1;
  REP(i,18) tens[i + 1] = tens[i] * 10;
  ll res = 0;
  for (int digit = 1; digit <= 18; ++digit) {
    res += dp(digit, D, true);
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll D;
	scanf("%lld", &D);
	solve(D);
	return 0;
}

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

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

    int pie = l*n - n;
    for (int i = 1; i <= n; i++) {
        pie += i;
    }

    if (l < 0) {
        if (n-1 < abs(l)) pie -= l+n-1;
    }
    else {
        pie -= l;
    }

    cout << pie << endl;
}


#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 30000000000000LL
#define GOLD 1.61803398874989484820458
const long long MAX_MOD = 1e6 + 3;
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long powering(long long now,long long now_go){
	long long ans = 1;
	while (now_go != 0) {
		if (now_go % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		now_go /= 2;
	}
	return ans;
}
long long inv(long long now) {
	return powering(now, MAX_MOD - 2LL);
}
long long d;
long long geko[32] = {};
long long bobo[30] = {};
long long solve(long long now, long long now_digit, long long L) {
	if (L / 2 == now_digit) {
		if (L % 2 == 0) {
			if (d == now) {
				return 1;
			}
			else {
				return 0;
			}
		}
		else {
			if (d == now) {
				return 10LL;
			}
			else {
				return 0LL;
			}
		}
	}
	long long ans = 0;
	for (long long i = -9; i <= 9; ++i) {
		long long tea = geko[L - now_digit - 1] - geko[now_digit];
		tea *= i;
		tea += now;
		if (tea >= 0) {
			if (tea % geko[now_digit + 1] == d % geko[now_digit + 1]) {
				//ok
				long long geko = solve(tea, now_digit + 1, L);
				if (geko == 0) continue;
				if (now_digit == 0) {
					bobo[i + 9]--;
				}
				ans += geko * bobo[i+9];
				if (now_digit == 0) {
						bobo[i + 9]++;
				}
			}
		}
		else {
			tea += geko[18];
			if (tea % geko[now_digit + 1] == d % geko[now_digit + 1]) {
				long long geko = solve(tea - bobo[18], now_digit + 1, L);
				if (geko == 0)continue;
				if (now_digit == 0) {
						bobo[i + 9]--;
				}
				ans += geko * bobo[i + 9];
				if (now_digit == 0) {
						bobo[i + 9]++;
				}
			}
			tea -= geko[18];
		}
	}
	return ans;
}
int main() {
	for (int i = 0; i <= 9; ++i) {
		for (int q = 0; q <= 9; ++q) {
			bobo[i - q + 9]++;
		}
	}
	geko[0] = 1;
	for (int i = 1; i <= 18; ++i) {
		geko[i] = 10LL * geko[i-1];
	}
	cin >> d;
	if (d % 9 != 0) {
		cout << 0 << endl;
		return 0;
	}
	int len = to_string(d).length();
	long long ans = 0;
	for (long long digit = len; digit <= len * 2; ++digit) {
		ans += solve(0, 0, digit);
	}
	cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
const int N=(1<<18);
const int mod=1e9+7;
int dp[50][N];
int n,a,b,c;
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	scanf("%d",&n);
	scanf("%d",&a);scanf("%d",&b);scanf("%d",&c);
	int bz=(1<<(a-1))|(1<<(a+b-1))|(1<<(a+b+c-1));
	int mx=(1<<(a+b+c));
	dp[0][0]=1;
	int p=1;
	for(int i=1;i<=n;i++){
		p=(1ll*10*p)%mod;
		for(int j=0;j<mx;j++){
			if(dp[i-1][j]==0)continue;
			for(int k=1;k<=10;k++){
				int now=(j<<k)|(1<<(k-1));
				now&=(mx-1);
				if((now&bz)!=bz){
					dp[i][now]=(dp[i][now]+dp[i-1][j])%mod;
				}
			}
		}
	}
	int ans=p;
	for(int i=0;i<mx;i++){
		ans=(ans-dp[n][i]+mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

struct node
{
	int num,fa,ls,rs;
	node(int _num,int _fa)
	{
		num=_num;
		fa=_fa;
		ls=rs=-1;
	}
};

typedef vector<node> Tree;

Tree T;

void insert(int t,int n)
{
	if(T[0].num==INT_MAX)
		T[0].num=n;
	else if(T[t].num>n)
		if(T[t].ls==-1)
		{
			T[t].ls=T.size();
			T.push_back(node(n,t));
		}
		else insert(T[t].ls,n);
	else
		if(T[t].rs==-1)
		{
			T[t].rs=T.size();
			T.push_back(node(n,t));
		}
		else insert(T[t].rs,n);
}

void find(int t,int x)
{
	if(T.size()==0||t==-1)
		printf("no\n");
	else if(T[t].num==x)
		printf("yes\n");
	else if(x<T[t].num)
		find(T[t].ls,x);
	else find(T[t].rs,x);
}

void lc(int fa,int son)
{
	T[fa].ls=son;
	if(son!=-1) T[son].fa=fa;
}

void rc(int fa,int son)
{
	T[fa].rs=son;
	if(son!=-1) T[son].fa=fa;
}

void del(int t,int x)
{
	if(t==-1) return ;
	if(T[t].num==x)
	{
		if(T[t].ls==-1)
			if(T[t].rs==-1)
				if(T[T[t].fa].ls==t)
					T[T[t].fa].ls=-1;
				else T[T[t].fa].rs=-1;
			else
				if(T[T[t].fa].ls==t)
				{
					T[T[t].fa].ls=T[t].rs;
					T[T[t].rs].fa=T[t].fa;
				}
				else
				{
					T[T[t].fa].rs=T[t].rs;
					T[T[t].rs].fa=T[t].fa;
				}
		else if(T[t].rs==-1)
				if(T[T[t].fa].ls==t)
				{
					T[T[t].fa].ls=T[t].ls;
					T[T[t].ls].fa=T[t].fa;
				}
				else
				{
					T[T[t].fa].rs=T[t].ls;
					T[T[t].ls].fa=T[t].fa;
				}
			else
			{
				int mir=T[t].rs;
				while(T[mir].ls!=-1) mir=T[mir].ls;
				del(t,T[mir].num);
				T[t].num=T[mir].num;
			}
	}
	else if(x<T[t].num)
		del(T[t].ls,x);
	else del(T[t].rs,x);
}

void Preorder(int t)
{
	if(t==-1) return;
	printf(" %d",T[t].num);
	Preorder(T[t].ls);
	Preorder(T[t].rs);
}

void Inorder(int t)
{
	if(t==-1) return;
	Inorder(T[t].ls);
	printf(" %d",T[t].num);
	Inorder(T[t].rs);
}

void print()
{
	Inorder(T[1].ls);
	printf("\n");
	Preorder(T[1].ls);
	printf("\n");
}

int main()
{
	T.clear();
	T.push_back(node(INT_MAX,1));
	T.push_back(node(-1,-1));
	T[1].ls=0;
	int n;
	scanf("%d",&n);
	while(n--)
	{
		char s[10];
		scanf("%s",s);
		if(s[0]=='i')
		{
			int t;
			scanf("%d",&t);
			insert(T[1].ls,t);
		}
		else if(s[0]=='f')
		{
			int t;
			scanf("%d",&t);
			find(T[1].ls,t);
		}
		else if(s[0]=='d')
		{
			int t;
			scanf("%d",&t);
			del(T[1].ls,t);
		}
		else print();
	}
	return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int MAX = 500000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
struct Node {
    Node *parent,
         *left,
         *right;
    int key;
};

Node *root, *NIL;

/* function */
void insert(int value);
Node* findNode(int target);
Node* getSuccessor(Node* target);
Node* getMinimum(Node* target);
void deleteNode(Node* target);
void preorder(Node* v);
void inorder(Node* v);

/* main */
int main(){

    // main
    int n, val;
    cin >> n;
    string man;
    for (int i = 0; i < n; i++) {
        cin >> man;
        if (man == "print") {
            inorder(root); cout << '\n';
            preorder(root); cout << '\n';
        }
        else {
            cin >> val;
            if (man == "insert") {
                insert(val);
            }
            else if (man == "delete" ) {
                Node* target = findNode(val);
                deleteNode(target);
            }
            else {
                Node* ret_node = findNode(val);
                if (ret_node != NIL)
                    cout << "yes" << '\n';
                else
                    cout << "no" << '\n';
            }
        }
    }

}

void deleteNode(Node* target) {
    Node* y;  // delete Node
    Node* x;  // y's child

    // determin delete Node : y;
    if (target->left == NIL || target->right == NIL)
        y = target;
    else
        y = getSuccessor(target);

    // determin y's child : x;
    if (y->left != NIL) x = y->left;
    else x = y->right;

    if (x != NIL)
        x->parent = y->parent;

    if (y->parent == NIL)
        root = x;
    else if (y == y->parent->left)
        y->parent->left = x;
    else
        y->parent->right = x;

    if (y != target)
        target->key = y->key;
}

Node* getSuccessor(Node* target) {
    // target has right subtree
    if (target->right != NIL)
        return getMinimum(target->right);

    /*
    Node* y = target->parent;
    while (y != NIL && target == y->right) {
        target = y;
        y = y->parent;
    }
    return y;
    */
}

Node* getMinimum(Node* target) {
    while (target->left != NIL)
        target = target->left;

    return target;
}

Node* findNode(int target) {

    Node* x = root;
    while (x != NIL) {
        if (target == x->key) {
            return x;
        }
        else if (target < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    return x;
}

void insert(int value) {

    // init Node
    Node* z = new Node();
    z->parent = NIL;
    z->left = NIL;
    z-> right = NIL;

    Node* y = NIL;  // parent of x(root)
    Node* x = root; // root of 'T'

    while (x != NIL) {
        y = x; // set parent
        if (value < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }

    z->parent = y;
    z->key = value;

    if (y == NIL) {  // 'T' is empty
        root = z;
    }
    else if (value < y->key) {
        y->left = z;  // z is y's left
    }
    else if (value > y->key) {
        y->right = z;  // z is y's right
    }
}

void preorder(Node* v) {
    if (v != NIL) {
        cout << ' ' << v->key;
        preorder(v->left);
        preorder(v->right);
    }

}

void inorder(Node* v) {
    if (v != NIL) {
        inorder(v->left);
        cout << ' ' << v->key;
        inorder(v->right);
    }
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	string s,t;cin>>s>>t;
	if(s==t)puts("0"),exit(0);
	reverse(s.begin(),s.end()),reverse(t.begin(),t.end());
	int k=0;
	queue<int>q;
	int ans=0;
	for(int i=0,j;i<n;i=j+1){
		for(j=i;j+1<n&&t[j+1]==t[j];++j);
		k=max(k,j);
		while(k<n&&t[i]!=s[k])++k;
		if(k==n)puts("-1"),exit(0);
		while(!q.empty()){
			int k1=q.front();
			if(k1+(int)q.size()<=j)q.pop();
			else break;
		}
		if(j<k)q.push(k);
		ans=max(ans,(int)q.size());
	}
	printf("%d\n",ans+1);
	return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
long long mod_inv(long long a, long long mod = MOD) {
  a %= mod;
  if (__gcd(a, mod) != 1) return -1;
  long long b = mod, x = 1, y = 0;
  while (b > 0) {
    long long tmp = a / b;
    a -= tmp * b;
    swap(a, b);
    x -= tmp * y;
    swap(x, y);
  }
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

const int MAX = 10000000;
long long fact[MAX + 1], fact_inv[MAX + 1];
void nCk_init(int val = MAX, long long mod = MOD) {
  fact[0] = 1;
  FOR(i, 1, val + 1) fact[i] = fact[i - 1] * i % mod;
  fact_inv[val] = mod_inv(fact[val], mod);
  for (int i = val; i > 0; --i) fact_inv[i - 1] = fact_inv[i] * i % mod;
}

long long nCk(int n, int k, long long mod = MOD) {
  if (n < 0 || n < k || k < 0) return 0;
  return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  nCk_init();
  int n, m; cin >> n >> m;
  long long ans = 0;
  REP(i, min(n, m) + 1) {
    int gp = 3 * m - i;
    if (gp & 1) continue;
    gp /= 2;
    (ans += nCk(n, i) * nCk(gp + n - 1, n - 1) % MOD) %= MOD;
  }
  long long tmp = 0;
  REP(i, m) (tmp += nCk(i + n - 2, n - 2)) %= MOD;
  (tmp *= n) %= MOD;
  ans -= tmp;
  if (ans < 0) ans += MOD;
  cout << ans << '\n';
  return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
char str[110];
int b[110];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",b+i);
		scanf("%s",str);
		for(int i=0;str[i];i++){
			int p=0;
			if('a'<=str[i]&&str[i]<='z')p=str[i]-'a';
			else p=str[i]-'A'+26;
			p-=b[i%a];
			if(p<0)p+=52;
			if(p<26)str[i]='a'+p;
			else str[i]='A'+p-26;
		}
		printf("%s\n",str);
	}
}

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void Solve(int n){
  std::vector<int> key(n);
  for(int i=0;i<n;i++){
    cin>>key[i];
  }
  std::string s;
  cin>>s;
  std::string result;
  int key_itr=0;
  for(int i=0;i<s.size();i++){
    char target=s[i];
    for(int i=0;i<key[key_itr];i++){
      target--;
      if(target<'A'){
        target='z';
      }
      else if('Z'<target&&target<'a'){
        target='Z';
      }
    }
    result+=target;
    key_itr++;
    if(key_itr>=n){
      key_itr=0;
    }
  }
  cout<<result<<endl;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  while(1){
    int n;
    cin>>n;
    if(n==0){
      return 0;
    }else{
      Solve(n);
    }
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define fi first
#define se second
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n;
pii a[100004];
bool cmp(pii A,pii B){
	return A.fi+A.se<B.fi+B.se;
}
int dp[5003];
int main(){
	read(n);
	for (int i=1;i<=n;i++) read(a[i].fi),read(a[i].se);
	sort (a+1,a+1+n,cmp);
	for (int i=1;i<5003;i++) dp[i]=2000000001;
	for (int i=1;i<=n;i++)
		for (int j=i-1;j>=0;j--)
			if (dp[j]<=a[i].fi) dp[j+1]=min(dp[j+1],dp[j]+a[i].se);
	for (int i=5002;i>=0;i--)
		if (dp[i]!=2000000001){
			write(i);break;
		}
}

#include <algorithm>
#include <cstdio>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

constexpr ll inf = ll(1e18)+9;
int main() {
    // input
    int n; scanf("%d", &n);
    vector<pair<int, int> > hps(n);
    repeat (i, n) {
        int h, p; scanf("%d%d", &h, &p);
        hps[i] = { h, p };
    }
    // solve
    sort(whole(hps), [&](pair<int, int> hp1, pair<int, int> hp2) {
        return hp1.first + hp1.second < hp2.first + hp2.second;
    });
    vector<ll> dp(n + 1, inf);
    dp[0] = 0;
    for (auto hp : hps) {
        int h, p; tie(h, p) = hp;
        repeat_reverse (j, n) {
            if (dp[j] <= h) {
                setmin(dp[j + 1], dp[j] + p);
            }
        }
    }
    int result = 0;
    repeat (i, n + 1) {
        if (dp[i] < inf) {
            result = i;
        }
    }
    // output
    printf("%d\n", result);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100 * (10 - n) << endl;
    }
}

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

#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,T;
    cin>>N>>T;
    vector<int>t(N);
    for(int i=0;i<N;i++){
        cin>>t[i];
    }
    int a=N*T;
    for(int i=1;i<N;i++){
        if((T-(t[i]-t[i-1]))>0){
            a-=(T-(t[i]-t[i-1]));
        }
    }
    cout<<a<<endl;
    return 0;
}


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

int main() {
  int64_t N;
  cin >> N;
  int64_t minimum;
  for(int i = 0; i < 5; i++) {
    if(i == 0) {
      cin >> minimum;
    }
    else {
      int64_t a;
      cin >> a;
      minimum = min(minimum, a);
    }
  }
  cout << (N - 1) / minimum + 5 << endl;
}

#include<bits/stdc++.h>
using namespace std;
long long mi(long long A,long long B,long long C,long long D,long long E){
  return min(min(min(min(A,B),C),D),E);
}
int main(){
  long long N,A,B,C,D,E;cin>>N>>A>>B>>C>>D>>E;
  if(mi(A,B,C,D,E)==A){cout<<(N+A-1)/A+4;return 0;}
  if(mi(A,B,C,D,E)==B){cout<<(N+B-1)/B+4;return 0;}
  if(mi(A,B,C,D,E)==C){cout<<(N+C-1)/C+4;return 0;}
  if(mi(A,B,C,D,E)==D){cout<<(N+D-1)/D+4;return 0;}
  if(mi(A,B,C,D,E)==E){cout<<(N+E-1)/E+4;return 0;}
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Dinic {
  struct edge {
    int to, cap, rever;
    edge(int to, int cap, int rever):to(to), cap(cap), rever(rever){}
  };
  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int V):graph(V), level(V), iter(V){}
  void add_edge(int from, int to, int cap) {
    graph[from].emplace_back(to, cap, graph[to].size());
    graph[to].emplace_back(from, 0, graph[from].size()-1);
  }
  void bfs(int s) {
    fill(all(level), -1);
    queue<int> que;
    level[s] = 0;
    que.push(0);
    while(que.size()) {
      int v = que.front(); que.pop();
      for(edge& e : graph[v]) {
        if(e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
  }
  int dfs(int v, int t, int f) {
    if(v == t) return f;
    for(int& i = iter[v]; i < graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.cap > 0 && level[v] < level[e.to]) {
        int d = dfs(e.to, t, min(e.cap, f));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rever].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  int max_flow(int s, int t) {
    int flow = 0;
    while(true) {
      bfs(s);
      if(level[t] < 0) return flow;
      fill(all(iter), 0);
      int f; while((f = dfs(s, t, inf)) > 0) flow += f;
    }
  }
};

int main(){
    ll n;cin >> n;
    Dinic dn(2*n+2);
    ll s=0,t=2*n+1;
    vpl a(n),b(n);
    rep(i,n){
        cin  >> a[i].fi >> a[i].se;
    }
    rep(i,n){
        cin  >> b[i].fi >> b[i].se;
    }
    rep(i,n){
        dn.add_edge(s,i+1,1);
        dn.add_edge(i+1+n,t,1);
    }
    rep(i,n){
        rep(j,n){
            if(a[i].fi<b[j].fi&&a[i].se<b[j].se){
                dn.add_edge(i+1,n+1+j,1);
            }
        }
    }
    cout << dn.max_flow(s,t) <<endl;
}

#include<iostream>
#include<string>
#include<algorithm>
#define NC 5

using namespace std;

int C[ NC ];

bool isStraight(){
    for ( int i = 2; i < 5; i++ ){
	if ( C[i-1] != C[i] - 1 ) return false;
    }
    if ( C[4] == 13 ) return ( C[0] == 1 ) ? true : false;
    return ( C[0] == C[1] - 1 ) ? true : false;
}

bool isFourC(){
    for ( int i = 2; i < 4; i++ ) if ( C[i-1] != C[i] ) return false;
    return ( C[0] == C[1] || C[3] == C[4] );
}

bool isFullHouse(){
    if ( C[0] == C[1] && C[2] == C[3] && C[3] == C[4] ||
	 C[0] == C[1] && C[1] == C[2] && C[3] == C[4] ) return true;
    else return false;
}

bool isThreeC(){
    if ( C[0] == C[1] && C[1] == C[2] ||
	 C[1] == C[2] && C[2] == C[3] ||
	 C[2] == C[3] && C[3] == C[4] ) return true;
    else return false;
}

bool isPair(int pair){
    int sum = 0;
    for ( int i = 1; i < 5; i++ ) if ( C[i-1] == C[i] ) sum++;
    return sum == pair; // one pair ツつゥ two pair
}

string judge(){
    sort( C, C + NC );

    if ( isStraight() ) return "straight";
    else if ( isFourC() ) return "four card";
    else if ( isFullHouse() ) return "full house";
    else if ( isThreeC() ) return "three card";
    else if ( isPair(2) ) return "two pair";
    else if ( isPair(1) ) return "one pair";
    else return "null";
}

bool read(){
    char comma;
    if ( !(cin >> C[0]) ) return false;
    for ( int i = 1; i < NC; i++ ){
	cin >> comma >> C[i];
    }
    return true;
}

int main(){
    while ( read() ){
	cout << judge() << endl;
    }
    return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--)
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll size = s.length();
    for(ll i=0;i<min(size,n);i++)
    {
        cout<<s[i];
    }
    if(size>n)
        cout<<"...";

}
    // Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}

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

int main(){
    int a;
    string b;
    cin >> a >> b;

    if(a >= b.size()){
        cout << b;
    }else{
        cout << b.substr(0,a) << "...";
    }
    return 0;
}


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

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

  if(s.at(0)=='7' ||s.at(1)=='7' || s.at(2)=='7') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

#include<iostream>
//#include<algorithm>
#include<cmath>
#include<string>
//#include<set>
//#include<vector>
#include<iomanip>
using namespace std;
int main(){

    int n;
    cin >> n;
    if(n%10==7){cout<<"Yes"; return 0;}
    else{n/=10;}
    if(n%10==7){cout<<"Yes"; return 0;}
    else{n/=10;}
    if(n%10==7){cout<<"Yes"; return 0;}
    else{n/=10;}
    cout<<"No";
    return 0;
}


#include<iostream>
using namespace std;
int main(void){
	int date[100];
	int n,q;
	int i,j;

	while(cin>>n>>q,(n||q)){
		for(i=0;i<100;i++)date[i]=0;

		for(i=0;i<n;i++){
			int m;
			cin>>m;
			for(j=0;j<m;j++){
				int d;
				cin>>d;
				date[d]++;
			}
		}
		int max=0;
		for(i=0;i<100;i++){
			if(date[i]>date[max]){
				max=i;
			}
		}
		if(date[max]>=q){
			cout<<max<<endl;
		}else{
			cout<<0<<endl;
		}
	}
	return 0;
}

#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#define scanf_s scanf
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);

bool solve(void){
	int N,Q,i,j,k,gen,a,ans=0,ansa;
	vector<int> date[50];
	scanf("%d %d",&N,&Q);
	if(N==0){return false;}
	ansa=Q-1;
	for(i=0;i<N;i++){
		scanf("%d",&j);
		for(;j>0;j--){
			scanf("%d",&a);
			date[i].pub(a);
		}
	}
	for(i=1;i<100;i++){
		gen=0;
		for(j=0;j<N;j++){
			for(k=0;k<date[j].size();k++){
				if(date[j][k]==i){ gen++; }
			}
		}
		if(ansa<gen){
			ansa=gen;ans=i;
		}
	}
	if(i==100){printf("%d\n",ans);}
	return true;
}
int main(void){while(solve()){}return 0;}


#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main(){
    int n;
    string str, s1;
    string order;
    int a, b;
    cin >> str;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> order >> a >> b;
        if (order == "print") {
            for (int i = a; i <= b; i++) {
                cout << str[i];
            }
        cout << "\n";
        } else if (order == "reverse") {
            for (int i = a, j = b; i < j; i++, j--) swap(str[i], str[j]);
        } else if (order == "replace") {
            cin >> s1;
            str.replace(a, b-a+1, s1);
        }
    }
    return 0;
}

#include <stdio.h>
#include <string.h>

void op_print(char *str, int a, int b)
{
	for(int i = a; i <= b; ++i)
	{
		putchar(str[i]);
	}
	putchar('\n');
}

void op_replace(char *str, int a, int b, char *p)
{
	for(int i = a; i <= b; ++i)
	{
		str[i] = p[i - a];
	}
}

void op_reverse(char *str, int a, int b)
{
	for(; a < b; ++a, --b)
	{
		char temp;
		temp   = str[a];
		str[a] = str[b];
		str[b] = temp;
	}
}

int main()
{
	int q, a, b;
	char str[1024], p[1024], op[16];

	scanf("%s %d", str, &q);
	for(int i = 0; i < q; ++i)
	{
		scanf("%s %d %d", op, &a, &b);

		if(strcmp(op, "print") == 0)
		{
			op_print(str, a, b);
		}
		if(strcmp(op, "reverse") == 0)
		{
			op_reverse(str, a, b);
		}
		if(strcmp(op, "replace") == 0)
		{
			scanf("%s", p);
			op_replace(str, a, b, p);
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

vector<string> three = {
    "a..",
    "a..",
    ".bb"
};
vector<string> four = {
    "ahff",
    "ahgg",
    "bbde",
    "ccde"
};
vector<string> five = {
    "ahhgg",
    "ai..f",
    "bi..f",
    "b.jje",
    "ccdde"
};
vector<string> six = {
    "aa..hi",
    "bb..hi",
    "cc..jk",
    "..ddjk",
    "..eelm",
    "..fflm"
};
vector<string> seven = {
    "ahhii..",
    "aj..mm.",
    "bjk....",
    "b.k..oo",
    "c..l..p",
    "c..l..p",
    ".ddeeff"
};

int main() {
    int n = 0;
    cin >> n;
    if (n == 2) {
        cout << -1 << endl;
    } else if (n == 3) {
        for (auto s : three) {
            cout << s << endl;
        }
    } else {
        vector<string> ans(n);
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                ans.at(i).push_back('.');
            }
        }
        int mod = n%4;
        if (mod == 0) {
            for (int i=0; i<4; i++) {
                for (int j=0; j<4; j++) {
                    ans.at(i).at(j) = four.at(i).at(j);
                }
            }
        } else if (mod == 1) {
            for (int i=0; i<5; i++) {
                for (int j=0; j<5; j++) {
                    ans.at(i).at(j) = five.at(i).at(j);
                }
            }
        } else if (mod == 2) {
            for (int i=0; i<6; i++) {
                for (int j=0; j<6; j++) {
                    ans.at(i).at(j) = six.at(i).at(j);
                }
            }
        } else if (mod == 3) {
            for (int i=0; i<7; i++) {
                for (int j=0; j<7; j++) {
                    ans.at(i).at(j) = seven.at(i).at(j);
                }
            }
        }
        int cur = 4 + mod;
        while (cur + 4 <= n) {
            for (int i=0; i<4; i++) {
                for (int j=0; j<4; j++) {
                    ans.at(cur+i).at(cur+j) = four.at(i).at(j);
                }
            }
            cur += 4;
        }
        for (auto s : ans) {
            cout << s << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

int main(){

  int m;
  cin >> m;
  ll res = 0;
  ll sum = 0;
  rep(i,m){
    ll c,d;cin >> d >> c;
    sum += c*d;
    res += c;
  }
  res--;
  res += sum/9;
  if(sum%9 == 0)res--;
  cout << res << endl;

  return 0;
}

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int n,tot,sum;

signed main(){
	read(n);
	for(int i=1,x,y;i<=n;i++){
		read(x,y);
		tot+=y;sum+=x*y;
	}
	write(tot-1+(sum-1)/9);
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  double n;
  cin>>n;
  vector<vector<double>> d(n,vector<double>(2));
  rep(i,n)rep(j,2) cin>>d[i][j];
  vector<int> t(n);
  rep(i,n) t[i]=i;
  double sum=0;
  int cnt=0;
  do{
    for(int i=1;i<n;i++){
      sum+=sqrt((d[t[i]][0]-d[t[i-1]][0])*(d[t[i]][0]-d[t[i-1]][0])+(d[t[i]][1]-d[t[i-1]][1])*(d[t[i]][1]-d[t[i-1]][1]));
    }
    cnt++;
  }while(next_permutation(all(t)));
  printf("%.10f\n",sum/cnt);
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
using Graph = vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  double X[N];
  double Y[N];
  double sum = 0;
  int num = 0;
  FOR(i,0,N) cin >> X[i] >> Y[i];
  FOR(i,0,N-1) {
    FOR(j,i+1,N) {
      sum += sqrt((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]));
      num++;
    }
  }
  double ans = sum/num*(N-1);
  cout << fixed << setprecision(7) << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#define N 1001000
typedef long long ll;
template<typename T> inline void read(T &x) {
  x = 0; char c = getchar(); bool flag = false;
  while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
  while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
  if (flag) x = -x;
}
using namespace std;
const int P = 998244353;
inline ll quickpow(ll x, int k) {
  ll res = 1;
  while (k) {
    if (k & 1)  res = res * x % P;
    x = x * x % P;
    k >>= 1;
  }
  return res;
}
int n, m;
ll jie[N], jieni[N];
inline void init() {
  int up = n + m;
  jie[0] = jieni[0] = 1;
  for (int i = 1; i <= up; ++i) jie[i] = jie[i - 1] * i % P;
  jieni[up] = quickpow(jie[up], P - 2);
  for (int i = up - 1; i; --i)  jieni[i] = jieni[i + 1] * (i + 1) % P;
}
inline ll get_c(int n, int m) {
  ll res = jie[n] * jieni[m] % P * jieni[n - m] % P;
  return res;
}
inline void work() {
  ll res = 0;
  if (n < m)  swap(n, m);
  for (int i = 1; i <= m; ++i) {
    res = (res + get_c(i + i - 1, i) * get_c(n - i + m - i, n - i)) % P;
  }
  res = (res + n * get_c(n + m, n)) % P;
  res = res * quickpow(get_c(n + m, n), P - 2) % P;
  printf("%lld\n", (res % P + P) % P);
}
int main() {
  read(n), read(m); init();
  work();
  return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const ll MOD = 998244353;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll Rev(ll x) {
	return bin_pow(x, MOD - 2);
}
ll W;

const int LOG = 20;
const int N = 1 << 20;
ll w[N];
int rev[N];

void initFFT() {
	for (ll x = 2;; x++) {
		ll y = x;
		for (int i = 1; i < LOG; i++)
			y = mult(y, y);
		if (y == MOD - 1) {
			W = x;
			break;
		}
	}
	w[0] = 1;
	for (int i = 1; i < N; i++)
		w[i] = mult(w[i - 1], W);
	rev[0] = 0;
	for (int mask = 1; mask < N; mask++) {
		int k = 0;
		while(((mask >> k) & 1) == 0) k++;
		rev[mask] = rev[mask ^ (1 << k)] ^ (1 << (LOG - 1 - k));
	}
}

ll F[2][N];
void FFT(ll *A) {
	for (int i = 0; i < N; i++)
		F[0][rev[i]] = A[i];
	int t = 0, nt = 1;
	for (int lvl = 0; lvl < LOG; lvl++) {
		int len = 1 << lvl;
		for (int st = 0; st < N; st += (len << 1))
			for (int i = 0; i < len; i++) {
				ll ad = mult(F[t][st + len + i], w[i << (LOG - 1 - lvl)]);
				F[nt][st + i] = add(F[t][st + i], ad);
				F[nt][st + len + i] = sub(F[t][st + i], ad);
			}
		swap(t, nt);
	}
	for (int i = 0; i < N; i++)
		A[i] = F[t][i];
}

ll f[N], rf[N];
ll a[N];

ll getC(int n, int k) {
	if (k < 0 || k > n) return 0;
	return mult(f[n], mult(rf[k], rf[n - k]));
}

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

	initFFT();

	f[0] = 1;
	for (int i = 1; i < N; i++)
		f[i] = mult(f[i - 1], i);
	rf[N - 1] = Rev(f[N - 1]);
	for (int i = N - 1; i > 0; i--)
		rf[i - 1] = mult(rf[i], i);

	for (int k = 0; k < N / 2; k++) {
		a[k] = mult(f[2 * k], mult(rf[k], rf[k]));
	}
	FFT(a);
	for (int i = 0; i < N; i++)
		a[i] = mult(a[i], a[i]);
	FFT(a);
	reverse(a + 1, a + N);
	ll rN = Rev(N);
	for (int i = 0; i < N; i++) {
		a[i] = mult(a[i], rN);
		a[i] = mult(a[i], mult(rf[2 * i], mult(f[i], f[i])));
		a[i] = sub(a[i], 1);
		a[i] = mult(a[i], (MOD + 1) / 2);
		a[i] += i;
	}

	int n, m;
	scanf("%d%d", &n, &m);
	if (n < m) swap(n, m);
	if (n == m) {
		printf("%lld\n", a[n]);
		return 0;
	}

	ll ans = 0;

	for (int k = 0; k <= m; k++) {
		int L = n - m + k - 1;
		ll p = getC(L + k, k);
		if (k > 0)
			p = sub(p, getC(L + k, k - 1));
		p = mult(p, getC(2 * (m - k), m - k));
		ans = add(ans, mult(p, add(L + 1, a[m - k])));
	}
	ans = mult(ans, mult(rf[n + m], mult(f[n], f[m])));
	printf("%lld\n", ans);

	return 0;
}


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

#define rep(i, a, n) for(int i=(a);i<(n);++i)
#define per(i, a, n) for(int i=(a);i>(n);--i)
#define pb emplace_back
#define mp make_pair
#define lowbit(x) (x & -x)

typedef long long LL;
typedef pair<int, int> pii;

const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1.0);

const int M = 45;
const int N = 2e5 + 10;
int n;
char s[100];

void decode(int &c2, int &c5, int &m){
	int len = strlen(s);
	LL a, b;
	bool flag = 0;
	rep(i, 0, len){
		if(s[i] == '.'){
			sscanf(s, "%lld.%lld", &a, &b);
			flag = 1;
			m = len - i - 1;
			break;
		}
	}
	if(!flag){
		sscanf(s, "%lld", &a);
		b = 0;
		m = 0;
	}

	rep(i, 0, m)	a = a * 10;
	a = a + b;

	c2=0, c5=0;

	while(a % 2 == 0){
		a >>= 1;
		++c2;
	}
	while(a % 5 == 0){
		a /= 5;
		++c5;
	}

	int c = min(c2, c5);
	m -= c;
	c2 -= c;
	c5 -= c;
}

unordered_map<int, int> MP0, O, MP2[M], MP5[M];

int main(){
	scanf("%d", &n);

	int c2, c5, lft;

	LL ans = 0, ans1 = 0;

	rep(i, 0, n){
		scanf("%s", s);
		decode(c2, c5, lft);

		if(c2 > 0){
			MP2[c2][lft]++;
			O[lft]++;
		} else if(c5 > 0){
			MP5[c5][lft]++;
			O[lft]++;
		} else {
			MP0[lft]++;
		}
		if(lft <= 0)	ans1--;
	}

	for(auto it : MP0){
		for(auto it1 : MP0){
			if(it.first + it1.first <= 0)	ans1 += 1LL * it.second * it1.second;
		}
	}

	for(auto it : MP0){
		for(auto it1 : O){
			if(it.first + it1.first <= 0)	ans += 1LL * it.second * it1.second;
		}
	}

	rep(i, 0, M){
		for(auto it : MP2[i]){
			rep(j, 0, M){
				for(auto it1 : MP2[j]){
					if(it.first + it1.first <= 0){
						ans1 += 1LL * it.second * it1.second;
					}
				}
				for(auto it1 : MP5[j]){
					if(it.first + it1.first - min(i, j) <= 0){
						ans += 1LL * it.second * it1.second;
					}
				}
			}
		}

		for(auto it : MP5[i]){
			rep(j, 0, M){
				for(auto it1 : MP5[j]){
					if(it.first + it1.first<= 0){
						ans1 += 1LL * it.second * it1.second;
					}
				}
			}
		}
	}

	printf("%lld\n", ans + ans1 / 2);

	return 0;
}

#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;

int used[110];

int main()
{
	int n;
	cin >> n;
	vector<pii> x(n), y(n);
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		x[i] = make_pair(a, b);
	}
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		y[i] = make_pair(a, b);
	}
	sort(all(x));
	sort(all(y));
	int ans = 0;
	rep(i, n)
	{
		int m = -1;
		int index = -1;
		rep(k, n)
		{
			if (used[k])
				continue;
			if (x[k].first < y[i].first && x[k].second < y[i].second && x[k].second > m)
			{
				m = x[k].second;
				index = k;
			}
		}
		if(index >= 0){
			used[index] = 1;
			ans++;
		}
		}
	cout << ans << endl;
}


#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;

int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

 // 最大公約数計算

ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}

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

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<char, ll>map;

	string m = "MARCH";
	int n;
	cin >> n;

	cout << n/3 << endl;

	return 0;
}

#include <iostream>

using namespace std;

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

  int res = 0;
  int mn = 200001;
  for (int n = 0; n < N; ++n) {
    int A;
    cin >> A;
    if (A < mn) {
      ++res;
      mn = A;
    }
  }
  cout << res << endl;

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <functional>

int main (){

  int m,nmin,nmax,ans,diff;
  int point[200];
  while(1){
    scanf("%d %d %d",&m,&nmin,&nmax);
    if(m == 0 && nmin == 0 && nmax == 0) break;
    for(int i = 0;i < m;i++){
      scanf("%d",&point[i]);
    }
    //std::sort(point,point+m,std::greater<int>());
    //ans = nmin;
    ans = 0;
    diff = 0;
    for(int ss = nmin;ss <= nmax;ss++){
      if(point[ss-1] - point[ss] >= diff){
        diff = point[ss-1] - point[ss];
        ans = ss;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

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

  int h,w;
  cin >> h >> w;

  int a,b;
  cin >> a >> b;

  rep(i,h){
    rep(j,w){
      bool left,up;
      if(j<a) left = true;
      else left = false;

      if(i<b) up = true;
      else up = false;
      cout << (left^up);
    }
    cout << endl;
  }

  return 0;

}


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

int main(){

	int card[5], cnt, max_cnt, min_cnt, cnt_one;
	char cnm;

	while(cin >> card[0]){
		cnt = 1;
		for(int i=1; i<9; i++){
			if(i % 2 == 0){
				cin >> card[cnt];
				cnt++;
			}
			else cin >> cnm;
		}

		sort(card, card + 5);
		max_cnt = 1;
		min_cnt = 5;
		cnt_one = 0;
		cnt = 1;
		for(int i=0; i<4; i++){
			if(card[i] == card[i+1]) cnt++;
			else {
				min_cnt = min(min_cnt, cnt);
				if(cnt == 1) cnt_one++;
				cnt = 1;
			}
			max_cnt = max(max_cnt, cnt);
		}
		if(card[3] != card[4]) cnt_one++;

		if(max_cnt == 4) cout << "four card" << endl;
		else if(max_cnt == 3){
			if(min_cnt == 1) cout << "three card" << endl;
			else cout << "full house" << endl;
		}
		else if(max_cnt == 2){
			if(cnt_one == 3) cout << "one pair" << endl;
			else cout << "two pair" << endl;
		}
		else if(card[0] + 4 == card[4] || (card[0] == 1 && card[1] == 10)){
			cout << "straight" << endl;
		}
		else cout << "null" << endl;
	}

	return 0;

}


#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const string MINUSINF = "-";

void chmax(string &a, string b) {
    if (a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

ll match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[11000];

int main()
{
    ll N, M; cin >> N >> M;
    vll A(M);
    rep(i, M) cin >>  A[i];

    rep(i, 11000) dp[i] = MINUSINF;

    dp[0] = "";
    for (int i = 0; i <= N; i++) {
        if (dp[i] == MINUSINF) continue;
        for (auto a : A) chmax(dp[i + match[a - 1]], dp[i] + (char)('0' + a));
    }
    cout << dp[N] << endl;
    return 0;
}

#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#pragma warning (disable: 4996)
using namespace std;

int dat[10] = { 0,2,5,5,4,5,6,3,7,6 };

int N, M, A[1 << 18];
int dp[1 << 18];

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) cin >> A[i];

	for (int i = 0; i <= N; i++) dp[i] = -(1 << 30);
	dp[0] = 0;
	for (int i = 0; i <= N; i++) {
		for (int k = 1; k <= M; k++) dp[i + dat[A[k]]] = max(dp[i + dat[A[k]]], dp[i] + 1);
	}

	int val = N; string S = "";
	while (val > 0) {
		int r = 0;
		for (int i = 1; i <= M; i++) {
			if (val >= dat[A[i]] && dp[val] - 1 == dp[val - dat[A[i]]]) r = max(r, A[i]);
		}
		val -= dat[r]; S += ('0' + r);
	}
	//reverse(S.begin(), S.end());
	cout << S << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()

const int N = 1005, mod = 1e9 + 7;
int a, b, c, d, gt[N], dp[N][N], n;

int pw(int x, int i){
	int b = 1;
	for(; i; i >>= 1, x = x * x % mod) if(i & 1) b = b * x % mod;
	return b;
}
int p(int n, int k){
	return (gt[n] * pw(gt[n - k], mod - 2) % mod) % mod;
}
main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b >> c >> d;
	gt[0] = 1;
	for(int i = 1; i <= n; ++i) gt[i] = gt[i - 1] * i % mod;
	for(int i = 0; i <= n; ++i) dp[0][i] = 1;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			dp[i][j] = dp[i][j - 1]; if(a <= j && j <= b){
				for(int k = c; k <= d; ++k){
					if(i - j * k < 0) break;
					dp[i][j] = (dp[i][j] + dp[i - j * k][j - 1] * p(n - i + j * k, j * k) % mod * pw(gt[k], mod - 2) % mod * pw(pw(gt[j], k), mod - 2) % mod) % mod;
					dp[i][j] %= mod;
				}
			}
		}
	}
	cout << dp[n][n];
}

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	h2 -= h1;
	m2 -= m1;
	while(h2 > 0){
		m2 += 60;
		h2--;
	}
	cout << m2-k << endl;

	return 0;
}


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

using namespace std;

int main(){

	int a[10], b[10];

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

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

	sort(a, a + 10);
	sort(b, b + 10);

	printf("%d %d\n", (a[7] + a[8] + a[9]), (b[7] + b[8] + b[9]));

	return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int W[10],K[10];
  int score1=0,score2=0;
  for(int i=0;i<10;i++){
    cin >>W[i];
  }
  for(int i=0;i<10;i++){
    cin >>K[i];
  }

  sort(W,W+10);
  sort(K,K+10);

  for(int i=9;i>6;i--){
    score1+=W[i];}
  cout <<score1<<" ";
  for(int i=9;i>6;i--){
   score2+=K[i];}
  cout <<score2<<endl;
  return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, k, a[100010];
vector<int> vec[100010];
int ans;

int dfs(int v, int p) {
	int res = 0;
	for (int i = 0; i < (int)vec[v].size(); i++) {
		if (vec[v][i] == p)continue;
		res = max(res, dfs(vec[v][i], v));
	}
	if (res == k - 1) {
		if (p > 1)ans++;
		return 0;
	}
	return res + 1;
}

signed main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i != 1)vec[a[i]].push_back(i);
	}
	if (a[1] != 1)ans++;
	dfs(1, 0);
	cout << ans << endl;
}


#include<stdio.h>
#include<cmath>

int main(){
double x1,x2,y1,y2,r,R;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
r=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
R=sqrt(r);
printf("%lf\n",R);
return 0;
}

#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n] , b[n] , c[n];
    for( int i = 0 ; i < n ; i++ ) cin >> a[i];
    for( int i = 0 ; i < n ; i++ ) cin >> b[i];
    for( int i = 0 ; i < n ; i++ ) cin >> c[i];
    sort( a , a + n );
    sort( b , b + n );
    sort( c , c + n );
    ll x = 0 , d = 0 , e = 0;
    for( int i = 0 ; i < n ; i++ ) {
        d = 1ll * ( lower_bound( a , a + n , b[i] ) - a );
        e = 1ll * ( n - (upper_bound( c , c + n , b[i] ) - c ) );
        x += d * e;
    }
    cout << x;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e3+23;

int n;
int bio[N][N];
int a[N][N];
int dp[N][N];
vector<pair<int, int>> g[N][N];

int dfs(int x, int y) {
  int &ret = dp[x][y];
  if (ret) return ret;
  bio[x][y] = 1;
  ret = 1;
  for (const auto &v: g[x][y]) {
    if (bio[v.first][v.second] == 1) {
      printf("-1");
      exit(0);
    }
    ret = max(ret, 1+dfs(v.first, v.second));
  }
  bio[x][y] = 2;
  return ret;
}

void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n-1; ++j) {
      scanf("%d", a[i]+j);
      --a[i][j];
      if (j) {
	g[min(i, a[i][j-1])][max(i, a[i][j-1])]
	  .emplace_back(min(i, a[i][j]), max(i, a[i][j]));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if (bio[i][j]) continue;
      ans = max(ans, dfs(i, j));
    }
  }
  printf("%d", ans);

}
int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int mod=1e9+7;

int id[1005][1005];
vector<int>to[1000005];
bool visited[1000005];
int dp[1000005];
bool calculated[1000005];

int toid(int i,int j){
  if(i>j){swap(i,j);}
  return id[i][j];
}

int dfs(int v){
  if(visited[v]){
    if(!calculated[v]){
      return -1;
    }
    return dp[v];
  }
  visited[v]=1;
  dp[v]=1;
  for(int u:to[v]){
    int res=dfs(u);
    if(res==-1){return -1;}
    dp[v]=max(dp[v],res+1);
  }
  calculated[v]=1;
  return dp[v];
}

int main() {
  int N;
  cin>>N;
  vector<vector<int>>A(N,vector<int>(N-1));
  for(int i=0;i<N;i++){
    for(int j=0;j<N-1;j++){
      cin>>A[i][j];
      A[i][j]--;
    }
  }
  int v=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
       if(i<j){
         id[i][j]=v++;
       }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N-1;j++){
      A[i][j]=toid(i,A[i][j]);
    }
    for(int j=0;j<N-2;j++){
      to[A[i][j+1]].push_back(A[i][j]);
    }
  }
  int ans=0;
  for(int i=0;i<v;i++){
    int res=dfs(i);
    if(res==-1){
      cout<<-1<<endl;return 0;
    }
    chmax(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)

const int mod=1000000007;

int main(){
  int d,t,s;
  cin>>d>>t>>s;

if(d-t*s<=0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

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

const int BIG_NUM = 1e9;
//8+
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int d, t, s;
    cin >> d >> t >> s;
    double c1 = (double) d / s;

    if( c1 <= t) {
    	cout << "Yes";
    } else {
    	cout << "No";
    }
    return 0;
}


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

int main()
{
    string str, comm, sa, sb, sinj;
    cin >> str;

    int n, a, b;
    cin >> n;
    cin.ignore();

    for (int i = 0; i < n; i++)
    {
        getline(cin, comm, ' ');
        if (comm.substr(0, 5) == "print") {
            getline(cin, sa, ' ');
            getline(cin, sb, '\n');
            // cout << "sa = " << sa << " sb = " << sb << endl;
            a = stoi(sa);
            b = stoi(sb);
            // cout << "a = " << a << " b = " << b << endl;
            cout << str.substr(a, b - a + 1) << endl;
        }
        else if (comm.substr(0, 7) == "reverse") {
            getline(cin, sa, ' ');
            getline(cin, sb, '\n');

            a = stoi(sa);
            b = stoi(sb);

            string revstr = str.substr(a, b - a + 1);
            reverse(revstr.begin(), revstr.end());
            str = str.substr(0, a) + revstr + str.substr(b + 1, str.length() - b - 1);

            // cout << str << endl;
        } else {
            getline(cin, sa, ' ');
            getline(cin, sb, ' ');
            getline(cin, sinj, '\n');

            a = stoi(sa);
            b = stoi(sb);

            str = str.substr(0, a) + sinj + str.substr(b + 1, str.length() - b - 1);

            // cout << str << endl;
        }
    }
    return 0;
}

#include <iostream>
#include <string>
#include <string.h>
using namespace std;
#define SWAP(var,a,b) {var tmp=a; a=b; b=tmp;}

int main()
{
  string str;
  int n;
  cin >> str >> n;
  string order;
  string buf;
  char c;
  int a,b;
  string p;
  string ShowString[100];
  int count=0;

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

      cin >> order >> a >> b;

      if(order=="replace")
	{
	  cin >> p ;

	  str.replace(a,b-a+1,p);
	}
      else if(order=="reverse")
	{
	  /*
	  for(int j=a,k=0;j<(b-a+1)/2;j++,k++)
	    {
	      c=str[j];
	      str[j]=str[b-k];
	      str[b-k]=c;
	      cout << str[j] << str[b-k];
	      }*/
	  // SWAP(char,str[j],str[b-k]);
	  buf=str.substr(a,b-a+1);
	  for(int j=0;j<b-a+1;j++)
	    str[a+j]=buf[b-a-j];
	}
      else if(order=="print")
	{
	  ShowString[count]=str.substr(a,b-a+1);
	  count++;
	}
      else
	cout << "error \n";
    }

  for(int i=0;i<count;i++)
    cout << ShowString[i] << endl;

  return 0;

}


#include <cstdio>

int main(){
 int a;
 scanf("%d",&a);
 printf("%d\n",a*a*a);
}

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

int main() {
  int X, N, d, S;
  cin >> X;
  N = X;

  for (int i = 0; i < 9; i++) {
    if (N != 0) {
      d = N % 10;
      N /= 10;
      S += d;
    }
    else {
      break;
    }
  }

  if (X % S == 0) {
    cout << "Yes" << endl;
  }

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


#include <bits/stdc++.h>
using namespace std;
/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}
/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*ここから*/
int main() {
    int P,Q,R;
    cin >> P >> Q >> R;
    int max = 0;
    if(P>Q){
        max = P;
    }else{
        max = Q;
    }
    if(max<R){
        max = R;
    }
    cout << P+Q+R-max << endl;
}

#include <stdio.h>
int main()
{
    int hour_1;
    int hour_2;
    int min_1;
    int min_2;
    int k;
    scanf("%d %d %d %d %d", &hour_1, &min_1, &hour_2, &min_2, &k);
    int total_hour = hour_2 - hour_1;
    int total_minute = min_2 - min_1;
    int duration = (total_hour * 60) + total_minute - k;
    printf("%d\n", duration);
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,m;cin>>n>>m;
    vector<ll>x(n);
    vector<ll>y(m);
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    ll cnt1=0;
    rep(i,m-1){
        cnt1=(cnt1+((i+1)*(m-i-1)*(y[i+1]-y[i]))%inf)%inf;
    }
    ll cnt2=0;
    rep(i,n-1){
        cnt2=(cnt2+((i+1)*(n-i-1)*(x[i+1]-x[i]))%inf)%inf;
    }
    cout<<cnt1*cnt2%inf<<endl;
}

///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<double, null_type, less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
typedef long long ll;
typedef double dd;
typedef long double ldd;
typedef pair <int, int> pii;
typedef pair <pii , int> ppii;
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
#define all(x) x.begin() , x.end()
#define debug(x) cerr<< #x << " = " << x << endl
#define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
#define uop(x, y) pii(min(x, y), max(x, y))
#define out return cout << "No" << endl, 0
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
const int mx = 6e3 + 10;
int n, m, fact[mx], inv[mx], C[mx][mx], M2[mx], M3[mx], p[mx];
int _pow(int a, int b){
	if(!b)
		return 1;
	return ((_pow((a * a) % m, b >> 1) * ((b & 1) ? a : 1)) % m);
}
void pre(){
	fact[0] = 1;
	for(int i = 1; i <= 3 * n; i++)
		fact[i] = (fact[i - 1] * i) % m;
	inv[3 * n] = _pow(fact[3 * n] , m - 2);
	for(int i = 3 * n - 1; ~i; i--)
		inv[i] = (inv[i + 1] * (i + 1)) % m;
	for(int i = 0; i <= 3 * n; i++)
		for(int j = 0; j <= i; j++)
			C[i][j] = fact[i] * inv[j] % m * inv[i - j] % m;
	M2[0] = 1;
	for(int i = 2; i <= 3 * n; i += 2)
		M2[i] = M2[i - 2] * C[i][2] % m;
	M3[0] = 1;
	for(int i = 3; i <= 3 * n; i += 3)
		M3[i] = M3[i - 3] * C[i][3] % m;
	p[0] = 1;
	for(int i = 1; i <= 3 * n; i++)
		p[i] = p[i - 1] * 2 % m;
	return;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	pre();
	int ans = 0;
	for(int a = 0; a <= n; a++)
		for(int b = 0; b <= n; b++){
			int c = 3 * n - 3 * a - 2 * b;
			if(c < b)
				continue;
			int cnt = (C[3 * n][3 * a] * p[a] % m * M3[3 * a] % m * inv[a] % m) % m;
			cnt = cnt * (C[3 * n - 3 * a][2 * b] * M2[2 * b] % m * inv[b] % m) % m;
			ans = (ans + cnt) % m;
		}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define REP(i,n) for (int i = 0; i < n; ++i)

const int MAX = 1e5+10;

int N, M;
ll K;
ll X[MAX];

vi mult(vi a, vi b) {
    int n = a.size();
    vi res(n);
    REP (i, n) res[i] = b[a[i]];
    return res;
}

vi swap(vi ord, ll k) {
    int n = ord.size();
    vi res(n);
    REP (i, n) res[i] = i;

    while (k) {
        if (k&1) res = mult(res, ord);
        ord = mult(ord, ord);
        k >>= 1;
    }
    return res;
}

int main() {
    cin >> N;
    REP (i, N) cin >> X[i];

    cin >> M >> K;
    vi ord(N-1);
    REP (i, N-1) ord[i] = i;
    REP (_, M) {
        int a;
        cin >> a;
        int k = ord[a-2];
        ord[a-2] = ord[a-1];
        ord[a-1] = k;
    }

    ord = swap(ord, K);
    ll x = X[0];
    REP (i, N-1) {
        cout << x << "\n";
        x += X[ord[i]+1] - X[ord[i]];
    }
    cout << x << endl;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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;
}
int n;
vector<ll> x;
vector<ll> d;
vector<int> mul(vector<int>&a,vector<int>&b){
    int m = b.size();
    vector<int> res(m);
    for(int i=0;i<m;i++){
        res[i] = b[a[i]];
    }
    return res;
}
vector<int> calc(vector<int>&a,ll k){
    int m = a.size();
    if(k==0){
        vector<int> res;
        rep(i,m){
            res[i] = i;
        }
        return res;
    }else if(k==1){
        return a;
    }
    if(k%2==0){
        vector<int> res;
        res = calc(a,k/2);
        return mul(res,res);
    }else{
        vector<int> res;
        res = calc(a,k/2);
        res = mul(res,res);
        res = mul(res,a);
        return res;
    }
}
int main(){
    cin >> n;
    x.resize(n);
    d.resize(n-1);
    rep(i,n)cin >> x[i];
    rep(i,n-1){
        d[i] = x[i+1]-x[i];
    }
    int m;
    ll k;
    cin >> m >> k;
    vector<int>a(m);
    rep(i,m){
        cin >> a[i];
        a[i]-=2;
    }
    vector<int>b(n-1);
    rep(i,n-1){
        b[i] = i;
    }
    rep(i,m){
        swap(b[a[i]],b[a[i]+1]);
    }
    // rep(i,n-1){
    //     cerr << b[i] << " ";
    // }
    // cerr << endl;
    vector<int> res = calc(b,k);
    // for(int i=0;i<n-1;i++){
    //     cerr << res[i] << " ";
    // }
    // cerr << endl;
    for(int i=0;i<n-1;i++){
        x[i+1] = x[i] + d[res[i]];
    }
    for(int i=0;i<n;i++){
        cout << x[i] << "\n";
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int main(void)
{
	int N;

	scanf("%d", &N);
	cin.get();
	while(--N, N>=0){
		char instr[1001];
		char *t;

		gets(instr);
		while( (t = strstr(instr, "Hoshino")) != NULL){
			t += 6;
			*t = 'a';
		}

		printf("%s\n", instr);
	}

	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define BUFSIZE 1024

char buf[BUFSIZE];
int main()
{
	int n = atoi(fgets(buf, BUFSIZE, stdin));
	while (n--) {
		fgets(buf, BUFSIZE, stdin);
		for (int i = 0; i < strlen(buf); ++i) {
			if (strncmp(buf + i, "Hoshino", 7) == 0)
				buf[i+6] = 'a';
		}
		printf(buf);
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll>
#define tri pair<pll, ll>
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> >
#define mll map<ll, ll>
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);}
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    ll tc = 0;
    while(tc++ < t){
    	ll n, m, d;
        cin>>n>>m>>d;
        ld ans = 1.0*(m-1)*(n-d)/(n*1.0*n);
        if(d > 0)	ans *= 2.0;
        cout<<fixed<<setprecision(10)<<ans;
    }
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ld n,m,d;
    cin >> n >> m >> d;
    ld EX = (n-d)*2/(n*n);
    if(d == 0){
        EX = 1 / n;
    }
    ld ans = EX;
    rep(i,m-2){
        ans += EX;
    }
    cout << setprecision(20) << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int ans=0;
	For(i,0,1){
		int t=read();
		ans+=max(4-t,0);
	}
	if(ans==6)ans=10;
	cout<<ans*100000<<endl;
}

#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int d[] = { 300000, 200000, 100000 };
  int x, y; cin >> x >> y;

  int ans = 0;
  if (x <= 3) ans += d[x-1];
  if (y <= 3) ans += d[y-1];

  if (x == 1 && y == 1) ans += 400000;

  cout << ans << endl;

  return (0);
}