//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using PQ = priority_queue<T>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
constexpr ll dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
inline void Yes() { cout << "Yes" << ENDL; }
inline void No() { cout << "No" << ENDL; }
inline void YES() { cout << "YES" << ENDL; }
inline void NO() { cout << "NO" << ENDL; }

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T>
vector<T> finddivisor(T x) {  //整数xの約数(xを含む)
  vector<T> divisor;
  for(T i = 1; (i * i) <= x; i++) {
    if(x % i == 0) {
      divisor.push_back(i);
      if(i * i != x) { divisor.push_back(x / i);}
    }
  }
  sort(divisor.begin(), divisor.end());
  return divisor;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

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

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

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

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m,k;cin>>n>>m>>k;
  V<ll> v(k);

  V<db> c1(n+2,0),c0=c1;
  c1[n]=c0[n]=0;

  V<bool> dam(n+1,false);
  rep(i,0,k){
    ll x;cin>>x;
    dam[x]=true;
  }

  auto p=[&](int fr,int to)->db{
    if(fr>=to)return 0;

    db ret=1.0/m;
    if(to==n)ret*=(fr+m-n+1);
    return ret;
  };

  ll l=n+1,r=n;
  db s1=0,s0=0;
  repr(i,0,n){
    // i -> [i+1,i+m]
    while(i+1<l){
      l--;
      s1+=c1[l]*p(i,l);
      s0+=(1+c0[l])*p(i,l);
    }
    while(i+m<r){
      s1-=c1[r]*p(i+1,r);
      s0-=(1+c0[r])*p(i+1,r);
      r--;
    }

    if(r==n && i<n-1){
      s1-=c1[r]*p(i+1,r);
      s0-=(1+c0[r])*p(i+1,r);

      s1+=c1[r]*p(i,r);
      s0+=(1+c0[r])*p(i,r);
    }

    if(dam[i]){
      c1[i]=1;
      c0[i]=0;
    }else{
      c1[i]=s1;
      c0[i]=s0;
    }

    //debug(s1,s0);
  }
  //debug(c1);
  //debug(c0);

  if(fabs(1-c1[0])<1e-7)cout<<-1<<ENDL;
  else cout<<c0[0]/(1-c1[0])<<ENDL;
}
//! ( . _ . ) !
//CHECK overflow,vector_size,what to output?
//any other simpler approach?
//list all conditions, try mathematical and graphic observation

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

#define MAX_N 1000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){// this size is really ok??
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

ll binom(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  ll res=1;
  for(ll i=0;i<k;i++) res=res*(n-i)%MOD;
  res=res*ifac[k]%MOD;
  return res;
}

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

ll mod_inverse(ll x){
  return mod_pow(x,MOD-2);
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

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

  int N;
  cin>>N;
  char AA,AB,BA,BB;
  cin>>AA>>AB>>BA>>BB;

  setComb();

  ll ans=0;
  if(AB=='A'&&AA=='A'){
      ans=1;
  }else if(AB=='B'&&BB=='B'){
      ans=1;
  }else if(AB=='B'&&BB=='A'){
      if(BA=='B'){
          for(ll k=1;;k++){
              ll M=N-k;
              M-=k;
              if(M<0) break;

              ll res=hcomb(k,M);
              add(ans,res);
          }
      }else{
          for(ll k=1;;k++){
              ll M=N-k;
              M-=k;
              if(M<0) break;

              ll res=hcomb(2*k-1,M);
              add(ans,res);
          }
      }
  }else{
      if(BA=='A'){
          for(ll k=1;;k++){
              ll M=N-k;
              M-=k;
              if(M<0) break;

              ll res=hcomb(k,M);
              add(ans,res);
          }
      }else{
          for(ll k=1;;k++){
              ll M=N-k;
              M-=k;
              if(M<0) break;

              ll res=hcomb(2*k-1,M);
              add(ans,res);
          }
      }
  }

  cout<<ans<<endl;

  return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define maxn 1000010
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int p[maxn],mn[maxn],mu[maxn];
int l,r,tot;
void euler(int n)
{
    tot=0; mn[1]=0; mu[1]=1;
    for(int i=2;i<=n;i++){
        if(!mn[i])p[++tot]=i,mn[i]=tot,mu[i]=-1;
        for(int j=1;j<=mn[i]&&i*p[j]<=n;j++)
            mn[i*p[j]]=j,mu[i*p[j]]=(j==mn[i]?0:-mu[i]);
    }
    // for(int i=1;i<=n;i++)
    //     printf("%d %d %d\n",i,p[mn[i]],mu[i]);
}
ll solve(int n,int m)
{
    ll ans=(ll)n*m;
    for(int i=1;i<=n&&i<=m;i++)
        ans-=(ll)mu[i]*(n/i)*(m/i);
    for(int i=2;i<=n&&i<=m;i++)
        ans-=(n/i)+(m/i)-1;
    // printf("%d %d : %lld\n",n,m,ans);
    return ans;
}
int main()
{
    l=read(); r=read();
    euler(r);
    writeln(solve(r,r)-2*solve(l-1,r)+solve(l-1,l-1));
    return 0;
}

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k):    It returns to an iterator to the kth element (counting from zero) in the set
// order_of_key(k) :    It returns to the number of items that are strictly smaller than our item k
#define fast            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb              push_back
#define f               first
#define s               second
#define F(i,a,b)        for(i=a;i<b;i++)
#define nl              "\n"
#define sp              " "
#define all(c)          (c).begin(),(c).end()
#define rev(i,b,a)      for(int i=b;i>=a;i--)
#define iota            cout<<-1<<nl
#define cty             cout<<"YES"<<nl
#define ctn             cout<<"NO"<<nl
#define lmax            LLONG_MAX
#define lmin            LLONG_MIN
#define sz(v)           (v).size()
#define deci(n)         fixed<<setprecision(n)
#define c(x)            cout<<(x)
#define csp(x)          cout<<(x)<<" "
#define c1(x)           cout<<(x)<<nl
#define c2(x,y)         cout<<(x)<<" "<<(y)<<nl
#define c3(x,y,z)       cout<<(x)<<" "<<(y)<<" "<<(z)<<nl
#define c4(a,b,c,d)     cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<nl
#define c5(a,b,c,d,e)   cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<nl
#define c6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<nl
typedef long double     ld;
typedef long long       ll;
typedef vector<ll>      vll;
typedef pair<ll,ll>     pll;
typedef vector<pll>     vpll;
const int mod=998244353;
const int mod1=1000000007;
const double pi=3.14159265358979323846264338327950288419716939937510582097494459230;
// priority_queue<t>
ll max(ll a , ll b){ if(a>b)return a; return b;}
ll min(ll a , ll b){ if(a<b)return a; return b;}
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
ll pct(ll x) { return __builtin_popcount(x); } // # of bits set
ll poww(ll a, ll b) { ll res=1; while(b) { if(b&1)	res=(res*a); a=(a*a); b>>=1; } return res; }
ll modI(ll a, ll m=mod) { ll m0=m,y=0,x=1;  if(m==1) return 0;  while(a>1)  { ll q=a/m; ll t=m;  m=a%m;  a=t; t=y; y=x-q*y;  x=t; } if(x<0) x+=m0; return x;}
ll powm(ll a, ll b,ll m=mod) {ll res=1;	while(b) {	if(b&1)	res=(res*a)%m;	a=(a*a)%m; b>>=1;	}	return res;}
//*******************************************************************************************************************************************//
ll pr[1000001]={0};

void go(){
    ll i,j;
 for(i=2;i<=1000000;i++)
 {
     if(pr[i])
         continue;
   pr[i]=i;
     for(j=i*i;j<=1000000;j+=i)
        pr[j]=i;
 }
}

void iamzeus()
{ ll i,j,x=0,y,ans=0,n,m,d,cnt=0,z,c=2,k;
  ll l,r,mult,bits;
 cin>>l>>r;
 vll v;
 for(i=max(l,2);i<=r;i++)
 {
     v.clear();
     d=i;
     while(d>1)
     {
         j=pr[d];
         v.pb(j);
         while(d%j==0)d/=j;
     }
         ll sum = 0;
    for (int msk=1; msk<(1ll<<v.size()); ++msk) {
        mult = 1,
            bits = 0;
        for ( z=0; z<(int)v.size(); ++z)
            if (msk & (1<<z)) {
                ++bits;
                mult *= v[z];
            }

        ll cur = (r / mult)-(i/mult)+(i%mult==0);
        if (bits % 2 == 1)
            sum += cur;
        else
            sum -= cur;
    }
    // c1(sum);
     mult=i;
     sum-=(r / mult)-(i/mult)+(i%mult==0);
     //c1(sum);
     ans+=sum*2;

 }
 c1(ans);
};
int main()
{fast;
    int t;
t=1;
 go();
//cin >>t;
 while(t--)
     iamzeus();
}


#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
    // string __fname = "";
    // ifstream in (__fname + ".in");
    // ofstream out (__fname + ".out");
    // #define cin in
    // #define cout out
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve(int);
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;for (int i = 1; i <= n; i++) solve(i);}
int64 ceildiv(int64 a, int64 b) {return a / b + !!(a % b);}
// // // // // // // // // // // // // // // // // // // // // //
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
const int64 mod = 1000000007;
const double pi = 3.14159265359;
const int ddx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

void solve(int id){

    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    vector <int> a (3);
    for (int i = 0; i < 3; i++) cin >> a[i];
    sort(a.begin(), a.end());
    if (a[2] - a[1] == a[1] - a[0]) {
        ctn("Yes");
    }
    else{
        ctn("No")
    }
    return 0;
}

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

#define fix_precision(i) cout << fixed << setprecision(i)
#define rp(i,n) for (int i = 0; i < n; i++)

const long long mod = 1e9 + 7;

template<typename T, typename U, typename V>
V modPower(T a, U b, V c){
    //a^b mod cを返す
    //帰り値の型はcと同じ
    V x = 1;//桁数がcと同じor超えることを考えて
    for (U i = 0; i < b; i++){
        x = (x*a)%c;
    }
    return x;
}

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


#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}

template <class T>
void chmin(T& a, const T& b) {
  if (b < a) a = b;
}

