#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vpll = vector<pll>;
const ll LINF = 1ll << 55;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 10;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

/// cin/cout overloading
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    out << *it << " ";
  }
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const pair<T, T> &P) {
  out << P.first << " " << P.second;
  return out;
}

template <typename T>
istream &operator>>(istream &in, vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    in >> *it;
  }
  return in;
}

template <typename T>
istream &operator>>(istream &in, pair<T, T> &P) {
  in >> P.first >> P.second;
  return in;
}

#define error(args...)                       \
  {                                          \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr << endl;                            \
  }

void err(istream_iterator<string>) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}

#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) (x).begin(), (x).end()
#define coutp(x, y) cout << (x) << " " << (y) << endl
#define coutn(x) cout << (x) << endl
#define coutd(x) cout << setprecision(10) << (x) << endl

int argmax(const vi &A, int start, int end) {
  int res = 0;
  int max = 0;
  rep(i, start, end) {
    if (A[i] > max) {
      max = A[i];
      res = i;
    }
  }
  return res;
}

/// main函数
int main() {
  ll N, C;
  cin >> N >> C;
  vpll pay;
  ll ai, bi, ci;
  rep(i, 0, N) {
    cin >> ai >> bi >> ci;
    pay.emplace_back(ai - 1, ci);
    pay.emplace_back(bi, -ci);
  }
  sort(pay.begin(), pay.end());
  ll ans = 0, p = 0, curr = 0;
  for (auto &[v, c] : pay) {
    ans += min(C, curr) * (v - p);
    p = v;
    curr += c;
  }
  coutn(ans);
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    // t / Z < Y / X
    // t * X < Y * Z
    if ((Y * Z) % X == 0) {
        cout << Y * Z / X - 1 << endl;
    } else {
        cout << Y * Z / X << endl;
    }

}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);

    solve();
}


//ver 8.1
#include <bits/stdc++.h>
using namespace std;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll,ll>;
using mll = map<ll,ll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
#define each(x,v) for(auto& x : (v))
#define reps(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
const ll INF = 1LL << 60;
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) ((a)<=(x)&&(x)<=(b))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){}
template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
template <typename T> void in1(T &s) {rep(i,s.size()){in(s[i]);}}
template <typename T> void in2(T &s,T &t) {rep(i,s.size()){in(s[i],t[i]);}}
template <typename T> void in3(T &s,T &t,T &u) {rep(i,s.size()){in(s[i],t[i],u[i]);}}
template <typename T> void in4(T &s,T &t,T &u,T &v) {rep(i,s.size()){in(s[i],t[i],u[i],v[i]);}}
template <typename T> void in5(T &s,T &t,T &u,T &v,T &w) {rep(i,s.size()){in(s[i],t[i],u[i],v[i],w[i]);}}
void out(){cout << endl;}
template <typename T,class... U> void out(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; out(u...);}
void die(){cout << endl;exit(0);}
template <typename T,class... U> void die(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; die(u...);}
template <typename T> void outv(T s) {rep(i,s.size()){if(i!=0)cout<<" ";cout<<s[i];}cout<<endl;}
template <typename T> void out1(T s) {rep(i,s.size()){out(s[i]);}}
template <typename T> void out2(T s,T t) {rep(i,s.size()){out(s[i],t[i]);}}
template <typename T> void out3(T s,T t,T u) {rep(i,s.size()){out(s[i],t[i],u[i]);}}
template <typename T> void out4(T s,T t,T u,T v) {rep(i,s.size()){out(s[i],t[i],u[i],v[i]);}}
template <typename T> void out5(T s,T t,T u,T v,T w) {rep(i,s.size()){out(s[i],t[i],u[i],v[i],w[i]);}}
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
template <typename T> T allSum(vector<T> a){T ans=T();each(it,a)ans+=it;return ans;}
template<typename T> bool inside(T a,T b){auto it=a.begin()-1;each(x,b){it=find(it+1,a.end(),x);if(it==a.end())return false;}return true;}
ll ceilDiv(ll a,ll b) {return (a+b-1)/b;}
ld dist(pair<ld,ld> a, pair<ld,ld> b){return sqrt(abs(a.fi-b.fi)*abs(a.fi-b.fi)+abs(a.se-b.se)*abs(a.se-b.se));} // ２点間の距離
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
#define YES(n) ((n) ? "YES" : "NO"  )
#define Yes(n) ((n) ? "Yes" : "No"  )
#define yes(n) ((n) ? "yes" : "no"  )

