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

long long N;
long long A[200005];
int main(){
	cin >> N;
	for(long long i = 0; i < N; i++) {
		cin >> A[i];
	}
	set<long long> aset;
	for(long long i = 0; i < N; i++) {
		if(aset.count(A[i]) != 0) {
			cout << "NO" << endl;
			return 0;
		}
		aset.insert(A[i]);
	}
	cout << "YES" << endl;
}

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

int main(void) {
  string s; cin >> s;
  string c = "abcdefghijklmnopqrstuvwxyz";
  bool find_flag = false;

  for (int i=0; i<26; i++) {
    bool target = false;
    for (int j=0; j<s.length(); j++) {
      if (c[i] == s[j]) target = true;
    }
    if (!target) {
      cout << c[i] << endl;
      find_flag = true;
      break;
    }
  }

  if (!find_flag) cout << "None" << endl;
  return 0;
}


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

  ll c,x,y;
  fenwick_tree<ll> fw(n);

  rep(i,n){
    cin>>x;
    fw.add(i,x);
  }

  rep(i,q){
    cin>>c>>x>>y;
    if(c==0) fw.add(x,y);
    else cout<<fw.sum(x,y)<<endl;
  }

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct BIT {
    int n; vector<LL> bit;
    void init(int _n) { n = _n; bit.assign(n + 1, 0); }
    void m(int x, LL d) {
        while (x <= n)
            bit[x] += d, x += x & (-x);
    }
    LL q(int x) {
        LL ret = 0;
        while (x > 0)
            ret += bit[x], x -= x & (-x);
        return ret;
    }
} solver;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, q; cin >> n >> q;
    solver.init(n);
    for (int i = 0 ; i < n ; i++) {
        LL v; cin >> v;
        solver.m(i + 1, v);
    }
    while (q--) {
        int t; cin >> t;
        if (t == 0) {
            int x; LL v; cin >> x >> v;
            solver.m(x + 1, v);
        } else {
            int l, r; cin >> l >> r;
            cout << solver.q(r) - solver.q(l) << '\n';
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  string s;
  string t;
  cin>>s>>t;
  string d;
  if(s==t){cout<<s.size()<<endl;return 0;}
  else{
	  int ans=s.size()+t.size();
   for(int i=0;i<N;i++){
	  if(s.substr(i)==t.substr(0,N-i)){
       d=s.substr(0,i)+t;
	   int a=d.size();
	   ans=min(ans,a);
	  }
  }
   cout<<ans<<endl;return 0;
  }
  return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

// ref : https://atcoder.jp/contests/abc167/submissions/13086967

int main(){
    int n;
    cin >> n;
    vector<P> pos, neg;

    rep(i, n){
        string s;
        cin >> s;
        int tmp = 0, mn = 0;
        for(char c : s){
            if (c == '(') tmp++;
            else tmp--;
            mn = min(mn, tmp);
        }
        if (tmp >= 0) pos.push_back({mn, tmp});
        else neg.push_back({mn, tmp});
    }
    sort(pos.rbegin(), pos.rend());

    int tot = 0;

    for (auto p : pos){
        if (tot + p.first < 0) {
            cout << "No" << endl;
            return 0;
        }
        tot += p.second;
    }

    sort(neg.begin(), neg.end(), [](auto a, auto b){ return a.second - a.first > b.second - b.first; } ); // sum - mnが大きい順にソートする

    for(auto& p : neg){
        if(tot + p.first < 0){
            cout << "No" << endl;
            return 0;
        }
        tot += p.second;
    }

    if(tot != 0){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


#include<cstdio>
#include<vector>

using namespace std;

int n,m;
vector<int> tomo[1001];
int ss[1001];

void saiki(int s,int dps){
		ss[s]=1;
	if(dps==2){
		return;
	}
	for(int i=0;i<tomo[s].size();i++){
		saiki(tomo[s][i],dps+1);
	}
}

int main(){
	while(1){
	scanf("%d%d",&n,&m);
	if(n==0&&m==0){
		break;
	}
	for(int i=0;i<1001;i++){
		ss[i]=0;
		tomo[i].clear();
	}
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		tomo[a].push_back(b);
		tomo[b].push_back(a);
	}

	saiki(1,0);

	int cont=0;
	for(int i=2;i<=n;i++){
		cont+=ss[i];
	}
	printf("%d\n",cont);
	}
}

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

#define LIMIT 100001

int N, Q, K;
vector<map<long long, long long>> nodeDis(LIMIT);
vector<long long> kToNode(LIMIT);
vector<bool> check(LIMIT);
vector<unordered_set<int>> vg(LIMIT);

void makeDistance(int k, long long dis){
  check[k] = true;
  kToNode[k] = dis;
  for(auto x: vg[k]){
    if(check[x]){
      continue;
    }
    makeDistance(x, dis + nodeDis[k].at(x));
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> N;
  for(int i = 0; i < N-1; i++){
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    nodeDis[a][b] = c;
    nodeDis[b][a] = c;
    vg[a].insert(b);
    vg[b].insert(a);
  }
  cin >> Q >> K;
  K--;
  makeDistance(K, 0);
  /*
  for(int i = 0; i < N; i++){
    cout << i << " " << kToNode[i] <<endl;
  }
  //*/
  for(int i = 0; i < Q; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << kToNode[a] + kToNode[b] <<endl;
  }
}


#include<iostream>
#include<queue>
#include<vector>
using namespace std;
long long int gcd(long long int a, long long int b);
//int a[200000];
vector<int> graph[100000];
int flag[100000];
int main() {

	//F
	int n;
	cin >> n;
	int u, v;
	cin >> u >> v;
	int a, b;
	int i;

	for (i = 0; i < n - 1; i++) {
		cin >> a >> b;
		graph[a - 1].push_back(b - 1);
		graph[b - 1].push_back(a - 1);
	}
	u = u - 1;
	v = v - 1;
	queue<int> que;
	que.push(u);

	for (i = 0; i < n; i++) {
		flag[i] = -1;
	}
	flag[u] = 0;
	while (que.size()) {
		a = que.front(); que.pop();
		for (i = 0; i < graph[a].size(); i++) {
			if (flag[graph[a][i]] == -1) {
				que.push(graph[a][i]);
				flag[graph[a][i]] = flag[a] + 1;
			}
		}
	}
	vector<int> path;
	path.push_back(v);
	a = v;
	while (flag[a] != 0) {
		for (i = 0; i < graph[a].size(); i++) {
			if (flag[graph[a][i]] == flag[a] - 1) {
				a = graph[a][i];
				path.push_back(a);
				break;
			}
		}
	}
	//cout << flag[v] << endl;
	//vからuのパスができた．
	//if (flag[v] == 1) {
	//	cout << 0 << endl;
	//	return 0;
	//}
	int counter = 0;
	counter = counter + (int)((path.size() - 2) / 2);
	//cout << counter << endl;
	v = path[((path.size() - 2) / 2)];
	u = path[((path.size() - 2) / 2)+ 1 + (path.size() % 2)];
	int w = path[((path.size() - 2) / 2) + 1];

	//for (i = 0; i < path.size(); i++)cout << path[i] << ' ';
	//cout << endl;
	//cout << path.size() << 'u' << u << 'v' << v << endl;
	for (i = 0; i < n; i++) {
		flag[i] = -1;
	}
	flag[u] = 0;
	int maxflag = 0;
	que.push(u);
	while (que.size()) {
		a = que.front(); que.pop();
		for (i = 0; i < graph[a].size(); i++) {
			if ((flag[graph[a][i]] == -1) && (graph[a][i]!=v) && (graph[a][i] != w)) {
				que.push(graph[a][i]);
				flag[graph[a][i]] = flag[a] + 1;
				if (maxflag < flag[a] + 1) {
					maxflag = flag[a] + 1;
					//cout << maxflag << endl;
				}
			}
		}
	}
	//cout << counter << ' ' << maxflag << ' ' << path.size() << endl;
	//for (i = 0; i < 9; i++)cout << flag[i] << ' ';
	//cout << endl;
	counter = counter + maxflag + (path.size() % 2);
	cout << counter << endl;
	return 0;

	//E
	/*long long int N;
	cin >> N;
	long long int counter = 0;
	if (N % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	else {
		if (N == 0) {
			cout << 0 << endl;
			return 0;
		}
		else {
			N = N - (N % 10);
			N = N / 10;
			counter = counter + N;
			while (N > 0) {
				N = N - (N % 5);
				N = N / 5;
				counter = counter + N;
			}
			cout << counter << endl;
			return 0;
		}
	}
	*/

	//D

	/*int n;
	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int counter = 0;
	int seek = 1;
	for (i = 0; i < n; i++) {
		if (a[i] == seek) {
			counter++;
			seek++;
		}
	}
	if (counter == 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << n - counter << endl;
	return 0;*/

	//C
	/*long long int A, B;
	cin >> A >> B;
	cout <<  A * B / gcd(A, B) << endl;
	return 0;*/

	//B
	/*int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int i;
	for (i = 0; i < n; i++) {
		cout << s[i];
		cout << t[i];
	}
	cout << endl;
	return 0;*/
}
long long int gcd(long long int a,long long  int b) {
	if (a == 0) {
		return b;
	}
	else if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dis[2][N];
vector<int> g[N];

void bfs(int be, int id) {
  queue<int> q;
  q.push(be);
  dis[id][be] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : g[u]) {
      if (!dis[id][v]) {
        dis[id][v] = dis[id][u] + 1;
        q.push(v);
      }
    }
  }
}

int main() {
  int n, x, y, u, v, res = 0;
  cin >> n >> x >> y;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  bfs(x, 0);
  bfs(y, 1);
  for (int i = 1; i <= n; i++) {
    if (dis[0][i] < dis[1][i]) res = max(res, dis[1][i] - 2);
  }
  cout << res << endl;
  return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);
 ll a[n+10];
 ll mn;
 ll sm=0;
 ll cnt=0;
 rep(i,0,n){
  sc(a[i]);
  sm+=abs(a[i]);
  if(a[i]<0)cnt++;
  if(i==0)mn=abs(a[i]);
  else mn=min(mn,abs(a[i]));
  //cout<<sm<<" "<<mn<<endl;
 }

 //負の要素が偶数個だと全てを+にできる
 ans=0;
 rep(i,0,n-1){
  if(cnt%2==0){
   pr(sm);return 0;
  }
 }

 pr(sm-mn*2);
 return 0;}

#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vll a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vll dp1(n + 1, -HIGHINF), dp2(n + 1, -HIGHINF);
    dp1[0] = 0;
    for (int i = 0; i < n; i++) {
        chmax(dp1[i + 1], max(dp1[i] + a[i], dp2[i] - a[i]));
        chmax(dp2[i + 1], max(dp1[i] - a[i], dp2[i] + a[i]));
    }
    // DEBUG_VLL(dp1)
    // DEBUG_VLL(dp2)

    cout << dp1.back() << '\n';
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
vector<vector<char> >tmp;
vector<vector<int> >scr;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<int>d(m);
		vector<vi >cost(m,vector<int>(m));
		vector<vi >tim(m,vector<int>(m));
		vector<bool>used(m);
		rep(i,m)rep(j,m){cost[i][j]=inf;tim[i][j]=inf;}
		rep(i,n){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			a--;b--;
			cost[a][b]=cost[b][a]=c;
			tim[a][b]=tim[b][a]=d;
		}
		cin>>n;
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			a--;b--;
			rep(j,m)d[j]=inf;
			rep(j,m)used[j]=false;
			if(c){
				d[a]=0;
				while(1){
					int v=-1;
					rep(j,m)if(!used[j]&&(v==-1||d[v]>d[j]))v=j;
					if(v==-1)break;
					used[v]=true;
					rep(j,m)d[j]=min(d[j],d[v]+tim[v][j]);
				}
			}else{
				d[a]=0;
				while(1){
					int v=-1;
					rep(j,m)if(!used[j]&&(v==-1||d[v]>d[j]))v=j;
					if(v==-1)break;
					used[v]=true;
					rep(j,m)d[j]=min(d[j],d[v]+cost[v][j]);
				}
			}
			cout<<d[b]<<endl;
		}
	}
}