signed main() {
  init();
  ll N;
  cin >> N;

  ll sum = 0;
  P l = {-INF, 0}, r = {INF, 0};
  bool f = false;
  ll v = 0;
  rep(i, N) {
    ll a, t;
    cin >> a >> t;

    if (t == 1) {
      sum += a;
      l.second += a;
      r.second += a;
    }
    if (t == 2 and l.first < a - sum) {
      if (r.first < a - sum) {
        f = true;
        v = a;
        // r.first = a - sum + 1;
      }
      l.first = a - sum;
      l.second = a;
    }
    if (t == 3 and a - sum < r.first) {
      if (a - sum < l.first) {
        f = true;
        v = a;
        // r.first = a - sum + 1;
      }
      // l.first = a - sum - 1;
      r.first = a - sum;
      r.second = a;
    }

    if (f) {
      if (t == 1) v += a;
      if (t == 2) chmax(v, a);
      if (t == 3) chmin(v, a);
    }
  }

  ll Q;
  cin >> Q;
  rep(i, Q) {
    ll x;
    cin >> x;
    if (f) {
      COUT(v);
      continue;
    }
    if (l.first != -INF and x <= l.first) {
      COUT(l.second);
      continue;
    }
    if (r.first != INF and r.first <= x) {
      COUT(r.second);
      continue;
    }
    COUT(x + sum);
  }

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = (1<<30)-1;
const ll LINF = (1LL<<60)-1;

#define rep(i, n) for (int i = 0; i < n; i++)
#define sz(a) (int)(a.size())

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

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

ll func(ll y, vector<ll>& a, vector<ll>& t, int n) {
    rep(i, n) {
            if (t[i] == 1)
                y += a[i];
            else if (t[i] == 2) {
                if (y <= a[i]) {
                    y = a[i];
                }
            }
            else if (t[i] == 3) {
                if (y >= a[i]) {
                    y = a[i];
                }
            }
        }
    return y;
}

//コーナーケースに気をつけろ！
int main() {
    int n;  cin >> n;
    vector<ll> a(n), t(n);
    rep(i, n)   cin >> a[i] >> t[i];
    int q;  cin >> q;
    vector<ll> x(q);
    rep(i, q)   cin >> x[i];
    ll l = -INF, r = INF;
    ll b, c;
    ll ok = l, ng = INF;
    while (ok+1 < ng) {
        ll x = (ok + ng) / 2;
        ll y = x;
        bool flag = false;
        rep(i, n) {
            if (t[i] == 1)
                y += a[i];
            else if (t[i] == 2) {
                if (y <= a[i]) {
                    flag = true;
                    y = a[i];
                }
            }
            else if (t[i] == 3) {
                if (y >= a[i]) {
                    y = a[i];
                }
            }
        }
        if (flag)
            ok = x;
        else
            ng = x;
    }
    l = ok;
    ng = -INF, ok = INF;
    while (ng+1 < ok) {
        ll x = (ok + ng) / 2;
        ll y = x;
        bool flag = false;
        rep(i, n) {
            if (t[i] == 1)
                y += a[i];
            else if (t[i] == 2) {
                if (y <= a[i]) {
                    y = a[i];
                }
            }
            else if (t[i] == 3) {
                if (y >= a[i]) {
                    flag = true;
                    y = a[i];
                }
            }
        }
        if (flag)
            ok = x;
        else
            ng = x;
    }
    r = ok;
    bool check1 = false, check2 = false, check3 = false;
    ll ans1, ans2, ans3;
    rep(i, q) {
        if (x[i] <= l) {
            if (check1)
                cout << ans1 << endl;
            else {
                check1 = true;
                ans1 = func(x[i], a, t, n);
                cout << ans1 << endl;
            }
        }
        else if (r <= x[i]) {
            if (check3)
                cout << ans3 << endl;
            else {
                check3 = true;
                ans3 = func(x[i], a, t, n);
                cout << ans3 << endl;
            }
        }
        else {
            if (check2)
                cout << x[i] + ans2 << endl;
            else {
                check2 = true;
                ans2 = func(x[i], a, t, n) - x[i];
                cout << x[i] + ans2 << endl;
            }
        }
    }
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << 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;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

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

ll modinv(ll a) {
	ll m = mod, y = 0, x = 1;
	while (a > 1) {
		ll q = a / m, t = m;
		m = a % m;
		a = t;
		t = y;
		y = x - q * y;
		x = t;
	}
	return x < 0 ? x + mod : x;
}

int main() {
	fio;
	ll n, m;
	cin >> n >> m;
	ll dp[n][m];
	for (int i = 0;i < m;i++)
		dp[0][i] = 1;
	vl s(n), minv(m + 1), mpm1j(m, 1);
	s[0] = m;
	mpm1j[0] = 0;
	ll mpmi = 1;
	for (int j = 1;j <= m;j++)
		minv[j] = modinv(j);
	for (int i = 1;i < n;i++) {
		mpmi = mpmi * m % mod;
		for (int j = 0;j < m;j++) {
			mpm1j[m - 1 - j] = mpm1j[m - 1 - j] * (m - 1 - j) % mod;
			dp[i][j] = (s[i - 1] + (mpmi * j + mpm1j[m - 1 - j]) % mod * minv[j + 1]) % mod;
		}
		for (int j = 0;j < m;j++)
			s[i] = (s[i] + dp[i][j]) % mod;
	}
	cout << s[n - 1] << '\n';
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define drep(i,b,a) for(int i = (b)-1; i >= (a); i--)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(v) sort(v.begin(),v.end());
#define RSORT(v) sort(v.rbegin(),v.rend());
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
const int inf = 1 << 30; const ll infl = 1LL << 60; const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool  odd(T x) { return x & 1; }
template<class T> inline bool even(T x) { return !(x & 1); }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill( (T*)array, (T*)(array+N), val );
}
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << endl; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s; }
//----------------------------------------------------------------------------------------------

int main()
{
    int n; ll mx;
    cin >> n >> mx;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];

    vector<ll> pre,pos;
    rep(i,0,n/2) pre.push_back(a[i]);
    rep(i,n/2,n) pos.push_back(a[i]);

    vector<ll> v1,v2;
    rep(S,0,bit(sz(pre))) {
        bitset<25> bs(S);
        ll tmp = 0;
        rep(i,0,sz(pre)) if(bs[i]) tmp += pre[i];
        if(tmp > mx) continue;
        v1.push_back(tmp);
    }
    rep(S,0,bit(sz(pos))) {
        bitset<25> bs(S);
        ll tmp = 0;
        rep(i,0,sz(pos)) if(bs[i]) tmp += pos[i];
        if(tmp > mx) continue;
        v2.push_back(tmp);
    }
    SORT(v2);
    ll res = 0;
    for(auto x : v1) {
        auto it = upper_bound(all(v2), mx-x);
        if(it == v2.begin()) continue;
        it--;
        chmax(res, x + *it);
    }
    cout << res << endl;
    return 0;
}