int main(){
  init();
  inl(n);
  ins(s);
  ins(t);
  ll ans=0;
  V<ll> a,b;
  rep(i,n)if(s[i]=='0')a.push_back(i);
  rep(i,n)if(t[i]=='0')b.push_back(i);
  if(a.size()!=b.size())die(-1);
  rep(i,a.size())if(a[i]!=b[i])ans++;
  out(ans);
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,b[404040];
pair<int,int>a[404040];
stack<pair<int,int> >st;
int main()
{
	string ans="";
	cin>>n;
	for(int i=0;i<2*n;i++)
	{
		cin>>a[i].first;
		a[i].second=i;
		ans+='(';
	}
	sort(a,a+2*n);
	for(int i=0;i<n;i++)
	{
		b[a[i].second]=1;
	}
	for(int i=0;i<2*n;i++)
	{
		if(st.size()==0 || st.top().first==b[i])
		{
			st.push(make_pair(b[i],i));
		}
		else
		{
			st.pop();
			ans[i]=')';
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
const int N=2e5+5;
const int M=1e5+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const double eps=1e-8;
const long double pi=acos(-1.0L);
#define ls (i<<1)
#define rs (i<<1|1)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
LL read()
{
    LL x=0,t=1;
    char ch;
    while((ch=getchar())<'0'||ch>'9') if(ch=='-') t=-1;
    while(ch>='0'&&ch<='9'){ x=(x<<3)+(x<<1)+ch-'0'; ch=getchar(); }
    return x*t;
}
vector<LL> a[3];
vector<pair<LL,int> >c;

int id(char ch)
{
    if(ch=='R') return 0;
    if(ch=='G') return 1;
    return 2;
}
int main()
{
    int n=read();
    for(int i=1;i<=2*n;i++)
    {
        LL x=read();
        int s[2];
        scanf("%s",s);
        a[id(s[0])].eb(x);
    }
    int tot=0;
    for(int i=0;i<3;i++)
    {
        if((int)a[i].size()&1) {
            for(auto x:a[i]) c.eb(x,tot);
            tot++;
        }
    }
    if(c.empty()) return 0*printf("0\n");
    sort(c.begin(),c.end());
    LL ans=1e16;
    for(int i=1;i<(int)c.size();i++)
        if(c[i].se!=c[i-1].se) ans=min(ans,c[i].fi-c[i-1].fi);
    for(int i=0;i<3;i++)
    {
        if((int)a[i].size()&1) continue;
        for(auto x:a[i]) c.eb(x,tot);
    }
    sort(c.begin(),c.end());
    LL t1=1e16,t2=1e16;

    for(int i=0;i<(int)c.size();i++)
        if(c[i].se==2) {
            if(i>0&&c[i-1].se==0) t1=min(t1,c[i].fi-c[i-1].fi);
            if(i<(int)c.size()-1&&c[i+1].se==0) t1=min(t1,c[i+1].fi-c[i].fi);
            if(i>0&&c[i-1].se==1) t2=min(t2,c[i].fi-c[i-1].fi);
            if(i<(int)c.size()-1&&c[i+1].se==1) t2=min(t2,c[i+1].fi-c[i].fi);
        }
   // printf("%lld %lld\n",t1,t2);
    printf("%lld\n",min(ans,t1+t2));
    return 0;
}
/*
2
100 R
2 B
99 G
1 G
*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
//#define mod 1000000007
#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}

const ll INF=1e18;
const int mx=200005;
//arc114
ll dp[200005][4];
class UnionFind{
public:
    vector<ll> par,num;

    int find(ll v){
        return (par[v]==v)? v: (par[v]=find(par[v]));
    }
    explicit UnionFind(ll N):par(N),num(N,1){
        iota(par.begin(),par.end(),0);
    }
    void unite(ll u,ll v){
        u=find(u),v=find(v);
        if(u==v)return ;
        if(num[u]<num[v])swap(u,v);
        num[u] += num[v];
        par[v] = u;
    }
    bool same(ll u,ll v){
        return find(u) == find(v);
    }
    bool ispar(ll v){
        return v=find(v);
    }
    ll size(ll v){
        return num[find(v)];
    }
};

int main(){
    //オーバーフローは大丈夫ですか？？
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V<ll> a(n);
    V<V<ll>> G(n);
    UnionFind uf(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
        uf.unite(i,a[i]);
    }
    set<ll> st;
    rep(i,n) st.insert(uf.find(i));
    ll x=st.size();
    ll ans=1;
    rep(i,x) ans=ans*2%mod;
    ans--;
    if(ans<0) ans+=mod;
    out(ans);
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！


#include <bits/stdc++.h>
#define max0(x,y) (x<y?y:x)
#define min0(x,y) (x>y?y:x)
using namespace std;
const double eps=1e-14,down=0.9997;
const int mn=3e3+7;
int n;
int w[mn][6],q1[4],q2[mn];
int fx()
{
	int ans=1e9+7;
    for(int j=1;j<=5;++j)
    {
    	int mx=0;
    	for(int i=1;i<=3;++i)
    	  mx=max0(w[q1[i]][j],mx);
    	ans=min0(ans,mx);
	}
	return ans;
}
int main()
{
    srand(154051);
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
      for(int j=1;j<=5;++j)
        scanf("%d",&w[i][j]);
    q1[1]=1;q1[2]=2;q1[3]=3;
    int cnt=0;
    for(int i=4;i<=n;++i)  q2[++cnt]=i;
    int best,rs;
    best=rs=fx();
    if(n==3)
    {
    	cout<<best;
    	return 0;
	}
    for(double t=13000;t>eps;t*=down)
    {
        int l=rand()%3+1,r=rand()%cnt+1;
        swap(q1[l],q2[r]);
        int tmp=fx();
        if(tmp>best)  best=tmp;
        if(tmp>rs||exp((double)(tmp-rs)/t)*RAND_MAX>rand())  rs=tmp;
        else  swap(q1[l],q2[r]);
    }
    cout<<best;
    return 0;
}

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

inline int in_int(istream& in) {int x; in >> x; return x;}
inline ll in_ll(istream& in) {ll x; in >> x; return x;}
inline string in_str(istream& in) {string x; in >> x; return x;}

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

class CMADTEAM {
public:
void solve(istream& in, ostream& out) {
    int N = in_int(in);
//    vector A(N, array<int, 5>{});
    vector<array<int, 5>> A(N);

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 5; ++j) {
            A[i][j] = in_ll(in);
        }
    }

    auto check = [&](int x) -> bool{
        set<int> s;
        for (int i = 0; i < N; ++i) {
            int bit = 0;
            for (int j = 0; j < 5; ++j) {
                bit <<= 1;
                if(A[i][j] >= x){
                    bit |= 1;
                }
            }
            s.insert(bit);
        }

        for (int i : s) {
            for (int j : s) {
                for (int k : s) {
                    if((i|j|k) == 31)return true;
                }
            }
        }
        return false;

    };

    int ok = 0;
    int ng = 1e9 + 1;

    while(abs(ok - ng) > 1){
        int cen = (ok + ng) / 2;
        (check(cen) ? ok : ng) = cen;
    }

    out << ok << endl;
}
};

int main() {
	CMADTEAM solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using pii = pair<int, int>;

#define endl " \n"
#define size(x) int((x).size())
#define all(a) a.begin(), a.end()
const int mod = 1e9+7, inf = INT_MAX, ninf = INT_MIN;

void setIO(string name = "") {
	cin.tie(0)->sync_with_stdio(0);
	if (!name.empty()) { freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); }
}

void solve();

int main() {
    setIO();
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;

    int s = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            int temp = i*100+j;
            s += temp;
        }
    }
    cout << s << endl[1];
}

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

int main(){
  int N,K;cin>>N>>K;
  int ans=0;
  for(int i=1;i<=N;i++){
    ans+=K*i*100;
    ans+=K*(K+1)/2;
  }
  cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=1e5+10;
int k,n,m,a[MAXN],b[MAXN];
ll ans[2*MAXN],ans2[2*MAXN];
bool check(int mid){
  int i,x,minb=0,maxb=0;
  for(i=1;i<=k;i++){
    x=(ll)m*a[i]/n;
    if(ans[2*i-1]>ans2[mid]&&ans[2*i]>ans2[mid])return 0;
    if(ans[2*i-1]<=ans2[mid]&&ans[2*i]>ans2[mid]){
	  minb=minb+x;
	  maxb=maxb+x;
	}
	if(ans[2*i-1]>ans2[mid]&&ans[2*i]<=ans2[mid]){
	  minb=minb+x+1;
	  maxb=maxb+x+1;
	}
	if(ans[2*i-1]<=ans2[mid]&&ans[2*i]<=ans2[mid]){
	  minb=minb+x;
	  maxb=maxb+x+1;
	}
  }
  if(minb<=m&&m<=maxb)return 1;
  else return 0;
}
inline int read(){
  int sum=0,f=1;char ch=getchar();
  while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=getchar();
  return f*sum;
}
int main(){
	k=read();n=read();m=read();
	int i,x;
	for(i=1;i<=k;i++){
	  a[i]=read();
	  x=(ll)m*a[i]/n;
	  ans[2*i-1]=abs((ll)n*x-(ll)m*a[i]);
	  ans[2*i]=abs((ll)n*(x+1)-(ll)m*a[i]);
	}
	for(i=1;i<=2*k;i++)ans2[i]=ans[i];
	sort(ans2+1,ans2+2*k+1);
	int l=1,r=2*k,mid;
	while(l<r){
	  mid=(l+r)>>1;
	  if(check(mid))r=mid;
	  else l=mid+1;
	}
	int minb=0;
	for(i=1;i<=k;i++){
      x=(ll)m*a[i]/n;
      if(ans[2*i-1]<=ans2[l]&&ans[2*i]>ans2[l]){
	    minb=minb+x;
	    b[i]=x;
	  }
	  if(ans[2*i-1]>ans2[l]&&ans[2*i]<=ans2[l]){
	    minb=minb+x+1;
	    b[i]=x+1;
	  }
	  if(ans[2*i-1]<=ans2[l]&&ans[2*i]<=ans2[l])minb=minb+x;
    }
    int d=m-minb;
    for(i=1;i<=k;i++){
      x=(ll)m*a[i]/n;
	  if(ans[2*i-1]<=ans2[l]&&ans[2*i]<=ans2[l]){
	    if(d){b[i]=x+1;d--;}
		else b[i]=x;
	  }
	}
	for(i=1;i<=k;i++)printf("%d ",b[i]);
	return 0;
}

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

signed main() {
    int k, n, m;
    cin >> k >> n >> m;
    ll a[k];
    rep(i, k) {
        cin >> a[i];
    }
    int use = 0;
    priority_queue<pair<ll, ll>> que;
    rep(i, k) {
        ll t = (a[i] * m + n - 1) / n;
        que.emplace(t * n - a[i] * m, i);
        use += t;
    }
    while(use > m) {
        auto p = que.top();
        que.pop();
        p.first -= n;
        que.emplace(p);
        use--;
    }
    ll b[k];
    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        b[p.second] = (p.first + m * a[p.second]) / n;
    }
    rep(i, k) {
        cout << b[i] << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define rev(v)  if(!v.empty())reverse(v.begin(),v.end())
#define PI 3.141592653589793238
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

ll inv_mod(ll x){
    return pow_mod(x,mod-2);
}

const ll N=(ll)3e5;
ll inv[N];
ll fac[N];

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

  for(ll i=1;i<N;i++)
  fac[i]=(i*fac[i-1])%mod;

  for(ll i=0;i<N;i++)
  inv[i]=inv_mod(fac[i]);
}

ll ncr(ll n,ll r){
    if(n<r)
    return 0;

    if(n==r||r==0)
    return 1LL;

    ll x=fac[n];
    ll y=inv[n-r];
    ll z=inv[r];

    return ((x*y)%mod*z)%mod;
}
bool test_cases=0;
ll grid[10004][101];

void solve()
{
   ll n;
   cin>>n;

   string s;
   cin>>s;

   ll ans=-1;

   ++n;

   ll a[n];

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

   ll l=1;

   ll r=(ll)1e4;

   while(l<=r){
       ll mid=(l+r)/2;

       for(ll i=0;i<n;i++){
           ll have=a[i]/mid;

           for(ll j=0;j<mid;j++){
               grid[j][i]=have;
           }

           ll rem=a[i]%mid;

           for(ll j=0;j<mid&&rem>0;j++,--rem)
           grid[j][i]++;
       }

       bool ok=true;

       for(ll i=0;i<mid;i++){
           for(ll j=1;j<n;j++){
               if(s[j-1]=='<'&&grid[i][j-1]>=grid[i][j]){
                   ok=false;
                   break;
               }
               if(s[j-1]=='>'&&grid[i][j-1]<=grid[i][j]){
                   ok=false;
                   break;
               }
           }
       }

       if(ok){
           ans=mid;
           l=mid+1;
       }
       else
       r=mid-1;
   }

   cout<<ans<<endl;

    for(ll i=0;i<n;i++){
           ll have=a[i]/ans;

           for(ll j=0;j<ans;j++){
               grid[j][i]=have;
           }

           ll rem=a[i]%ans;

           for(ll j=0;j<ans&&rem>0;j++,--rem)
           grid[j][i]++;
       }

   for(ll i=0;i<ans;i++){
           for(ll j=0;j<n;j++){
             cout<<grid[i][j]<<" ";
           }
           cout<<endl;
       }

}
int main()
{

   // init();   //factorial calculations

   //Start from Here.

  ll t;
  t=1;

  while(t--)
  solve();
//Good Bye!
    return 0;
}

#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

ll dp[2001][2001];

int main()
{
	int h,w;
	cin >> h >> w;
	map<ll,ll> sumx,sumy,sumxy;
	vector<string> S(h);
	for(auto &i:S)cin >> i;
	for(int i = 0;i<h;i++){
		for(int j = 0;j<w;j++){
			if(i==0&&j==0){
				dp[i][j]=1;
				sumx[i] += 1;
				sumy[j] += 1;
				sumxy[i-j]+=1;
				continue;
			}
			if(S[i][j]=='.'){
			(dp[i][j]+=sumx[i])%=MOD;
			(dp[i][j]+=sumy[j])%=MOD;
			(dp[i][j]+=sumxy[i-j])%=MOD;
			(sumx[i]+=dp[i][j])%=MOD;
			(sumy[j]+=dp[i][j])%=MOD;
			(sumxy[i-j]+=dp[i][j])%=MOD;
			}else{
				dp[i][j] = 0;
				sumx[i]=0;
				sumy[j]=0;
				sumxy[i-j]=0;
			}

		}
	}

	cout<<dp[h-1][w-1]<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int,int>;
int main() {
  const ll LINF = 1LL<<62;
  int n,t;
  cin >> n >> t;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int l = n/2;
  int r = n-l;
  set<ll> sa;
  for (int s=0; s<(1<<l); s++) {
    ll sum = 0;
    rep(i,l) {
      if ((s>>i)%2 == 1) sum += a[i];
    }
    sa.insert(sum);
  }
  set<ll> sb;
  for (int s=0; s<(1<<r); s++) {
    ll sum = 0;
    rep(i,r) {
      if ((s>>i)%2 == 1) sum += a[l+i];
    }
    sb.insert(sum);
  }
  vector<ll> vb;
  vb.push_back(-LINF);
  for (ll e : sb) vb.push_back(e);
  ll ans = 0;
  for (ll x : sa) {
    int j = upper_bound(vb.begin(), vb.end(), t-x) - vb.begin() - 1;
    ll y = vb[j];
    ans = max(ans, x+y);
  }
  cout << ans << endl;
  return 0;
}

#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 202020
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cerr<<clock()/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
vector<ll>a[3];

int main()
{
	file();
	map<char,int>mp; mp['R']=0,mp['G']=1,mp['B']=2;
	read(n);
	ll x; char cc;
	rep(i,1,n*2) read(x),cin>>cc,a[mp[cc]].push_back(x);
	rep(i,0,2) sort(a[i].begin(),a[i].end());
	auto qq=[&](int id,ll w)
	{
		if (!a[id].size()) return ll(1e18);
		int t=lower_bound(a[id].begin(),a[id].end(),w)-a[id].begin(); ll res=1e18;
		if (t) chkmin(res,w-a[id][t-1]);
		if (t!=(int)a[id].size()) chkmin(res,a[id][t]-w);
		return res;
	};
	int c=0,p=0; rep(i,0,2) if (a[i].size()%2==0u) ++c,p=i; if (c==3) return puts("0"),0;
	ll ans=1e18;
	rep(i,0,2) if (i!=p) for (auto x:a[i]) chkmin(ans,qq(3-i-p,x));
	int p1=(p==0?1:0),p2=3-p-p1;
	auto wk=[&](){ll mn=1e18;for (auto x:a[p]) chkmin(ans,mn+qq(p2,x)),chkmin(mn,qq(p1,x));};
	wk(); swap(p1,p2); wk();
	cout<<ans;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <utility>
#include <cstdarg>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define space char(32)
#define line char(10)
#define debug(x) cerr << '[' << #x << " = " << x << ']' << line
#define speedup ios_base::sync_with_stdio(false); cin.tie(NULL)
#define output_array(arr) for(auto &i: arr) cout << i << line
#define input_array(arr) for(auto &i: arr) cin >> i
#define For(n) for(int i = 0; i < n; i++)
#define hell 1000000007

typedef long long ll;

using namespace std;

int main()
{
	speedup;

	ll str, y, a, b, exp = 0;

	cin >> str >> y >> a >> b;

	while(str < y){
		if(str <= (str + b) / a) // && str * a < LLONG_MAX)
			str *= a;
		else
			break;
		++exp;
		// debug(str);
	}

	if(str >= y){
		--exp;
	}
	else{
		ll temp;
		temp = (y - str) / b;

		str += temp * b;

		exp += temp;

		if(str == y)
			exp--;
	}

	cout << exp << line;

	return 0;
}

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

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

    ll ans2 = 0;
    while((double)a*x< y && a*x < x+b){
        x *= a;
        ans2++;
    }
    ans2 += (y-x-1)/b;
    cout  << ans2 << endl;
}


#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
#define ml ll t,g; cin>>t; f(g=0;g<t;g++)
#define pi acos(-1)
using namespace std;
bool cmp(const pair<string,ll> &a,
         const pair<string,ll> &b)
{
    if(a.second!=b.second)
        return (a.second > b.second);
    else
        return (a.first < b.first);
}
int main()
{
    FastRead
    ll n,i,j,k;
    cin>>n;
    ll a[n+5],b[n+5],c=0;
    double ab,bc,ac;
    f(i=0; i<n; i++)
    {
        cin>>a[i]>>b[i];
    }
    f(i=0; i<n-2; i++)
    {
        f(j=i+1; j<n-1; j++)
        {
            f(k=j+1; k<n; k++)
            {
                if(((b[j]-b[i])*(a[k]-a[i]))==((b[k]-b[i])*(a[j]-a[i])))
                {
                    c=1;
                    break;
                }

            }
            if(c==1)
             break;
        }
        if(c==1)
            break;
    }
    if(c==1)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

/*ver 7*/
#include <bits/stdc++.h>
using namespace std;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll,ll>;
using mll = map<ll,ll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
#define each(x,v) for(auto& x : v)
#define reps(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
const ll INF = 1LL << 60;
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<=b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){}
template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
template <typename T> void in1(T &s) {rep(i,s.size()){in(s[i]);}}
template <typename T> void in2(T &s,T &t) {rep(i,s.size()){in(s[i],t[i]);}}
template <typename T> void in3(T &s,T &t,T &u) {rep(i,s.size()){in(s[i],t[i],u[i]);}}
template <typename T> void in4(T &s,T &t,T &u,T &v) {rep(i,s.size()){in(s[i],t[i],u[i],v[i]);}}
template <typename T> void in5(T &s,T &t,T &u,T &v,T &w) {rep(i,s.size()){in(s[i],t[i],u[i],v[i],w[i]);}}
void out(){cout << endl;}
template <typename T,class... U> void out(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; out(u...);}
void die(){cout << endl;exit(0);}
template <typename T,class... U> void die(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; die(u...);}
template <typename T> void outv(T s) {rep(i,s.size()){if(i!=0)cout<<" ";cout<<s[i];}cout<<endl;}
template <typename T> void out1(T s) {rep(i,s.size()){out(s[i]);}}
template <typename T> void out2(T s,T t) {rep(i,s.size()){out(s[i],t[i]);}}
template <typename T> void out3(T s,T t,T u) {rep(i,s.size()){out(s[i],t[i],u[i]);}}
template <typename T> void out4(T s,T t,T u,T v) {rep(i,s.size()){out(s[i],t[i],u[i],v[i]);}}
template <typename T> void out5(T s,T t,T u,T v,T w) {rep(i,s.size()){out(s[i],t[i],u[i],v[i],w[i]);}}
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
template <typename T> T allSum(vector<T> a){T ans=T();each(it,a)ans+=it;return ans;}
ll ceilDiv(ll a,ll b) {return (a+b-1)/b;}
ld dist(pair<ld,ld> a, pair<ld,ld> b){return sqrt(abs(a.fi-b.fi)*abs(a.fi-b.fi)+abs(a.se-b.se)*abs(a.se-b.se));} // ２点間の距離
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
#define YES(n) ((n) ? "YES" : "NO"  )
#define Yes(n) ((n) ? "Yes" : "No"  )
#define yes(n) ((n) ? "yes" : "no"  )

bool cheak(V<ll> &x,V<ll> &y,ll a,ll b,ll c){
	ll s;
	s=(x[a]-x[b])*(y[b]-y[c])-(y[a]-y[b])*(x[b]-x[c]);
	if(s==0)return true;
	return false;
}
int main(){
	init();
	inl(n);
	V<ll> x(n),y(n);
	in2(x,y);
	set<pair<ll,ll>> s;
	rep(i,n)reps(j,i+1,n)reps(k,j+1,n){
		if(cheak(x,y,i,j,k))die("Yes");
	}
	out("No");
	return 0;
}


#include <bits/stdc++.h>
#define FOR(ii,aa,bb) for(int ii=aa;ii<bb;ii++)
#define for0(ii,bb) FOR(ii,0,bb)
#define for1(ii,bb) FOR(ii,1,bb+1)
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>
#define piii pair<int,pii>
#define pdi pair<double,int>
#define vi vector<int>
#define sp " "
#define nl "\n"
#define all(x) x.begin(),x.end()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define int ll

using namespace std;

const int N = 200005;
const int INF = 1e9+5;
const int mod = 1e9+7;

int n,ans;
vector<vector<pii>> g;
vector<int> dist;

int topla(int x,int y){
    return (x+y)%mod;
}

int carp(int x,int y){
    return x*y%mod;
}

void dfs(int u,int d,int p=-1){
    dist[u]=d;
    for(auto e:g[u]){
        int v=e.st,w=e.nd;
        if(v==p)continue;
        dfs(v,d^w,u);
    }
}

signed main(){
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    fastio()
    cin >> n;
    g.resize(n+1);
    dist.resize(n+1);
    for(int i=1;i<n;i++){
        int u,v,w;
        cin >> u >> v >> w;
        g[u].pb({v,w});
        g[v].pb({u,w});
    }
    dfs(1,0);
    for(int i=0;i<60;i++){
        vector<int> cnt(2);
        for(int j=1;j<=n;j++){
            cnt[(dist[j]>>i)&1ll]++;
        }
        ans=topla(ans,carp(carp(cnt[0],cnt[1]),(1ll<<i)%mod));
    }
    cout << ans << nl;
}

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using P = pair<int, int>;
using Vp = vector<P>;
using VVp = vector<Vp>;
using pl = pair<ll, int>;
using Vpl = vector<pl>;
using VVpl = vector<Vpl>;

ll gcd(ll a, ll b)
{
    while (a) {
        b %= a;
        swap(a, b);
    }
    return b;
}

ll dsum(ll a)
{
    ll num = 0;
    while (a) {
        num += a % 10ll;
        a /= 10ll;
    }
    return num;
}

bool is_pal(string S)
{
    bool ok = true;
    for (int i = 0; i < (int)S.size(); i++) {
        int j = (int)S.size() - i - 1;
        ok = ok && (S[i] == S[j]);
    }
    return ok;
}

ll m = 998244353;
ll mpow(ll a, ll n)
{
    ll ret = 1;
    while (n) {
        if (n % 2) {
            ret *= a;
            ret %= m;
        }
        a = (a * a) % m;
        n /= 2;
    }
    return ret;
}

int calc(int a, int N)
{
    if (a > N) {
        return a - N;
    } else {
        return a + N;
    }
}
int main()
{
    int N, M;
    cin >> N >> M;
    VVp cond(N + 1);
    for (int i = 0; i < M; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        cond[x].push_back(make_pair(y, z));
    }
    ll dp[1 << 19];
    dp[0] = 1;
    for (int i = 1; i < (1 << N); i++) {
        Vi num(N + 1, 0);
        dp[i] = 0;
        int di = 0;
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) {
                dp[i] += dp[i - (1 << j)];
                num[j + 1]++;
                di++;
            }
        }
        for (int j = 1; j <= N; j++) {
            num[j] += num[j - 1];
        }
        bool ok = true;
        for (P con : cond[di]) {
            int y, z;
            tie(y, z) = con;
            if (num[y] > z) {
                ok = false;
            }
        }
        if (!ok) {
            dp[i] = 0;
        }
    }
    cout << dp[(1 << N) - 1] << endl;
}


#include <algorithm>
#include <iostream>

using namespace std;

const int MD = 1000000007;

long long inv(int n) {
	return n == 1 ? 1 : inv(n - MD % n) * (MD / n + 1) % MD;
}

long long choose(int n, int k) {
	return n < k ? 0 : k == 0 ? 1 : choose(n - 1, k - 1) * n % MD * inv(k) % MD;
}

int main() {
	int n, m, k; cin >> n >> m >> k;
	if (n - m >= k + 1) {
		cout << "0\n";
		return 0;
	}
	int ans = choose(n + m, n) - choose(n + m, n + (k + 1 - (n - m)));
	if (ans < 0)
		ans += MD;
	cout << ans << '\n';
	return 0;
}

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

ll fat[MAX+100];
ll ifat[MAX+100];

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

void init(){
	fat[0] = 1;
	for(ll i=1;i<=MAX;i++){
	  fat[i] = (fat[i-1]*i)%mod;
	}
	ifat[MAX] = power(fat[MAX], mod-2, mod);
	for(ll i=MAX-1;i>=0;i--) ifat[i] = (ifat[i+1]*(i+1))%mod;
}

ll choose(int x, int y){
	if(y < 0 || y > x || x < 0) return 0;
	return fat[x]*(ifat[y]*ifat[x-y]%mod)%mod;
}

void solve(){
	init();
	int n, m, k;
	cin>>n>>m>>k;
	if(n > m + k){
		cout<<"0\n";
		return;
	}

	int ans = choose(n+m, n);
	for(int i=k+1;i<=n;i++){
		int j = i - k - 1;
		int l = j;
		int a = k, b = 0;
		int aux = (choose(2*l + a - b, l) - choose(2*l + a - b, l - 1)) * choose(n+m-i-j, n-i) % mod;
		ans -= aux;
		ans %= mod;
	}
	ans = (ans + mod) % mod;
	cout<<ans<<"\n";

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

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


//kyoprosaikoooooooooooo!!
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
double pai = 3.141592653589793238;
using namespace std;
//素数判定 O(√N)
ll prime (ll abc) {
  if (abc < 2) {
    return 0;
  }
  else if (abc == 2) {
    return 1;
  }
  else if (abc % 2 == 0) {
    return 0;
  }
  double sqrtabc = sqrt(abc);
  for (int i = 3; i <= sqrtabc; i++) {
    if (abc % i == 0) {
      return 0;
    }
  }
  return 1;
}
//素因数分解(約数列挙) O(√N)
vector<ll> divisor(ll n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
//小さい方に揃える
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//大きい方に揃える
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//繰り返し二乗法 O(logN)
ll pow(ll x, ll n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
    x *= x;               //ret = ret * x % mod / x = x * x % mod でMODとれる
    n >>= 1;  // n を1bit 左にずらす
  }
  return ret;
}
struct Edge {
  ll to;
  ll w;
  Edge(ll to, ll w) : to(to) , w(w) {}
};
using Graph = vector<vector<Edge>>;
int main() {
  ll N, Q;
  cin >> N >> Q;
  set<ll> X;
  for (ll i = 0; i < N; i++) {
    ll a;
    cin >> a;
    X.insert(a);
  }
  vector<ll> A;
  for (ll v : X) {
    A.push_back(v);
  }
  ll SA = A.size();
  vector<ll> P;
  P.push_back(A[0] - 1);
  for (ll i = 1; i < SA; i++) {
    P.push_back(A[i] - A[i - 1] - 1);
  }
  vector<ll> L;
  ll sum = 0;
  for (ll n : P) {
    sum += n;
    L.push_back(sum);
  }
  for (ll i = 0; i < Q; i++) {
    ll j;
    cin >> j;
    ll O = lower_bound(L.begin(), L.end(), j) - L.begin();
    cout << j + O << endl;
  }
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define reps(x, s) for(llint (x) = 0; (x) < (llint)(s).size(); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define sz(x) ((ll)(x).size())
#define ceil(x, y) (((x)+(y)-1) / (y))
#define all(x) (x).begin(),(x).end()
#define outl(...) dump_func(__VA_ARGS__)
#define inf 1e18

using namespace std;

typedef long long llint;
typedef long long ll;
typedef pair<ll, ll> P;
bool exceed(ll x, ll y, ll m){return x >= m / y + 1;}

struct edge{
	ll to, cost;
	edge(){}
	edge(ll a, ll b){
		to = a, cost = b;
	}
};

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for(int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
	for(typename map<T, U>::iterator itr = map_var.begin(); itr != map_var.end(); itr++) {
		os << "(" << itr->first << ", " << itr->second << ")";
		itr++;
		if(itr != map_var.end()) os << ",";
		itr--;
	}
	return os;
}
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
	for(typename set<T>::iterator itr = set_var.begin(); itr != set_var.end(); itr++) {
		os << *itr;
		++itr;
		if(itr != set_var.end()) os << " ";
		itr--;
	}
	return os;
}
void dump_func() {cout << endl;}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    cout << head;
    if(sizeof...(Tail) > 0) cout << " ";
    dump_func(std::move(tail)...);
}

ll n;
string s, x;
ll dp[200005][7];

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

	cin >> n >> s >> x;
	s = "#" + s, x = "#" + x;

	dp[n][0] = 1;
	rep(i, 1, 6) dp[n][i] = -1;

	for(int i = n-1; i >= 0; i--){
		rep(j, 0, 6){
			if(x[i+1] == 'T') dp[i][j] = max(dp[i+1][j*10%7], dp[i+1][(j*10+s[i+1]-'0')%7]);
			if(x[i+1] == 'A') dp[i][j] = min(dp[i+1][j*10%7], dp[i+1][(j*10+s[i+1]-'0')%7]);
		}
	}

	if(dp[0][0] > 0) outl("Takahashi");
	if(dp[0][0] < 0) outl("Aoki");

	return 0;
}

#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define lol __int128
#define ld long double
#define pii pair<int, int>
#define dbg(x) cerr << #x << " = " << x << "\n"
using namespace std;
ll a, b, c;
ll power(ll x, ll y, ll m) {
	x %= m;
	ll res = 1;
	while(y) {
		if(y & 1)
			res = res * x % m;

		x = x * x % m;
		y >>= 1;
	}

	return res;
}

int32_t main() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
	boost;
	cin >> a >> b >> c;
	a %= 10;
	if(a <= 1 || a == 5 || a == 6) cout << a;
	else if(a == 2 || a == 3 || a == 7 || a == 8) {
		cout << power(a, (power(b, c, 4) == 0 ? 4 : power(b, c, 4)), 10);
	} else {
		cout << power(a, (power(b, c, 2) == 0 ? 2 : power(b, c, 2)), 10);
	}
}