#define NODE 0
#define WEIGHT 1
#define COST_IDX 0
#define TIME_IDX 1
#define P_IDX 0
#define Q_IDX 1
#define R_IDX 2
#include <iostream>
#include <cstring>
using namespace std;

int n, m, k;
int weights[101][101][2];
int min_w[101][101][2];
int requests[200][3];

struct heap_queue {
  int arr[101];
  int *cmp_val;
  int lookup[101];
  int size=0;
};

void heap_push(int elm, heap_queue &q) {
  q.arr[q.size] = elm;
  int above, i = q.size++;
  while (i && q.cmp_val[q.arr[(above=(i-1)>>1)]] > q.cmp_val[elm]) {
    q.arr[i] = q.arr[above];
    q.lookup[q.arr[i]] = i;
    i = above;
  }
  q.arr[i] = elm;
  q.lookup[elm] = i;
}

int heap_pop(heap_queue &q) {
  int popped = q.arr[0];
  int elm = q.arr[--q.size];
  int below, i = 0;
  while ((below=(i<<1)+1) < q.size) {
    if (below+1 < q.size && q.cmp_val[q.arr[below+1]] < q.cmp_val[q.arr[below]])
      below++;
    if (q.cmp_val[q.arr[below]] >= q.cmp_val[elm])
      break;
    q.arr[i] = q.arr[below];
    q.lookup[q.arr[i]] = i;
    i = below;
  }
  q.arr[i] = elm;
  q.lookup[elm] = i;
  return popped;
}

void change_val(int elm, heap_queue &q) {
  int above, i = q.lookup[elm];
  while (i && q.cmp_val[q.arr[(above=(i-1)>>1)]] > q.cmp_val[elm]) {
    q.arr[i] = q.arr[above];
    q.lookup[q.arr[i]] = i;
    i = above;
  }
  q.arr[i] = elm;
  q.lookup[elm] = i;
}

bool read_input() {
  cin >> n >> m;
  if (n*m == 0)
    return false;
  memset(weights, 0, sizeof(int)*101*101*2);
  memset(min_w, 0, sizeof(int)*101*101*2);
  for (int i = 0; i < n; i++) {
    int a, b, c, t;
    cin >> a >> b >> c >> t;
    weights[a][b][COST_IDX] = weights[b][a][COST_IDX] = c;
    weights[a][b][TIME_IDX] = weights[b][a][TIME_IDX] = t;
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> requests[i][P_IDX] >> requests[i][Q_IDX] >> requests[i][R_IDX];
  }
  return true;
}

int resolve_request(int i_th) {
  int p, q, r;
  p = requests[i_th][P_IDX];
  q = requests[i_th][Q_IDX];
  r = requests[i_th][R_IDX];

  if (min_w[p][q][r])
    return min_w[p][q][r];

  int weight_sum_map[101];
  memset(weight_sum_map, -1, sizeof(int)*101);

  /* starting node has weight_sum of 0 */
  weight_sum_map[p] = 0;

  int in_queue[101] = {};
  heap_queue heap_q;
  heap_q.cmp_val = weight_sum_map;
  heap_push(p, heap_q);
  in_queue[p] = 1;

  while (heap_q.size) {
    int current_node = heap_pop(heap_q);
    in_queue[current_node] = 0;
    int weight_sum = weight_sum_map[current_node];
    min_w[p][current_node][r] = weight_sum;

    if (current_node == q)
      break;
    for (int i = 1; i < 101; i++) {
      if (!weights[current_node][i][r])
	continue;
      int adj_node = i;
      int w = weights[current_node][adj_node][r];
      int new_weight_sum =  weight_sum + w;
      if (weight_sum_map[adj_node] == -1 || new_weight_sum < weight_sum_map[adj_node]) {
	weight_sum_map[adj_node] = new_weight_sum;
	if (!in_queue[adj_node]) {
	  heap_push(adj_node, heap_q);
	  in_queue[adj_node] = 1;
	} else {
	  change_val(adj_node, heap_q);
	}
      }
    }
  }
  return weight_sum_map[q];
}

void solve() {
  //cout << endl;
  for (int i = 0; i < k; i++)
    cout << resolve_request(i) << endl;
}

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


#include <iostream>
#include <algorithm>
#include <vector>
typedef int TInt;
typedef std::vector<TInt> TList;

TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
int insertionSort(TList& A, int g)
{
    int cnt = 0;
    for(int i = g; i < A.size(); ++i){
        TInt v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
    return cnt;
}
void Reverse(TList& List)
{
    TList R;
    for(TList::reverse_iterator It = List.rbegin();
        It != List.rend();
        ++It)
    {
        R.push_back(*It);
    }
    std::swap(R, List);
}
TList GetG(int Max)
{
    TList G;
    int h = 1;
    while(h <= Max){
        G.push_back(h);
        h = 3 * h + 1;
    }
    // Reverse(G);
    std::reverse(G.begin(), G.end());
    return G;
}
int shellSort(TList& A, const TList& G)
{
    int cnt = 0;
    for(TList::const_iterator It = G.begin();
        It != G.end();
        ++It){
        cnt += insertionSort(A, *It);
    }
    return cnt;
}
void OutputLine(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << " " << *It;
    }
    std::cout << std::endl;
}
void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    // std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << *It << std::endl;
    }
}
int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    TList A = Input();
    TList G = GetG(A.size());
    int cnt = shellSort(A, G);
    std::cout << G.size() << std::endl;
    OutputLine(G);
    std::cout << cnt << std::endl;
    Output(A);
    return 0;
}