/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ?
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define AL(x) x.begin(),x.end()
#define pw(x) (1ull<<(x))
#define NMSL cout << "NMSL" << endl;
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x, y) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define debug3(x, y, z) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define debug4(a, b, c, d) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define fio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in128 __int128_t
using namespace std;
const int N = 2e6+10;
const int INF = numeric_limits<int>::max() / 4;
const double EPS = 1e-3;
const long double PI = 3.14159265358979323846;
const int mod = 998244353 ;
int fac[N],inv[N];
int n,m;
int ppow(int a,int b=mod-2)
{
    int ans=1%mod;
    a%=mod;
    while(b)
    {
        if(b&1)
            ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
void init()
{
    fac[0]=1;
    for(int i=1; i<N; ++i)
        fac[i]=fac[i-1]*i%mod;
    inv[N-1]=ppow(fac[N-1]);
    for(int i=N-2; i>=0; --i)
        inv[i]=(i+1)*inv[i+1]%mod;
}
int C(int n,int m)
{
    if(m<0||m>n)return 0;
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main()
{
    fio
    init();
    cin>>n>>m;
    int ans=0;
    for(int i=1; i<=m; ++i)
    {
        int x=i,sum=1;
        vector<int>temp;
        for(int j=2; j*j<=x; ++j)
        {
            int cnt=0;
            while(x%j==0)
            {
                x/=j;
                cnt++;
            }
            if(cnt)
                temp.push_back(cnt);
        }
        if(x>1)temp.push_back(1);
        for(int b : temp)
            sum=sum*C(n+b-1,b)%mod;
        ans=(ans+sum)%mod;
    }cout<<ans;
    return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll I=1167167167167167167;
ll Q=998244353;
#define rep(i,a) for (ll i=0;i<a;i++)
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
template<class T> void print_tate(vector<T> &v) {rep(i,v.size()) cout<<v[i]<<"\n";}
void yneos(bool a){if(a) cout<<"Yes"<<"\n"; else cout<<"No"<<"\n";}

//おちこんだりもしたけれど、私はげんきです。
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin>>N;
	vector<ll> kai(N+1,1);
	int weigt[N];
	int sum=0;
	rep(i,N) cin>>weigt[i],sum+=weigt[i];
	rep(i,N) kai[i+1]=(kai[i]*(i+1))%Q;
	if(sum%2==1){
		cout<<"0\n";
		return 0;
	}
	ll dp[N+1][sum+1];
  memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i =0;i < N;i++){
		for(int j=sum/2;j>=weigt[i];j--){
			for(int k=N-1;k>=0;k--) dp[k+1][j]=(dp[k+1][j]+dp[k][j-weigt[i]])%Q;
		}
	}
	ll ans=0;
	for(int i = 0;i < N;i++){
		ans=(ans+(dp[i][sum/2]*((kai[i]*kai[N-i])%Q))%Q)%Q;
	}
	cout<<(ans)%Q<<endl;
}


#include<bits/stdc++.h>
#define ls(p) p<<1
#define rs(p) p<<1|1
#define de(x) cout<<#x<<" = "<<x<<endl;
#define rep(i,a,b) for(int i = (a);i<=(b);++i)
#define endl '\n'
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e5+10;
const int INF = 1e9+10;

int main(){
 ll x = 1;
 x = x*5*7*11*13*15*16*17*18*19*23*29;
 ++x;
	cout<<x<<endl;
}
/*
10 acesxd

*/

#include<bits/stdc++.h>
using namespace std;
long long gcd(long long int a, long long int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
long long lcm(int a, int b)
{
    return (a / gcd(a, b)) * b;
}
int main(){
    long long int n;
    cin>>n;
    long long ans = 1;
    for(long long int i=2;i<=n;i++){
        ans = lcm(ans,i);
    }
    cout<<ans+1<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#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 ll = long long;
const long long INF = 1LL << 60;
const int SINF = 1LL << 30;
const ll mod = 1000000000+7;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const double pi = 3.14159265358979323846;
pair<double, double> rotate(double x, double y, double d) {
    double rx = x * cos(d) - y*sin(d);
    double ry = x * sin(d) + y*cos(d);
    return make_pair(rx, ry);
}

int main() {
    int n;
    cin >> n;
    double x0, y0, xn2, yn2;
    cin >> x0 >> y0 >> xn2 >> yn2;
    double xm = (x0+xn2)/2;
    double ym = (y0+yn2)/2;

    pair<double, double> ans = rotate(x0-xm, y0-ym, 2*pi/n);
    printf("%.20f %.20f\n", ans.first + xm, ans.second + ym);
}

#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()-1; (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define outl(x) cout << x << endl
#define SP << " " <<
#define inf 1e18

using namespace std;

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

string X, Y, R;

ll get(string s)
{
	ll p = -1;
	rep(i, 0, (int)s.size()-1){
		if(s[i] == '.'){
			p = i;
			break;
		}
	}
	if(p == -1) s += '.', p = (int)s.size()-1;

	ll l = s.size();
	rep(i, 1, 4-(l-1 - p)) s += '0';

	ll ret = 0;
	rep(i, 0, (int)s.size()-1){
		if(s[i] == '.') continue;
		ret *= 10;
		ret += s[i]-'0';
	}
	return ret;
}

bool check(ll sx, ll sy, ll tx, ll ty, ll r)
{
	//outl(sx SP sy SP tx SP ty SP r);
	//cout << ((sx-tx)*(sx-tx) + (sy-ty)*(sy-ty) <= r*r) << endl;
	return (sx-tx)*(sx-tx) + (sy-ty)*(sy-ty) <= r*r;
}

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

	cin >> X >> Y >> R;
	ll x = get(X), y = get(Y), r = get(R);

	//cout << x << " " << y << " " << r << endl;

	ll s = (x-r)/10000 - 5, t = (x+r)/10000 + 5, ans = 0;
	rep(i, s, t){
		if(!check(i*10000, y, x, y, r)) continue;

		ll uy = (y + 10000000000 + 9999) / 10000 * 10000 - 10000000000;
		ll dy = (y + 10000000000) / 10000 * 10000 - 10000000000;

		if(uy == dy && abs(y) % 10000 == 0) ans--;

		ll ub = r / 10000 + 5, lb = 0, mid;
		while(ub-lb>1){
			mid = (ub+lb)/2;
			if(check(i*10000, uy+(mid-1)*10000, x, y, r)) lb = mid;
			else ub = mid;
		}
		//cout << lb << endl;
		ans += lb;

		ub = r / 10000 + 5, lb = 0, mid;
		while(ub-lb>1){
			mid = (ub+lb)/2;
			if(check(i*10000, dy-(mid-1)*10000, x, y, r)) lb = mid;
			else ub = mid;
		}
		ans += lb;

		//cout << i << " " << ans << endl;
	}
	cout << ans << endl;

	return 0;
}


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<atcoder/all>
#define rep(i, n) for(long long i = 0;i < (n);i++)
using namespace std;
// using namespace atcoder;
using ll = long long;
using Pii = pair<int, int>;
const ll MOD = 1000000007;
const ll MOD3 = 998244353;
const ll INFl = 10000000000000000;
const int INFi = 1000000000;
const double EPS = 0.0000001;
// using mint = modint1000000007;

int main() {

	int n;
	cin >> n;

	vector<double> a(n);

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

	sort(a.begin(), a.end());

	double x = 0;

	int idx  = n / 2;

	x = a[idx] / 2.0;

	double ans = 0;

	rep(i, n) {
		ans += a[i];
	}

	ans += x * n;

	rep(i, n) {
		if(2 * x > a[i]) {
			ans -=a[i];
		}
		else ans -= 2 * x;
	}
	// cout << ans / (double)n << endl;
	printf("%10lf\n", ans / (double)n);

}

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

double A[100100];
double ssum[100100];

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

    int n; cin>>n;
    for (int i=1; i<=n; i++) cin>>A[i];

    sort(A+1, A+n+1);

    ssum[n+1] = 0;
    for (int i=n; i>=1; i--) {
        ssum[i] = ssum[i+1] + A[i];
    }

    double lo = 0, hi = A[n];

    for (int tt=50; tt; tt--) {
        double le = (lo + lo + hi) / 3;
        double ri = (lo + hi + hi) / 3;

        int x = lower_bound(A+1, A+n+1, le+le) - A;

        int big = n - x + 1;
        int small = n - big;

        double fle = (small - big) * le + ssum[x];

        x = lower_bound(A+1, A+n+1, ri+ri) - A;

        big = n - x + 1;
        small = n - big;

        double fri = (small - big) * ri + ssum[x];

        if (fle > fri) lo = le;
        else hi = ri;
    }

    int x = lower_bound(A+1, A+n+1, lo+lo) - A;

    int big = n - x + 1;
    int small = n - big;

    double res = (small - big) * lo + ssum[x];

    cout<<res/n<<'\n';

    return 0;
}


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

#define INF 0x3f3f3f3f
#define endl '\n'
#define ll long long
#define mp make_pair
typedef pair<int, int> ii;

int solution(vector<int> dp, const int& level, const int& k, const vector<ii>& options, const vector<vector<int>>& cond){
	if(level == k) return 0;
	int opt1 = options[level].first;
	int opt2 = options[level].second;
	int inc1 = 0, inc2 = 0;
	vector<int> dp2 = dp;
	if(dp[opt1] == 0){
		dp[opt1] = 1;
		for(int dish: cond[opt1]){
			if(dp[dish] == 1) ++inc1;
		}
	}
	if(dp2[opt2] == 0){
		dp2[opt2] = 1;
		for(int dish: cond[opt2]){
			if(dp2[dish] == 1) ++inc2;
		}
	}
	return max(solution(dp, level+1, k, options, cond) + inc1, solution(dp2, level+1, k, options, cond) + inc2);
}

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

	int n, m;
	cin >> n >> m;
	vector<vector<int>> cond(n+1);
	while(m--){
		int a, b;
		cin >> a >> b;
		cond[a].push_back(b);
		cond[b].push_back(a);
	}
	int k, copy;
	cin >> k;
	copy = k;
	vector<ii> options;
	while(copy--){
		int c, d;
		cin >> c >> d;
		options.push_back(mp(c, d));
	}
	vector<int> dp(n+1, 0);
	dp[0] = -1;
	cout << solution(dp, 0, k, options, cond);
	return 0;
}

#include <iostream>
using namespace std;

struct choice {
  int a = 0;
  int b = 0;
};

int count(bool *D, int N, struct choice *C, int M) {
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int a = C[i].a;
    int b = C[i].b;
    if (D[a] && D[b]) {
      ans++;
    }
  }
  return ans;
}

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

  struct choice C[M]; // conditions
  for (int i = 0; i < M; i++) {
    cin >> C[i].a;
    cin >> C[i].b;
  }

  cin >> K;
  struct choice V[K]; // votes
  for (int i = 0; i < K; i++) {
    cin >> V[i].a;
    cin >> V[i].b;
  }

  ans = 0;
  for (int n = 0; n < (1 << K); n++) {
    bool D[N + 1] = {}; // dishes
    for (int k = 0; k < K; k++) {
      int v = n & (1 << k); // mask
      int i = v ? V[k].a : V[k].b;
      D[i] = 1;
    }
    int sum = count(D, N + 1, C, M);
    if (ans < sum) {
      ans = sum;
    }
  }

  cout << ans;

  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a,b) memset(a, b, sizeof(a))
#define dbg(x) cout << "[" << #x << "]: " << x << endl;
#define forn(i,n) for(int i=0; i < n;i++)
#define forab(i,a,b) for(int i = a; i <= b; i++)
#define forba(i,b,a) for(int i = b; i >= a; i--)
#define each(val, v) for(auto val : v)
#define abs(u) (u >= 0 ? u : -u)

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

const int MAXN = 2e3 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;

int uf[MAXN];
int sz[MAXN];

int add(int a, int b){
    a += b;

    if( a >= MOD) a -= MOD;

    if(a < 0) a += MOD;

    return a;
}

int mul(int a, int b){
    int ret = (1LL * a * b)%MOD;

    return ret;
}

int pw(int a, int n){
    int ret = 1;

    while(n > 0){
        if(n&1 == 1){
            ret = mul(ret, a);
        }
        a = mul(a,a);
        n = n>> 1;
    }

    return ret;
}

int inv(int a){
    return pw(a,MOD-2);
}

int divide(int a, int b){
    return mul(a, inv(b));
}

int fat[MAXN];
int invfat[MAXN];

void pre_fat(int n){

    fat[0] = 1;
    fat[1] = 1;

    invfat[0] = 1;
    invfat[0] = 1;

    for(int i = 2; i <= n; i++){
        fat[i] = mul(fat[i-1], i);
        invfat[i] = divide(invfat[i-1], i);
    }
}

int find(int x){
    if(uf[x] == x) return x;

    return uf[x] = find(uf[x] );
}

int uni(int a, int b){

    int aa = find(a),  bb = find(b);

    if(aa == bb) return 0;

    if(sz[aa] > sz[bb]) swap(aa,bb);

    sz[bb] += sz[aa];

    uf[aa] = bb;

    return 1;
}

int lin(int i){
    return i;
}

int shift = 55;

int col(int i){
    return i + shift;
}

int M[MAXN][MAXN];