/******************************************
* AUTHOR : RTG *
******************************************/
#include <bits/stdc++.h>
using namespace std;

int main() {

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

	#ifndef ONLINE_JUDGE
    // For getting input from input.txt file
    FILE *input = freopen("/home/tharun/Documents/cpg/input.txt", "r", stdin);
    // Printing the Output to output.txt file
    FILE *output = freopen("/home/tharun/Documents/cpg/output.txt", "w", stdout);
    int start_time = (int)clock();
    #endif

    int n,x;
    cin>>n>>x;
    for(int i=0;i<n;i++){
    	int tmp;
    	cin>>tmp;
    	if(tmp==x);
    	else
    	cout<<tmp<<" ";
    }

    #ifndef ONLINE_JUDGE
    // Time taken for execution
    cout<<"\nTime = "<<clock() - start_time<<"ms";
    #endif

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,a;
  cin >> n >> x;
  while(cin >> a){
    if(a != x) cout << a << ' ';
  }
}


#include<bits/stdc++.h>
#define int ll
#define sz(x) int((x).size())
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
using namespace std;
using ll = long long;
using pi = pair<int,int>;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int minf = 0xc0c0c0c0c0c0c0c0;

vector<int> adj[200200];
int D;
int cnt;

int dfs(int cur, int p=-1) {
    int mn=0, mx=0;
    for (auto &nxt : adj[cur]) {
        if (nxt == p) continue;
        int r = dfs(nxt, cur);
        mn = min(mn, r);
        mx = max(mx, r);
    }
    if (mx + mn >= 1) return mx - 1;
    if (mn == -D) {
        ++cnt;
        return D;
    }
    return mn - 1;
}

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

    int n,k; cin>>n>>k;
    for (int i=1; i<n; i++) {
        int a,b; cin>>a>>b;
        adj[a].pb(b); adj[b].pb(a);
    }
    int here = -1;
    for (int le=1,ri=n-1; le<=ri;) {
        D = le+ri>>1;
        cnt = 0;
        int r = dfs(1);
        if (r < 0) ++cnt;
        if (cnt <= k) {
            here = D;
            ri = D - 1;
        }
        else {
            le = D + 1;
        }
    }
    assert(~here);
    cout<<here<<'\n';
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<long long,long long>
#define mp make_pair
#define pb push_back
int n,c[100005],vis[100005],nowc[100005];
vector <int> g[100005];
vector <int> ans;
void dfs(int now)
{
	/*
	cout<<now<<endl;
	for(int i=1;i<=n;i++) cout<<vis[i]<<" ";
	puts("");
	for(int i=1;i<=n;i++) cout<<nowc[i]<<" ";
	puts("");
	system("pause");
	*/
	vis[now]=1;
	if(nowc[c[now]]==0) ans.pb(now);
	nowc[c[now]]++;
	for(int i=0;i<g[now].size();i++)
	{
		if(!vis[g[now][i]]) dfs(g[now][i]);
	}
	nowc[c[now]]--;
}
void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>c[i];
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(1);
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++) cout<<ans[i]<<"\n";
}
signed main()
{
	int _=1;
	//cin>>_;
	while(_--) solve();
	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int a, b, w;
    cin>>a>>b>>w;
    w*=1000;
    int l=1e6+1, r=-(1e6+1);
    for(int i=1;i<=w;i++){
        if(a*i<=w && w<=b*i){
            l=min(l, i);
            r=max(r, i);
        }
    }
    if(l==1e6+1)  cout<<"UNSATISFIABLE"<<endl;
    else cout<<l<<" "<<r<<endl;
}