#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;

	while (cin >> n, n){
		vector<pair<double, string>> veg(n);
		REP(i, n){
			double a, b, c, d, e, f, g, h, m;
				cin >> veg[i].second;
				cin >> a >> b >> c >> d >> e >> f >> g >> h >> m;
				veg[i].first = -(m*h*g-a)/((b+c+d)+(e+f)*m);

		}
		SORT(veg);
		REP(i, n){
			cout << veg[i].second << endl;
		}
		cout << '#' << endl;
	}
}


// A - 01 Matrix

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int grid[1000][1000];

int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			if ((i < B && j < A) || (i >= B && j >= A)) {
				grid[i][j] = 0;
			} else {
				grid[i][j] = 1;
			}
		}
	}

	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			cout << grid[i][j];
		}
		cout << endl;
	}

	return 0;
}

#include <iostream>

using namespace std;
int main(void){

    int n,i,a[100];
    cin >> n;

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

    for(i=n-1;i>=0;i--){
        cout << a[i];
        if(i!=0) cout << " ";
        else cout << endl;
    }

}


#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
int a[100000];
vector<int> G[100000];
int in[100000];
int N, K;
int ans;
int solve(int v) {
	if (G[v].size() == 0) return 0;
	int ma = 0;
	for (int to : G[v]) {
		int t = solve(to) + 1;
		if (t == K && v > 0) {
			t = 0;
			ans++;
		}
		ma = max(ma, t);
	}
	return ma;

}
int main() {
	cin >> N >> K;
	rep(i, N) {
		cin >> a[i];
		a[i]--;
	}
	if (a[0] != 0) ans++;
	for (int i = 1; i < N; i++) {
		G[a[i]].push_back(i);
	}
	solve(0);
	cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int x_max = 100004;
const int n_max = 205;

signed main(){
    int n,x;
    cin >> n >> x;
    int A[n];
    REP(i,n) cin >> A[i];
    sort(A,A+n);

    int dp[2][x_max];
    REP(j,x_max) dp[0][j] = j % A[0];
    FOR(i,1,n){
        REP(j,x_max){
            dp[i%2][j] = 0;
            Add(dp[i%2][j],dp[(i-1)%2][j % A[i]]);
            Add(dp[i%2][j],i * dp[(i-1)%2][j]);
        }
    }
    cout << dp[(n-1)%2][x] << endl;

}


#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

typedef pair<int, int> P;
typedef pair<P, P> PP;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int a[510][510];
    rep(i, H) {
        rep(j, W) {
            cin >> a[i][j];
        }
    }
    vector<PP> v;
    rep(i, H) {
        rep(j, W - 1) {
            if(a[i][j] % 2 == 1) {
                a[i][j]--;
                a[i][j + 1]++;
                v.push_back({{i, j}, {i, j + 1}});
            }
        }
    }
    rep(i, H - 1) {
        if(a[i][W - 1] % 2 == 1) {
            a[i][W - 1]--;
            a[i + 1][W - 1]++;
            v.push_back({{i, W - 1}, {i + 1, W - 1}});
        }
    }
    cout << v.size() << endl;
    for(auto& e: v) {
        cout << e.first.first + 1 << " ";
        cout << e.first.second + 1 << " ";
        cout << e.second.first + 1 << " ";
        cout << e.second.second + 1<< endl;
    }

    return 0;
}

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

int main() {
	int k, t;
	cin >> k >> t;
	vector<int>a(t);
	for (int i = 0; i < t; i++)cin >> a.at(i);
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	if (a.at(0) <= ceil((double)k / 2))cout << 0 << endl;
	else {
		if (k % 2 == 0)cout << 1 + 2 * (a.at(0) - ceil((double) k/2 ) - 1) << endl;
		else cout << 2 * (a.at(0) - ceil((double)k / 2)) << endl;
	}
}


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

int main()
{
	string s;
	cin >> s;
	cout << s.substr(0, s.size() - 8) << endl;
}

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

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

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


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

int main() {
    string s;
    cin >> s;
    int ans = 7;
    string w[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
    for (unsigned int i = 0; i < 7; i++) {
        if(s == w[i]) {
            ans -= i;
        }
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

int main() {

    string arr[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin>>s;
    int x = find(arr,arr+7,s)-arr;
    cout<<7-x<<endl;

    return 0;
}


#include<iostream>
using namespace std;
int main(){
	int a,b,k,i;
	cin>>a>>b>>k;
	for(i=0;i<k;i++){
		if(i&1){
			a+=(b>>=1);
		}else{
			b+=(a>>=1);
		}
	}
	cout<<a<<" "<<b;
	return 0;
}

#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

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

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }

};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }
};

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll a, b;
  cin >> a >> b;
  ll k;
  cin >> k;
  for(ll i=0;i<k;i++){
    if(a%2==1)a-=1;
    b += a/2;
    a/=2;
    i++;
    if(i==k)break;
    if(b%2==1)b-=1;
    a += b/2;
    b/=2;
  }
  cout << a << " " << b << endl;
  return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef int_fast64_t ll;

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    constexpr ModFact() : fact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
    }
};

ModFact<100000, ll, MOD> fact;

ll N, M, ans = 1, cnt = 1;
constexpr ll th = 1LL<<45;
char S[200000];

int main() {
    scanf("%lld\n", &N);
    M = N << 1;
    fread_unlocked(S, 1, M, stdin);
    if(S[0] == 'B' && S[M-1] == 'B') {
        bool f = false;
        for(size_t i = 0; i < M-1;) {
            if(S[i++] == S[i]) f ^= true;
            if(f) {
                ans *= (cnt << 1) - i;
                if(ans > th) ans %= MOD;
            }
            else if(++cnt > N) break;
        }
        if(cnt != N) ans = 0;
        else ans = ((ans % MOD) * fact.fact[N]) % MOD;
    } else ans = 0;
    printf("%lld\n", ans);
    return 0;
}

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

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

    string res = "AC";
    int C_cnt = 0;
    if (s.at(0) == 'A') {
        for (int i = 1; i < s.size(); i++) {
            if (s.at(i) == 'C') {
                if (2 <= i && i <= (s.size()-2)) {
                    C_cnt++;
                } else {
                    res = "WA";
                }
            } else {
                if (!('a' <= s.at(i) && s.at(i) <= 'z')) res = "WA";
            }
        }
        if (C_cnt != 1) res = "WA";
    } else {
        res = "WA";
    }

    cout << res << endl;

    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
char s[200005];
int n,cnt[26];
ll ans=0;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)cnt[s[i]-'a']++;
	ans=1;
	for(int i=0;i<26;i++)for(int j=i+1;j<26;j++)ans+=1ll*cnt[i]*cnt[j];
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll ans=1;
    map<char,int>mp;
    rep(i,n){
        mp[s[i]]++;
        ans+=i+1-mp[s[i]];
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll mn = INF;
    REP(i,0,SZ(S)-2) {
        ll N = 100*(S[i]-'0') + 10*(S[i+1]-'0') + (S[i+2]-'0');
        mn = MIN(mn,abs(N-753));
    }
    PR(mn);

    return 0;
}

/*

*/

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);

#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
    // cout<<c<<endl;
    string s;
    cin>>s;
    n = (int)s.size();

    int ans =753;
    int mini=INF;
    for (int i = 0,j=2; i <=n-3; i++)
    {
    	/* code */
    	// j++;
    	string str=s.substr(i,3);

    	// watch(str-"0");
    	int x = stoi(str);
    	// debug(x);
    	mini=min(mini,abs(ans-x));

    }
    cout<<mini<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9+7 ;

const ll INF = 1e18 ;

int main(){

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

    int N;
    cin  >>  N;

    vector<vector<int>> A(N, vector<int>(2));

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

    auto comp = [&](vector<int>& a, vector<int>& b) {
        return a[0] + a[1] < b[0] + b[1];
    };

    sort(A.begin(), A.end(), comp);

    vector<vector<ll>> dp (N+1 , vector<ll> (N+1, INF));

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

        dp[i][0] = 0 ;
    }

    for(int i = 1 ; i <= N; ++i){
        for(int j = 1 ; j <= i ; ++j ){
            dp[i][j] = dp[i-1][j];
            if (A[i-1][0] >= dp[i-1][j-1]){
                dp[i][j] = min(dp[i][j] , dp[i-1][j-1] + A[i-1][1]);
            }
        }
    }

    for(int j = N ;  j >= 0; --j){
        if (dp[N][j] != INF){
            cout <<  j << "\n";
            break;
        }
    }

    return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vs s(b*2+1);
    rep(i, b*2+1) rep(j, a*2+1) {
        s[i].pb(((i+j)%2)+'0');
    }
    rep(i, b*2+1) for (int j=a*2+1; j<w; ++j) s[i].pb(s[i].back());
    for (int j=b*2+1; j<h; ++j) {
        s.pb(s.back());
    }
    if (w<=a*2) rep(i, h) s[i].pop_back();
    rep(i, h) cout << s[i] << endl;
    return 0;
}


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