void solve(){

    pre_fat(100);

    int ans = 1;
    int n;
    int k;
    cin >> n;
    cin >> k;

    for(int i = 0; i < MAXN; i++){
        uf[i] = i;
        sz[i] = 1;
    }
    forn(i,n){
        forn(j,n){
            cin >> M[i][j];
        }
    }

    forn(i1, n){
        for(int i2 = i1 + 1; i2 < n; i2++){
            bool certo =true;

            forn(j,n){
                if( M[i1][j]+ M[i2][j] > k ){
                    certo = false;
                }
            }

            if(certo){
                uni( lin(i1) , lin(i2));
            }
        }
    }

    forn(i1, n){
        for(int i2 = i1 + 1; i2 < n; i2++){

            bool certo =true;

            forn(j,n){
                if( M[j][i1]+ M[j][i2] > k ){
                    certo = false;
                }
            }
            if(certo){
                uni( col(i1) , col(i2));
            }
        }
    }

    set<int> ja_foi;

    forn(i,n){
        int i_li = find( lin(i) );
        int i_col = find( col(i) );

        if( ja_foi.find(i_li) == ja_foi.end() ){

            ans = mul( ans, fat[ sz[i_li] ] );
        }

        if(ja_foi.find(i_col) == ja_foi.end()){
            ans = mul(ans, fat[ sz[i_col] ] );
        }

        ja_foi.insert(i_li);
        ja_foi.insert(i_col);
    }

    cout << ans << '\n';

}

int main(){

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

    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }

    return 0;
}

/*================================================================
*
*   创 建 者： badcw
*   创建日期： 2020/11/15 8:40 下午
*
================================================================*/
#include <bits/stdc++.h>

#define VI vector<int>
#define ll long long
using namespace std;

namespace IO {
    template<class T>
    void _R(T &x) { cin >> x; }
    void _R(int &x) { scanf("%d", &x); }
    void _R(ll &x) { scanf("%lld", &x); }
    void _R(double &x) { scanf("%lf", &x); }
    void _R(char &x) { x = getchar(); }
    void _R(char *x) { scanf("%s", x); }
    void R() {}
    template<class T, class... U>
    void R(T &head, U &... tail) {_R(head),R(tail...);}
    template<class T>
    void _W(const T &x) { cout << x; }
    void _W(const int &x) { printf("%d", x); }
    void _W(const ll &x) { printf("%lld", x); }
    void _W(const double &x) { printf("%.16f", x); }
    void _W(const char &x) { putchar(x); }
    void _W(const char *x) { printf("%s", x); }
    template<class T, class U>
    void _W(const pair<T, U> &x) {_W(x.first),putchar(' '),_W(x.second);}
    template<class T>
    void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
    void W() {}
    template<class T, class... U>
    void W(const T &head, const U &... tail) {_W(head),putchar(sizeof...(tail) ? ' ' : '\n'),W(tail...);}
}
using namespace IO;

const int maxn = 2e5+50;
const int mod = 1e9+7;

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

ll qp(ll a, ll n, int mod) {
    ll res = 1;
    n %= mod - 1;
    if (n < 0) n += mod - 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

map<int, int> mp[maxn];
int pre[maxn];
int F(int x) { return x == pre[x] ? x : pre[x] = F(pre[x]); }
int n, m;

int main(int argc, char* argv[]) {
//    freopen("data.in", "r", stdin);
//    freopen("data.out", "w", stdout);
//    clock_t StartTime = clock();
    R(n, m);
    for (int i = 1; i <= n; ++i) {
        int x; R(x);
        mp[i][x] = 1;
        pre[i] = i;
    }
    while (m--) {
        int op, x, y;
        R(op, x, y);
        if (op == 1) {
            int u = F(x), v = F(y);
            if (u == v) continue;
            if (mp[u].size() < mp[v].size()) swap(u, v);
            pre[v] = u;
            for (auto i : mp[v]) mp[u][i.first] += i.second;
            mp[v].clear();
        } else {
            int u = F(x);
            if (mp[u].count(y)) W(mp[u][y]);
            else W(0);
        }
    }
//    cout << "Total time: " << (clock() - StartTime) * 1000 / CLOCKS_PER_SEC << "ms" << endl;
    return 0;
}


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

using ll = long long int;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define F first
#define S second

ll min(ll x, ll y){
    return ((x < y) ? x : y);
}

ll max(ll x, ll y){
    return ((x > y) ? x : y);
}

const ll MOD = 998244353;

ll modpow (ll b, ll e){
    ll ans = 1;
    while (e){
        if (e%2) ans *= b;
        ans %= MOD;
        b *= b; b %= MOD;
        e /= 2;
    }
    return ans;
}

int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    ll ans = 0;
    if (n == 1){
        cout << modpow(k,m) << endl;
    }else if (m == 1){
        cout << modpow(k,n) << endl;
    }else{
        for (ll i = 1; k >= i; i++){
            ll mins = modpow(i,n);
            mins -= modpow(i-1,n);

            mins += MOD; mins %= MOD;

            ll maxs = modpow(k-i+1,m);

            //cout << mins << " " << maxs << endl;

            ans += (mins*maxs); ans %= MOD;
        }
        cout << ans << endl;
    }

}

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

double X, Y, R;

bool inside(ll x, ll y) {
    const int LARGE = 10000;
    x *= LARGE;
    y *= LARGE;
    ll XX = round(X * LARGE);
    ll YY = round(Y * LARGE);
    ll RR = round(R * LARGE);
    return (x - XX) * (x - XX) + (y - YY) * (y - YY) <= RR * RR;
}

ll counter(ll x, ll base, ll delta) {
    ll ok = base;
    ll er = base + delta;
    if (!inside(x, ok)) return 0;
    while(abs(ok - er) > 1) {
        ll mid = (ok + er) / 2;
        if (inside(x, mid)) ok = mid;
        else er = mid;
    }
    return abs(er - base);
}

int main() {
    cin >> X >> Y >> R;
    ll ans = 0;
    for (ll x = floor(X - R - 1); x < floor(X + R + 1); x++) {
        ans += counter(x, floor(Y) + 1, floor(R) + 1);
        ans += counter(x, floor(Y), - floor(R) - 1);
    }
    cout << ans << 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;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

int main() {
	fio;
	vi c(1001);
	tc {
		int a;
		cin >> a;
		for (int i = 1;i * i <= a;i++)
			if (a % i == 0) {
				c[i]++;
				if (i != a/i)
					c[a/i]++;
			}
	}
	int ans = 2;
	for (int i = 3;i < 1001;i++)
		if (c[i] > c[ans])
			ans = i;
	cout << ans << '\n';
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    ll res = 0;
    ll gcd = 0;
    for(ll i=2; i<=1000; i++){
        ll tmp = 0;
        rep(j,n) if(a.at(j)%i==0) tmp++;
        if(gcd <= tmp){
            res = i;
            gcd = tmp;
        }
    }
    cout << res << endl;
}


#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
    ll modpow(ll x, ll b,ll mod=MOD){
        ll res = 1;
        while(b){
            if(b&1)res = res * x % mod;
            x = x * x % mod;
            b>>=1;
        }
        return res;
    }

    ll modinv(ll x){
        return modpow(x, MOD-2);
    }

    bool was_output = false;
    template<class t>
    void output(t a){
        if(was_output)cout << " ";
        cout << a;
        was_output = true;
    }
    void outendl(){
        was_output = false;
        cout << endl;
    }

    template<class t>
    istream& operator>>(istream&is, vector<t>&x){
        for(auto &i:x)is >> i;
        return is;
    }

    template<class t, class u>
    istream& operator>>(istream&is, pair<t, u>&x){
        is >> x.first >> x.second;
        return is;
    }

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

    template<class t = long long>
    t in(){
        t res; cin >> res; return res;
    }

    template<class t>
    void out(t x){
        cout << x;
    }

    template<class t>
    vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
        sort(line.begin(),line.end(),comp);
        return line;
    }

    template<class t>
    vector<t> reversed(vector<t> line){
        reverse(line.begin(),line.end());
        return line;
    }
    string reversed(string str){
        reverse(str.begin(),str.end());
        return str;
    }

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

    long long lcm(long long a,long long b){
        return a / gcd(a,b) * b;
    }
}

using namespace templates;