#include <bits/stdc++.h>

long long mod = 1e9 + 7;

long long modinv(long long dividend, long long divisor, long long modnum){
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = divisor / b;
        divisor -= t * b; std::swap(divisor, b);
        u -= t * v; std::swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    long long ans = dividend * u % mod;
    return ans;
}

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

    if(N > M + K){
        std::cout << 0 << std::endl;
        return 0;
    }

    long long mult = 1, d1_1 = 1, d1_2 = 1, d2_1 = 1, d2_2 = 1;

    for(int i=N+M; i>0; i--){
        mult = (mult * i) % mod;
    }
    for(int i=N; i>0; i--){
        d1_1 = (d1_1 * i) % mod;
    }
    for(int i=M; i>0; i--){
        d1_2 = (d1_2 * i) % mod;
    }
    for(int i=N-K-1; i>0; i--){
        d2_1 = (d2_1 * i) % mod;
    }
    for(int i=M+K+1; i>0; i--){
        d2_2 = (d2_2 * i) % mod;
    }

    long long ans1 = modinv(mult, d1_1, mod);
    ans1 = modinv(ans1, d1_2, mod);
    long long ans2 = modinv(mult, d2_1, mod);
    ans2 = modinv(ans2, d2_2, mod);

    if(N == K){
        std::cout << ans1 << std::endl;
        return 0;
    }

    if(ans1 < ans2){
        ans1 += mod;
    }

    std::cout << ans1 - ans2 << std::endl;

    return 0;
}


#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define reps(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define prl(a) cout << (a) << endl
#define allrange(a) a.begin(),a.end()

bool solve_translated(vector<pair<int,int>> &S,vector<pair<int,int>> &T){
    int N = S.size();
    int dx = S[0].first-T[0].first;
    int dy = S[0].second-T[0].second;
    bool flg = true;
    reps(i,1,min(N,20)){
        if(!((S[i].first==T[i].first+dx) && (S[i].second==T[i].second+dy))){flg = false; break;}
    }
    return flg;
}
vector<pair<int,int>> Pitagora_rot(vector<pair<int,int>> &S,int a, int b , int c){
    int N = S.size();
    vector<pair<int,int>> PS(N);
    auto pt0 = S[0];
    PS[0] = pt0;
    bool flg = true;
    int dx,dy,x,y;
    reps(i,1,N){
        dx = S[i].first - pt0.first;
        dy = S[i].second - pt0.second;
        x=dx*a-dy*b;
        y=dx*b+dy*a;
        if(((x%c)!=0) || ((y%c)!=0)) {flg = false; break;}
        PS[i] = make_pair(x/c+pt0.first, y/c+pt0.second);
    }
    if(flg) return PS;
    else return vector<pair<int,int>>();
}

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

    vector<pair<int,int>> S(N),T(N);
    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        S[i].first = x;S[i].second = y;
    }

    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        T[i].first = x;
        T[i].second = y;
    }
    sort(allrange(T));