int main()
 {
 	int p,q,r,a,b;
 	cin>>p>>q>>r;
	a=min(p+q,q+r);
	b=min(a,p+r);
	cout<<b<<endl;
	return 0;
}

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int n,x[1000010],p;
char s[1000010],t[1000010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,l;
	scanf("%d%s%s",&n,&s,&t);
	for(i=n-1,j=n,k=0,l=0;i>=0;i--)
	  {
	   if(j>i && t[i]!=s[i])
	     j=i;
	   if(j<=i && t[i]!=s[j])
	     {
	      for(;j>=0 && t[i]!=s[j];j--);
	      if(j<0)
	        {
	         printf("-1\n");
	         return 0;
	        }
	      k++;
	      l++;
	      x[j+l]++;
	      p=max(p,k);
	     }
	   k-=x[i+l];
	   x[i+l]=0;
      }
    printf("%d\n",p);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

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

unordered_map<ll, ll> memo;

ll inv(ll a) {
    if(memo.find(a) != memo.end()) return memo[a];
    ll x, y;
    extgcd(a, MOD, x, y);
    return memo[a] = (x + MOD) % MOD;
}

int main(){
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    ll f[1001];
    f[0]=1;
    rep(i,n) f[i+1]=f[i]*(i+1)%MOD;
    vector<vector<ll>> s(n+1,vector<ll>(n+1,0));
    rep(i,n+1) s.at(0).at(i)=1;
    for (ll i=a;i<=b;i++){
        rep(k,n+1){
        s.at(k).at(i)=s.at(k).at(i-1);
        ll in=1;
        ll invf=inv(f[i]);
        rep(j,c) in=in*invf%MOD;
        for (int j=c;j<=min(d,k/i);j++){
            ll tmp=f[n-k+i*j]*inv(f[n-k])%MOD;
            tmp=tmp*in%MOD;
            in=in*invf%MOD;
            tmp=tmp*inv(f[j])%MOD;
            (s.at(k).at(i)+=s.at(k-i*j).at(i-1)*tmp%MOD)%=MOD;
        }
        }

    }
    cout << s.at(n).at(b)%MOD << endl;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007LL;

ll dp[110][10];
bool memo[110][10];
vector<ll> a;
ll W;

ll f(ll i, ll j){
  if(memo[i][j]) return dp[i][j];
  memo[i][j]=true;
  dp[i][j]=0LL;
  if(j>=2) dp[i][j]+=(f(i-1,j-1)*(a[j-2]*a[W-j]))%mod;
  dp[i][j]+=(f(i-1,j)*(a[j-1]*a[W-j]))%mod;
  if(j<=W-1) dp[i][j]+=(f(i-1,j+1)*(a[j-1]*a[W-j-1]))%mod;
  dp[i][j]%=mod;
  return dp[i][j];
}

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

int main() {
  ll H,K;
  cin>>H>>W>>K;
  a.assign(W+1,1LL);
  for(ll i = 2LL;i <= W;i++){
    a[i]=a[i-1LL]+a[i-2LL];
  }
  memo[0][1]=true;
  dp[0][1]=1LL;
  for(int i = 2;i <=W;i++){
    memo[0][i]=true;
    dp[0][i]=0LL;
  }
  cout<<f(H,K)<<endl;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  if(n%k==0) cout<<0<<endl;
  else cout<<1<<endl;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.beggin(), x.end(), greater<t>());
#define dump(x)  cout << #x << " = " << (x) << endl
#define vuniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define minse(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

int main(){
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; i++) {
        cout << (i == x - k + 1 ? "": " ") << i;
    }
    cout << endl;
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    vector<int> C(N);
    ll totalB = 0;
    rep(i, N){
        cin >> A[i] >> B[i];
        C[i] = A[i] + B[i];
        totalB += B[i];
    }

    sort(C.begin(), C.end());
    int n = (N+1) / 2;
    ll totalA = 0;
    rep(i, n){
        totalA += C[N-1-i*2];
    }

    cout << totalA - totalB << endl;

    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define INF 99999999
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    long long ans = 0;
    cin >> n;
    vector <vector<int>> v(n, vector<int>(3));
    int a, b, c;
    for (vector<int>& tmp : v) {
        cin >> a >> b;
        c = a+b;
        tmp[0] = c; tmp[1] = a; tmp[2] = b;
        ans -= b;
    }
  /*
    for(vector<int> tmp : v) {
        cout << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
    }
    */
    sort(v.begin(), v.end(), greater<>());
    for(int i = 0; i < n; i += 2) {
        ans += v[i][0];
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
#define N 50

int main(){
	while(1){
		int n,m;
		int ca[N];
		cin >> n >> m;
		if(!n&&!m) break;
		fill(ca,ca+n,0);

		int wan = m;
		int k = 0;
		while(1){
			while(wan){
				ca[k]++;
				k++;
				k = k%n;
				wan--;
			}
			if((k==0&&ca[n-1]==m)||(ca[k-1]==m)){
				break;
			}else{
				wan = ca[k];
				ca[k] = 0;
				k++;
				k = k%n;
			}
		}
		if(!k){
			cout << n-1 << endl;
		}else{
			cout << k-1 << endl;
		}
	}
	return 0;
}

#include<iostream>
#include<stdio.h>
#include<cmath>
#include<vector>
using namespace std;
#define loop(i,a,b) for(int i=a,i<b;i++)
#define rep(i,a) loop(i,0,a)
int main(){
  int n,p;
  while(cin>>n>>p,n||p){
    int wan=p;
    vector<int>in(n);
    int to=0;
    while(1){
      if(wan){
	wan--;
	in[to]++;
      }else{
	wan+=in[to];
	in[to]=0;
      }
      if(in[to]==p)break;
      to++;
      if(to==n)to=0;
    }
    cout<<to<<endl;
  }
}


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

int n,k,d[10];

int sum(int a,int b,int c=0,int d=0){
	int x=a*(b>=10?100:10)+b;
	if(k==2)return x;
	x=x*(c>=10?100:10)+c;
	if(k==3)return x;
	return x=x*(d>=10?100:10)+d;
}

int main(){
	while(scanf("%d%d",&n,&k),n){
		for(int i=0;i<n;i++)scanf("%d",&d[i]);
		sort(d,d+n);
		vector<int> data;
		for(int i=n-1;i>=0;i--){
			for(int j=n-1;j>=0;j--){
				if(i==j)continue;
				if(k==2){
					data.push_back(sum(d[i],d[j]));
					continue;
				}
				for(int r=n-1;r>=0;r--){
					if(i==r||j==r)continue;
					if(k==3){
						data.push_back(sum(d[i],d[j],d[r]));
						continue;
					}
					for(int z=n-1;z>=0;z--){
						if(i==z||j==z||r==z)continue;
						data.push_back(sum(d[i],d[j],d[r],d[z]));
					}
				}
			}
		}
		sort(data.begin(),data.end());
		data.erase(unique(data.begin(),data.end()),data.end());
		printf("%ld\n",data.size());
	}
}


#include <iostream>
using namespace std;

int main() {
	int m,min,max,ten[200],gap=10001,sa;

	cin>>m>>min>>max;

	while(1){
		if(m==0 && min==0 && max==0){
			break;
		}
	    for(int i=1;i<=m;i++){
    		cin>>ten[i];
    	}
    	for(int i=min;i<=max;i++){
    		if(gap>=ten[i+1]-ten[i]){
	    		gap=ten[i+1]-ten[i];
    			sa=i;
	    	}
	    }
    	cout<<sa<<endl;
    	gap=10001;
    	sa=0;
	    cin>>m>>min>>max;
	}

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll m,n1,n2;
  while(cin >> m >> n1 >> n2 && m+n1+n2){
    vector<ll> v(m);
    rep(i,m){
      cin >> v[i];
    }
    sort(all(v));
    ll gapM = -1,ans = 0;
    REP(i,n1,n2+1){
      if(gapM <= v[m-i] - v[m-i-1]){
        gapM = v[m-i] - v[m-i-1];
        ans = i;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b)+min(c,d) << endl;
}

#include<iostream>
using namespace std;

int main(){
    int a,b,c,d,e,f,m,n;
    cin >> a >> b >> c >> d >> e >> f;

    if(a<b && a<c && a<d) m=b+c+d;
    if(b<a && b<c && b<d) m=a+c+d;
    if(c<a && c<b && c<d) m=a+b+d;
    if(d<a && d<b && d<c) m=a+b+c;
    if(e<f){
        n=f;
    }else{
        n=e;
    }
    cout << m+n << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 1e9;

void insertion_sort(vector<int>& A, int n, int g, int& cnt)
{
  for (int i = g; i < n; ++i) {
    int key = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > key) {
      A[j + g] = A[j];
      j -= g;
      ++cnt;
    }
    A[j + g] = key;
  }
}

void shell_sort(vector<int>& A, int n, int& cnt)
{
  vector<int> G;
  int h = 1;
  G.push_back(h);
  int upper = n / 2;
  // if (n >= 1000) { upper = n / 9; }
  // else if (n >= 100) { upper = n / 7; }
  for (int i = 3 * h + 1; i < upper; i = 3 * i + 1) {
    G.push_back(i);
  }
  reverse(G.begin(), G.end());
  int m = G.size();
  fprintf(stdout, "%d\n", m);
  for (int i = 0; i < m; ++i) {
    if (i) { fprintf(stdout, " "); }
    fprintf(stdout, "%d", G[i]);
  }
  fprintf(stdout, "\n");
  for (int i = 0; i < m; ++i) {
    insertion_sort(A, n, G[i], cnt);
  }
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &A[i]);
  }
  int cnt = 0;
  shell_sort(A, n, cnt);
  fprintf(stdout, "%d\n", cnt);
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, "%d\n", A[i]);
  }
  return 0;
}

#include <iostream>
#include <vector>

template<typename T>
void print_ary(std::vector<T> ary, char delim = '\n') {
    for(int i = 0; i < ary.size()-1; i++) {
        std::cout << ary[i] << delim;
    }
    std::cout << ary[ary.size()-1];
}

template<typename T>
void insertion_sort(std::vector<T>&& ary) {
    for (int i = 1; i < ary.size(); i++) {
        int target = ary[i];
        int j = i - 1;
        while(j >= 0 &&  ary[j] > target) {
            ary[j+1] = ary[j];
            j--;
        }
        ary[j+1] = target;
        print_ary(ary, ' ');
        std::cout << std::endl;
    }
}

template<typename T>
void bubble_sort(std::vector<T> && ary) {
    int n = ary.size();
    bool flag = true;
    int counter = 0;
    while (flag) {
        flag = false;
        for (int j = n - 1; j > 0; j--) {
            if (ary[j] < ary[j - 1]) {
                std::swap(ary[j], ary[j - 1]);
                flag = true;
                counter++;
            }
        }
    }
    print_ary(ary, ' ');
    std::cout << std::endl << counter << std::endl;;
}

template<typename T>
void selection_sort(std::vector<T>&& ary){
    int counter = 0;
    for (int i = 0; i < ary.size(); i++) {
        int min_index = i;
        for(int j = i + 1; j < ary.size(); j++) {
            if (ary[min_index] > ary[j]) {
                min_index = j;
            }
        }
        if(i != min_index) {
            std::swap(ary[i], ary[min_index]);
            counter++;
        }
    }
    print_ary(ary, ' ');
    std::cout << std::endl << counter << std::endl;;
}

template<typename T>
void insertion_sort(std::vector<T>&& ary, int g, int& cnt) {
    int n = ary.size();
    for (int i = g; i < n; i++) {
        int target = ary[i];
        int j = i - g;
        while(j >= 0 && ary[j] > target) {
            ary[j + g] = ary[j];
            cnt++;
            j -= g;
        }
        ary[j + g] = target;
    }
}

template<typename T>
void shell_sort(std::vector<T>&& ary){
    int cnt = 0;
    std::vector<int> G;
    for(int h = 1; ; ){
        if(h > ary.size())
            break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    std::cout << G.size() << std::endl;
    for(int i = G.size() - 1; i >= 0; i--) {
        insertion_sort(std::move(ary), G[i], cnt);
        std::cout << G[i];
        if (i != 0) {
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
    std::cout << cnt << std::endl;
    print_ary(ary);
}

int main(int argc, char const* argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> ary(n);
    for (auto &i: ary) {
        std::cin >> i;
    }
    shell_sort(std::move(ary));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n;  cin >> n;
    map<int, int> a;
    a[0] = 3;
    ll res=1;
    REP(i, n){
        int x;  cin >> x;
        res *= a[x];
        res %= MOD;
        a[x] -= 1;
        a[x+1] += 1;
    }
    cout << res << endl;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  vi v(4);

  rep(i, 4) v[i] = in();
  sort(all(v));
  print(v[1] + v[2] + v[3] + max(in(), in()));

  return (0);
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll A,B,M,t;
	vector<ll>AA,BB,ANS;
	cin>>A>>B>>M;
	rep(i,A){
		cin>>t;
		AA.push_back(t);
	}
	rep(i,B){
		cin>>t;
		BB.push_back(t);
	}
	rep(i,M){
		ll x,y,z,zz;
		cin>>x>>y>>z;
		zz=AA[x-1]+BB[y-1]-z;
		ANS.push_back(zz);
	}
	sort(AA.begin(),AA.end());
	sort(BB.begin(),BB.end());
	ANS.push_back(AA[0]+BB[0]);
	sort(ANS.begin(),ANS.end());
	cout<<ANS[0]<<endl;
}

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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int>a(A);
  vector<int>b(B);
  vector<vector<int>>xyc(3, vector<int>(M));
  for(int i=0; i<A; i++)cin >> a.at(i);
  for(int i=0; i<B; i++)cin >> b.at(i);
  for(int i=0; i<M; i++){
    for(int j=0; j<3; j++){
      cin >> xyc.at(j).at(i);
    }
  }

  int mina = a.at(0);
  int minb = b.at(0);
  for(int i=0; i<A; i++){
    if(mina > a.at(i))mina = a.at(i);
  }
  for(int i=0; i<B; i++){
    if(minb > b.at(i))minb = b.at(i);
  }

  int ans = mina + minb;

  for(int i=0; i<M; i++){
    int waribiki = a.at(xyc.at(0).at(i)-1) + b.at(xyc.at(1).at(i)-1) - xyc.at(2).at(i);
    if(ans > waribiki)ans = waribiki;
  }

  cout << ans << endl;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

vector < ll > fact(N);

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

ll inv(ll a){
  return pwr(a, mod - 2);
}

ll comb(int n, int r){
  return (((fact[n] * inv(fact[n - r]) % mod) * inv(fact[r])) % mod);
}

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

  fact[0] = 1;
  for(int i = 1; i < N; i++) fact[i] = (i * fact[i - 1]) % mod;

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

  ll ans = 1;
  for(int i = 2; i <= sqrt(m); i++){
    if(m % i == 0){
      int cnt = 0;
      while(m % i == 0){
        cnt++;
        m /= i;
      }
      ans = (ans * comb(n + cnt - 1, n - 1)) % mod;
    }
  }
  if(m > 1){
    ans = (ans * n) % mod;
  }

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

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

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef pair<ll,ll> PLL;

#define REP(x,l,u) for(ll x = l; x < u; x++)
#define RREP(x,l,u) for(ll x = l; x >= u; x--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mst(x,v) memset(x, v, sizeof(x))
#define sz(x) (ll)x.size()

string to_string(string s) {return s;}
string to_string(char c) {string s = string(1, c);return s;}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

void in() {}
template <typename A> void in(A & x) { cin >> x; }
template <typename A, typename B> void in(pair<A,B> & x) { in(x.first); in(x.second); }
template <typename A> void in(vector<A> & x) { REP(i,0,(ll)x.size()) in(x[i]); }
template <typename Head, typename... Tail> void in(Head & H, Tail & ... T) {in(H); in(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

const ll inf = (ll)1e18 + 5;
const ll mod = 1e9+7;

ll nax = 1005;
VLL p(nax*nax, 1);
VLL P;

void init() {
	p[0] = 0;
	p[1] = 0;

	for (ll x = 2; x < nax*nax; x++) {
		if (p[x] == 0) {
			continue;
		}

		P.push_back(x);

		for (ll f = x; x * f < nax * nax; f++) {
			p[x*f] = 0;
		}
	}
}

map<ll,ll> pf(ll x) {
    map<ll,ll> f;
    REP(i,0,sz(P)) {
        if (P[i] * P[i] > x) break;
        while (x % P[i] == 0) {
            f[P[i]]++;
            x /= P[i];
        }
    }
    if (x > 1) f[x]++;
    return f;
}

VLL F(100500, -1);
VLL INVF(100500, -1);

ll pow(ll a, ll b) {
	if (b == 0) return 1;
	ll h = pow(a, b/2);
	ll ans = b % 2 ? h * h % mod * a : h * h;
	ans %= mod;
	return ans;
}

ll f(ll x) {
	if (F[x] != -1) return F[x];
	if (x == 0) return 1;
	F[x] = f(x-1) * x % mod;
	return F[x];
}

ll invf(ll x) {
	if (INVF[x] != -1) return INVF[x];
	INVF[x] = pow(f(x), mod-2);
	return INVF[x];
}

ll ncr(ll n, ll r) {
	// n! / r! / (n-r)!
	ll ans = f(n);
	ans *= invf(r);
	ans %= mod;
	ans *= invf(n-r);
	ans %= mod;
	return ans;
}

void solve() {
	ll n, m;
	in(n, m);

	map<ll,ll> factors = pf(m);

	REP(i,0,n) f(i); // ease on the recursion

	ll ans = 1;
	for (PLL a : factors) {
		ans *= ncr(a.second + n - 1, a.second) % mod;
		ans %= mod;
	}
	cout << ans << endl;

}

signed main() {
	init();
	ll t = 1;
	REP(i,0,t) solve();
	return 0;
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string a, b, c; cin >> a >> b >> c;
    if(a.back()==b[0] && b.back()==c[0]){
        cout << "YES" << ln;
    }else cout << "NO" << ln;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B, C, D;
	int L, R;
	cin >> A >> B >> C >> D;

	L = A + B;
	R = C + D;

	if(L > R){
		printf("Left\n");
	}
	else if(L == R){
		printf("Balanced\n");
	}
	else{
		printf("Right\n");
	}
	return 0;
}

#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;

    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    size_t a = 0, b = 0, c = 0;
    char turn = sa[a++];

    while (true) {

        if (turn == 'a') {
            if (sa.size() == a) {
                cout << "A\n";
                return 0;
            }
            turn = sa[a++];
        } else if (turn == 'b') {
            if (sb.size() == b) {
                cout << "B\n";
                return 0;
            }
            turn = sb[b++];
        } else if (turn == 'c') {
            if (sc.size() == c) {
                cout << "C\n";
                return 0;
            }
            turn = sc[c++];
        }
    }
}


#include <iostream>
#include <vector>

int main() {
    int A, B, M; std::cin >> A >> B >> M;
    std::vector<int> a(A);
    int ma = 0;
    for (int i = 0; i < A; i++) {
        std::cin >> a[i];
        if (i == 0) {
            ma = a[0];
        } else {
            ma = std::min(ma, a[i]);
        }
    }
    std::vector<int> b(B);
    int mb = 0;
    for (int i = 0; i < B; i++) {
        std::cin >> b[i];
        if (i == 0) {
            mb = b[0];
        } else {
            mb = std::min(mb, b[i]);
        }
    }

    int m = ma + mb;

    for (int i = 0; i < M; i++) {
        int x, y, c; std::cin >> x >> y >> c;
        x--; y--;
        m = std::min(m, a[x] + b[y] - c);
    }
    std::cout << m << std::endl;
    return 0;
}

#include <iostream>
#include <array>
#include <string>

using namespace std;

enum dir_t {NORTH, EAST, WEST, SOUTH};
enum face_t {TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT};

class Dice {
public:
    Dice(int32_t top, int32_t bottom, int32_t front, int32_t back, int32_t left, int32_t right) {
        val[TOP]    = top;
        val[BOTTOM] = bottom;
        val[FRONT]  = front;
        val[BACK]   = back;
        val[LEFT]   = left;
        val[RIGHT]  = right;
    }

    int32_t operator[](face_t f) {
        return val[f];
    }

    void roll(dir_t dir) {
        switch (dir) {
            case NORTH: inner_roll(TOP, FRONT, BOTTOM, BACK); break;
            case EAST:  inner_roll(TOP, LEFT, BOTTOM, RIGHT); break;
            case WEST:  inner_roll(TOP, RIGHT, BOTTOM, LEFT); break;
            case SOUTH: inner_roll(TOP, BACK, BOTTOM, FRONT); break;
        }
    }

private:
    array<int32_t, 6> val;

    void inner_roll(face_t f1, face_t f2, face_t f3, face_t f4) {
        int32_t temp;
        temp = val[f1];
        val[f1] = val[f2];
        val[f2] = val[f3];
        val[f3] = val[f4];
        val[f4] = temp;

        return;
    }
};

int main() {
    int32_t top, bottom, front, back, left, right;
    string op;

    cin >> top >> front >> right >> left >> back >> bottom >> op;

    Dice d(top, bottom, front, back, left, right);

    for (uint8_t dir : op) {
        switch (dir) {
            case 'N': d.roll(NORTH); break;
            case 'E': d.roll(EAST);  break;
            case 'W': d.roll(WEST);  break;
            case 'S': d.roll(SOUTH); break;
        }
    }

    cout << d[TOP] << endl;

    return 0;
}


#include <iostream>

using namespace std;

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

    int x = 0;
    while (n > 2)
    {
        x++;
        n = n - 3;
    }
    cout << x << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << 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; }

int main(){
  ll n;
  cin >> n;
  print(n / 3);
}


// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int zeller(int y, int m, const int &d) {
  if (m == 1 || m == 2) y--, m += 12;
  int k = y % 100, j = y / 100;
  return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j + 6) % 7;
}

void solve() {
  int m, d;
  string t[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  while (cin >> m >> d, m) cout << t[zeller(2004, m, d)] << endl;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int m,d;
  while(cin>>m>>d,m+d){
    int day = 0;
    m--;
    // 2 , 4 , 6 , 9 . 11
    int month[12] = {31,29,31,30,31,30,
		     31,31,30,31,30,31};
    rep(i,m){
      day+=month[i];
    }
    day=(day + d + 7 - 1)%7;
    switch(day){
    case 0:
      cout<<"Thursday"<<endl;
      break;
    case 1:
      cout<<"Friday"<<endl;
      break;
    case 2:
      cout<<"Saturday"<<endl;
      break;
    case 3:
      cout<<"Sunday"<<endl;
      break;
    case 4:
      cout<<"Monday"<<endl;
      break;
    case 5:
      cout<<"Tuesday"<<endl;
      break;
    case 6:
      cout<<"Wednesday"<<endl;
      break;
    }

  }
}


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

int main() {
  vector<int> a(3);
  rep(i,0,3) cin >>a[i];
  sort(a.begin(),a.end());
  int K; cin >>K;
  a[2]*=pow(2,K);
  cout <<accumulate(a.begin(),a.end(),0) <<endl;
  return 0;
}

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

using namespace std;

int main() {

  int n, a = 0, b = 0, c;
  cin >> a >> b >> c;
  cin >> n;
  cout << (a + b + c) - max(max(a, b), c) + (max(max(a, b), c) << n);
}


///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=3005;
int n,t;
int dp[M][M];
int a[M],b[M];
vector<pi>vec;
int solve(int pos,int tym)
{
    if(pos>n)return 0;
    if(tym>=t)return 0;
    int &ret=dp[pos][tym];
    if(ret!=(-1))return ret;
    ret=solve(pos+1,tym);
    ret=max(ret,solve(pos+1,tym+a[pos])+b[pos]);
    return ret;
}
 main()

{
    fast
    memset(dp,-1,sizeof dp);
    cin>>n>>t;
    f(i,1,n)
    {
        cin>>a[i]>>b[i];
        vec.pb(mp(a[i],-b[i]));
    }
    sort(vec.begin(),vec.end());
    f(i,0,n-1)
    {
        a[i+1]=vec[i].fi;
        b[i+1]=-vec[i].si;
    }
    int ses=solve(1,0);
    cout<<ses<<endl;
    return 0;

}

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 1005

ll N,M;
int min_dist[SIZE],pre_node[SIZE];
vector<int> G[SIZE];

vector<int> bfs(int start){

	vector<int> ret(N+1);

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

		min_dist[i] = BIG_NUM;
		pre_node[i] = -1;
	}
	min_dist[start] = 0;

	queue<int> Q;
	Q.push(start);

	while(!Q.empty()){

		int node_id = Q.front();
		Q.pop();

		for(int i = 0; i < G[node_id].size(); i++){

			int next = G[node_id][i];
			if(min_dist[next] != BIG_NUM)continue;

			min_dist[next] = min_dist[node_id]+1;
			pre_node[next] = node_id;
			Q.push(next);
		}
	}

	int minimum = BIG_NUM,last_node = -1;

	for(int i = 0; i < N; i++){
		if(i == start)continue;

		for(int k = 0; k < G[i].size(); k++){
			if(G[i][k] == start){
				if(minimum > min_dist[i]){
					minimum = min_dist[i];
					last_node = i;
				}
			}
		}
	}

	if(last_node == -1)return ret;

	int tmp = last_node;
	ret.clear();

	while(tmp != -1){
		ret.push_back(tmp);
		tmp = pre_node[tmp];
	}

	return ret;
}

int main(){

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

	int from,to;

	for(ll i = 0; i < M; i++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		G[from].push_back(to);
	}

	vector<int> ans(N+1);

	for(ll start = 0; start < N; start++){

		vector<int> work = bfs(start);

		if(work.size() < ans.size()){

			ans = work;
		}
	}

	if(ans.size() == N+1){

		printf("-1\n");
		return 0;

	}else{

		printf("%lld\n",ans.size());
		for(int i = 0; i < ans.size(); i++){

			printf("%d\n",ans[i]+1);
		}
	}

	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;

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

    vector<Pii> nums(h*w+1, {-1, -1});
    bool ok = true;
    for(int i=0;i<h;++i) {
        cin >> a;
        if(nums[a].first != -1) ok = false;
        nums[a].first = i;
    }
    for(int i=0;i<w;++i) {
        cin >> a;
        if(nums[a].second != -1) ok = false;
        nums[a].second = i;
    }

    if(!ok) {
        cout << 0 << endl;
        return 0;
    }

    int used_line[h], used_row[w];
    ll line_cnt = 0, row_cnt = 0;
    fill(used_line, used_line+h, 0);
    fill(used_row, used_row+w, 0);

    ll ans = 1LL;
    for(ll i=h*w;i>=1;--i) {
        // cerr << i << ": " << nums[i].first << ", " << nums[i].second  << "\t";
        if(nums[i].first != -1) {
            ++used_line[nums[i].first];
            if(used_line[nums[i].first] == 1) {
                ++line_cnt;
            }
        }
        if(nums[i].second != -1) {
            ++used_row[nums[i].second];
            if(used_row[nums[i].second] == 1) {
                ++row_cnt;
            }
        }
        if(nums[i].first == -1 && nums[i].second == -1) {
            ans *= ((row_cnt*line_cnt) - (h*w - i));
        } else if(nums[i].first == -1) {
            ans *= line_cnt;
        } else if(nums[i].second == -1) {
            ans *= row_cnt;
        }
        ans %= MOD;

        if(ans <= 0) {
            ans = 0;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    vector<int> a, b;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;

        if(x < 0)
            b.Pb(-x);
        else
            a.Pb(x);
    }

    reverse(All(b));

    int la = a.size(), lb = b.size();

    int ans = INT_MAX;
    for(int i = 0; i < la; i++){
        int x = i + 1;
        if(x > k)
            break;
        if(k - x > lb)
            continue;
        if(k == x){
            ans = min(ans, a[i]);
            break;
        }

        x = k - x - 1;
        ans = min(ans, 2 * a[i] + b[x]);
    }

    for(int i = 0; i < lb; i++){
        int x = i + 1;
        if(x > k)
            break;
        if(k - x > la)
            continue;
        if(k == x){
            ans = min(ans, b[i]);
            break;
        }

        x = k - x - 1;
        ans = min(ans, 2 * b[i] + a[x]);
    }

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


#include <bits/stdc++.h>
#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 PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int dp[41];

int main(){
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    for(int j=0;j<30;j++){
	for(int i=1;i<=3;i++){
	    dp[i+j] += dp[j];
	}
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int fact = dp[n]/10 + ((dp[n]%365==0) ? 0 : 1) ;
	cout << fact/365 + ((fact%365==0) ? 0 : 1) << endl;
    }
    return 0;
}

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			int m, e, j;
			cin >> m >> e >> j;

			if (m == 100 || e == 100 || j == 100 || (m + e) / 2 >= 90 || (m + e + j) / 3 >= 80)cout << 'A' << endl;
			else if ((m + e + j) / 3 >= 70 || ((m + e + j) / 3 >= 50) && ((m >= 80) || (e >= 80)))cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
	int n,K;cin >> n >> K;
	vector<int> num;
	rep(i,10) num.push_back(i);
	rep(i,K) {
		int a;cin >> a;
		rep(j,num.size()){
			if(num[j]==a) num.erase(num.begin()+j);
		}
	}
	//rep(i,num.size()) cout << num[i]<< endl;
	int ans = 100000;
	for(int a:num)for(int b:num)for(int c:num)for(int d:num)for(int e:num){
		int temp = 10000*a+1000*b+100*c+10*d+e;
		int temp2 = 1000*b+100*c+10*d+e;
		int temp3 = 100*c+10*d+e;
		int temp4 = 10*d+e;
		int temp5 = e;
		if(temp >= n) ans = min(ans,temp);
		if(temp2 >= n) ans = min(ans,temp2);
		if(temp3 >= n) ans = min(ans,temp3);
		if(temp4 >= n) ans = min(ans,temp4);
		if(temp5 >= n) ans = min(ans,temp5);
	}
	cout << ans << endl;

}

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int num[10];
bool is_OK(int X){
    while(X > 0){
        int n = X % 10;
        if(num[n]){
            return false;
        }
        X /= 10;
    }
    return true;
}
int main(void){
    int N,K;
    cin >> N >> K;
    int D[K];
    for(int i=0;i<K;i++){
        cin >> D[i];
    }

    for(int i=0;i<K;i++){
        num[D[i]]++;
    }
    int ans;
    for(int i=N;;i++){
        if(is_OK(i)){
            cout << i << endl;
            return 0;
        }
    }
}


// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    double rad;

    while(cin >> rad)
    {
		cout << setprecision(10) << fixed << 2.0 * acos(-1.0) * rad << "\n";
    }

}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ;
  string s , t  ;
  cin >> s >> t ;
  deque<char> S , T ;
  rep(i,n){
    S.push_back(s.at(i)) ;
    T.push_back(t.at(i));
  }
  if(s == t ) {
    cout << s.size() <<endl ;
    return 0 ;
  }

  int ans = 2 * n ;

  rep(i,n){
    S.pop_front();
    T.pop_back();

    if( S == T){
      ans = S.size() + 2*(i+1) ;
      cout <<  ans <<endl ;
      return 0 ;
    }
  }

}

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll k, t; cin >> k >> t;
    vll a(t);
    Map m;
    ll mx = 0; ll s = 0;
    rep(i, 0, t){
        cin >> a[i];
        m[i] = a[i];
        s += a[i]; mx = max(mx, a[i]);
    }
    ll g = s - mx;
    if(mx < g){
        prtl(0);
    }else{
        prtl(mx - g - 1);
    }
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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 (a>b) { a=b; return true; } return false; }

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