string func(){
    int n = in();
    vector<string> strs(3);
    foreach(i,strs)i=in<string>();
    string res = "";
    rep(_,n)res += "1";
    rep(_,n)res += "0";
    res += "1";
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n = in();
    rep(i,n){
        cout << func() << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;

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

#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(12) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }

int main(){
    ll N=ii();
    vector<ll> A;
    REP(i,0,N){
        A.push_back(ii());
    }
    sort(A.begin(),A.end());
    vector<ll> S;
    ll s=0;
    for(ll a:A){
        s+=a;
        S.push_back(s);
    }
    ll ret=0;
    REP(i,1,N){
        ret+=A[i]*i-S[i-1];
    }
    oie(ret);

    return 0;
}


/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << "\n"
struct UnionFind {
private:
    ll N;
    vector<ll> parent;
    vector<ll> num;
    vector<ll> diff_weight;

public:
    UnionFind(ll n){
        N = n;
        rep(i,0,N) parent.push_back(i);
        rep(i,0,N) num.push_back(1);
        rep(i,0,N) diff_weight.push_back(0);
    }

    ll root(ll x){
        if(x == parent[x]){
            return x;
        }else{
            ll r = root(parent[x]);
            diff_weight[x] += diff_weight[parent[x]];
            return parent[x] = r;
        }
    }

    void unite(ll a, ll b, ll w = 0){
        w += weight(a); w -= weight(b);
        a = root(a); b = root(b);
        if(a == b) return;
        parent[b] = a;
        ll sum = num[a] + num[b];
        num[a] = sum;
        num[b] = sum;
        diff_weight[b] = w;
    }

    bool same(ll a, ll b){ return root(a) == root(b);}

    ll sz(ll x){ return num[root(x)];}

    ll weight(ll x){
        root(x);
        return diff_weight[x];
    }

    ll diff(ll a, ll b){
        return weight(b) - weight(a);
    }
};

struct Combination{
private:
    ll N;
public:
    vector<ll> fac, facinv, inv;

    Combination(ll n){
        N = n;
        fac.resize(N+1); facinv.resize(N+1); inv.resize(N+1);
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        inv[1] = 1;
        rep(i,2,N+1){
            fac[i] = fac[i-1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            facinv[i] = facinv[i-1] * inv[i] % MOD;
        }
    }

    ll power(ll x, ll n, ll m = MOD){
        if(n == 0) return 1LL;
        ll res = power(x * x % m, n/2, m);
        if(n % 2 == 1) (res *= x) %= m;
        return res;
    }

    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        if(n < k) return 0LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }

    ll npk(ll n, ll k){
        if(k == 0) return 1LL;
        if(n < k) return 0LL;
        return fac[n] * facinv[n-k] % MOD;
    }
};

void solve(){
    ll N,K;
    cin >> N >> K;
    ll a[55][55];
    rep(i,0,N){
        rep(j,0,N){
            cin >> a[i][j];
        }
    }
    Combination cb(55);
    ll ans = 1;
    UnionFind uf(55);

    rep(i,0,N){
        rep(j,i+1,N){
            ll max_val = 0;
            rep(k,0,N){
                max_val = max(max_val, a[i][k] + a[j][k]);
            }
            if(max_val <= K){
                uf.unite(i, j);
            }
        }
    }
    bool check[55] = {};
    rep(i,0,N){
        ll r = uf.root(i);
        if(not check[r]){
            check[r] = true;
            ans *= cb.fac[uf.sz(r)];
            ans %= MOD;
        }
    }

    UnionFind uf2(55);

    rep(i,0,N){
        rep(j,i+1,N){
            ll max_val = 0;
            rep(k,0,N){
                max_val = max(max_val, a[k][i] + a[k][j]);
            }
            if(max_val <= K){
                uf2.unite(i, j);
            }
        }
    }
    bool check2[55] = {};
    rep(i,0,N){
        ll r = uf2.root(i);
        if(not check2[r]){
            check2[r] = true;
            ans *= cb.fac[uf2.sz(r)];
            ans %= MOD;
        }
    }
    print(ans);

}

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

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 998244353;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

template<class T> class Math
{
public:
    vector<T>fact,invfact;
    Math( int n )
    {
        fact.resize(n);
        invfact.resize(n);
        fact[0] = invfact[0] = 1;
        for(int i=1;i<n;i++)
        {
            fact[i] = mod( i * fact[i-1] );
            invfact[i] = modinv( fact[i] );
        }
    }
    T modinv( T x, T m = MOD )
    {
        return expo(x,m-2,m);
    }
    T expo( T base, T exp, T m = MOD )
    {
        T res = 1;
        while( exp )
        {
            if( exp&1 )
                res = mod( res*base, m );
            base = mod( base*base, m );
            exp >>= 1;
        }
        return res;
    }
    T choose( T n, T k )
    {
        if( k < 0 || k > n ) return 0;
        T ans = fact[n];
        ans = mod( ans * invfact[n-k] );
        ans = mod( ans * invfact[k] );
        return ans;
    }
};

class DSU
{
public:
    vector<int>rt,sz;
    int components;
    DSU( int n )
    {
        rt.resize(n+5);
        sz.resize(n+5);
        components = n;
        for(int i=0;i<n;i++)
        {
            rt[i] = i;
            sz[i] = 1;
        }
    }
    int get_components()
    {
        return components;
    }
    int root( int x )
    {
        while( x != rt[x] )
        {
            rt[x] = rt[rt[x]];
            x = rt[x];
        }
        return x;
    }
    void connect( int x, int y )
    {
        int r1 = root(x);
        int r2 = root(y);
        if( r1 == r2 )
            return;
        if( sz[r1] < sz[r2] )
            swap(r1,r2);
        sz[r1] += sz[r2];
        rt[r2] = r1;
        components--;
    }
};

int grid[55][55];

int main()
{
    #ifdef gupta_samarth
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fastio();

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

    Math<ll> m(102);

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

    ll ans = 1;
    for(int rep=0;rep<2;rep++)
    {
        DSU d(n);

        for(int i=0;i<n;i++)
        {
            for(int j=0;j<i;j++)
            {
                int ok = 0;
                for(int ind=0;ind<n;ind++)
                {
                    if( grid[i][ind] + grid[j][ind] <= k )
                        ok++;
                }
                if( ok == n )
                    d.connect(i,j);
            }
        }

        set<int>comps;
        for(int i=0;i<n;i++)
            comps.insert(d.root(i));

        for( int x : comps )
            ans = mod( ans * m.fact[d.sz[x]] );

        // transpose
        for(int i=0;i<n;i++)
        {
            for(int j=i;j<n;j++)
            {
                swap(grid[i][j], grid[j][i]);
            }
        }
    }
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 1e16;
const long long mod = 1e9+7;
const long long hashmod = 100003;
const int MAXN = 100000;
const int MAXM = 1000000;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
int n,m,a[105],c[105];
int arrow[10005],ch[10005];
pi edge[10005];
vecpi v[105];

void dfs(int x) {
	c[x] = 1;
	for(pi i : v[x]) {
		if(!ch[abs(i.y)]) {
			if(i.y > 0) arrow[i.y] = 1;
			else arrow[-i.y] = 0;
			ch[abs(i.y)] = 1;
		}
		if(!c[i.x]) dfs(i.x);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for(int i = 1;i <= m;i++) {
		int x,y; cin >> x >> y;
		edge[i] = {x,y};
	}
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = 1;i <= m;i++) {
		int x = edge[i].x, y = edge[i].y;
		if(a[x] < a[y]) arrow[i] = 0;
		else if(a[x] > a[y]) arrow[i] = 1;
		else v[x].pb({y,i}), v[y].pb({x,-i});
	}
	for(int i = 1;i <= n;i++) {
		if(!c[i]) dfs(i);
	}
	for(int i = 1;i <= m;i++) {
		if(arrow[i]) cout << "->\n";
		else cout << "<-\n";
	}
}

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define ll long long
const long long MOD = 998244353;
const int N = 2020;
int d[N][N];
int dx[] = {0, -1, 0, 1};
int dy[] = {-1, 0, 1, 0};
vector<pair<int, int> > g[N];
char a[N][N];
int n, m;
void BFS01(int sx, int sy)
{
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++)d[i][j] = 1e9;
	}
	d[sx][sy] = 0;
	deque<pair<int, int> > q;
	q.emplace_back(sx, sy);
	while (!q.empty()) {
		int vx, vy;
		tie(vx, vy) = q.front();
		q.pop_front();
		int c = a[vx][vy];
		if (c >= 'a' && c <= 'z') {
			for (auto el:g[c - 'a']) {
				int x = el.first;
				int y = el.second;
				if (d[x][y] > d[vx][vy] + 1) {
					d[x][y] = d[vx][vy] + 1;
					q.push_back({x, y});
				}
			}
			g[c - 'a'].resize(0);
		}
		for (int i = 0; i < 4; i++) {
			int x = vx + dx[i];
			int y = vy + dy[i];
			if (x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] != '#' && d[x][y] > d[vx][vy] + 1) {
				d[x][y] = d[vx][vy] + 1;
				q.push_back({x, y});
			}
		}
	}
}
void solve()
{
	cin >> n >> m;
	int sx, sy;
	int tx, ty;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
			if (a[i][j] == 'G') sx = i, sy = j;
			if (a[i][j] == 'S') tx = i, ty = j;
			char c = a[i][j];
			if (c >= 'a' && c <= 'z') g[c - 'a'].emplace_back(i, j);
		}
	}
	BFS01(sx, sy);
	if (d[tx][ty] == 1e9) cout << -1 << endl;
	else cout << d[tx][ty] << endl;
}
int main()
{
#ifdef QWERTY
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	srand(time(NULL));
	int TC = 1;
//	cin >> TC;
	while (TC--) {
//		cout << TC << endl;
		solve();
	}
	return 0;
}


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

int main() {
    ll n, x, a, count=0;
    cin >> n >> x;

    vector<ll> ans(n);
    rep(i,n) {
        cin >> a;
        if (a != x) {
            ans[count] += a;
            count++;
        }
    }
    rep(i,count) cout << ans[i] << " ";

    return 0;
}

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

int main(){
int n,x;
cin>>n>>x;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n;i++){
    if(a[i]!=x)
    cout<<a[i]<<" ";
}
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) int(x.size())
const int mod = 1e9 + 7;
const int inf = 2e9 + 5;
const ll linf = 9e18 + 5;
const ll ll0 = 0 * 1ll;

void init () {
}

void input () {
}

void solve() {
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];

    sort(arr, arr + 3);

    if (arr[2] - arr[1] == arr[1] - arr[0]) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