/*ピタゴラ三角形
    5	12	13
    8	15	17
    3	4	5
*/
    constexpr int tri[12][3] ={
    {3,4,5},
    {4,3,5},
    {-3,4,5},
    {-4,3,5},
    {0,1,1},
    {1,0,1},
    {-1,0,1},
    {0,-1,1},
    {-3,-4,5},
    {-4,-3,5},
    {3,-4,5},
    {4,-3,5}
    };

 /*
    vector<vector<int>> tri(0);
    tri.push_back(vector<int>({3,4,5}));
    tri.push_back(vector<int>({4,3,5}));
    tri.push_back(vector<int>({-3,4,5}));
    tri.push_back(vector<int>({-4,3,5}));
    tri.push_back(vector<int>({0,1,1}));
    tri.push_back(vector<int>({1,0,1}));
    tri.push_back(vector<int>({-1,0,1}));
    tri.push_back(vector<int>({0,-1,1}));
    tri.push_back(vector<int>({-3,-4,5}));
    tri.push_back(vector<int>({-4,-3,5}));
    tri.push_back(vector<int>({3,-4,5}));
    tri.push_back(vector<int>({4,-3,5}));
 //   tri.push_back(vector<int>({-5, -12, 13}));
 //   tri.push_back(vector<int>({-12, -5, 13}));
 //   tri.push_back(vector<int>({-8,-15,17}));
 //   tri.push_back(vector<int>({-15,-8,17}));
 //   tri.push_back(vector<int>({5, 12, 13}));
 //   tri.push_back(vector<int>({12, 5, 13}));
 //   tri.push_back(vector<int>({8,15,17}));
 //   tri.push_back(vector<int>({15,8,17}));
 //   tri.push_back(vector<int>({-5, 12, 13}));
 //  tri.push_back(vector<int>({-12, 5, 13}));
  //  tri.push_back(vector<int>({-8,15,17}));
  //  tri.push_back(vector<int>({-15,8,17}));
 //   tri.push_back(vector<int>({5, -12, 13}));
 //   tri.push_back(vector<int>({12, -5, 13}));
 //   tri.push_back(vector<int>({8,-15,17}));
 //   tri.push_back(vector<int>({15,-8,17}));

 */
    bool flg;

    if(N==2){
        auto sx = S[0].first-S[1].first;
        auto sy = S[0].second-S[1].second;
        auto tx = T[0].first-T[1].first;
        auto ty = T[0].second-T[1].second;
        flg= (sx*sx+sy*sy==tx*tx+ty*ty);
    } else {
        rep(j,12){
            auto S2 = Pitagora_rot(S,tri[j][0],tri[j][1],tri[j][2]);
            if(S2.empty()) continue;
            sort(allrange(S2));
            flg = solve_translated(S2,T);
            if(flg) break;
        }
    }
    if(flg) prl("Yes"); else prl("No");
}

#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<stack>
#include<numeric>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<cstdarg>

using namespace std;

#define DEBUG(var) cout << #var << ": " << var << " ";
#define DEBUG_EN(var) cout << #var << ": " << var << endl;

struct Edge {
  int to;
  long long weight;
  Edge() : to(0), weight(0) {}
  Edge(int to, long long weight) : to(to), weight(weight) {}
  Edge(const Edge& e) {
    to = e.to;
    weight = e.weight;
  }
  bool operator>(const Edge &e) const { return weight > e.weight; }
  bool operator<(const Edge &e) const { return weight < e.weight; }
  bool operator==(const Edge &e) const { return weight == e.weight; }
  bool operator<=(const Edge &e) const { return weight <= e.weight; }
  bool operator>=(const Edge &e) const { return weight >= e.weight; }
};

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
using weightedGraph = vector<vector<Edge>>;
using heap = priority_queue<int, vector<int>, greater<int>>;

const ll BIL = 1e9;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 29;
const ld PI = 3.141592653589793238462643383;