int main(){
    FastIO;
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n){
        cin >> a[i];
        a[i]*=-1;
    }
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    for(int i = 0; i < n; i++){
        int bi = b[i];
        auto itrA = upper_bound(all(a), -bi);
        if (itrA == a.end()) continue;
        size_t posA = distance(a.begin(), itrA);

        auto itrC = upper_bound(all(c), bi);
        if (itrC == c.end()) continue;
        size_t posC = distance(c.begin(), itrC);

        ll cntA = n-posA;
        ll cntC = n-posC;
        ans += cntA * cntC;
    }

    cout << ans << endl;
}

#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin >>n;
  vector<ll> a(n);
  rep(i,n) cin >>a[i];
  map<ll,ll>  mp;
  rep(i,n) mp[a[i]]++;
  ll ans=0;
  for(auto x :mp){
    if(x.second%2==1) ans++;
  }
  cout <<ans<<endl;
}


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

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

  int ans = 100000000;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;

    int count = 0;

    if (x % 2 != 0)
      ans = 0;

    while (x % 2 == 0) {
      x /= 2;
      count++;
    }
    ans = min (ans,count);
  }
  cout << ans << endl;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll color1 = 0;
    ll color2 = 0;
    ll color3 = 0;
    ll count = 1;
    rep(i,N){
        if (color1 == A[i] && color2 == A[i] && color3 == A[i]){
            color1++;
            count = (count * 3) % 1000000007;
        }
        else if (color1 == A[i] && color2 == A[i]){
            color1++;
            count = (count * 2) % 1000000007;
        }
        else if (color2 == A[i] && color3 == A[i]){
            color2++;
            count = (count * 2) % 1000000007;
        }
        else if (color1 == A[i]) color1++;
        else if (color2 == A[i]) color2++;
        else if (color3 == A[i]) color3++;
        else{
            count = 0;
        }
    }
    cout << count << endl;
}