void output() {
}

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

    int number_of_testcases = 1;
    //cin >> number_of_testcases;
    while (number_of_testcases--) {
        init();

        input();

        solve();

        output();
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using uint=unsigned int;
using ull=unsigned long long;
const ll LL_MAX=LLONG_MAX;

class union_find{
private:
  vector<ll> par;
  vector<ll> siz;

public:
  union_find(ll n) : par(n),siz(n,1LL){
    for (ll i=0;i<n;i++) par[i]=i;
  }

  ll root(ll x){
    ll i=x;
    queue<ll> line;
    while(i!=par[i]){
      line.push(i);
      i=par[i];
    }
    ll l=line.size();
    for (ll j=0;j<l;j++){
      par[line.front()]=i;
      line.pop();
    }
    return i;
  }

  ll size(ll x){
    return siz[root(x)];
  }

  bool unite(ll x,ll y){
    x=root(x);
    y=root(y);
    if (x==y) return false;
    if (size(x)<size(y)){
      par[x]=y;
      siz[y]+=siz[x];
    }
    else{
      par[y]=x;
      siz[x]+=siz[y];
    }
    return true;
  }

  bool same(ll x,ll y){
    if (root(x)==root(y)) return true;
    else return false;
  }
};

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T *x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
void outl(T x){
  cout << x << endl;
}
template < >
void outl<int>(int x){
  printf("%d\n",x);
}
template < >
void outl<double>(double x){
  printf("%.16lf\n",x);
}
template < >
void outl<char>(char x){
  printf("%c\n",x);
}
template < >
void outl<string>(string x){
  printf("%s\n",x.c_str());
}
template < >
void outl<uint>(uint x){
  printf("%u\n",x);
}
template < >
void outl<ll>(ll x){
  printf("%lld\n",x);
}
template < >
void outl<ull>(ull x){
  printf("%llu\n",x);
}
void outl(){
  printf("\n");
}

template <typename T>
void out(T x){
  cout << x << flush;
}
template < >
void out<int>(int x){
  printf("%d",x);
}
template < >
void out<char>(char x){
  printf("%c",x);
}
template < >
void out<double>(double x){
  printf("%.16lf",x);
}
template < >
void out<string>(string x){
  printf("%s",x.c_str());
}
template < >
void out<uint>(uint x){
  printf("%u",x);
}
template < >
void out<ll>(ll x){
  printf("%lld",x);
}
template < >
void out<ull>(ull x){
  printf("%llu",x);
}

void outyes(){
  printf("Yes\n");
}
void outno(){
  printf("No\n");
}

void outyn(bool x){
  if (x) printf("Yes\n");
  else printf("No\n");
}

void outsp(){
  printf(" ");
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

template <typename T>
T npr(T x,T y){
  T loop=max(x-y,y),ans=1;
  for (T i=loop;i<=x;i++){
    ans*=i;
  }
  return ans;
}//xPy

template <typename T>
T ncr(T x,T y){
  T loop=min(x,x-y),ans=npr(x,y);
  for (T i=1;i<=loop;i++){
    ans/=i;
  }
  return ans;
}//xCy

template <typename T>
T fac(T x){
    if (x==1) return 1;
    return x*fac(x-1);
}

void div1(ll &x) {
    x%=1000000007;
}

ll mypow(ll x,ll n){
    ll ans=1;
    for (ll i=1;i<=n;i = i<<1){
        if ((n & i)== i){//ループj回目で2進表記のときにj桁目が1かどうか判定
            ans*=x;
        }
        x*=x;
    }
    return ans;
}

ll divpow(ll x,ll n){
    ll ans=1;
    div1(x);
    for (ll i=1;i<=n;i = i<<1){
        if ((n & i)== i){//ループj回目で2進表記のときにj桁目が1かどうか判定
            ans*=x;
            div1(ans);
        }
        x*=x;
        div1(x);
    }
    return ans;
}

int main(){
  int n=in,a[n],ans=0;
  forin(a,n);
  for (int i=0;i<n;i++){

      ans+=max(a[i]-10,0);
  }
  outl(ans);
}


#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1>
void pr(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1>
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1>
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }

#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
#define PI pair<int,int>
template<typename T1>
T1 gcd(const T1 &a, const T1 &b) {
    if (a == 0 || b == 0) return a + b;
    return gcd(b, a %b);
}
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 200001
#define MOD 998244353

ll C1[MAX], C2[MAX];
ll D1[MAX], D2[MAX];
bool HC[MAX];
ll n, x, c;
void solve() {
    cin >> n;
    rep(i,n) {
        cin >> x >> c;
        if (!HC[c]) {
            C1[c] = C2[c] = x;
        }
        HC[c] = 1;
        chmin(C1[c], x);
        chmax(C2[c], x);
    }
    C1[0] = C2[0] = D1[0] = D2[0] = 0;
    reps(i, 1, n+1) {
        if (!HC[i]) {
            C1[i] = C1[i-1];
            C2[i] = C2[i-1];
            D1[i] = D1[i-1];
            D2[i] = D2[i-1];
            continue;
        }

        D1[i] = min(D1[i-1] + abs(C2[i] - C1[i-1]),
                    D2[i-1] + abs(C2[i] - C2[i-1])) + abs(C1[i] - C2[i]);
        D2[i] = min(D1[i-1] + abs(C1[i] - C1[i-1]),
                    D2[i-1] + abs(C1[i] - C2[i-1])) + abs(C1[i] - C2[i]);
        //debug(i, C1[i], C2[i], D1[i], D2[i]);
    }
    out(min(D1[n] + abs(C1[n]), D2[n] + abs(C2[n])))
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
#ifdef _OLIMPOLOCAL
    cin >> test;
#endif
    rep(testCase, test) {
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int INF = 2e9 + 5;
const int dpINF = 1e16;
const int off = 1e9;
void print(vector<pair<int, int>> a) {
    cout << "\n";
    for(auto i : a) {
        cout << i.first << " " << i.second << "\n";
    }
    cout << "\n";
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);

    for(int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
//        a[i].first += off;
    }
    sort(a.begin(), a.end(), [](pair<int, int> l, pair<int, int> r) { return l.second < r.second; });

    vector<pair<int, int>> v(n+2, {INF, -INF});
    v[0] = {0, 0};
    v[n+1] = {0, 0};
    for(int i = 0; i < n; i++) {
        v[a[i].second].first = min(v[a[i].second].first, a[i].first);
        v[a[i].second].second = max(v[a[i].second].second, a[i].first);
    }
//    print(v);
//    print(a);

    int dp[n+5][2];
    for(int i = 0; i <= n+4; i++) {
        for(int j = 0; j < 2; j++) {
            dp[i][j] = dpINF;
        }
    }
    dp[0][0] = dp[0][1] = 0;

    cerr << "\n";
    for(int i = 1; i <= n+1; i++) {
        if (v[i].first == INF) {
            v[i] = v[i-1];
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
            continue;
        }
        dp[i][0] = min(dp[i][0], dp[i-1][0] + abs(v[i-1].first - v[i].second) + abs(v[i].second - v[i].first));
        dp[i][0] = min(dp[i][0], dp[i-1][1] + abs(v[i-1].second - v[i].second) + abs(v[i].second - v[i].first));
        dp[i][1] = min(dp[i][1], dp[i-1][0] + abs(v[i-1].first - v[i].first) + abs(v[i].second - v[i].first));
        dp[i][1] = min(dp[i][1], dp[i-1][1] + abs(v[i-1].second - v[i].first) + abs(v[i].second - v[i].first));
//        cout << dp[i][0] << " " << dp[i][1] << "\n";
    }

    int ans = min(dp[n+1][0], dp[n+1][1]);
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, C;
    cin >> N >> C;
    vector<pair<int, int>> event;
    REP(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        event.emplace_back(a - 1, c);
        event.emplace_back(b, -c);
    }
    sort(ALL(event));
    int ans = 0, fee = 0, t = 0;
    for (auto [x, y] : event) {
        if (x != t) {
            ans += min(C, fee) * (x - t);
            t = x;
        }
        fee += y;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}

#include<bits/stdc++.h>
using namespace std;
long long used[222222];
int s[222222];
int t[222222];
int main()
{
	long long n,w;
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		long long p;
		cin>>s[i]>>t[i]>>p;
		used[s[i]]+=p;
		used[t[i]]-=p;
	}
	for(int i=0;i<=200000;i++)
	{
		used[i]+=used[i-1];
		if(used[i]>w)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;

}


// AtCoder Beginner Contest 204
// B -
#include <iostream>
#include <vector>

int main(int argc, char *argv[]);
int main(int argc, char *argv[])
{
  unsigned short N;
  std::cin >> N;

  std::vector<unsigned short> nuts(N);
  for(unsigned short i=0; N>i; i++)
    std::cin >> nuts[i];

  std::vector<unsigned short>::const_iterator it=nuts.cbegin();
  const std::vector<unsigned short>::const_iterator end=nuts.cend();

  unsigned long sum=0;
  while(end != it)
    {
      if(10 < *it)
        sum += *it-10;
      it++;
    }

  std::cout << sum << std::endl;

  return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define F first
#define S second
#define nl "\n"
#define pll pair<ll, ll>
#define all(v) (v).begin(), (v).end()
#define decimal(n) cout << fixed << setprecision(n)
#define mod 1000000007
// #define mod 998244353
#define pi 3.14159265358979323846

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t = 1, tc;
    //cin >> t;
    for (tc = 1; tc <= t; tc++)
    {
        ll n,i,x,s=0;
        cin>>n;
        for(i=0;i<n;i++){
            cin>>x;
            s+=max(0ll,x-10);
        }
        cout<<s;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>

#define int long long
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
#define lc (x<<1)
#define rc (x<<1|1)
#define fan(x) (((x-1)^1)+1)
#define max Max
#define min Min
#define abs Abs

using namespace std;

inline int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
	return ans*f;
}

inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x/10) write(x/10);
	putchar((char)(x%10)+'0');
}

template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a>b?b:a;}
template<typename T,typename TT> inline T Max(T a,TT b){return a>b?a:b;}

signed main()
{
	int x=read(),y=read();
	if(min(x,y)+3>max(x,y)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
     int a,b;
     cin>>a>>b;
     int ans =abs(a-b);
     if(ans<3)cout<< "Yes"<<endl;
     else cout<< "No"<<endl;
}


// 2021-02-21 21:21:33
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

// clang-format on
ll pw10(ll n, ll m, ll mod) {
  ll res = 1;
  ll b = n;
  while (m > 0) {
    if (m & 1) res *= b;
    b *= b;
    res %= mod;
    b %= mod;
    m >>= 1;
  }
  return res % mod;
}
void answer() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a % 10 == 0) {
    cout << 0 << '\n';
    return;
  }
  if (a % 10 == 1) {
    cout << 1 << '\n';
    return;
  }
  int mod;
  {
    vector<int> id(10, -1);
    ll n = a % 10;
    int cur = 0;
    while (id[n] == -1) {
      id[n] = cur++;
      n *= a;
      n %= 10;
    }
    mod = cur;
  }
  ll d = pw10(b, c, mod);
  d--;
  d += mod;
  d %= mod;
  ll ans = a % 10;
  rep(i, d) {
    ans *= a;
    ans %= 10;
  }
  cout << ans << '\n';
}

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


#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(i,n) for(int i = 0; i < n; ++ i)
#define mod 10e+7
#define pb push_back
const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

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

}

int max(int x,int y)
{
    if(x==0 && y==0)
        return -1;
    else if(x>y)
        return x;
    else if(x<=y)
        return y;
    return 0;
}

int min(int x,int y)
{
    if(x==0 && y==0)
        return -1;
    else if(x>y)
        return y;
    else if(x<=y)
        return x;
    return 0;
}

void solve()
{
  int n,f=0;
  cin>>n;
  string str;
  unordered_set<string> S;
  while(n--)
  {
    cin>>str;
    S.insert(str);
  }
  unordered_set<string>::iterator itr;
  for(itr=S.begin();itr!=S.end();++itr)
  //for(const string& str1 : S)
  {
    if(S.count('!'+*itr))
    {
      cout<<*itr;
      return;
    }
  }
  cout<<"satisfiable";
}

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

    while (T--)
        solve();

    return 0;
}

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