int main(int argc,char* argv[]){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<complex<double>> s(n), t(n);
  for(int i=0;i<n;i++) {
    double a, b;
    cin >> a >> b;
    s[i] = {a, b};
  }
  for(int i=0;i<n;i++) {
    double c, d;
    cin >> c >> d;
    t[i] = {c, d};
  }
  if(n == 1) {
    cout << "Yes" << endl;
    return 0;
  }
  using vc = vector<complex<double>>;
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
    if(i == j) continue;
    auto a = t[i], b = t[j];
    if(norm(s[1]-s[0]) != norm(b-a)) continue;
    vc na = s, nb = t;
    auto f = [&](vc& p, complex<double> q, complex<double> r) {
      for(int i=0;i<n;i++) p[i] -= q;
      for(int i=0;i<n;i++) p[i] *= r;
      sort(p.begin(), p.end(), [](complex<double> lhs, complex<double> rhs) {
        if(lhs.real() == rhs.real()) return lhs.imag() < rhs.imag();
        return lhs.real() < rhs.real();
      });
    };
    f(na, s[0], b-a);
    f(nb, a, s[1]-s[0]);
    bool flag = true;
    for(int i=0;i<n;i++) {
      if(abs(na[i] - nb[i]) > 1e-6) flag = false;
    }
    if(flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


// ※※※ 解答不能 ※※※
// https://atcoder.jp/contests/abc207/editorial/2153
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using vd = vector<double>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int a0[101], b0[101], a1[101], b1[101], a2[101], b2[101], a3[101], b3[101], c[101], d[101];

int main(){
    int N;
    scanf("%d", &N);
    vd a(N), b(N), c(N), d(N);
    rep(_, 2){
        rep(i, N) scanf("%lf %lf", &a[i], &b[i]);
        int x = 0, y = 0;
        rep(i, N){
            x += a[i];
            y += b[i];
            a[i] *= N;
            b[i] *= N;
        }
        rep(i, N){
            a[i] -= x;
            b[i] -= y;
        }
        swap(a, c);
        swap(b, d);
    }
    rep(i, N){
        if(a[i] != 0 || b[i] != 0){
            swap(a[i], a[0]);
            swap(b[i], b[0]);
        }
    }
    string ans = "No";
    const double eps = 1e-6;
    rep(i, N){
        double angle = atan2(d[i], c[i]) - atan2(b[0], a[0]);
        bool ok = true;
        rep(j, N){
            double A = a[j] * cos(angle) - b[j] * sin(angle);
            double B = a[j] * sin(angle) + b[j] * cos(angle);
            bool ok2 = false;
            rep(k, N){
                if(abs(A - c[k]) <= eps && abs(B - d[k]) <= eps) ok2 = true;
            }
            ok &= ok2;
        }
        if(ok) ans = "Yes";
    }
    printf("%s\n", ans.c_str());
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll modn = 1000000007;
const double eps = 1e-3;
const double pi = acos(-1);
struct pii{
    double x,y;
    double len2() const{
        return x*x+y*y;
    }
    double arc(){
        return atan2(y,x);
    }
    pii rot(double th){
        return pii{cos(th)*x-sin(th)*y,sin(th)*x+cos(th)*y};
    }
};

bool comp(const pii& a,const pii &b){
    return fabs(a.len2()-b.len2())<1e-6;
}
pii s[200],t[200];
pii temp_t[200];
int n;
pii operator -(const pii& a,const pii &b){
    return pii{a.x-b.x,a.y-b.y};
}

bool check(int a,int b){
    pii dis = t[a];
    for(int i=0;i<n;i++)temp_t[i]=t[i]-dis;
    double th = -(temp_t[b]).arc();
    for(int i=0;i<n;i++)temp_t[i]=temp_t[i].rot(th);
    for(int i=0;i<n;i++){
        int flag=0;
        for(int j=0;j<n;j++){
            if((temp_t[i]-s[j]).len2()<eps){
                flag=1;
                break;
            }
        }
        if(flag==0)return 0;

    }
    return 1;
    //temp_t[b]
}

int main()
{
    cin>>n;
    if(n==1){
        cout<<"Yes"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)cin>>s[i].x>>s[i].y;

    for(int i=1;i<n;i++){
        s[i]=s[i]-s[0];
    }
    s[0]=s[0]-s[0];
    double th = -s[1].arc();
    for(int i=1;i<n;i++){
        s[i]=s[i].rot(th);
    }//for(int i=0;i<n;i++)cout<<s[i].x<<" "<<s[i].y<<endl;
    for(int i=0;i<n;i++)cin>>t[i].x>>t[i].y;
    ll ans = 0;
    for(int i=0;i<n;i++){

        for(int j=0;j<n;j++){
            if(j==i)continue;
            if(!comp(t[j]-t[i],s[1]))continue;
            if(check(i,j)){ans=1;}
            if(ans)break;
        }
        if(ans)break;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


#include <iostream>
#include<cmath>
#include<vector>
#include<set>
#include <algorithm>
#include<map>
#include<string>
using namespace std;typedef long long ll;
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
#define FORA(i,I) for(const auto& i:I)
//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

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

int main() {
    ll i,n,k;
    vector<ll>a,b;
    cin>>n;
    for(i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(i!=n/i){
                a.pb(i);
                b.pb(n/i);
            }else{
                a.pb(i);
            }
        }
    }
    ll cnt1=a.size();
    ll cnt2=b.size();
    for(i=0;i<cnt1;i++){
        cout<<a[i]<<endl;
    }
    for(i=cnt2-1;i>=0;i--){
        cout<<b[i]<<endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  int ans = 2, count = 0;
  rep(i, 1010) {
    if (i < 2) continue;
    int j = 0;
    rep(k, N) if (!(A.at(k) % i)) j++;
    if (j >= count) {
      ans = i;
      count = j;
    }
  }
  cout << ans << endl;
}


#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <time.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  reverse(all(v));
  ll p = v[0];
  ll m = MOD-v[0];
  ll dp = 1;
  ll dm = 1;
  rep(i,1,v.sz){
    ll dp1 = (dp+dm)%MOD;
    ll dm1 = dp;
    ll p1 = (p+m+v[i]*dp1%MOD)%MOD;
    ll m1 = (MOD+p-v[i]*dm1%MOD)%MOD;
    p = p1;
    m = m1;
    dp = dp1;
    dm = dm1;
  }
  cout << p%MOD << endl;
}

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

int main(){
    int n;
    cin >> n;
    ll a[401];
    for(int i = 0; i < 401; ++i){
        a[i] = 0;
    }
    for(int i = 0; i < n; ++i){
        ll tmp;
        cin >> tmp;
        ++a[tmp+200];
    }

    ll sum = 0;
    for(int i = 0; i < 401; ++i){
        for(int j = i; j < 401; ++j){
            sum += a[i]*a[j]*(i-j)*(i-j);
        }
    }
    cout << sum << endl;
    return 0;
}


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

#define fi first
#define se second
#define rng(i, a, b) for (int i=int(a);i<int(b);++i)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i=int(b)-1;i>=int(a);--i)
#define per(i, b) gnr(i, 0, b)
#define all(obj) begin(obj), end(obj)
#define allr(obj) rbegin(obj), rend(obj)
#define cinv(a) rep(i,(int)a.size()) cin >> a[i]
#define debug(a) rep(i,(int)a.size()) cout << a[i] << " "
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<Pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

template<typename T>
bool chmax(T& a, const T& b){if(a < b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a, const T& b){if(a > b){a=b;return true;}return false;}
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int di[] = {0, -1, 0, 1};
const int dj[] = {1, 0, -1, 0};
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e15;
const double eps = 1e-4;
const char nl = '\n';

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

ll nCk(int n, int k)
{
	ll x = 1, y = 1;
	for (int i = 1; i <= k; ++i)
	{
		x = x*(n-i+1)%MOD;
		y = y*i%MOD;
	}
	return x*power(y, MOD-2)%MOD;
}

struct UF
{
	vi d;
	UF(int n) : d(n, -1) {}
	int root(int x)
	{
		if (d[x] < 0) return x;
		return d[x] = root(d[x]);
	}
	bool unite(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -d[root(x)]; }
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c; cin >> a >> b >> c;
	cout << (a*a + b*b < c*c ? "Yes" : "No") << nl;
}

#include <iostream>

using namespace std;

int main(){
    long long a, b, c;
    cin >> a >> b >> c;

    if (a * a + b * b < c * c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using db = double;
using vi = vector<int>;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout << #x <<"	"<< x <<endl
const int inf = 0x3f3f3f3f;
const db eps = 1e-8;
const int mod = 1e9+7;
ll qpow(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b&1)ret = ret*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ret;
}
const int maxn = 1<<10;
int n;
int a[maxn], b[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin >> n;
	for(int i=1; i<=n; ++i){
		a[i] = (2*i)%n+1;
		b[i] = (2*i+1)%n+1;
	}
	for(int i=1; i<=n; ++i)cout << a[i] <<" " << b[i] <<"\n";
    return 0;
}

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

//head

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int now = 1;
	auto get = [&]() {
		if(now == n) return now = 1;
		return ++now;
	};
	//cout << n << endl;
	rep(i, n) {
		cout << get() << ' ' << get() << '\n';
	}
}


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

#define FREP(i,a,b) for(long long i=a;i<b;i++)
#define REP(i,n) FREP(i,0,n)
#define PB push_back
#define ll long long
#define MP make_pair
#define mod 1000000007
#define endl "\n"
#define vi vector<ll>
#define si set<ll>
#define mi map<ll,ll>
#define bs binary_search
#define pri(a,n) REP(i,n)cout<<a[i]<<" ";
#define all(x) x.begin(),x.end()
#define sz(a) (ll)a.size()
#define sa(a,n) sort(a,a+n)
#define sra(a,n) sort(a,a+n,greater<ll>())
#define sv(v) sort(all(v))
#define srv(v) sort(v.rbegin(),v.rend())
#define sp(x) fixed<<setprecision(x)
#define mem(a) memset(a,-1,sizeof(a))
#define ff first
#define ss second
#define deb(x) cout<<#x<<' '<<x<<endl;
#define FASTIO ios_base::sync_with_stdio(false);\
               cin.tie(NULL);\
               cout.tie(NULL);

void _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()
{
    ll n, k, q = 0, c = 0;
    string s;
    cin >> n >> k;
    while (n) {
        c += (n % 10);
        n /= 10;
    }
    while (k) {
        q += (k % 10);
        k /= 10;
    }
    cout << max(c, q);
}

int main()
{
    FASTIO;
    int t = 1;
    // cin >> t;         // Test Case :-||-: //

    while (t--)
    {
        _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();
    }

    return 0;
}

// Thanks for stalking :P

#include<iostream>
using namespace std;
#include<vector>
#include <algorithm>
#define re(i,n) for(int i = 0; i < n; i++)
const int MOD = 998244353;

long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

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

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

int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}

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

    int a = ctoi(sa[0]) + ctoi(sa[1]) + ctoi(sa[2]);
    int b = ctoi(sb[0]) + ctoi(sb[1]) + ctoi(sb[2]);

    if(a > b) cout << a << endl;
    else cout << b << endl;

    return 0;

}


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

long long a[60];
long long ans;
map<long long,long long> dp[60];

long long coin(int n,long long x)
{
	long long p,q,r;

	if (dp[n][x]>0) return dp[n][x];
	p=x/a[n];
	q=x%a[n];
	if (q==0){
		dp[n][x]=1;
		return dp[n][x];
	}
	if (x>a[n+1]-a[n]) {
		dp[n][x]=coin((n-1),(x-a[n+1]+a[n]));
		return dp[n][x];
	}
	if (x<a[n]-a[n+1]) {
		dp[n][x]=coin((n-1),(x+a[n+1]-a[n]));
		return dp[n][x];
	}
	r=coin((n-1),q);
	if (x<0){
		r+=coin((n-1),(q+a[n]));
		dp[n][x]=r;
		return r;
	}
	if (x>0){
		r+=coin((n-1),(q-a[n]));
		dp[n][x]=r;
		return r;
	}
}

int main() {
	int n;
	long long x,r;

	cin >> n >> x ;
	rep(i, n) cin >> a[i] ;
	ans=0;
	n--;
	x%=a[n];
	if (x==0) {
		cout << 1 << endl;
		return 0;
	}
	ans=coin((n-1),x);
	if (x<0)ans+=coin((n-1),(x+a[n]));
	if (x>0)ans+=coin((n-1),(x-a[n]));

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

#include <complex>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

using Expr = complex<double>;

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

    vector<bool> portal(n + 1, false);
    for (int i = 0; i < k; i += 1) {
        int pos;
        cin >> pos;
        portal[pos] = true;
    }

    vector<Expr> dp(n + 1, Expr{0, 0});
    Expr sum = dp[n];

    auto max_portals = 0;
    auto curr_portals = 0;

    for (int i = n - 1; i >= 0; i -= 1) {
        if (portal[i]) {
            dp[i] = {1, 0};
            curr_portals += 1;
            max_portals = max(max_portals, curr_portals);
        } else {
            dp[i] = Expr{0, 1} + sum / (1.0 * m);
            curr_portals = 0;
        }

        sum += dp[i];
        if (i + m <= n) {
            sum -= dp[i + m];
        }
    }

    if (max_portals >= m) {
        cout << "-1\n";
    } else {
        auto res = -dp[0].imag() / (dp[0].real() - 1.0);
        cout << fixed << setprecision(4) << res << "\n";
    }

    return 0;
}


#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 = 1000000007;
//constexpr long long MOD = 998244353;
constexpr long long INF = 1e9+100;
constexpr long long LINF = 1e18+100;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); 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(){
    int a,b,x,y; cin >> a >> b >> x >> y;
    int res = 0;
    if(a==b)res = x;
    else if(a<b){
        res = min(y, x*2)*abs(a-b)+x;
    }
    else{
        res = min(y, x*2)*(abs(a-b)-1)+x;
    }
    cout << res << ln;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,x,y;
    while(cin>>a>>b>>x>>y)
    {
        long long ans1,ans2;
        if(a==b)
           cout<<x<<endl;
        else if(a>b)
        {
            ans1=(a-b-1)*y+x;
            ans2=(a-b-1)*2*x+x;
            cout<<min(ans1,ans2)<<endl;
        }
        else
        {
            ans1=x+(b-a)*y;
            ans2=(b-a)*2*x+x;
            cout<<min(ans1,ans2)<<endl;
        }
    }
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 998244353;

ll modpow(ll b, ll e) {
  ll ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}

vl fac;
ll inv(ll x) {
  return modpow(x, mod-2);
}

ll c(ll n, ll r) {
  if (r > n or r < 0) return 0;
  return (fac[n] * inv(fac[r]) % mod) * inv(fac[n-r]) % mod;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

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

  fac.pb(1);
  rep(i,1,212345) {
    fac.pb((fac.back()*i)%mod);
  }

  vl a(n);
  rep(i,0,n) cin >> a[i];

  vl s(k+1);
  rep(i,0,k+1) {
    rep(j,0,n) {
      s[i] += modpow(a[j], i);
      s[i] %= mod;
    }
  }

  rep(x,1,k+1) {
    ll ans = 0;
    rep(i,0,x+1) {
      ll tans = c(x, i);
      tans *= s[i];
      tans %= mod;
      tans *= s[x-i];
      tans %= mod;
      ans += tans;
      ans %= mod;
    }
    rep(i,0,n) {
      ans -= modpow(2*a[i], x);
      ans %= mod; ans += mod; ans %= mod;
    }
    ans *= inv(2);
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << '\n';
  }

}

#include <bits/stdc++.h>

const int K = 300;
const int N = 200000;
const int P = 998244353;
inline int add(int x, int y) {x += y; return x >= P ? x - P : x;}
inline int sub(int x, int y) {x -= y; return x < 0 ? x + P : x;}
inline int mul(int x, int y) {return (int)(1ll * x * y % P);}

int s[K + 5], t[K + 5], c[K + 5][K + 5];

int p[N + 5], a[N + 5], n, k;
int main() {
	scanf("%d%d", &n, &k);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]), p[i] = 1;
	for(int j=0;j<=k;j++) for(int i=1;i<=n;i++)
		s[j] = add(s[j], p[i]), t[j] = add(t[j], mul(p[i], p[i])), p[i] = mul(p[i], a[i]);
	for(int i=0;i<=k;i++) for(int j=0;j<=i;j++)
		c[i][j] = (j ? add(c[i - 1][j - 1], c[i - 1][j]) : 1);

	int iv2 = (P + 1) >> 1;
	for(int i=1;i<=k;i++) {
		int ans = 0;
		for(int j=0;j<=i;j++) {
			int del = mul(iv2, sub(mul(s[j], s[i - j]), s[i]));
			ans = add(ans, mul(c[i][j], del));
		}
		printf("%d\n", ans);
	}
}


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

typedef long long  ll;
typedef long double ld;

#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod  1000000007

const int N = 100005;

ll sigma(ll n)
{
        return (n*(n+1))/2;
}
signed main()
{
        speed;
        int n,k;
        cin>>n>>k;
        ll ans=100*k*sigma(n);
        ans+=sigma(k)*n;
        cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

    string res = "";
    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            res.clear();
            res += to_string(i);
            res += '0';
            res += to_string(j);
            sum += stoll(res);
        }
    }

    cout << sum << endl;
    return 0;
}


#include <bits/stdc++.h>

#define FOR(i,n)    for(lli i=0;i<(lli)(n);++i)
#define FORU(i,j,k) for(lli i=(j);i<=(lli)(k);++i)
#define FORD(i,j,k) for(lli i=(j);i>=(lli)(k);--i)

#define pb push_back
#define mt make_tuple

using namespace std;

using lli = long long int;
using pll = pair<lli, lli>;

using vi = vector<lli>;
using vvi = vector<vi>;
using pii = tuple<lli, lli>;
using vii = vector<pii>;
using vvii = vector<vii>;

#define X(a) get<0>(a)
#define Y(a) get<1>(a)
#define Z(a) get<2>(a)

string TYPE(const int*)          { return "%d";   }
string TYPE(const lli*)          { return "%lld"; }
string TYPE(const size_t*)       { return "%u";   }
string TYPE(const double*)       { return "%lf";  }
string TYPE(const char*)         { return "%c";   }
string TYPE(const char**)        { return "%s";   }
string TYPE(const unsigned int*) { return "%u";   }

const int MAX_BUF = 100*1000+42;
char buf[MAX_BUF];