/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

const long long MAXN = 1e6 + 1;
using namespace std;

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

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

#define int __int64_t

int a[MAXN];

int prem[MAXN];

int n;

vector <int> mult(const vector <int>& a, const vector <int>& b) {
    vector <int> c(a.size());
    for (int i = 0; i < a.size(); i++) {
        c[i] = a[b[i]];
    }
    return c;
}

vector <int> binpow(vector <int>& a, int K) {
    int sz = a.size();
    vector <int> ans(sz);
    for (int i = 0; i < sz; i++) ans[i] = i;
    while(K) {
        if (K & 1) {
            ans = mult(ans, a);
        }
        a = mult(a, a);
        K >>= 1;
    }
    return ans;
}

main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    n = readInt();
    vector <int> d(n - 1);
    vector <int> perm(n - 1);
    for (int i = 0; i < n; i++) {
        a[i] = readInt();
    }
    for (int i = 0; i < n - 1; i++) {
        d[i] = a[i + 1] - a[i];
        perm[i] = i;
    }

    int M = readInt(), K = readInt();
    for (int i = 1; i <= M; i++) {
        int x = readInt() - 1;
        swap(perm[x - 1], perm[x]);
    }

    vector <int> kekekek = binpow(perm, K);
    int cur = a[0];
    for (int i = 0; i < n - 1; i++) {
        cout << cur << endl;
        cur += d[kekekek[i]];
    }
    cout << cur;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;