void input(set<string>& rseStr)
{
  int nStrSiz;
  cin >> nStrSiz;

  for (int nx = 0; nx < nStrSiz; ++nx)
  {
    string sStr;
    cin >> sStr;
    rseStr.insert(sStr);
  }
}

string isExistStr(const set<string>& cnrseStr)
{
  for (auto sStr : cnrseStr)
  {
    if (sStr[0] == '!')
    {
      string s2ndSubStr = sStr.substr(1);
      if ( cnrseStr.count(s2ndSubStr) )
        return s2ndSubStr;
    }
  }
  return "satisfiable";
}

int main()
{
  set<string> seStr;
  input(seStr);
  cout << isExistStr(seStr) << endl;

  return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include<string>
using namespace std;
#define boost ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

long long n,m;
string s,st;
long long a[200005]={0};
void get_values()
{
    std::cin >> n >> m;
    n=n+m;
    //for(int i=0;i<n;i++)
      //  std::cin >> a[i];
    //std::cin >> s;
    //n=s.length();
}

void solve()
{
    long long i,j,t,ans=0,x,y;
    if(n>=15 && m>=8)
        std::cout << 1 << std::endl;
    else if(n>=10 && m>=3)
        std::cout << 2 << std::endl;
    else if(n>=3)
        std::cout << 3 << std::endl;
    else
        std::cout << 4 << std::endl;
}

int main() {
    boost;
    get_values();
    solve();
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define pi pair
#define K 1000000007
using namespace std;

ll a[2000000];
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll test_case=1;//cin>>test_case;
	while(test_case--)
	{
       ll a,b;cin>>a>>b;
       cout<<fixed;
       cout<<setprecision(10)<<(100*(a-b))/(double)a<<endl;
	}
	return 0;
}


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

int n;
ll a[310000];

const int SEG_LEN=1<<19;
int seg[SEG_LEN*2];

void update(int ind, int val){
  ind += SEG_LEN;
  seg[ind]=val;
  while(ind!=0){
    ind/=2;
    seg[ind]=seg[ind*2]+seg[ind*2+1];
  }
  return;
}

int getsum(int ql, int qr, int sl=0, int sr=SEG_LEN, int pos=1){
  if(qr<=sl || sr<=ql) return 0;
  if(ql<=sl && sr<=qr) return seg[pos];
  int sm=(sl+sr)/2;
  return getsum(ql,qr,sl,sm,pos*2)+getsum(ql,qr,sm,sr,pos*2+1);
}

int main(){
  cin>>n;
  rep(i,n) cin>>a[i];
  ll inv=0;
  rep(i,n){
    update(a[i],1);
    inv += getsum(a[i]+1,n);
  }
  cout<<inv<<endl;
  rep(i,n-1){
    inv=inv-a[i]+n-a[i]-1;
    cout<<inv<<endl;
  }
}

#include<bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define nep(i,r,l) for(int i=r;i>=l;i--)
void sc(int &x){scanf("%d",&x);}
void sc(int &x,int &y){scanf("%d%d",&x,&y);}
void sc(int &x,int &y,int &z){scanf("%d%d%d",&x,&y,&z);}
void sc(ll &x){scanf("%lld",&x);}
void sc(ll &x,ll &y){scanf("%lld%lld",&x,&y);}
void sc(ll &x,ll &y,ll &z){scanf("%lld%lld%lld",&x,&y,&z);}
void sc(char *x){scanf("%s",x);}
void sc(char *x,char *y){scanf("%s%s",x,y);}
void sc(char *x,char *y,char *z){scanf("%s%s%s",x,y,z);}
void out(int x){printf("%d\n",x);}
void out(ll x){printf("%lld\n",x);}
void out(int x,int y){printf("%d %d\n",x,y);}
void out(ll x,ll y){printf("%lld %lld\n",x,y);}
void out(int x,int y,int z){printf("%d %d %d\n",x,y,z);}
void out(ll x,ll y,ll z){printf("%lld %lld %lld\n",x,y,z);}
using namespace std;
const int N=3e5+5;
struct node
{
    int x,y,id;
}a[N];
int n;
bool cmp1(node &x,node &y)
{
    return x.x<y.x;
}
bool cmp2(node &x,node &y)
{
    return x.y<y.y;
}
map<pair<int,int>,bool>vis;
vector<int>v;
void add(int x,int y)
{
    if(vis[{a[x].id,a[y].id}]) return;
    vis[{a[x].id,a[y].id}]=vis[{a[y].id,a[x].id}]=true;
    v.push_back(max(abs(a[x].x-a[y].x),abs(a[x].y-a[y].y)));
}
int main()
{
    //freopen("1.in","r",stdin);freopen("1.out","w",stdout);
    sc(n);
    rep(i,1,n) sc(a[i].x,a[i].y),a[i].id=i;
    sort(a+1,a+1+n,cmp1);
    add(1,n);
    add(1,n-1);
    add(2,n);
    sort(a+1,a+1+n,cmp2);
    add(1,n);
    add(1,n-1);
    add(2,n);
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    out(v[1]);
}


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

typedef long long ll;
typedef long double ld;
const ll M=998244353;
const ll MAXN=1e6+7;
const ld pi=acos(-1);

#define gi(n) ll n=read()
#define endl '\n'
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define per(i,a,b) for(ll i=b-1; i>=a; --i)

typedef vector<ll> V;
typedef vector<V> VV;
typedef set<ll> S;
typedef pair<ll,ll> pl;
typedef vector<pl> Vp;
typedef map<ll,ll> ml;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define fs first
#define sc second

inline ll read(){
	ll x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll pow1(ll p,ll d, ll P){return d?(pow1(p*p%P,d>>1,P)*(d&1?p%P:1))%P:1;}
//ll mul(ll a,ll b,ll P){return b?(mul(a*2%P,b>>1,P)+(b&1?a:0))%P:0;}
//ll pow1(ll p,ll d, ll P){return d?mul(pow1(mul(p,p,P),d>>1,P),(d&1?p%P:1),P):1;}

V prime;
bool is_composite[MAXN];
void sieve (ll n){
	std::fill (is_composite, is_composite + n, false);
	rep(i,2,n){
		if(!is_composite[i]) prime.pb(i);
		for(ll j = 0; j < (ll)prime.size() && i*prime[j] < n; ++j){
			is_composite[i*prime[j]] = true;
			if(i % prime[j] == 0) break;
		}
	}
}
ll modInverse(ll a, ll m){
	ll m0=m,y=0,x=1;
	if(m==1) return 0;
	while(a>1){
		ll q=a/m,t=m;
		m=a%m;
		a=t;
		t=y;

		y = x-q*y;
		x = t;
	}
	if(x<0) x += m0;
	return x;
}

V fact(100007);

void dfs(ll v,V &visited, V &v1,VV w){
	visited[v] = true;
	v1.pb(v);

	V::iterator i;
	for(i = w[v].begin(); i != w[v].end(); ++i)
		if(!visited[*i])
			dfs(*i, visited,v1,w);
}

void doit(){
	gi(n);
	gi(l);
	VV a(n, V (n));
	rep (i,0,n)
		rep(j,0,n) a[i][j] = read();
	ll cr = 0;
	VV row(n),col(n);
	rep(i,0,n) {
		row[i].pb(i);
		rep(j,i+1,n){
			ll ok = 1;
			rep(k,0,n) if(a[i][k] + a[j][k] > l) ok = 0;
			if(ok) {
				row[i].pb(j);
				row[j].pb(i);
			}
		}
	}
	ll cc = 0;
	rep(i,0,n) {
		col[i].pb(i);
		rep(j,i+1,n){
			ll ok = 1;
			rep(k,0,n) if(a[k][i] + a[k][j] > l) ok = 0;
			if(ok) {
				col[i].pb(j);
				col[j].pb(i);
			}
		}
	}
	ll ans = 1;
//	cout << cr << " " << cc << "\n";
	V vis(n,0);
	V x[2*n];
	ll k = 0;
	rep(i,0,n)
		if(row[i].size())
			if(!vis[i])
				dfs(i,vis,x[k],row), k++;

	rep(i,0,n) vis[i] = 0;

	rep(i,0,n)
		if(col[i].size())
			if(!vis[i])
				dfs(i,vis,x[k],col), k++;

/*	rep(i,0,n) {
		if(row[i].size()) {
			cout << i << "\t";
			rep(j,0,row[i].size()) cout << row[i][j] << " ";
			cout << "\n";
		}
	}
	rep(i,0,n) {
		if(col[i].size()) {
			cout << i << "\t";
			rep(j,0,col[i].size()) cout << col[i][j] << " ";
			cout << "\n";
		}
	}

	rep (i,0,2*n) {
		for (auto j:x[i]) cout << j << " ";
		if(x[i].size())cout << "\n";
	}
*/
	rep (i,0,2*n) {
		ans *= fact[x[i].size()];
		ans %= M;
	}

//	cr = (sqrt(8*cr)-1)/2;
//	cc = (sqrt(8*cc)-1)/2;
	cout << ans;
}

int main(){
	fact[0] = 1;
	rep (i,1,fact.size()) fact[i] = (fact[i-1] * i) % M;
//	for(gi(t);t--;cout<<endl)
		doit();
	return 0;
}

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

class UnionFind {
public:
  vector<ll> par, siz;
  UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
    for(int i=0; i<sz_; ++i) par[i]=i;
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_,1);
    for(int i=0; i<sz_; ++i) par[i]=i;
  }

  ll root(ll x) {
    while(x!=par[x]) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  void merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x!=y) {
      if(siz[x]<siz[y]) swap(x,y);
      siz[x]+=siz[y];
      par[y]=x;
    }
  }

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  ll size(ll x) {
    return siz[root(x)];
  }
};