void RD() {}
template<typename T, typename... Args>
void RD(T* v, Args... args)
{
    scanf((" " + TYPE(v)).c_str(), v);
    RD(args...);
}
template<typename... Args>
void RD(string* v, Args... args)
{
    scanf(" %s", buf);
    (*v) = buf;
    RD(args...);
}

template<class A, class B, typename... Args>
void PR(bool nl, pair<A, B> p, Args... args);
void PR(bool nl = true)
{ if(nl) printf("\n"); }
template<typename T, typename... Args>
void PR(bool nl, T v, Args... args)
{
    printf((TYPE(&v) + " ").c_str(), v);
    PR(nl, args...);
}
template<typename... Args>
void PR(bool nl, string& v, Args... args)
{
    printf("%s", v.c_str());
    PR(nl, args...);
}
template<class A, class B, typename... Args>
void PR(bool nl, pair<A, B> p, Args... args)
{
    PR(false, "{", p.first, ",", p.second, "}");
    PR(nl, args...);
}
template<typename... Args>
void PR(Args... args)
{ PR(true, args...); }

const long long int oo = 1000*1000*1000;

struct Coord {
    int x, y;
    Coord(int x = 0, int y = 0) : x(x), y(y) {}
    Coord operator + (const Coord& droite) const
    { return Coord(x + droite.x, y + droite.y); }
};

struct AB {
    int k; vector<lli> arbre;
    AB(int _k = 20, lli def = 0) { k = _k;
        FOR(i, 1 << k)
            arbre.push_back(i < (1 << (k-1)) ? 0LL : def);
        FORD(i, ((1 << (k-1)) - 1), 1)
            arbre[i] = arbre[i << 1] + arbre[(i << 1) ^ 1];
    }
    void set(int i, lli x) { int feuille = i + (1 << (k-1));
        arbre[feuille] = x;
        iset(feuille >> 1);
    }
    void iset(int noeud) {
        if(noeud) {
            arbre[noeud] = arbre[noeud << 1] + arbre[(noeud << 1)  ^ 1];
            iset(noeud >> 1);
    }   }
    lli sum(int deb, int fin, int noeud = 1, int p = 0, int q = -1) {
        if(q < p) q = 1 << (k-1);
        if(deb <= p && q <= fin) return arbre[noeud];
        if(deb >= q || fin <= p) return 0LL;
        int mil = (p + q) / 2;
        return sum(deb, fin, noeud << 1, p, mil) + sum(deb, fin, (noeud << 1) ^ 1, mil, q);
    }
};

const int MAX_M = 10'000+42;

int dv[MAX_M][MAX_M];

int main()
{
    lli m, n; RD(&n, &m);
    if(m == 1 || m == 3) {
        PR(0);
        return 0;
    }
    lli k = 0, r = 1;
    int cnt = 0;
    lli period = 0, offset = 0;
    if(m == 9) {
        period = 9;
    } else {
        while(dv[k][r] == 0) {
            ++cnt;
            dv[k][r] = cnt;
            r = 10*r;
            k = (10*k + r/m) % m;
            r = r % m;
            //PR(cnt, k, r);
        }
        period = cnt - dv[k][r]+1;
        offset = dv[k][r]-1;
        //PR(k, r);
    }
    //PR(period, offset);
    if(n <= offset) {
        k = 0, r = 1;
        FOR(i, n) {
            r = 10*r;
            k = (10*k + r/m) % m;
            r = r % m;
        }
        PR(k);
        return 0;
    }
    //PR(cnt);
    n = ((n-offset) % period) + offset;
    k = 0, r = 1;
    FOR(i, n) {
        r = 10*r;
        k = (10*k + r/m) % m;
        r = r % m;
    }
    PR(k);
    return 0;
}

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

int64_t ans=0;
int sx,sy;
int H,W;
vector<vector<bool> > flag;
vector<vector<int> > vv;

void dfs(int x,int y,int num,int64_t count,char dir){
  if(num==0){
    if(sy==y-1){
      if(dir!='L'){
        count++;
      }
    }else if(sy==y+1){
      if(dir!='R'){
        count++;
      }
    }else if(sx==x-1){
      if(dir!='U'){
        count++;
      }
    }else if(sx==x+1){
      if(dir!='D'){
        count++;
      }
    }
    ans=max(ans,count);
    return;
  }
  for(auto &tmp:vv.at(x*W+y)){
    int nx=tmp/W;
    int ny=tmp%W;
    if(flag.at(nx).at(ny)){
      flag.at(nx).at(ny)=false;
      bool judge=true;
      char c=dir;
      if(ny==y-1){
        if(dir!='L'){
          judge=false;
          c='L';
        }
      }else if(ny==y+1){
        if(dir!='R'){
          judge=false;
          c='R';
        }
      }else if(nx==x-1){
        if(dir!='U'){
          judge=false;
          c='U';
        }
      }else if(nx==x+1){
        if(dir!='D'){
          judge=false;
          c='D';
        }
      }
      if(judge){
        dfs(nx,ny,num-1,count,c);
      }else{
        dfs(nx,ny,num-1,count+1,c);
      }
    }
  }
}

int main(){
  cin >> H >> W;
  vector<string> S(H);
  flag.resize(H+1,vector<bool>(W+1,false));
  vv.resize(H*W+W+1,vector<int>(H*W+W+1));
  for(int i=0;i<H;i++){
    cin >> S.at(i);
  }
  int num=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)=='#'){
        if(S.at(i).at(j-1)=='.'){
          flag.at(i).at(j)=true;
          flag.at(i+1).at(j)=true;
          vv.at(i*W+j).emplace_back((i+1)*W+j);
          vv.at((i+1)*W+j).emplace_back(i*W+j);
        }
        if(S.at(i).at(j+1)=='.'){
          flag.at(i).at(j+1)=true;
          flag.at(i+1).at(j+1)=true;
          vv.at(i*W+j+1).emplace_back((i+1)*W+j+1);
          vv.at((i+1)*W+j+1).emplace_back(i*W+j+1);
        }
        if(S.at(i-1).at(j)=='.'){
          flag.at(i).at(j)=true;
          flag.at(i).at(j+1)=true;
          vv.at(i*W+j).emplace_back(i*W+j+1);
          vv.at(i*W+j+1).emplace_back(i*W+j);
        }
        if(S.at(i+1).at(j)=='.'){
          flag.at(i+1).at(j)=true;
          flag.at(i+1).at(j+1)=true;
          vv.at((i+1)*W+j).emplace_back((i+1)*W+j+1);
          vv.at((i+1)*W+j+1).emplace_back((i+1)*W+j);
        }
      }
    }
  }
  for(int i=0;i<H+1;i++){
    for(int j=0;j<W+1;j++){
      if(flag.at(i).at(j)){
        sx=i;
        sy=j;
        num++;
      }
    }
  }
  flag.at(sx).at(sy)=false;
  dfs(sx,sy,num-1,0,' ');
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int;
#define fast ios_base::sync_with_stdio; cin.tie(NULL); cout.tie(NULL);
#define rloop(i, a, b) for(int i=a; i>=b; i--)
#define loop(i, a, b) for(int i=a; i<b; i++)

int main()
{
    fast;
    {
        int n, y;
        cin>>n;
        map<int, string>m;
        string x;
        loop(i, 0, n)
        {
            cin>>x>>y;
            m.insert(pair<int, string>(y, x));
        }
        int c = m.size();
        for(auto it: m)
        {
            // c--;
            // cout<<c<<" ";
            if(c==2)
            {
                cout<<it.second;
                break;
            }
            c--;
        }
    }
}

#define _GLIBCXX_DEBUG      //配列外参照の検出
#include <bits/stdc++.h>    //標準ライブラリをインクルード
using namespace std;        //std::の省略
typedef long long ll;       //long longをllに省略

bool compare_second(pair<string, ll> a, pair<string, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
    ll N; cin>>N;
    vector<pair<string, ll>> S(N);
    for(int i=0; i<N; i++){
        cin>>S[i].first>>S[i].second;
    }

    sort(S.rbegin(), S.rend(), compare_second);
    cout << S[1].first << endl;
}


/*
* @author:  codancer
* @createTime:  2020-11-16, 22:37:41
*/

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

typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
#define deb(x) cerr<<#x<<" = "<<(x)<<"\n"
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll Rand(ll B) {
	return (ull)rng() % B;
}
int main(){
	int n;
	cin>>n;
	if(n<0){
		n=0;
	}
	cout<<n<<endl;
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define test(t) int t;cin>>t;while(t--)
using namespace std;

int main()
{
	ll x;
	cin>>x;
	if(x<0)
		cout<<0<<"\n";
	else
		cout<<x<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline ll read(void){
	reg bool f=false;
	reg char ch=getchar();
	reg ll res=0;
	while(!isdigit(ch))f|=(ch=='-'),ch=getchar();
	while(isdigit(ch))res=10ll*res+(ch^'0'),ch=getchar();
	return f?-res:res;
}

ll n;
int cnt[3];

int main(void){
	n=read();
	reg int tmp=n%3;
	while(n){
		++cnt[(n%10)%3];
		n/=10;
	}
	reg int sum=cnt[0]+cnt[1]+cnt[2];
	if(!tmp)
		puts("0");
	else if(tmp==1)
		if(cnt[1]>0&&sum>1)
			puts("1");
		else if(cnt[2]>1&&sum>2)
			puts("2");
		else
			puts("-1");
	else
		if(cnt[2]>0&&sum>1)
			puts("1");
		else if(cnt[1]>1&&sum>2)
			puts("2");
		else
			puts("-1");
	return 0;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <optional>
#include <utility>
#include <vector>
#include <cmath>
// #include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif

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

struct nimotsu {
    int size, value;
};

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(16);

    int n; std::string S, X; std::cin >> n >> S >> X;
    // 確実にできるか
    constexpr std::array<char, 7> D = {0 % 7, 10 % 7, 20 % 7, 30 % 7, 40 % 7, 50 % 7, 60 % 7};
    const auto seven_mod = [](char a){ return (a < 7) ? a : a - 7; };
    auto dfs = [&](auto self, int index) -> char {
        if(index == n) return 1;
        const char np = self(self, index + 1); if(np == 0) return 0;
        S[index] -= '0'; if(S[index] >= 7) S[index] -= 7;
        short res = 0;
        // Aoki doesn't want to make the number to be nine times
        if(X[index] == 'A'){
            for(char i = 0; i < 7; ++i) if( (np >> D[i]) & (np >> seven_mod(D[i] + S[index])) & 1) res |= (1 << i);
        }
        else{
            for(char i = 0; i < 7; ++i) if( ((np >> D[i]) | (np >> seven_mod(D[i] + S[index]))) & 1) res |= (1 << i);
        }
        return res;
    };
    const short res = dfs(dfs, 0);
    std::cout << ((res & 1) ? "Takahashi" : "Aoki" ) << '\n';
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define N 150300
#define M 301300
#define INF 0x3f3f3f3f
int A[N],B[N],C[N],fa[N],tag[N],que[N],dis[N],n,D[20][20],f[20][N],vis[N];
struct node{
	int to,next;
}q[M];
int head[N],ss;
void addedge(int x,int y)
{
	q[++ss]=(node){y,head[x]};head[x]=ss;
	q[++ss]=(node){x,head[y]};head[y]=ss;
}
void dij(int S)
{
	int f=1,e=0;
	que[++e]=S;
	for (int i=1;i<=n;++i) vis[i]=0,dis[i]=INF;
	dis[S]=0;
	vis[S]=true;
	while(f<=e)
	{
		int u=que[f++];
		for (int j=head[u];j;j=q[j].next)
		{
			int t=q[j].to;
			if (vis[t]) continue;
			que[++e]=t;
			dis[t]=dis[u]+1;
			vis[t]=true;
		}
	}
}
int main()
{
	int m,k,ans=INF;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i) scanf("%d%d",&A[i],&B[i]),addedge(A[i],B[i]);
	scanf("%d",&k);
	for (int i=1;i<=k;++i) scanf("%d",&C[i]),tag[C[i]]=i;
	for (int i=1;i<=k;++i)
	{
		dij(C[i]);
		for (int j=1;j<=k;++j) D[i][j]=dis[C[j]];
	}
	memset(f,0x3f,sizeof(f));
	for (int i=1;i<=k;++i) f[i][1<<i-1]=0;
	for (int S=0;S<(1<<k);++S)
	{
		for (int i=1;i<=k;++i)
		{
			if (f[i][S]==INF) continue;
			for (int j=1;j<=k;++j)
			{
				if (i==j||S&(1<<j-1)) continue;
				f[j][S|(1<<j-1)]=min(f[j][S|(1<<j-1)],f[i][S]+D[i][j]);
			}
		}
	}
	for (int i=1;i<=k;++i) ans=min(ans,f[i][(1<<k)-1]);
	printf("%d",ans==INF?-1:ans+1);
	return 0;
}

//by qlwpc

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
template <class T1, class T2>
bool chmax(T1 &a, const T2 b) { return a < b ? a = b, true : false; }
template <class T1, class T2>
bool chmin(T1 &a, const T2 b) { return a > b ? a = b, true : false; }
template <class T>
istream &operator>>(istream &is, vector<T> &v) { for (T &i : v) is >> i; return is; }
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &i : v) os << i << ' '; return os; }
void _co() { cout << '\n'; }
template <class Head, class... Tail>
void _co(Head&& head, Tail&&... tail) { cout << ' ' << head; _co(forward<Tail>(tail)...); }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) { cout << head; _co(forward<Tail>(tail)...); }
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) { cerr << head << ' '; ce(forward<Tail>(tail)...); }
void sonic() { ios::sync_with_stdio(false); cin.tie(nullptr); }
void setp(const int n) { cout << fixed << setprecision(n); }
constexpr int64_t LINF = 1000000000000000001;
constexpr int64_t MOD = 1000000007;
constexpr int64_t MOD_N = 998244353;
constexpr long double EPS = 1e-11;
const double PI = acos(-1);

template <class T>
struct Graph {
    struct edge {
        int64_t from, to;
        T dist;

        bool operator<(const edge &rhs) const { return dist < rhs.dist; }

        bool operator>(const edge &rhs) const { return dist > rhs.dist; }

        edge &operator+=(const edge &rhs) {
            to = rhs.to;
            dist += rhs.dist;
            return *this;
        }
        edge operator+(const edge &rhs) { return edge(*this) += rhs; }
    };

    int64_t V;
    vector<T> dist;
    vector<vector<edge>> edges;

    Graph() {}
    Graph(int64_t v) : V(v) {
        edges = vector<vector<edge>>(V);
        dist = vector<T>(V, LINF);
    }

    void add_edge(int64_t a, int64_t b, T d = 1, bool is_dual = false) {
        edges[a].push_back(edge{a, b, d});
        if (is_dual) edges[b].push_back(edge{b, a, d});
    }

    void dijkstra(int64_t s) {
        dist.assign(V, LINF);
        priority_queue<edge, vector<edge>, greater<edge>> p_que;
        p_que.push(edge{s, s, T()});
        while (!p_que.empty()) {
            edge e = p_que.top();
            p_que.pop();
            if (e.dist >= dist[e.to]) continue;
            dist[e.to] = e.dist;
            for (auto i : edges[e.to]) p_que.push(e + i);
        }
    }
};

int main(void) {
    ll n, m;
    cin >> n >> m;
    Graph<ll> g(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        g.add_edge(a - 1, b - 1, 1, true);
    }

    ll k;
    cin >> k;
    Vec c(k);
    cin >> c;

    vector<Graph<ll>> gs(k);
    rep(i, k) gs[i] = g;
    rep(i, k) gs[i].dijkstra(c[i] - 1);

    Vec2<ll> dp(1 << k, Vec(k, LINF));
    rep(i, k) {
        dp[1 << i][i] = 1;
    }

    rep(i, 1 << k) {
        rep(j, k) {
            rep(l, k) {
                if (!(i >> j & 1) || (i >> l & 1))
                    continue;
                chmin(dp[i | 1 << l][l], dp[i][j] + gs[j].dist[c[l] - 1]);
            }
        }
    }

    ll ans = LINF;
    rep(i, k) chmin(ans, dp[(1 << k) - 1][i]);
    if (ans == LINF)
        ans = -1;
    co(ans);

    return 0;
}


#include<bits/stdc++.h>
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)? EOF:*p1++)
using namespace std;
typedef long long ll;
const int N=2e5+5,mod=1e9+7;
int n,k;
ll f[N][2][2][17];
bool vs[N][2][2][17];
int cnt[N],bk[N][17];
char s[N];
int gt(char x)
{
	if(x<='9') return x-'0';
	return x-'A'+10;
}
ll dfs(int st,int f1,int f2,int nm)
{
	if(st>n) return f2&&(nm==k);
	if(vs[st][f1][f2][nm]) return f[st][f1][f2][nm];
	vs[st][f1][f2][nm]=1;
	ll &lp=f[st][f1][f2][nm],i,j;
	if(f1)
	{
		lp=(lp+dfs(st+1,1,1,cnt[st]))%mod;
		for(i=0,j=gt(s[st]);i<j;i++)
			lp=(lp+dfs(st+1,0,f2|!!i,nm+(!bk[st-1][i])))%mod;
		return lp;
	}
	if(!f2) return lp=(15*dfs(st+1,0,1,1)+dfs(st+1,0,0,0))%mod;
	return lp=((16-nm)*dfs(st+1,0,1,nm+1)+nm*dfs(st+1,0,1,nm))%mod;
}
int main()
{
	int i,j;
	scanf("%s%d",s+1,&k),n=strlen(s+1);
	for(i=1;i<=n;i++)
		cnt[i]=cnt[i-1]+(!bk[i-1][gt(s[i])]),memcpy(bk[i],bk[i-1],sizeof(bk[i])),bk[i][gt(s[i])]=1;
	cout<<dfs(1,1,0,0);
	return 0;
}


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

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

#define fast                     ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll                       long long
#define ld                       long double
#define endl                     '\n'
#define all(A)                   (A).begin(),(A).end()
#define traceA(A,x)              cerr<<#A<<": ";for(int i = 0; i < (x) ; ++i) cerr<<A[i]<<' ';cerr<<endl
#define traceV(A)                cerr<<#A<<": ";for(auto i:A)cerr<<i<<' ';cerr<<endl
#define traceM(A,n,m)            cerr<<#A<<": "<<endl;for(int i = 0; i < (n) ; ++i){for(int j = 0; j < (m) ; ++j) cerr << A[i][j] << ' ';cerr << endl;}

#define TRACE
#ifdef TRACE
#define trace(...) __f__(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1> void __f__(const char* name,Arg1&& arg1){cerr<<name<<" : "<<arg1<<endl;}
template <typename Arg1,typename... Args> void __f__(const char* names,Arg1&& arg1,Args&&... args){const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f__(comma+1,args...);}
#else
// #define trace(...) 1
#endif

const ll mod = 1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll sub(ll a,ll b){a-=b;if(a<0)a+=mod;return a;}
inline ll mul(ll a,ll b){return (a*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll inv(ll a){return power(a,mod-2);}

const ll inf = 1e18+77;
const int MOD = 1e9+7;
const int N = 2e5 + 77;

int A[N];

void sol(){
    int n; cin >> n;
    for(int i = 0 ; i < n ; ++i) cin >> A[i];
    sort(A,A+n);
    for(int i = 0 ; i < n ; ++i){
        if(A[i] != i+1){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int32_t main(){
    fast;
    int t  = 1;
    // cin >> t;
    while(t--) sol();
    return 0;
}

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

int main() {
int N;
int count =0;
cin>>N;
vector<int> vec(N);
for (int i = 0; i < N; i++) {cin >> vec.at(i);}
sort(vec.begin(), vec.end());
for(int n=0;n<N;n++){if(vec.at(n)!=n+1){count++;break;}}
if(count==0){cout<<"Yes"<<endl;}
else if(count==1){cout<<"No"<<endl;}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937/*_64*/ rng(chrono::steady_clock::now().time_since_epoch().count());
#define printArr(arr, n) cerr << #arr << " = ["; for(int i=0; i<(n); i++){if (i) cerr << ", "; cerr << arr[i];} cerr << "]\n"
template<class A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";};
template<class A, class B> ostream& operator<<(ostream &cout, const pair<A,B> &x) {return cout << "(" <<x.first << ", " << x.second << ")";};
void _print() {cerr << "]\n";}
template <class T, class... V> void _print(T t, V... v) {cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#define fi first
#define se second
#define SZ(x) (int)((x).size())
#define pii pair<int,int>

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	ll cur = 1;
	for (ll q = 2; q <= n; q++) {
		cur = cur*q/__gcd(cur,q);
	}
	cout << cur+1 << "\n";
	return 0;
}

#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

using namespace std;

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

constexpr ll MOD = 1000000007;

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

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

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

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

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

    double sx,sy,gx,gy;
    IN(sx,sy,gx,gy);

    double a = (-gy-sy)/(gx-sx);
    double b = -a*gx-gy;
    print(a,b)

    double ans = -b / a;

    printf("%.10lf\n", ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  int d = floor(1.08 * N) - 206;
  if(d > 0)
    cout << ":(";
  else if(d == 0)
    cout << "so-so";
  else if(d < 0)
    cout << "Yay!";
  cout << endl;
}

#line 1 "main.cpp"
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

void solve() {
    int n;
    cin >> n;

    cout << (1 << n) - 1 << "\n";
    for (int b = 1; b < (1 << n); ++b) {
        for (int x = 0; x < (1 << n); ++x) {
            cout << "AB"[__builtin_popcount(x & b) % 2];
        }
        cout << "\n";
    }
}

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

    solve();

    return 0;
}