ll x[100010];
int a[100010], nsw[100010], now[100010], vid[100010], vnum[100010], repl[100010];
bool looked[100010]={};
vector<vector<int>> v;

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> x[i];
	int M;
	ll K;
	cin >> M >> K;
	for(int i=0; i<M; ++i) cin >> a[i];
	for(int i=1; i<N; ++i) nsw[i]=i;
	for(int i=0; i<M; ++i) swap(nsw[a[i]-1], nsw[a[i]]);
	for(int i=1; i<N; ++i) now[nsw[i]]=i;
	int cnt=0;
	for(int i=1; i<N; ++i){
		if(!looked[i]){
			int b=i;
			v.emplace_back();
			do{
				vnum[b]=v[cnt].size();
				v[cnt].emplace_back(b);
				vid[b]=cnt;
				looked[b]=1;
				b=now[b];
			}while(b!=i);
			++cnt;
		}
	}
	for(int i=1; i<N; ++i){
		ll sz=v[vid[i]].size();
		ll r=(K%sz+vnum[i])%sz;
		repl[v[vid[i]][r]]=i;
	}
	cout << x[0] << endl;
	ll ans=x[0];
	for(int i=1; i<N; ++i){
		ans += x[repl[i]]-x[repl[i]-1];
		cout << ans << endl;
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

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

void Trace( int *A, int N, int cnt){
	//?????????????????????????????????N-1??¨??????
	for (int i = 0; i < N - 1; i++){
		printf("%d ", A[i]);
	}
	printf("%d\n", A[N - 1]);
	printf("%d\n", cnt);
}

int BubbleSort(int *A, int N){
	int cnt = 0;

	for (int i = N-1; i > 0; i--){
		for (int j = N-1; j >= 0; j--){

			//??\???????????????
			if (A[j - 1] > A[j]){
				int t = A[j - 1];
				A[j - 1] = A[j];
				A[j] = t;
				cnt++;
			}
		}
	}

	return cnt;
}

int main(int argc, char *argv[]){
	int N;

	scanf("%d", &N);

	int *A = (int*)malloc(sizeof(int) * N);

	//??\???
	for (int i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}

	int cnt = BubbleSort(A, N);
	Trace(A, N, cnt);

	free(A);

	return 0;
}

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

#define N 1000

using namespace std;

int main()
{
	int n;
	int s;
	string str;

	cin >> n;
	cin.ignore();

	for(int i = 0; i < n; i++)
	{
		getline(cin,str);

		for(s = 0; s < N; s++){

		if(str[s] == 'H' && str[s+1] =='o' && str[s+2] == 's' && str[s+3] == 'h'
			&& str[s+4] == 'i' && str[s+5] == 'n' && str[s+6] == 'o' ){

				str[s] = 'H';
				str[s+1] = 'o';
				str[s+2] = 's';
				str[s+3] = 'h';
				str[s+4] = 'i';
				str[s+5] = 'n';
				str[s+6] = 'a';
			}

		}
		cout << str << endl;

	}
}


#include <iostream>
using namespace std;

char solve(int m,int e,int j){
	if( m == 100 || e == 100 || j == 100 )
		return 'A';
	if( (m+e)>=180 || (m+e+j)>=240)
		return 'A';
	if( (m+e+j)>=210 || ( (m+e+j)>=150 && (m>=80||e>=80) ) )
		return 'B';
	return 'C';
}

int main(){
	int n,m,e,j;
	while( cin >> n , n ){
		for(int i=0 ; i<n ; ++i ){
			cin >> m >> e >> j;
			cout << solve(m,e,j) << endl;
		}
	}
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#define  MAXN 10010
using namespace std;
struct Edge
{
	int point1;
	int point2;
	int weight;
};
bool cmp(Edge &x, Edge &y)
{
	return x.weight < y.weight;
}
int pre[MAXN];
vector <Edge> vec;
int find(int x)
{//并查集
	int root = x;

	while (pre[root] != root)
		root = pre[root];//找根
	int t = x;
	while (pre[t] != root)
	{//路径压缩
		int temp = pre[t];
		pre[t] = root;
		t = temp;
	}

	return root;
}
int main()
{
	int n, m;
	int min_sum = 0;

	scanf("%d%d", &n, &m);//n是点数，m是边数
	for (int i = 0; i < n; i++)
		pre[i] = i;//初始化并查集
	for (int i = 0; i < m; i++)
	{//输入每条边的两个顶点及其权重
		Edge temp;

		scanf("%d%d%d", &temp.point1, &temp.point2, &temp.weight);
		vec.push_back(temp);
	}
	sort(vec.begin(), vec.end(), cmp);//按权重对边进行排序
	int coun = 0;
	for (int i = 0; i < m; i++)
	{//最多只有m条边
		int fx = find(vec[i].point1);
		int fy = find(vec[i].point2);

		if (fx != fy)
		{//如果这条边的两个顶点所在集合不相同就合并
			coun++;//成功合并后就多了一条边
			min_sum += vec[i].weight;
			pre[fx] = fy;//合并
			if (coun == n - 1)
				break;//krusal有n-1条边
		}
	}
	printf("%d\n", min_sum);
	return 0;
}


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int tab[30][30];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
int W, H;
int Gx, Gy;

bool out(int x, int y){
  return !(0 <= x && x < W && 0 <= y && y < H);
}

int dfs(int x, int y, int d){
  if(d > 10) return d;

  int res = 11;
  REP(i,4){
	int tx = x+dx[i], ty = y+dy[i];
	if(out(tx,ty) || tab[ty][tx] != 0)
	  continue;

	while(!out(tx,ty) && tab[ty][tx] == 0){
	  if(tx == Gx && ty == Gy)
		return d+1;
	  tx += dx[i], ty += dy[i];
	}
	if(out(tx,ty)) continue;

	tab[ty][tx] = 0;
	res = min(res, dfs(tx-dx[i], ty-dy[i], d+1));
	tab[ty][tx] = 1;
  }
  return res;
}

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

  while(cin>>W>>H,W){
	fill((int*)tab,(int*)tab+30*30,0);
	int sx, sy;
	REP(y,H) REP(x,W){
	  cin >> tab[y][x];
	  if(tab[y][x] == 2)
		sx = x, sy = y, tab[y][x] = 0;
	  if(tab[y][x] == 3)
		Gx = x, Gy = y, tab[y][x] = 0;
	}
	int ans = dfs(sx, sy, 0);
	if(ans > 10) cout << -1 << endl;
	else cout << ans << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,ans;
    string s,t;
    cin>>n>>s>>t;
    ans=n;
    for(int i=0;i<n;i++){
        if(s.substr(i)==t.substr(0,n-i))break;
        ans++;
    }
    cout<<ans<<endl;
}

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S, T;
  cin>>S>>T;
  int num = 0;
  bool can;
  for(int i=0;i<N;++i) {
    can = true;
    for(int j=0;j<N-i;++j) {
      if(S[i+j]!=T[j]) can = false;
    }
    if(can) {
      num = N-i;
      break;
    }
  }
  cout<<2*N-num<<endl;
}


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

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int max_a = *max_element(a.begin(), a.end());
  int g = a[0];
  rep(i, n) g = gcd(g, a[i]);
  // cerr << g << " " << max_a << endl;
  if (k % g == 0 && k <= max_a) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

const long long mod = 1e9 + 7;
const int inf = 1e5 + 9, maxn = 2e2 + 9;
long long dp[maxn][inf], s[inf];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s + n);
    for (int i = 0; i < inf; i++) {
        dp[0][i] = i % s[0];
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= x; j++) {
            dp[i][j] += dp[i - 1][j % s[i]] * 1LL + dp[i - 1][j] * i * 1LL;
            dp[i][j] %= mod * 1LL;
        }
    }
    cout << dp[n - 1][x] << '\n';
    return 0;
}