int main() {
  ll N,K; cin>>N>>K;
  vector<vector<ll>> A(N,vector<ll>(N,0));
  for(int i=0; i<N; ++i) {
    for(int j=0; j<N; ++j) cin>>A[i][j];
  }

  //vector<bool> checkRow(N,false);
  //vector<bool> checkColumn(N,false);
  UnionFind ufRow(N), ufColumn(N);
  //ll rows, columns;
  for(int i=0; i<N-1; ++i) {
    for(int j=i+1; j<N; ++j) {
      bool canSwapR = true, canSwapC = true;
      for(int k=0; k<N; ++k) {
        if(A[i][k]+A[j][k] > K) canSwapC = false;
        if(A[k][i]+A[k][j] > K) canSwapR = false;
      }
      if(canSwapR) {
        //checkRow[i]=true; checkRow[j]=true;
        ufRow.merge(i,j);
      }
      if(canSwapC) {
        //checkColumn[i]=true; checkColumn[j]=true;
        ufColumn.merge(i,j);
      }
    }
  }
  //rows = count(checkRow.begin(),checkRow.end(),true);
  //columns = count(checkColumn.begin(),checkColumn.end(),true);
  // 各々の階乗をかければいいはず
  ll ans = 1;
  vector<bool> seen(N,false);
  for(int i=0; i<N; ++i) {
    if(!seen[ufRow.root(i)]) {
      for(int j=1; j<=ufRow.size(i); ++j) ans=ans*j%MOD;
      seen[ufRow.root(i)] = true;
    }
  }
  seen.assign(N,false);
  for(int i=0; i<N; ++i) {
    if(!seen[ufColumn.root(i)]) {
      for(int j=1; j<=ufColumn.size(i); ++j) ans=ans*j%MOD;
      seen[ufColumn.root(i)] = true;
    }
  }
  /*
  for(int i=1; i<=rows; ++i) ans=ans*i%MOD;
  for(int i=1; i<=columns; ++i) ans=ans*i%MOD;
  */
  cout << ans << endl;
}


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

#define read(x)    freopen(x, "r", stdin);
#define write(x)   freopen(x, "w", stdout);

#define ll long long
#define lli long long int
#define ve vector<int>
#define FOR(n)          for(int i=0; i<(int)(n); ++i)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
#define PRINT_CASE      printf("Case %d: ",z)
#define pb push_back
#define mod 1000000007
#define maxx 200005

             //#define sazzad

int main()
{
    #ifdef sazzad
read("input.txt");
// write("output.txt");
#endif

      int r,g,b,ans,res;
      vector<int>v(4);
      FOR(4) scanf("%d",&v[i]);
      ans = *min_element(v.begin(),v.end());
      printf("%d\n",ans);

	return 0;
}

#include <iostream>
#include <math.h>
#include <unordered_set>
using namespace std;
int main(void)
{
    long long int N;
    cin >> N;
    long long int a, b;
    a = 2;
    b = 2;
    long long int count = 0;
    unordered_set<long long int> s;
    while (pow(a, b) <= N) {
        while (pow(a, b) <= N) {
            count++;
            s.insert(pow(a, b));
            b++;
        }
        b = 2;
        a++;
    }
    cout << N-s.size() << endl;
}


#include <iostream>

using namespace std;

int main() {
  char S, T; cin >> S >> T;
  if (S == 'Y') {
    cout << (char)toupper(T) << endl;
  } else {
    cout << T << endl;
  }
}

#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>
#include <hash_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace std;

#define     lp(i,a,n)       for(ll i=a;i<n;i++)
#define     lp2(i,n,a)      for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<int,int>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            '\n'
#define     Endl            '\n'
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightX[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightY[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=1e6+1,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1e-9;

void solve(){
    char a,b;
    cin>>a>>b;
    if(a=='Y'){
        if(b>=97)
            cout<<char(b-32)<<endl;
        else
            cout<<b<<endl;
    }
    else{
        if(b<97)
            cout<<char(b+32)<<Endl;
        else
            cout<<b<<endl;
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n,m;
     cin>>n>>m;
     int a[20][20];
     int sum=0;
     for(int i=1;i<=n;i++)
     {
         for(int j=1;j<=m;j++)
         {
              sum+=i*100+j;
         }
     }
     cout<<sum<<endl;
}

#include<fstream>
#include<iostream>
#include<sstream>
#include<vector>
#include<stack>
#include<string>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<map>
#include<stdlib.h>
#include<queue>
#include<tuple>
#include<iomanip>
#include<bitset>
#include<deque>
#include<stdio.h>
#include<set>
#include<array>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using graph = vector<vector<int>>;
const long long MOD = 1000000007;
const long long INF = 1e18;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using matrix = vector<vector<ll>>;

void chmin(int &x,int y){ x = min(x,y); }

int digit(ll x){
  int count = 1;
  while(x/10>0){
    count ++;
    x /= 10;
  }
  return count;
}

bool prime(ll x){
  if(x==1) return false;
  for(ll i=2;i*i<=x;i++){
    if(x%i==0) return false;
  }
  return true;
}

void decom(ll x,map<ll,int> &hatano){
  for(ll i=2;i*i<=x;i++){
    if(x%i==0&&prime(i)){
      while(x%i==0){
      x /= i;
      hatano[i] ++;
    }
    }
  }
  if(x!=1) hatano[x] ++;
}

ll speedpow(ll x,ll y){
  ll res = 1;
  ll test = x;
  for(int i=0;i<31;i++){
    if(y&(1<<i)) res *= test;
    res = res%MOD;
    test = (test*test)%MOD;
  }
  return res;
}

ll combination(ll x,ll y){
  ll test = 1;
  ll test1 = 1;
  for(ll i=0;i<y;i++){
    test = (test*(x-i))%MOD;
    test1 = (test1*(i+1LL))%MOD;
  }
  return (test * speedpow(test1,MOD-2))%MOD ;
}

int euclid(int x,int y){
  if(y==0) return x;
  return euclid(y,x%y);
}

//行列累乗

matrix mul(matrix &a, matrix &b) {
  int p = a.size();
    matrix res(p, vector<long long>(p, 0));
    for(int i = 0; i < p; i++)
        for(int j = 0; j < p; j++)
            for(int k = 0; k < p; k++)
                (res[i][j] += a[i][k] * b[k][j]) %= MOD;
    return res;
}

matrix pow(matrix m, long long k) {
  int p = m.size();
    matrix res(p, vector<long long>(p, 0));
    for(int i = 0; i < p; i++)
        res[i][i] = 1; // 単位行列にする

    while(k > 0) {
        if(k & 1) res = mul(res, m);
        m = mul(m, m);
        k >>= 1;
    }
    return res;
}

// フェニック木
/*
ll n;

ll bit1[100002];
ll bit2[100002];

ll sum(ll *b,ll x){
  ll res = 0;
  while(x>0){
    res += b[x];
    x -= x&(-x);
  }
  return res;
}

void add(ll *b,ll i,ll x){
  //bit[i] += x;
  if(i==0) return;
  while(i<=100002){
    b[i] += x;
    i += i&(-i);

  }
}*/

struct dijkstra{
  int n,m;
  vector<vector<pair<ll,int>>> g;
  vector<ll> ans;

  /*コンストラクタ x:点の数 y:辺の数*/
  dijkstra(int x,int y){
    n=x;m=y;g.assign(n,{});ans.assign(n,INF);
    rep(i,m){
      int a,b;ll c;cin >> a >> b >> c;
      g[a].push_back(make_pair(c,b));
    }
  }

  void solve(int x){
    ans[x]=0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> que;
    que.push(make_pair(0,x));

    while(!que.empty()){
      //cout << "hatano" << endl;
      pair<ll,int> p = que.top();que.pop();
      int v = p.second;
      int d = p.first;
      if(ans[v]!=d) continue;

      for(auto e:g[v]){
        if(ans[e.second]<=e.first+d) continue;
        que.push(make_pair(e.first+d,e.second));
        ans[e.second]=e.first+d;
      }

    }

  }
  ~dijkstra(){

  }

};

int main(){

    int n,k;cin >> n >> k;
    int ans=0;

    rep(i,n){
      rep(j,k){
        ans += (i+1)*100+(j+1);
      }
    }
    cout << ans << endl;

}


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

int main() {

  int64_t N;
  cin>>N;
  vector<int64_t> vec(0);
  for(int i=1; i<=sqrt(N); i++){
    if(N%i==0){
      vec.push_back(i);
    }
  }
  for(int i=0; i<vec.size(); i++){
    cout<<vec.at(i)<<endl;
  }
  int a;
  a=vec.size();
  if(vec.at(a-1)!=N/vec.at(a-1))
    cout<<N/vec.at(a-1)<<endl;
  for(int i=1; i<a; i++){

    cout<<N/vec.at(a-i-1)<<endl;
  }
}

//2*10^9
//9*10^18
// __int128_t
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long int
#define ll long long int

const ll M=1e9+7;

//to handle when remainder is -neg we add + M
//but when rem is +pos that time also we add so use %M
//so it will work for both
ll mod(ll n){
    return (n%M + M)%M;
}
ll modAdd(ll a, ll b){
    return mod(mod(a)+mod(b));
}
ll modMul(ll a, ll b){
    return mod(mod(a)*mod(b));
}
ll modMinus(ll a, ll b){
    return mod(mod(a)-mod(b));
}
ll modpow(ll x, ll n)
{
    if (n == 0)
        return 1%M;
    if (n == 1)
        return x%M;
    ll u = modpow(x,n/2);
    u = modMul(u,u);
    if (n%2)
        u = modMul(u,x);
    return u;
}

ll mod1(ll n, ll mod){
    return (n%mod + mod)%mod;
}
ll modMul1(ll a, ll b, ll mod){
    return mod1(mod1(a,mod)*mod1(b,mod),mod);
}
ll modpow1(ll x, ll n, ll mod)
{
    if (n == 0)
        return 1%mod;
    if (n == 1)
        return x%mod;
    ll u = modpow1(x,n/2,mod);
    u = modMul1(u,u,mod);
    if (n%2)
        u = modMul1(u,x,mod);
    return u;
}

ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool isPrime(ll n){
    int end = sqrt(n);
    for(int i=2;i<=end;i++)
        if(n%i==0)
            return false;
    return true;
}

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

    int t=1;
    //cin>>t;

    while(t--){
        ll n,m;
        cin>>n>>m;

        ll result = modpow1(10,n,m*m);
        cout<<(result/m)<<endl;
    }
    return 0;
}