#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
#define mod 1000000007
#define decimal(n,k) cout<<fixed<<setprecision(k)<<n<<endl
#define LL_MAX LLONG_MAX
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
int exp(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x){return exp(x,mod-2);}
int add(int a,int b){a%=mod,b%=mod;a=((a+b)%mod+mod)%mod;return a;}
int sub(int a,int b){a%=mod,b%=mod;a=((a-b)%mod+mod)%mod;return a;}
int mul(int a,int b){a%=mod,b%=mod;a=((a*b)%mod+mod)%mod;return a;}
int gcd(int a, int b){if (b == 0)return a; return gcd(b, a % b);}
int log2n( int n){ return (n > 1) ? 1 + log2n(n / 2) : 0;}
int fac[100009];int ncr_mod(int n,int k){int ans=fac[n];ans*=modinv(fac[k]);ans%=mod;ans*=modinv(fac[n-k]);ans%=mod;return ans;}
vector<int>v_prime;void Sieve(int n){bool prime[n + 1];memset(prime,true,sizeof(prime));for (int p = 2; p*p <=n;p++){if(prime[p] ==true) {for(int i = p*p; i<= n; i += p)prime[i]=false;}}for(int p = 2;p<= n;p++)if (prime[p])v_prime.pb(p);}
vector<int>v_factor;void factor(int n){ for (int i=1; i<=sqrt(n); i++) {if (n%i == 0) {if (n/i == i) v_factor.pb(i);else { v_factor.pb(i),v_factor.pb(n/i);};} } sort(all(v_factor)); }
void out(vector<int>&a){for(int i=0;i<a.size();i++) cout<<a[i]<<" ";  cout<<endl;}
void sout(set<int>s){for(auto it=s.begin();it!=s.end();++it)cout<<*it<<" ";  cout<<endl;}
void mout(map<int,int>mm){for(auto it=mm.begin();it!=mm.end();++it) cout<<it->fi<<" "<<it->se<<endl;}
int power(int x, int y){int temp;if( y == 0)return 1; temp = power(x, y / 2);if (y % 2 == 0) return temp * temp;else return x * temp * temp;}

// s.top().second;

signed main()
{

      run;

/*
open for mod factorial

     fac[0]=1;
      for(int i=1;i<100009;i++)
      {
          fac[i]=fac[i-1]*i;
           fac[i]%=mod;
      }
*/

/*
  for sieve open this and use v_prime

          int pp=pow(10,6)+100000;
               Sieve(pp);
*/

 //   factor(n)  &&   USE v_factor For calculating factors

int  t=1;
//cin>>t;
while(t--)
{
             //  map<int,int>mp; // x.second-->frequency

             int  n,i,x,y,ok=0,sum=0,ans=0,j,k,cnt=0,m,c=0;
             int  h[100009]={0};

                 // cin>>n;

                 string s;
                cin>>s;

 n=s.size();

 for(i=n-1;i>=0;i--)
 {
     if(s[i]!='0')
     {
         c=i;
         break;
     }

 }
 string ss,ss1;

 for(i=0;i<=c;i++)
 {
     ss+=s[i];

 }
 ss1=ss;

 reverse(all(ss));
 if(ss1==ss)
 {
     yes;

 }
 else
 no;

}
}

#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

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

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

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n; ++i) {
        os << v[i] << (i == n - 1 ? "" : " ");
    }
    return os;
}

template <typename X>
void in(X& x) {
    std::cin >> x;
}

template <typename X, typename Y>
void in(X& x, Y& y) {
    in(x); in(y);
}

template <typename X, typename Y, typename Z>
void in(X& x, Y& y, Z& z) {
    in(x); in(y, z);
}

template <typename X, typename Y, typename Z, typename W>
void in(X& x, Y& y, Z& z, W& w) {
    in(x); in(y, z, w);
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"

#ifdef LOCAL
#define err(args...)      eout(#args, args)
#else
#define err(args...)      42
#endif

#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vl  = std::vector<ll>;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    int n, k; in(n, k);
    ll ans = 0;
    for (int t = std::max(2, 2 + k); t <= std::min(2*n, 2*n + k); ++t) {
        int na = std::min(t - 1, n) - std::max(t - n, 1) + 1;
        int u = t - k;
        int nc = std::min(u - 1, n) - std::max(u - n, 1) + 1;
        ans += (ll) na*nc;
    }
    out(ans);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 10e9+7

typedef vector<int> vint;
typedef long long ll;

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

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

        char map[h][w];

        rep(i,h){
                string s;
                cin>>s;
                rep(j,w){
                        map[i][j]=s[j];
                }
        }
        int res=0;

        rep(i,h){
                //cout<<"i="<<i<<endl;
                rep(j,w){
                        //cout<<"j="<<j<<endl;
                        if(map[i][j]=='.'){
                                //cout<<i<<j<<endl;
                                if(map[i+1][j]=='.'&&i+1<h){res++;}
                                if(map[i][j+1]=='.'&&j+1<w){res++;}
                        }
                        else{continue;}
                }
        }
        cout<<res<<endl;
        return 0;
}


#include<cstdio>
#include<algorithm>
#define int long long
const int Q=100005;
const int INF=(1ll<<57);
using namespace std;
typedef long long ll;
#define rg register int
char buf[1<<21],*p1=buf,*p2=buf;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline bool ig(char c){return c>=48&&c<=57;}
inline void read(int &oi){char c;int f=1,res=0;while(c=gc(),(!ig(c))&&c^'-');c^'-'?res=(c^48):f=-1;while(c=gc(),ig(c))res=res*10+(c^48);oi=f*res;}
inline void print(int oi){if(oi<0)putchar('-'),oi=~oi+1;if(oi>9)print(oi/10);putchar(oi%10+48);}
inline void write(int oi,char c){print(oi);putchar(c);}
inline long double minn(long double x,long double y){return x<y?x:y;}
int n,a[Q],s[Q];
//int ans1=INF,ans2=INF;
long double mn=INF;
signed main(){
	read(n);for(rg i=1;i<=n;++i)read(a[i]);
	sort(a+1,a+1+n);
	for(rg i=1;i<=n;++i)s[i]=s[i-1]+a[i];
	for(rg i=1;i<=n;++i){
		long double x=a[i]/2.0;
		long double now=x*i+s[n]-s[i]-(n-i)*x;
//		printf("%.2Lf  %.6Lf\n",x,now);
		mn=minn(mn,now);
//		double x=a[i]/2.0;
//		int tim1=s[n]-s[i]+2*x*i-n*x;
//		int tim2=((1.0*s[n]-s[i]+2.0*x*i-1.0*n*x)-tim1)*10;
//		if(tim1<ans1||(tim1==ans1&&tim2<ans2))ans1=tim1,ans2=tim2;
	}
//	printf("%lld %lld\n",ans1,ans2);
//	printf("%.10Lf\n",mn);
	printf("%.20Lf\n",1.0*mn/n);
	return 0;
}

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
template<typename T>
struct BIT{
    //1-index
    //0-indexで取ると無限ループする
    private:
    V<T> arr;
    int n;

    public:
    BIT(int siz){
        n=siz;
        arr.assign(n+1,0);
    }
    //一点更新 aにvを加える
    void add(T a,T v){
        //x+=(x&-x) 初項a,それ以降a<=2^Nが列挙
        for(T x=a;x<=n;x+=(x&-x)){
            arr[x]+=v;
        }
    }
    T sum(T a){
        // 1からaまでの区間和
        T ret=0;
        for(T x=a;x>0;x-=(x&-x))ret+=arr[x];
        return ret;
    }
    T get(T x){//x番目に大きい数　// 区間和がw以上となる最小のindを返す
        if(x<=0) return 0;
        T N=1;
        while(N*2<=n)N*=2;
        T v=0;
        for(T i=N;i>0;i/=2){
            if(v+i<=n&&arr[v+i]<x){
                x-=arr[v+i];
                v+=i;
            }
        }
        return v+1;
    }
    T query(int l,int r){
        return sum(r)-sum(l);
    }
};
struct Q{
    int t,x;
    ll y;
    Q(){}
};
map<ll,ll> mp;
int main(){
    ll n,m,q;
    cin>>n>>m>>q;
    mp[0];
    V<Q> d(q);
    V<ll> a(n,0),b(m,0);
    for(int i=0;i<q;i++){
         cin>>d[i].t>>d[i].x>>d[i].y;
         d[i].x--;
         mp[d[i].y];
    }
    int id=1;
    for(auto &p:mp){
          p.se=id++;
    }
    BIT<ll> da(id+5),db(id+5),suma(id+5),sumb(id+5);
    da.add(mp[0],n);
    db.add(mp[0],m);
    ll ans=0;
    for(int i=0;i<q;i++){
          ll t=d[i].t,x=d[i].x,y=d[i].y;
          if(t==1){
                ans-=db.query(0,mp[a[x]])*a[x]+sumb.query(mp[a[x]],id+5);
                da.add(mp[a[x]],-1);
                suma.add(mp[a[x]],-a[x]);
                a[x]=y;
                da.add(mp[a[x]],1);
                suma.add(mp[a[x]],a[x]);
                ans+=db.query(0,mp[a[x]])*a[x]+sumb.query(mp[a[x]],id+5);
          }else{
                ans-=da.query(0,mp[b[x]])*b[x]+suma.query(mp[b[x]],id+5);
                db.add(mp[b[x]],-1);
                sumb.add(mp[b[x]],-b[x]);
                b[x]=y;
                db.add(mp[b[x]],1);
                sumb.add(mp[b[x]],b[x]);
                ans+=da.query(0,mp[b[x]])*b[x]+suma.query(mp[b[x]],id+5);
          }
         cout<<ans<<"\n";
    }
}


#include <bits/stdc++.h>
#include <numeric>
using namespace std ;
#define ll long long int
#define ull unsigned long long int
#define s(a) scanf("%lld",&a)
#define S(a) scanf("%ull",&a)
#define For(i,n) for(i=0;i<n;i++)
#define FOR(i,n) for(i=1;i<=n;i++)
#define pie acos(-1.0)
//#define cin std::cin
//#define cout std::cout
ll test, flag,R ,gcd_,temp,temp1,G,B,a,b, n,i,p,q,sum,S,l,r, m,Y,z,XD,j,j_1,k,k1,res ,min_ ,flag1,max_,XD1,count_,s_size ;
char ch ,ch_1 ;
string s,s3;
//char s[100010] ;
char c2[520][520];
ll pl,x,y,mi,c,d, u,v ,ans,ans1;
char garbage,garbage1 ;
struct vox{
   ll a;
   ll index ;
   ll b ;
} ;
bool comp(vox x, vox y) {
   return x.a < y.a ;
}
bool com(vox x, vox y) {
   return x.index < y.index ;
}
ll lcm(ull a, ull b)
{
    return (a / __gcd(a, b)) * b;
}
int main()
{
          //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

            scanf("%lld",&n) ;
            ll arr[100001] ;
            set<ll>s ;
            sum = 0 ;
            for(i=0;i<n;i++) {
              scanf("%lld",&x) ;
              scanf("%lld",&y) ;
              x--;
              sum = sum + (y*(y+1))/2 - (x*(x+1))/2 ;
            }
            printf("%lld\n",sum);
            return 0;
           }

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

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(void)
{
    int N, M;
    cin >> N >> M;

    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;

        G[a].push_back(b);
    }

    // 頂点 0 をスタートとした探索
    ll ans = 0;
    rep(i, N)
    {
        seen.assign(N, false); // 全頂点を「未訪問」に初期化
        dfs(G, i);
        int tmp = 0;
        rep(i, N)
        {
            if(seen[i]) ++tmp;
        }
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'
#define int long long

signed main()
{

    int a[3];
    mem(a,0);

    int n;
    cin>>n;

    int l=0;

    int sum=0;

    while(n>0)
    {
        int x=n%10;
        n=n/10;
        a[x%3]++;
        sum+=x;
        l++;
    }

    sum=sum%3;
    if(!sum)
    {
        cout<<"0\n";
    }
    else if(sum==1)
    {
        if(a[1]&&l>1) cout<<"1\n";
        else if(a[2]>=2&&l>2) cout<<"2\n";
        else cout<<"-1\n";
    }
    else
    {
        if(a[2]&&l>1) cout<<"1\n";
        else if(a[1]>=2&&l>2) cout<<"2\n";
        else cout<<"-1\n";
    }

    return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 0
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;
ll l;
ll dp[222][15];
ll cal(int i, int c){
	if(i == l)return 0;
	if(c == 11)return 1;
	ll &ret = dp[i][c];
	if(ret!=-1)return ret;
	ret = 0;
	ret  = cal(i + 1, c);
	ret += cal(i + 1, c + 1);
	return ret;
}
void test_case(){
	cin>>l;
	memset(dp, -1, sizeof dp);
	cout<<cal(0, 0)<<endl;
}
int main(){
	int t = 1;
	// scanf("%d", &t);
	while(t--)test_case();
}


#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = a; i < b; i++)
#define rrep(i,a,b) for (int i = a - 1; i >= b; i--)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define pvec(a) for (int i = 0; i < a.size(); i++) cout << a[i] << " "; cout << '\n'
#define wt(a) cout << a << '\n'
using namespace std;
using ll = long long;
template<class T, class U>bool chmin(T& a, U b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U>bool chmax(T& a, U b) {if (a < b) {a = b; return 1;} return 0;}

//-------------------------------------------------------------------------------------//

// ans = mod_pow(a, b, (ll)MOD);
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

int main() {
    ll A, B, C;
    cin >> A >> B >> C;

    ll a = mod_pow(B, C, (ll)4);
    int memo[10][4];
    rep (i, 0, 10) {
        memo[i][0] = i;
        memo[i][1] = memo[i][0] * i % 10;
        memo[i][2] = memo[i][1] * i % 10;
        memo[i][3] = memo[i][2] * i % 10;
    }

    if (a == 0) cout << memo[A % 10][3] << endl;
    else if (a == 1) cout << memo[A % 10][0] << endl;
    else if (a == 2) cout << memo[A % 10][1] << endl;
    else cout << memo[A % 10][2] << endl;
    return 0;
}

/* {{{ */
#include <bits/stdc++.h>
using namespace std;
#ifdef __LOCAL
#include <prettyprint.hpp>
#define debug(a) cerr << "[\033[33mDEBUG\033[m] " << (#a) << ": " << (a) << endl
#else
#define debug(s) cerr << "[\033[33mDEBUG\033[m] local only" << endl
#endif
using ll = long long;
template <class T> using vec = vector<T>;
#define endl "\n"
#define INF (int)1e9
#define LINF (long long)1e12
#define MOD (int)1e9+7
#define _rep(i,_a,_b,a,b,...) for (int i=(a), lim##i=(b); i<lim##i; i++)
#define rep(i, ...) _rep(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define _rrep(i,_a,_b,a,b,...) for (int i=(a), lim##i=(b); i>=lim##i; i--)
#define rrep(i, ...) _rrep(i, __VA_ARGS__, __VA_ARGS__, __VA_ARGS__, 0)
#define each(e, c) for (auto &e: c)
#define all(v) begin(v), end(v)
#define popcount __builtin_popcount
template <class T> bool chmin(T& a, const T& b) { return a>b?a=b,true:false; }
template <class T> bool chmax(T& a, const T& b) { return a<b?a=b,true:false; }
void keep_my_fingers_crossed()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}
/* }}} */

int main()
{
  keep_my_fingers_crossed();
  ll n, w;
  cin >> n >> w;
  vec<pair<ll, ll>> a;
  rep(i, n)
  {
    ll s, t, p;
    cin >> s >> t >> p;
    a.push_back({ s, p });
    a.push_back({ t, -p });
  }
  sort(all(a), [&](auto x, auto y){ return x.first < y.first; });

  map<ll, ll> usage;
  ll total = 0;
  for (auto [t, p]: a)
  {
    total += p;
    usage[t] = total;
  }

  for (auto [key, val]: usage)
  {
    if (val > w)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


/*input

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iomanip>
#include <climits>
#define mod 1000000007

// templates
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define po(x,y)   fixed<<setprecision(y)<<x
#define ss(s) scanf(" %[^\n]%*c", s)
#define ps(s) printf("%s\n",s)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;

void sc(int&n) {int number; scanf("%d", &number); n = number;}
void sc(ll&n) {ll number; scanf("%lld", &number); n = number;}
void _print(ll t) {printf("%lld", t);}
void _print(int t) {printf("%d", t);}
void _print(string t) {cout << t;}
void _print(char t) {printf("%c\n", t);}
void _print(lld t) {cout << t;}
void _print(double t) {cout << t;}
void _print(ull t) {cout << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cout << "{"; _print(p.F); cout << ","; _print(p.S); cout << "}";}
template <class T> void _print(vector <T> v) {cout << "vec->[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T> void _print(set <T> v) {cout << "set->[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T> void _print(multiset <T> v) {cout << "multiset->[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T, class V> void _print(map <T, V> v) {cout << "map->[ "; for (auto i : v) {_print(i); cout << " ";} cout << "]";}

const ll inf = (ll)1e17 + 10;
const int N = (int)1e5 + 10;
vector<array<ll, 3>>adj[N];

void bfs(int n) {

	vector<ll>dist(n + 1, 0);
	for (int i = 0; i <= n; ++i)
	{
		dist[i] = inf;
	}
	set<array<ll, 2>>pq;
	dist[0] = 0;
	pq.insert({0, 0});
	while (!pq.empty()) {

		auto [t, node] = *pq.begin();
		pq.erase(pq.begin());
		for (auto c : adj[node]) {
			ll cost = 0;
			ll sq = 0;
			cost = t + c[1] + (c[2] / (t + 1));
			sq = sqrt(c[2]);
			if (sq * sq != c[2])sq++;
			sq--;
			if (t < sq) {
				cost = min(cost, sq + c[1] + (c[2] / (sq + 1)));
			}
			if (dist[c[0]] > cost) {
				pq.erase({dist[c[0]], c[0]});
				dist[c[0]] = cost;
				pq.insert({dist[c[0]], c[0]});

			}

		}
	}
	if (dist[n - 1] == inf)dist[n - 1] = -1;
	_print(dist[n - 1]);
}
void solve()
{
	int n, m;
	sc(n), sc(m);
	for (int i = 0; i < m; ++i)
	{
		ll u, v, c, d;
		sc(u), sc(v), sc(c), sc(d);
		u--, v--;
		adj[u].push_back({v, c, d});
		adj[v].push_back({u, c, d});
	}
	bfs(n);
}

int main()
{
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	int t = 1;
	// sc(t);
	while (t--) {
		solve();
	}
	return 0;

}

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

int main() {
    string S1, S2, S3;
    cin >> S1 >> S2 >> S3;

    set<char> se;
    vector<int> ch;
    string T = S1 + S2 + S3;
    rep(i, T.size()) {
        if (!se.count(T[i])) ch.push_back(T[i] - 'a');
        se.insert(T[i]);
    }
    if (ch.size() > 10) {
        cout << "UNSOLVABLE" << endl;
        return 0;
    }

    vector<int> alp(26, -1);
    vector<int> num = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    vector<int> R1, R2, R3;
    rep(i, S1.size()) R1.push_back(S1[i] - 'a');
    rep(i, S2.size()) R2.push_back(S2[i] - 'a');
    rep(i, S3.size()) R3.push_back(S3[i] - 'a');

    int l1 = S1.size(), l2 = S2.size(), l3 = S3.size();
    do {
        rep(i, ch.size()) alp[ch[i]] = num[i];
        ll N1 = 0, N2 = 0, N3 = 0;
        if (alp[R1[0]] == 0) continue;
        if (alp[R2[0]] == 0) continue;
        if (alp[R3[0]] == 0) continue;
        rep(i, l1) N1 += alp[R1[l1-i-1]] * pow(10, i);
        rep(i, l2) N2 += alp[R2[l2-i-1]] * pow(10, i);
        rep(i, l3) N3 += alp[R3[l3-i-1]] * pow(10, i);
        if (N1 == 0 || N2 == 0 || N3 == 0) continue;
        if (N1 + N2 == N3) {
            cout << N1 << endl << N2 << endl << N3 << endl;
            return 0;
        }
    } while (next_permutation(all(num)));

    cout << "UNSOLVABLE" << endl;
}


// Cookie197
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<iomanip>
#include<math.h>
using namespace std;
#define no_tle ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define pii pair<ll,ll>
#define mp make_pair
#define si short
#define mod 1000000007
#define endl '\n'
int main(){
    ll n,ans;
    cin>>n;
    ans=n;
    ll b;
    for(b=0;b<66;b++){
        if(pow(2,b)>n) break;
        ll tmp=pow(2,b);
        ans=min(ans,n-(n/tmp)*tmp+b+(n/tmp));
    }
    cout<<ans<<endl;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;
typedef long long ll;
ll pow(ll a)
{
    ll ans = 1;
    while (a--)
    {
        ans *= 2;
    }
    return ans;
}
int main()
{
    ll n; cin >> n;
    ll a, b, c;
    ll l = 60;
    while (pow(l) > n)
    {
        l --;
    }
    ll ans = 1e18 + 5;
    for (ll i = l; i >= 0; i--)
    {
        b = i;
        a = n / pow(b);
        c = n - a * pow(b);
        ans = min(ans, a + b + c);

    }
    //cout << a << ' ' << b << ' ' << c << endl;
    cout << ans << endl;

    return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

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

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define si cout << "First\n";
#define no cout << "Second\n";

void solve(){
	int N; cin >> N;
	map<int,int> cnt;
	forn(i,0,N){
		int x; cin >> x;
		cnt[x]++;
	}
	if(N%2 == 0){
		bool can = false;
		for(auto &x : cnt){
			if(x.se&1)can = true;
		}
		if(can){
			si;
		}
		else{
			no;
		}
	}else{
		bool can = true;
		for(auto &x : cnt){
			if(x.se&1)can = false;
		}
		if(can){
			si;
		}
		else{
			no;
		}
	}

}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T; cin >> T;
	while(T--){
		solve();
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    bool first;
    if (N % 2 == 1) {
	first = false;
    } else {
	sort(A, A+N);
	first = false;
	for (int i=0; i<N; i+=2) {
	    if (A[i] != A[i+1]) first = true;
	}
    }

    puts(first? "First": "Second");
}

int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline long long read() {
 long long x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
struct node{
       long long pos,val;
	   bool operator<(const node &rhs)const{
           if(val==rhs.val)return pos<rhs.pos;
		   return val<rhs.val;
	   }
}a[200005];
int n;
long long num[200005],cnt;
long long  dis[200005][2],tot[200005];
long long dp[200005][2];
const int inf=2147483640;
int main () {
#ifndef ONLINE_JUDGE
	File("e");
#endif
    n=read();
	F(i,1,n)a[i].pos=read(),a[i].val=read(),num[a[i].val]++;
    int lst=1,nxt=1;
	sort(a+1,a+n+1);
	F(i,1,n)dis[i][0]=inf,dis[i][1]=-inf;
//	F(i,1,n)cout<<a[i].pos<<" "<<a[i].val<<endl;
    F(i,1,n){
		dis[a[i].val][0]=min(dis[a[i].val][0],a[i].pos);
		dis[a[i].val][1]=max(dis[a[i].val][1],a[i].pos);
	}
//		cout<<dp[1][0]<<" "<<dp[1][1]<<endl;
//cout<<cnt<<endl;
    int lstl=0,lstr=0,nowl=0,nowr=0;
	num[n+1]=1;
	F(i,1,n+1){
		if(num[i]==0){
           dp[i][0]=dp[i-1][0];
		   dp[i][1]=dp[i-1][1];
		   continue;
		}
		nowl=dis[i][0];
		nowr=dis[i][1];
        dp[i][0]=min(dp[i-1][0]+abs(nowr-lstl),dp[i-1][1]+abs(nowr-lstr))+abs(nowr-nowl);
        dp[i][1]=min(dp[i-1][0]+abs(nowl-lstl),dp[i-1][1]+abs(nowl-lstr))+abs(nowr-nowl);
        lstl=nowl;
		lstr=nowr;
		//		cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<tot[i]<<endl;
	}
	printf("%lld\n",min(dp[n+1][1],dp[n+1][0]));
	return 0;
}

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

int main(void){
    int N;
    vector<int> ColorMin;
    vector<int> ColorMax;
    cin >> N;
    ColorMin.assign(N, 0);
    ColorMax.assign(N, 0);
    for(int i=0; i<N; i++){
        int Xbuf, Cbuf;
        cin >> Xbuf >> Cbuf;
        Cbuf--;
        if(ColorMin[Cbuf]==0){
            ColorMin[Cbuf]=Xbuf;
        }else ColorMin[Cbuf]=min(ColorMin[Cbuf], Xbuf);
        if(ColorMax[Cbuf]==0){
            ColorMax[Cbuf]=Xbuf;
        }else ColorMax[Cbuf]=max(ColorMax[Cbuf], Xbuf);
    }
    long long dpl = 0;
    long long dpr = 0;
    int curl = 0;
    int curr = 0;
    for(int i=0; i<N; i++){
        if(ColorMin[i] == 0)continue;
        long long dplbuf = min(dpl+abs(curl-ColorMax[i]), dpr+abs(curr-ColorMax[i]))+ColorMax[i]-ColorMin[i];
        long long dprbuf = min(dpl+abs(curl-ColorMin[i]), dpr+abs(curr-ColorMin[i]))+ColorMax[i]-ColorMin[i];
        dpl = dplbuf;
        dpr = dprbuf;
        curl = ColorMin[i];
        curr = ColorMax[i];
    }
    cout << min(dpl+abs(curl), dpr+abs(curr)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
	cin>>s;
  	char first, second, third;
  	first = s[0];
  	second = s[1];
    third = s[2];

  	s[0] = second;
  	s[1] = third;
  	s[2] = first;
  	cout << s << "\n";

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

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

	for(int i = 0; i < s.length(); i++){
		if(i % 2 == 0){
			if(isupper(s[i])){
				cout << "No" << endl;
				return 0;
			}
		}
		if(i % 2 == 1){
			if(islower(s[i])){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	printf("Yes\n");

	return 0;

}


#include <bits/stdc++.h>

#define ll             long long
#define sf             scanf
#define pf             printf
#define nl             printf("\n")
#define pb             push_back
#define TEST           int Test;cin>>Test;for(int _t=1;_t<=Test;_t++)

using namespace std;

int main()
{
	int a,b,c,d;
	sf("%d %d %d %d",&a,&b,&c,&d);
	pf("%d\n",(a*d)-(b*c));
	return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e7+10;
int p[N];
const ll MOD=(ll)(1e9)+(ll)(7); //is prime

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << b-c;

}


#include<bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ldb;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int,custom_hash>
#define usl unordered_set<long long,custom_hash>
#define uspii unordered_set<pii,custom_hash>
#define uspll unordered_set<pll,custom_hash>
#define sl set<long long>
#define si set<int>
#define spii set<pii>
#define spll set<pll>
#define umii unordered_map<int,int,custom_hash>
#define umsi unordered_map<string,int,custom_hash>
#define umci unordered_map<char,int,custom_hash>
#define umll unordered_map<long long,long long,custom_hash>
#define mll map<long long,long long>
#define mii map<int,int>
#define vi vector<int>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvi vector<vector<int>>
#define vpii vector<pii>
#define vpll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define fi first
#define sec second
#define pb push_back
#define pob pop_back
#define beg begin
#define en end
#define mp make_pair
#define all(x) x.begin(),x.end()
#define al(arr,n) arr,arr+n
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define MOD2
#define f(i,a,b,c) for(int i=a;i<b;i+=c)
#define frev(i,n,b,c)  for(int i=n-1;i>=b;i-=c)
#define put(x,val) memset(x,val,sizeof(x))
#define inp(arr,n) for(int i=0;i<n;i++){cin>>arr[i];}
const ll inf = 1000000000000000000;
using namespace std;
bool prime[1000005];
ll  fact[1000005];

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

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

ll power(ll x , ll n , ll m=inf){
	if(x==0)return 0;
	if(n==0)return 1;
	ll ans;
	if(n%2==0){
		ll smallAns = power(x,n/2,m);
		ans = (smallAns*smallAns)%m;
	} else {
		ll smallAns = power(x,n-1,m);
		ans = x;
		ans = (ans*smallAns)%m;
	}
	return (ans+m)%m; // for negative values also

}

ll modInverse(ll n,ll p){return power(n, p - 2, p);}

ll nCr(ll n,ll r, ll p=LLONG_MAX){ //FOR USING IT FIRST INITIALIZE FACT ARRAY
    if (n < r)	return 0;
    if (r == 0)	return 1;
    	return (fact[n] * modInverse(fact[r], p) % p* modInverse(fact[n - r], p) % p)% p;
}

void fillFact(){
	fact[0]=1;
	f(i,1,1000005,1){
		fact[i]=(fact[i-1]*i)%MOD;
	}
}

void fillPrime(){
	ll i,j,n = 1000001;
	f(i,0,n,1){
		prime[i] = 1;
	}
	prime[0]=0;
	prime[1]=0;
	for(i=2;i*i<=n;i++){
		if(prime[i]){
			for(j=i*i;j<=n;j+=i){
				prime[j] = 0;
			}
		}
	}
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll kadane(ll arr[],int n){
	ll dp[n];
	dp[0]=arr[0];
	ll maxm=dp[0];
	f(i,1,n,1){
		if(dp[i-1]>0)	dp[i]=arr[i]+dp[i-1];
		else	dp[i]=arr[i];
		maxm=max(maxm,dp[i]);
	}
	return maxm;
}

bool compare(pii p1,pii p2){
	return p1.sec<p2.sec;
}

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

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

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

	int t=1;
	// cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int ans=1.08*n;
		cout<<(ans==206?"so-so":(ans<206?"Yay!":":("))<<endl;
	}

	return 0;
}

#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
	int n,v=0;
	cin>>n;
	string p=to_string(n);
	int l=p.length()-1;
	while(p[l]=='0'){
		p.erase(l,1);
		l--;
	}
	int y=p.length();
	for(int i=0;i<y;i++)
	{
		if(p[i]!=p[y-i-1]) {v++; break;}
	}
	if(v>0) cout<<"No";
	else cout<<"Yes";
}


#include <bits/stdc++.h>

using ll = long long;
const int N(1010);
ll n, f[N];
int pos, fl[N];
std::vector<int> ans;

int main()
{
	std::scanf("%lld", &n), f[1] = 1;
	for (int i = 2; i <= 90; i++) f[i] = f[i - 1] + f[i - 2];
	for (int i = 90; i; i--)
		if (n >= f[i]) n -= f[i], fl[i] = 1, pos = std::max(pos, i);
	for (int i = pos, j = 1; i; i--, j++)
	{
		if (fl[i])
		{
			if (i & 1) ans.push_back(1);
			else ans.push_back(2);
		}
		if (j & 1) ans.push_back(4);
		else ans.push_back(3);
	}
	printf("%lu\n", ans.size());
	for (auto i : ans) printf("%d\n", i);
	return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
//#define ll long long
#define ll int
//#define MOD 1000000007LL
//#define MOD 998244353LL
#define doublecout(a) cout<<setprecision(16)<<a<<endl;
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
//const ll llMAX=9223372036854775807LL;
//const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}

ll h,w,a,b;

int main(){
  ll ans=0;
  cin >> h>>w>>a>>b;
  ll n=h*w,nn=1;
  for(ll i=0;i<n;i++) nn*=3;

  vi data(h*w,-1);// N * M の2次元配列
  for(ll i=0;i<nn;i++){
    ll iii=i;
    ll c1=0,c2=0;
    for(ll j=0;j<n;j++){
      ll t=iii%3;
      iii/=3;
      if (t==0)c1++;
    }
    if (c1!=b) continue;

    iii=i;
    for(ll j=0;j<n;j++){
      ll t=iii%3;
      iii/=3;
      data[j]=t;
    }

    c1=0;

    ll flag=0;
    for(ll j=0;j<h;j++){
      for(ll k=0;k<w;k++){
        ll d=data[j*w+k];
        if (d==0){
            c1++;
            if (c1>b){flag=1;break;}
            continue;
        }
        if (d==1){
          if (k+1==w){flag=1;break;}
          c2++;
          data[j*w+k+1]=3;
          continue;
        }

        if (d==2){
          if (j+1==h){flag=1;break;}
          c2++;
          data[j*w+k+w]=3;
          continue;
        }
      }
      if (flag==1)break;
    }

    if ((c1!=b)|(c2!=a))flag=1;
    if (flag==0)ans++;
  }

  for(ll i=0;i<a;i++){
    ans/=2;
  }

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


#include<bits/stdc++.h>
#define SORT(v) sort(v.rbegin() , v.rend())
#define si(n) scanf( "%d" , &n)
#define sii(n , m) scanf( "%d %d" , &n , &m)
#define sl(n) scanf( "%lld" , &n)
#define sll(n , m) scanf( "%lld %lld" , &n, &m)
#define ss(cad) scanf( "%s" , cad)
#define sz(x) (int)x.size()
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl
#define N_MAX 1000010
#define M 1000000007
#define EPS 1e-9

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vp;

int main(){
	int n;
	si(n);
	int ans = 0;
	for(int i = 0; i < n; i++){
		int val;
		si(val);
		if(val <= 10)
			continue;
		else
			ans += val - 10;
	}
	printf("%d\n", ans);
  return 0;
}

#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h>
#include <functional>
#include <cassert>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> A(N),B(N);
    ll sum = 0;
    for(int i=0; i<N; i++) cin >> A[i],sum += A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    vector<ll> even,odd;
    for(int i=0; i<N; i++){
      if(i%2){
        odd.emplace_back(B[i]-A[i]);
      }else{
        even.emplace_back(B[i]-A[i]);
      }
    }
    sort(odd.rbegin(),odd.rend());
    sort(even.rbegin(),even.rend());
    ll ans = sum;
    for(int i=0; i<N/2; i++){
      sum += odd[i] + even[i];
      chmax(ans,sum);
    }
    cout << ans << "\n";
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cctype>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9

using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    int N, X;
    cin >> N >> X;
    string s;
    cin >> s;

    rep(i, N){
        if(s[i] == 'o') X++;
        else if(s[i] == 'x') if(X>0) X--;
    }
    cout << X << endl;

    return 0;
}

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)
template<class T> struct Fenwick {
    int n;
    T* d;
    Fenwick() : n(0), d(NULL) {}
    Fenwick(int n_) : n(n_) {
	d = new T[n_]();
    }
    Fenwick(const Fenwick &y) : n(y.n) {
	d = new T[n];
	memcpy(d, y.d, sizeof (T) * n);
    }
    ~Fenwick() {
	delete[] d; d = NULL;
	n = 0;
    }
    friend void swap(Fenwick &x, Fenwick &y) {
	swap(x.n, y.n); swap(x.d, y.d);
    }
    Fenwick& operator=(Fenwick y) {
	swap(*this, y);
	return *this;
    }
    inline void add(int i, const T &x) {
	for (; i<n; i|=i+1) d[i] += x;
    }
    inline T sum(int r) const {
	T s = T();
	for (; r; r&=r-1) s += d[r-1];
	return s;
    }
    T sum(int l, int r) const {
	return sum(r) - sum(l);
    }
    int lower_bound(const T &x) const { // sum(ret) < x <= sum(ret+1);
	if (n == 0) return 0;
	int i = 0; T s = T();
	for (int k=1<<__lg(n); k; k>>=1) {
	    if (i+k <= n && s + d[i+k-1] < x) {
		i += k; s += d[i-1];
	    }
	}
	return i;
    }
    int upper_bound(const T &x) const { // sum(ret) <= x < sum(ret+1);
	if (n == 0) return 0;
	int i = 0; T s = T();
	for (int k=1<<__lg(n); k; k>>=1) {
	    if (i+k <= n && !(x < s + d[i+k-1])) {
		i += k; s += d[i-1];
	    }
	}
	return i;
    }
};

int H, W, M;
int R[200011], C[200011];
int idx[200011];
bool use[200011];
bool act[200011];

void MAIN() {
    scanf("%d%d%d", &H, &W, &M);
    REP (i, M) scanf("%d%d", R+i, C+i), R[i]--, C[i]--;

    LL ans = 0;
    if (M == 0) {
	ans = (LL) H * W;
    } else {
	int minR = H;
	int minC = W;
	REP (i, M) {
	    if (R[i] == 0) amin(minC, C[i]);
	    if (C[i] == 0) amin(minR, R[i]);
	}

	ans += (LL)H * W;
	ans -= W - minC;
	ans -= H - minR;

	REP (i, M) idx[i] = i;
	sort(idx, idx + M, [&](int i, int j) {
		return C[i] < C[j];
		});

	for (int i=minR; i<H; i++) use[i] = true;

	REP (i, M) {
	    if (!use[R[idx[i]]]) {
		use[R[idx[i]]] = true;
		act[idx[i]] = true;
	    }
	}

	Fenwick<LL> F(H+11);

	LL bad = 0;
	int p = M-1;
	for (int i=W-1; i>0; i--) {
	    int nxt = H;

	    int q = p;
	    while (q >= 0 && C[idx[q]] == i) {
		q--;
	    }

	    for (int k=p; k>q; k--) {
		int r = R[idx[k]];
		int c = C[idx[k]];
		amin(nxt, r);
	    }

	    if (minC <= i) nxt= 0;
	    F.add(nxt, 1);

	    for (int k=p; k>q; k--) {
		int r = R[idx[k]];
		int c = C[idx[k]];

		// [c, Right[r]);
		if (r != 0 && act[idx[k]]) {
		    bad += F.sum(0, r+1);
		}
	    }

	    p = q;
	}

	for (int i=minR; i<H; i++) {
	    bad += F.sum(0, i+1);
	}

	ans -= bad;
    }
    printf("%lld\n", ans);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#define ll long long int
#define endl '\n'
#define M 998244353
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t=1,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n>>m>>k;
        ll sn = (n *(n+1))/2;
        sn = sn%M;
        ll sm = (m *(m+1))/2;
        sm = sm%M;
        ll sk = (k *(k+1))/2;
        sk = sk%M;
        ll ans = ((sn%M * sm%M)%M * sk%M)%M;
        cout<<ans<<endl;
    }
}

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

int main()
{
  long long a,b,c,h=998244353;
  cin>>a>>b>>c;
  long long d=((a*(a+1))/2)%h;
  long long e=((b*(b+1))/2)%h;
  long long f=((c*(c+1))/2)%h;
  long long ans=(((d*e)%h)*f)%h;
  cout<<ans;
}


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

#define ll long long
#define ar array

ll n;

void solve() {
    cin >> n;
    set<ll> a;
    for(ll i=1; i*i<=n; ++i) {
        if(n%i==0)
            a.insert(i), a.insert(n/i);
    }
    for(ll c : a)
        cout << c << "\n";
}

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

    solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;i++)
int main() {
    long long int N;
    cin >>N;
    long long int a=pow(N,0.5);
    int A=0;
    rep(i,a)if(N%(i+1)==0){
        if((i+1)*(i+1)!=N)A+=2;
        else A++;
    }
    long long int ans[A]={};
    int j = 0;
    rep(i,a)if(N%(i+1)==0){
        ans[j]=i+1;
        ans[A-j-1]=N/(i+1);
        j++;
    }
    rep(i,A)cout<<ans[i]<<endl;
}


#include <bits/stdc++.h>

#define fo(i, x, y) for (int i = x; i <= (y); ++i)
#define fd(i, x, y) for (int i = x; i >= (y); --i)
using namespace std;

typedef long long ll;

const int maxn = 50 + 5;

int n;
ll X;
ll a[maxn], b[maxn], g[maxn];
ll f[maxn][2];

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && ch != '-');
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = res * 10 + ch - '0', ch = getchar();
	return res * p;
}

int main()
{
	n = getint(); scanf("%lld", &X);
	fo(i, 1, n) scanf("%lld", &a[i]);
	fo(i, 1, n - 1) b[i] = a[i + 1] / a[i];
	b[n] = (X - 1) / a[n] + 1 + 10;
	fd(i, n, 1) g[i] = X / a[i], X %= a[i];
	f[0][0] = 1;
	fo(i, 1, n)
	{
		// k = 0
		f[i][0] += f[i - 1][0];
		if (g[i] < b[i] - 1) f[i][0] += f[i - 1][1];
		else f[i][1] += f[i - 1][1];
		//k > 0
		if (g[i] < b[i] - 1) f[i][1] += f[i - 1][1];
		if (g[i] > 0) f[i][1] += f[i - 1][0];
	}
	printf("%lld\n", f[n][0]);
	return 0;
}

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
void solve()
{
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int mp[500]={0};
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=-200;j<=200;j++)
		{
			ans+=mp[j+200]*((a[i]-j)*(a[i]-j));
		}
		mp[a[i]+200]++;
	}
	cout<<ans<<endl;
}
int32_t main()
{
	IOS;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <bitset>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

int main() {
  ll n,k,sum=0,summ=0;
  cin >> n >> k;
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=k;j++){
      sum+=i*100;
      summ+=j;
    }
  }
  cout << sum+summ << endl;
}

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

long long ll_pow(long long a, long long n){
    long long ans = 1;
    for(long long i=0; i< n; i++){
        ans *= a;
    }
    return ans;
}

int main(){
	int a,b;
	cin >>a>>b;
  	if(a+b>=15&&b>=8) cout<<'1'<<endl;
  else if(a+b>=10&&b>=3) cout<<'2'<<endl;
  else if(a+b>=3) cout<<'3'<<endl;
  else cout<<'4'<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N>
int SIZE(const T (&t)[N])
{
    return N;
}
template<typename T>
int SIZE(const T &t)
{
    return t.size();
}
string to_string(const string s, int x1=0, int x2=1e9)
{
    return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"';
}
string to_string(const char* s)
{
    return to_string((string) s);
}
string to_string(const bool b)
{
    return (b ? "true" : "false");
}
string to_string(const char c)
{
    return string({c});
}
template<size_t N>
string to_string(const bitset<N> &b, int x1=0, int x2=1e9)
{
    string t = "";
    for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__)
    {
        t += b[__iii__] + '0';
    }
    return '"' + t + '"';
}
template <typename A, typename... C>
string to_string(const A (&v), int x1=0, int x2=1e9, C... coords);
int l_v_l_v_l = 0, t_a_b_s = 0;
template <typename A, typename B>
string to_string(const pair<A, B> &p)
{
    l_v_l_v_l++;
    string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--;
    return res;
}
template <typename A, typename... C>
string to_string(const A (&v), int x1, int x2, C... coords)
{
    int rnk = rank<A>::value; string tab(t_a_b_s, ' ');
    string res = "";
    bool first = true;
    if(l_v_l_v_l == 0)
        res += n_l;
   res += tab + "[";
   x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v));
   auto l = begin(v);
   advance(l, x1);
   auto r = l;
   advance(r, (x2-x1) + (x2 < SIZE(v)));
   for (auto e = l; e != r; e = next(e))
   {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        l_v_l_v_l++;
        if(e != l)
        {
            if(rnk > 1)
            {
                 res += n_l;
                 t_a_b_s = l_v_l_v_l;
            };
       }
       else{
        t_a_b_s = 0;
      }
      res += to_string(*e, coords...);
      l_v_l_v_l--;
    }
    res += "]";
    if(l_v_l_v_l == 0)
        res += n_l;
    return res;
}
void dbgm(){;}
template<typename Heads, typename... Tails>
void dbgm(Heads H, Tails... T)
{
    cout << to_string(H) << " | "; dbgm(T...);
}
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void solve() {
        ll n;
        cin>>n;
        unordered_set<string>s;
        vector<string>vec;
        for(ll i=0;i<n;i++)
        {
            string t;
            cin>>t;
            if(t[0]=='!')
            {
                string sub=t.substr(1);
                s.insert(sub);
                continue;
           }
           vec.push_back(t);
       }
       //dbg(s);
       for(auto x:vec)
       {
            if(s.find(x)!=s.end()){
                cout<<x<<"\n";
                return;
           }
       }
       cout<<"satisfiable"<<"\n";
}
int main()
{

    ll t=1;
    //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

#include<bits/stdc++.h>

#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cerr << #x << ':' << x << endl;
#define  rep(i,n)          for(long long i = 0; i <  n ; i++)
#define  reps(i,n)         for(long long i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
const ll MOD = 1e9+7;
bool cmp(int X, int Y) {return X > Y;}

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}

const int N = 100005;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};

ll vis[N];

int main(){
	ll n;cin>>n;
	ll a[n];
	ll gd = 0;
	rep(i,n){
		cin>>a[i];
		gd  = gcd(gd,a[i]);
	}
cout<<gd;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

map<int, int > prime_factor(int n) {
  map<int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
  int n;
  cin >> n;
  map<int, int> cnt;
  int ans=0;
  REP(i,n){
    int a;
    cin >> a;
    map<int,int> mp = prime_factor(a);
    for(auto v: mp){
      cnt[v.first]++;
    }
  }
  int mx=0;
  for(auto v: cnt){
    if(mx < v.second){
      ans = v.first;
      mx = v.second;
    }

  }
  cout << ans << endl;
}

#include <bits/stdc++.h>
#define SIZE 1005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int n;
	scanf("%d",&n);
	int t=1;
	while(t<n) t<<=1;
	for(int i=0;i<n;i++)
	{
		int a=i*2;
		int b=i*2+1;
		for(int j=11;j>=0;j--)
		{
			if(a>=n&&(a>>j&1)) a^=1<<j;
			if(b>=n&&(b>>j&1)) b^=1<<j;
		}
		printf("%d %d\n",a+1,b+1);
	}
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int mx=2000;
const int mod= 1e9+7;
const ll inf=1e12+4;

int arr[6]={4,8,15,16,23,42};
int cnt[100];
int a[mx];int b[mx];int aa[mx];int bb[mx];
int k;int n,m;
int ok[mx];
int ans=0;

void solve(int i){
if(i==k){
    int l=0;
    for(int j=0;j<m;j++){
        if(ok[a[j]]&&ok[b[j]]){l++;}
    }ans=max(ans,l);
    return;
}
ok[aa[i]]++;
solve(i+1);
ok[aa[i]]--;
ok[bb[i]]++;
solve(i+1);ok[bb[i]]--;
return ;
}
int main() {

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

cin>>n>>m;

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

    }cin>>k;
    for(int i=0;i<k;i++){
   cin>>aa[i]>>bb[i];

    }
    solve(0);cout<<ans;

}

}

#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o); ++i)
#define REP(i,a,b)for(ll i=(ll)(a);(i)<(ll)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

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

int main() {
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> b(m);
    rep(j, m) {
        cin >> b[j].first >> b[j].second;
        b[j].first--; b[j].second--;
    }

    ll k; cin >> k;
    vector<ll> c(k), d(k);
    rep(i, k) {
        cin >> c[i] >> d[i];
        c[i]--; d[i]--;
    }
    ll ans = 0;
    for (ll bit = 0; bit < (1 << k); bit++)
    {
        ll cnt = 0;
        vector<bool> selected(n);
        rep(j, k) {
            if (bit & (1 << j)) selected[d[j]] = true;
            else selected[c[j]] = true;
        }
        // rep(j, n) {
        //     cout << selected[j] << endl;
        // }
        rep(i, m) {
            if (selected[b[i].first] && selected[b[i].second]) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 +13;

long long A[N], L[N], R[N];

int n;
double x;

int main(){

    cin >> n;

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

    R[1] = 0;
    for (int i = 2; i<= n; i++){

        if (A[i-1] == A[i]){
            R[i] = R[i-1];
            continue;
        }

        if (A[i] > A[i-1]){
            R[i] = i-1;
            continue;
        }

        int tmp = A[i-1];
        int idx = i - 1;
        while (tmp >= A[i])
        {
            idx = R[idx];
            tmp = A[idx];

        }
        R[i] = idx;
    }

    L[n] = n+1;

    for (int i = n-1; i>= 1; i--){

        //cout << "i " << i << endl;
        if (A[i] == A[i +1]){
            L[i] = L[i+1];
            continue;
        }

        if (A[i] > A[i+1]){
            L[i] = i+1;
            continue;
        }

        int tmp = A[i+1];

        //cout << "tmp "<< tmp << endl;

        int idx = i + 1;
        while (tmp >= A[i])
        {
            idx = L[idx];
            tmp = A[idx];

            //cout <<"tmp "<< tmp << "idx " << idx << endl;
        }

        L[i] = idx;
    }

    long long maximo = 0;
    for (int i = 1; i<= n; i++){
        int l = L[i];
        int r = R[i];

        //cout << "l "<< l << " r "<< r << endl;
        long long suma = (l - r - 1)*A[i];

        if (suma > maximo ){
            maximo = suma;
        }

    }

    cout << maximo;

/*
    cout << "R ";
    for (int i = 1; i<= n; i++){
        cout << R[i] << " ";
    }
    cout << "L ";
    for (int i = 1; i<= n; i++){
        cout << L[i] << " ";
    }
*/

    return 0;
}

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
  long long int n=0,x=0,man=0,che=0;
	long double euc=0.0;
  cin >> n;
  for (int i=0;i<n;i++){
    cin >> x;
    if(x<0)
			x *= -1;
    man += x;
    euc += x*x;
    if(x>che) che = x;
  }
  euc = sqrt(euc);
  cout << man << endl;
  cout << fixed << setprecision(15) << euc << endl;
  cout << che << endl;
  return 0;
}


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

#define UpdMin(x, y) x = min(x, y)

const int MAX_N = 200010;
bool Flag[MAX_N];
int N;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		int x;
		cin >> x;
		Flag[x] = true;
		while (Flag[ans])
			ans++;
		cout << ans << endl;
	}
	return 0;
}

#include <bits/stdc++.h>

template <typename T>
T next() {
    T temp; std::cin >> temp;
    return temp;
}

template <>
int next() {
    int temp; scanf("%d", &temp);
    return temp;
}
template <>
long long next() {
    long long temp; scanf("%lld", &temp);
    return temp;
}
template <>
double next() {
    double temp; scanf("%lf", &temp);
    return temp;
}
template <>
float next() {
    float temp; scanf("%f", &temp);
    return temp;
}

template <typename T1, typename T2>
std::pair<T1, T2> next() {
    std::pair<T1, T2> temp;
    temp.first = next<T1>();
    temp.second = next<T2>();
    return temp;
}

template <typename T>
std::vector<T> next(int n) {
    std::vector<T> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T>();
    return temp;
}

template <typename T1, typename T2>
std::vector<std::pair<T1, T2>> next(int n) {
    std::vector<std::pair<T1, T2>> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T1, T2>();
    return temp;
}

template <typename T>
void print(const T &x, char endc = '\n') {
    std::cout << x << endc;
    return;
}
void print(const int &x, char endc = '\n') {
    printf("%d%c", x, endc);
    return;
}
void print(const long long &x, char endc = '\n') {
    printf("%lld%c", x, endc);
    return;
}
void print(const size_t &x, char endc = '\n') {
    printf("%zu%c", x, endc);
    return;
}
void print(const float &x, char endc = '\n') {
    printf("%f%c", x, endc);
    return;
}
void print(const double &x, char endc = '\n') {
    printf("%lf%c", x, endc);
    return;
}

template<typename T1, typename T2>
void print(const std::pair<T1, T2> &p, char sepc = ' ', char endc = '\n') {
    print(p.first, sepc);
    print(p.second, endc);
    return;
}

template<typename T>
void print(const std::vector<T> &v, char sepc = ' ', char endc = '\n') {
    for(const T &e : v) print(e, sepc);
    printf("%c", endc);
    return;
}

template<typename T>
class SparseGraph {
    struct Node {
        std::vector<std::pair<int, T>> adj;
        T value;
    };

private:
    std::vector<Node> nodes;
    int nodeSize;
    int edgeSize = 0;

public:
    SparseGraph(int n) {
        nodes.resize(n);
        nodeSize = n;
    }

    SparseGraph(const std::vector<T> &values) {
        int n = values.size();
        nodes.resize(n);
        nodeSize = n;
        for(int i = 0; i < n; i++)
            nodes[i].value = values[i];
    }

    void addEdge(int u, int v, const T &edgeVal = 0) {
        nodes[u].adj.push_back({v, edgeVal});
        edgeSize++;
    }

    const int &getNodeSize() const {
        return nodeSize;
    }

    const int &getEdgeSize() const {
        return edgeSize;
    }

    const T &valueOf(int here) const {
        return nodes[here].value;
    }

    const std::vector<std::pair<int, T>> &adjOf(int here) const {
        return nodes[here].adj;
    }
};

using namespace std;

void eachTC() {
    int A = next<int>(), B = next<int>();
    int solid = A+B, fat = B;

    int res;
    if(solid >= 15 && fat >= 8)
        res = 1;
    else if(solid >= 10  && fat >= 3)
        res = 2;
    else if(solid >= 3)
        res = 3;
    else
        res = 4;

    print(res);
}

int main() {
    constexpr bool multipleTC = false;
    int T = multipleTC ? next<int>() : 1;
    while(T--) eachTC();

    return 0;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> X(N), Y(N), Z(N);
    rep(i,N){
        cin >> X[i] >> Y[i] >> Z[i];
    }
    vector<vector<ll>> dp((1LL << N), vector<ll>(N, 1e18));
    dp[1][1] = 0;
    dp[0][1] = 0;
    dp[0][0] = 0;
    dp[1][0] = 0;
    rep(bit, (1LL << N)){
        rep(i,N){
            rep(j,N){
                cmin(dp.at(bit | (1LL << j)).at(j), dp.at(bit | (1LL << i)).at(i) + abs(X[j]-X[i]) + abs(Y[j]-Y[i]) + max(0LL, Z[j] - Z[i]));
            }
        }
    }
    cout << dp[(1LL << N) - 1][0] << endl;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
#define d(x) cerr << #x << " = " << x << endl
const int maxn = 25;
const ll inf = 0x3f3f3f3f;
int n;
ll x[maxn], y[maxn], z[maxn];
ll dis[maxn][maxn];
ll f[maxn][1 << 17];

ll llabs(ll x) {
	if (x < 0) return -x;
	return x;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld%lld%lld", &x[i], &y[i], &z[i]);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			dis[i][j] = llabs(x[i] - x[j]) + llabs(y[i] - y[j]) + max(0LL, z[j] - z[i]);
			//d(i); d(j); d(dis[i][j]); d(llabs(x[i] - x[j])); d(x[i]); d(x[j]);
		}
	}
	//system("pause");
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
				//d(dis[i][j]); d(i); d(j);
			}
		}
	}
	memset(f, inf, sizeof(f)); f[1][0] = 0;
	for (int S = 0; S < (1 << n); S++) {
		for (int u = 1; u <= n; u++) {
			for (int v = 1; v <= n; v++) {
				if (S >> (v - 1) & 1) {
					f[v][S] = min(f[v][S], f[u][S & ~(1 << (v - 1))] + dis[u][v]);
				}
			}
		}
	}
	ll ans = f[1][(1 << n) - 1];
	for (int i = 2; i <= n; i++) ans = min(ans, f[i][(1 << n) - 1] + dis[i][1]);
	printf("%lld\n", ans);
    return 0;
}


#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 2005

ll H,W;
ll tate[SIZE][SIZE],yoko[SIZE][SIZE],naname[SIZE][SIZE],dp[SIZE][SIZE];
char base_map[SIZE][SIZE];
char work[SIZE][SIZE];

int main(){

	scanf("%lld %lld",&H,&W);

	for(int row = 0; row < H; row++){
		scanf("%s",base_map[row]);
		for(int col = 0; col < W; col++){

			work[row+1][col+1] = base_map[row][col];
		}
	}

	for(ll row = 0; row <= H; row++){
		for(ll col = 0; col <= W; col++){

			tate[row][col] = 0;
			yoko[row][col] = 0;
			naname[row][col] = 0;
			dp[row][col] = 0;
		}
	}

	tate[1][1] = 1;
	yoko[1][1] = 1;
	naname[1][1] = 1;
	dp[1][1] = 1;

	//1行目
	for(ll col = 2; col <= W; col++){
		if(work[1][col] == '#')continue;

		dp[1][col] = yoko[1][col-1];
		yoko[1][col] = (dp[1][col]+yoko[1][col-1])%MOD;
		tate[1][col] = dp[1][col];
		naname[1][col] = dp[1][col];
	}

	for(ll row = 2; row <= H; row++){
		for(ll col = 1; col <= W; col++){
			if(work[row][col] == '#')continue;

			dp[row][col] = (yoko[row][col-1]+tate[row-1][col]+naname[row-1][col-1])%MOD;
			yoko[row][col] = (dp[row][col]+yoko[row][col-1])%MOD;
			tate[row][col] = (dp[row][col]+tate[row-1][col])%MOD;
			naname[row][col] = (dp[row][col]+naname[row-1][col-1])%MOD;
		}
	}

	printf("%lld\n",dp[H][W]);

	return 0;
}

#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vv<bool> graph = vvec(N, N, false);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a][b] = true;
    }

    vector<bool> is_perfect(1 << N, true);
    rep(s, 1 << N) {
        rep(i, N - 1) rep(j, i + 1, N) {
            if ((s >> i & 1) == 0 || (s >> j & 1) == 0) continue;
            if (!graph[i][j]) is_perfect[s] = false;
        }
    }

    vector<int> dp(1 << N, INF);
    dp[0] = 0;
    rep(s, 1, 1 << N) {
        if (is_perfect[s]) {
            dp[s] = 1;
            continue;
        }
        for (int t = s; t > 0; --t) {
            t &= s;
            dp[s] = min(dp[s], dp[t] + dp[s ^ t]);
        }
    }

    write(dp[(1 << N) - 1]);
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 eng(seed);

ll random2(){
    return (1ll << 31ll)*eng()+eng();
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 200001;

ll TWO[MAXN] = {0};
ll FIB[MAXN] = {0};

char AB[2][2];

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

    //freopen("fhc.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    cin >> n;
    rep(c1,0,2){
        rep(c2,0,2){
            char ch;
            cin >> ch;
            AB[c1][c2] = ch;
        }
    }
    ll t = 1;
    rep(c1,0,MAXN){
        TWO[c1] = t;
        t *= 2;
        t %= big;
        if(c1 == 0)FIB[c1] = 0;
        if(c1 == 1)FIB[c1] = 1;
        if(c1 > 1)FIB[c1] = (FIB[c1-1]+FIB[c1-2])%big;
    }

    if(n < 4){
        cout << "1\n";
        return 0;
    }

    if((AB[0][1] == 'A' && AB[0][0] == 'A') || (AB[0][1] == 'B' && AB[1][1] == 'B')){
        cout << "1\n";
        return 0;
    }
    if(AB[0][1] != AB[1][0]){
        cout << TWO[n-3] << "\n";
        return 0;
    }
    cout << FIB[n-1] << "\n";

    return 0;
}

#include <bits/stdc++.h>

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 4e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 1e9 + 7, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

int n; char s[4][10], AA, AB, BA, BB;
ll f[kN];

ll QPow(ll a, ll b) {
	ll ret = 1, bas = a;
	for(; b; b >>= 1, bas = bas * bas % kMod) if(b & 1) ret = ret * bas % kMod;
	return ret;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	int T = 1; //rd(T);
	while(T--) {
		rd(n);
		for(int i = 0; i < 4; ++i) scanf("%s", s[i]);
		AA = s[0][0];
		AB = s[1][0];
		BA = s[2][0];
		BB = s[3][0];
		if(n == 2 || AB == 'A' && AA == 'A' || AB == 'B' && BB == 'B') {
			printf("1\n");
		} else if(AB == 'A' && BA == 'B' || AB == 'B' && BA == 'A') {
			printf("%lld\n", QPow(2, n - 3));
		} else {
			//printf("?");
			f[0] = 1; f[1] = 2;
			for(int i = 2; i <= n; ++i) f[i] = (f[i - 1] + f[i - 2]) % kMod;
			printf("%lld\n", (f[n - 3] + kMod) % kMod);
		}
	} return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);cerr<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T> void verr(const set<T> &st) { repa(a, st) cerr << a << " "; cerr << endl; }
template <class S, class T> void verr(const map<S, T> &mp) { repa(a, mp) cerr << "{" << a.first << ", " << a.second << "} "; cerr << endl; }
template <class S, class T, class N> void verr(const vector<pair<S,T>>& a, const N& n) { rep(i, n) cerr << "{" << a[i].first << ", " << a[i].second << "} "; cerr << endl; }
template <class T, class N> void verr(const vector<T>& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << endl; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << endl; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

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

    vvc<ll> acc(N + 1, vl(N + 1));
    rep(i, N) {
        repe(j, 1, N + 1){
            acc[i + 1][j] = (acc[i][j] + A[i]) % j;
        }

    }

    vvc<ll> dp(N + 1, vl(N + 1));
    vvc<vl> R(N + 1, vvc<ll>(N + 1));

    dp[0][0] = 1;

    vvc<ll> memo(N + 1, vl(N + 1));

    rep(i, N) {
        repe(j, 1, N + 1) {
            if (A[i] % j == 0) {
                (dp[i + 1][j] += dp[i][j] + dp[i][j - 1]) %= MOD;
            } else {
                // repa(id, R[j][acc[i + 1][j]]) {
                //     (dp[i + 1][j] += dp[id][j - 1]) %= MOD;
                // }
                (dp[i + 1][j] += memo[j][acc[i + 1][j]]) %= MOD;
            }
            // R[j][acc[i + 1][j]].eb(i + 1);
            (memo[j][acc[i + 1][j]] += dp[i + 1][j - 1]) %= MOD;
        }
    }

    // rep(i, N + 1)  verr(dp[i], N + 1);
    cout << accumulate(all(dp[N]), 0ll) % MOD << endl;
}

#include<iostream>
#include<vector>
using namespace std;
using ll=long long;
const ll MOD=1000000007;

int main(){
  int n;cin>>n;
  vector<ll>sum(n+1,0);
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    sum.at(i+1)=sum.at(i)+a;
  }

  vector<vector<int>>idx(n+1,vector<int>(n+1,-1));
  vector<vector<int>>pre(n+1,vector<int>(n+1,-1));
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      idx.at(i).at(j)=pre.at(j).at(sum.at(i)%j);
      pre.at(j).at(sum.at(i)%j)=i;
    }
  }

  vector<vector<ll>>dp(n+1,vector<ll>(n+1,0));
  for(int i=1;i<=n;i++)dp.at(i).at(1)=1;
  ll ans=0;
  for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j++){
      if(idx.at(j).at(i)!=-1){
	int x=idx.at(j).at(i);
	dp.at(j).at(i)=dp.at(x).at(i)+dp.at(x).at(i-1);
        dp.at(j).at(i)%=MOD;
      }
    }
    ans+=dp.at(n).at(i);
    ans%=MOD;
  }
  cout<<ans<<endl;
}


#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))
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }

template<class T> void DBG(T&& x) { cerr << x << " "; }
template<class T, class...Args> void DBG(T&& x, Args&&... args) { DBG(x); DBG(args...); }
#define DBG(...) { cerr << "[" << #__VA_ARGS__ << "]: "; DBG(__VA_ARGS__); cerr << endl; }
template<class num> inline void rd(num& x) { cin >> x; }
template <class Ty, class... Args> inline void rd(Ty& x, Args&... args) { rd(x); rd(args...); }
template<class num> inline void print(num&& x) { cout << x; }
template <class Ty, class... Args> inline void print(Ty&& x, Args&&... args) { print(x); print(' '); print(args...); }
#define print(...) print(__VA_ARGS__), print('\n')

inline void run_test(int test_number) {
	int n, m; rd(n, m);
	vector<string> a(n);
	for (int i = 0; i < n; i++) rd(a[i]);

	int ans = 0;

	auto has = [&a](int i, int j) { return a[i][j] == '#'; };
	for (int i = 1; i + 1 < n; i++) {
		for (int j = 1; j + 1 < m; j++) {
			if (a[i][j] == '#') {

				ans += !has(i-1, j) && !has(i, j-1);
				ans += !has(i+1, j) && !has(i, j-1);
				ans += !has(i+1, j) && !has(i, j+1);
				ans += !has(i-1, j) && !has(i, j+1);
				ans += has(i-1, j) && has(i, j-1) && !has(i-1, j-1);
				ans += has(i+1, j) && has(i, j-1) && !has(i+1, j-1);
				ans += has(i+1, j) && has(i, j+1) && !has(i+1, j+1);
				ans += has(i-1, j) && has(i, j+1) && !has(i-1, j+1);
			}
		}
	}

	print(ans);
}

int main() {

//#ifndef LOCAL_PC
//	freopen("FILE.in", "r", stdin);
//#endif

	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n_tests = 1;
	for (int i = 1; i <= n_tests; i++) run_test(i);
}

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

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

    vector<string> S;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        S.push_back(s);
    }

    int ans = 0;
    for (int h = 0; h < H  - 1; h++) {
        for (int w = 0; w < W - 1; w++) {
            int count = 0;
            for (int hp = 0; hp <=1; hp++) {
                for (int wp=0; wp <=1; wp++) {
                    if (S[h + hp][w + wp] == '#') count++;
                }
            }
            if (count == 1 || count == 3) {
                ans ++;
            }
        }

    }

    cout << ans << endl;

}

/*
5 5
.....
..#..
.###.
..#..
.....

*/

/*
5 6
......
..#...
.####.
..#...
......

*/


#include <bits/stdc++.h>
#define fi first
#define se second
#define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define IT iterator
#define V vector
#define TP template <class o>
#define TPP template <typename t1, typename t2>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = b; i >= a; i--)
#define FOR(i,n) rep(i,1,n)
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;
typedef unsigned ui;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int N = 110, size = 1 << 20, mod = 998244353, inf = 2e9;
const ll INF = 1e15;

// char buf[size],*p1=buf,*p2=buf;
TP void qr(o& x) {
    char c = gc;
    x = 0;
    int f = 1;
    while (!isdigit(c)) {
        if (c == '-')
            f = -1;
        c = gc;
    }
    while (isdigit(c))
        x = x * 10 + c - '0', c = gc;
    x *= f;
}
TP void qw(o x) {
    if (x / 10)
        qw(x / 10);
    putchar(x % 10 + '0');
}
TP void pr1(o x) {
    if (x < 0)
        x = -x, putchar('-');
    qw(x);
    putchar(' ');
}
TP void pr2(o x) {
    if (x < 0)
        x = -x, putchar('-');
    qw(x);
    putchar('\n');
}

// math
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll power(ll a, ll b = mod - 2, ll p = mod) {
    ll c = 1;
    while (b) {
        if (b & 1)
            c = c * a % p;
        b /= 2;
        a = a * a % p;
    }
    return c;
}

TP void cmax(o& x, o y) {
    if (x < y)
        x = y;
}
TP void cmin(o& x, o y) {
    if (x > y)
        x = y;
}
TPP void ad(t1& x, t2 y) {
    x += y;
    if (x >= mod)
        x -= mod;
}
TPP void dl(t1& x, t2 y) {
    x -= y;
    if (x < 0)
        x += mod;
}

template<typename T>
struct BIT {
	T* c; int n; // require you to define 0 as the initial value !!
	BIT(int _n):n(_n){c=new T[n];c--; FOR(i,n) c[i]=T(0); }
	void add(int x,T y) { for( ;x<=n;x += x&-x) c[x]=c[x]+y; }
	T sum(int x) {T y=T(0); for( ;x;x &= x-1) y=y+c[x]; return y;}
};

// dbinom
ll jc[N], inv[N];
void jc_init(int n) {
    jc[0] = 1;
    for (int i = 1; i <= n; i++)
        jc[i] = jc[i - 1] * i % mod;
    inv[n] = power(jc[n]);
    for (int i = n; i; i--)
        inv[i - 1] = inv[i] * i % mod;
}
ll C(int x, int y) {
    if (x < y || y < 0)
        return 0;
    return jc[x] * inv[y] % mod * inv[x - y] % mod;
}

int n,k,bin[N]; //左端点
char s[N],win[N][N];

char f(char a,char b) {
	if(a == b) return a;
	if(a == 'R') {
		if(b == 'S') return a;
		return b;
	}
	if(a == 'S') {
		if(b == 'R') return b;
		return a;
	}
	if(a == 'P') {
		if(b == 'S') return b;
		return a;
	}
	return 0;
}

void solve() {
	qr(n);qr(k);
	scanf("%s",s+1); bin[0]=1;
	FOR(i,n) win[0][i]=s[i];
	FOR(j,k) {
		bin[j]=bin[j-1]*2%n;
		FOR(i,n) win[j][i]=f(win[j-1][i],win[j-1][(i+bin[j-1]-1)%n+1]);
	}
	putchar(win[k][1]);
}

int main() {
    int T = 1;
//    qr(T);
    while (T--)
        solve();
    return 0;
}

// atcoder/arc121/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    n *= 2;
    vec<pair<lli, char>> v(n);
    cin >> v;

    vec<lli> r, g, b;
    each (i, v) {
      if (i.second == 'R') r.push_back(i.first);
      if (i.second == 'G') g.push_back(i.first);
      if (i.second == 'B') b.push_back(i.first);
    }
    sort(r.begin(), r.end());
    sort(g.begin(), g.end());
    sort(b.begin(), b.end());

    lli mn = 1LL << 60;

    if (r.size() % 2 == 0 && g.size() % 2 == 0 && b.size() % 2 == 0) {
      mn = 0;
    }
    if (0) ;
    else if (r.size() % 2 == 0) ;
    else if (g.size() % 2 == 0) swap(r, g);
    else if (b.size() % 2 == 0) swap(r, b);

    each (i, g) {
      auto itr = lower_bound(b.begin(), b.end(), i);
      if (itr != b.end()) setmin(mn, abs(i - *itr));
      if (itr != b.begin()) {
        --itr;
        setmin(mn, abs(i - *itr));
      }
    }

    lli x = 1LL << 60;
    lli y = 1LL << 60;
    each (i, r) {
      auto itr = lower_bound(b.begin(), b.end(), i);
      if (itr != b.end()) setmin(x, abs(i - *itr));
      if (itr != b.begin()) {
        --itr;
        setmin(x, abs(i - *itr));
      }
    }
    each (i, r) {
      auto itr = lower_bound(g.begin(), g.end(), i);
      if (itr != g.end()) setmin(y, abs(i - *itr));
      if (itr != g.begin()) {
        --itr;
        setmin(y, abs(i - *itr));
      }
    }
    setmin(mn, x + y);
    cout << mn << endl;
  }

  return 0;
}


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

int main(){
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    int x=0;
    int y=0;
    int z=0;

    int n=0;
    int m=0;
    int i,j,k;
    int te=0;
    int A[101] ={0};
    int B[101] = {0};
    int C[101] = {0};
    int D[101] = {0};

    int AA[101][101];
    int BB[3][10];
    int CC[3][10];
    int DD[3][10];

    char op;
    char OP[100];
    long sum=0;
    double f1=0;
    double f2=0;

    double dx;
    double dy;
    double da;
    double db;
    double dt=0;
    double dc = 0;

    //cin >> x >>y >>z;
    //cin >> a;
    //cin >> a >> b;
    //cin >> a >> b >> c;
    //cin >> a>> b >> x >> y >> z;

    cin >> n >> dx >> dy;
    for(i=0;i<n;i++){
        cin >> da >> db;
        if(dy/dx >db/da ){
            continue;
        }
        else{
            dt = db-((dy-db)/(dx-da))*da;
                if(dt>dc){
                    dc=dt;
            }
        }
    }
    printf("%.10lf",dc);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define r(i,a,b) for(int i=a; i<(b); i++)
using ll = long long;
#define tc(a,b) cout << a << ": " << b << endl
#define l() cout << endl

/*--------------------------------
=== 数値の絶対値最大 ===
https://docs.microsoft.com/ja-jp/cpp/c-language/cpp-integer-limits?view=msvc-160

符号なしなら先頭にUが付き、0以上の範囲になり+方向に2倍の数値になる。
-type-	name		aboutvalue	binary
short	SHRT_MAX	3* 10^  4	2^15
int		INT_MAX		2* 10^  9	2^31
ll		LLONG_MAX	9* 10^ 18	2^63

=== 表示の桁詰め ===
右詰	は right << setw(桁数) を出力内部に記載する
0埋め	は上の頭部に setfill('0') << を付け足す
[注意] 0埋めを解除するために cout << setfill(' '); をする必要がある。

--------------------------------*/

int main(){
  double n,d,h;
  cin >> n >> d >> h;

  double ans = 0.0;

  r(i, 0,n){
    double di, hi;  cin >> di >> hi;

    double x = d * (h-hi) / (d-di);

    ans = max(ans, h-x);
  }

  cout << ans << endl;
}


#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int n;
PP p[MAXN];
vector<pair<int,P> > v;
int calc_dist(int x,int y)
{
    return max(max(p[x].F.F-p[y].F.F,p[y].F.F-p[x].F.F),max(p[x].F.S-p[y].F.S,p[y].F.S-p[x].F.S));
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&p[i].F.F,&p[i].F.S);
        p[i].S=i;
    }
    sort(p,p+n);
    v.push_back(make_pair(calc_dist(0,n-1),P(p[0].S,p[n-1].S)));
    v.push_back(make_pair(calc_dist(0,n-2),P(p[0].S,p[n-2].S)));
    v.push_back(make_pair(calc_dist(1,n-1),P(p[1].S,p[n-1].S)));
    for(int i=0;i<n;i++) swap(p[i].F.F,p[i].F.S);
    sort(p,p+n);
    v.push_back(make_pair(calc_dist(0,n-1),P(p[0].S,p[n-1].S)));
    v.push_back(make_pair(calc_dist(0,n-2),P(p[0].S,p[n-2].S)));
    v.push_back(make_pair(calc_dist(1,n-1),P(p[1].S,p[n-1].S)));
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    printf("%d\n",v[v.size()-2].F);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
// template <class T = ll> using P = pair< T,T>;
template <class T = ll> using V = vector<T>;
template <class T = ll> using VV = V<V<T>>;
#define rep(i,n) for(int i=0; i<(n);++i)
#define repp(i, l, r) for(int i = (l); i < (r); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()

int main()
{
    int n;
    cin >> n;
    V<pair<int,int>> x(n);
    V<pair<int,int>> y(n);
    rep(i, n) {
        cin >> x[i].first >> y[i].first;
        x[i].second = i;
        y[i].second = i;
    }
    sort(all(x), greater<pair<int,int>>());
    sort(all(y), greater<pair<int,int>>());

    V<pair<pair<int,int>,int>> ans;
    {
        pair<pair<int,int>,int> can;
        pair<int,int> a;
        a.first = x[0].second;
        a.second = x[n-1].second;
        can.first = a;
        can.second = x[0].first - x[n-1].first;
        ans.push_back(can);
    }
        {
        pair<pair<int,int>,int> can;
        pair<int,int> a;
        a.first = y[0].second;
        a.second = y[n-1].second;
        can.first = a;
        can.second = y[0].first - y[n-1].first;
        ans.push_back(can);
    }
        {
        pair<pair<int,int>,int> can;
        pair<int,int> a;
        a.first = x[1].second;
        a.second = x[n-1].second;
        can.first = a;
        can.second = x[1].first - x[n-1].first;
        ans.push_back(can);
    }
        {
        pair<pair<int,int>,int> can;
        pair<int,int> a;
        a.first = x[0].second;
        a.second = x[n-2].second;
        can.first = a;
        can.second = x[0].first - x[n-2].first;
        ans.push_back(can);
    }
        {
        pair<pair<int,int>,int> can;
        pair<int,int> a;
        a.first = y[1].second;
        a.second = y[n-1].second;
        can.first = a;
        can.second = y[1].first - y[n-1].first;
        ans.push_back(can);
    }
        {
        pair<pair<int,int>,int> can;
        pair<int,int> a;
        a.first = y[0].second;
        a.second = y[n-2].second;
        can.first = a;
        can.second = y[0].first - y[n-2].first;
        ans.push_back(can);
    }
    sort(all(ans), [](auto lhs, auto rhs){return lhs.second > rhs.second;});
    ll cnt = 0;
    pair<int,int> pre;
    for(auto abc : ans){
        if(pre == abc.first) continue;
        cnt++;
        pre = abc.first;
        if(cnt == 2){
            cout << abc.second << endl;
        }
    }

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

double n;
double x0[2], xh[2];
const double PI = 3.141592653589793238;

void solve()
{
	double R = sqrt((x0[0] - xh[0]) * (x0[0] - xh[0]) + (x0[1] - xh[1]) * (x0[1] - xh[1]));
	double t = PI / 2 * (n - 2) / n;
	double A = fabs(R * cos(t));
	double ans0, ans1;

	double x = xh[0] - x0[0];
	double y = xh[1] - x0[1];

	ans0 = (x * cos(t) + y * sin(t)) * A / R + x0[0];
	ans1 = (-x * sin(t) + y * cos(t)) * A / R + x0[1];

	printf("%.10f %.10f\n", ans0, ans1);
}

int main()
{
	cin >> n;
	for (int i = 0; i < 2; i++)cin >> x0[i];
	for (int i = 0; i < 2; i++)cin >> xh[i];
	solve();
	return 0;
}

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <numeric>
#include <algorithm>
#include <queue>
#include <sstream>
#include <stack>
#include <variant>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define REP(n) FOR(__i, n)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vull vector<ull>
#define ALL(c) c.begin(), c.end()
#define SORT(x) sort(ALL(x))
#define SZ(x) ((int) x.size())
#define pb push_back
#define ii pair<int, int>
#define pll pair<ll, ll>
#define MOD 1000000007

void test_case()
{
  int N;
  double x0, y0, xh, yh;
  cin >> N >> x0 >> y0 >> xh >> yh;

  double mx = (x0 + xh) / 2;
  double my = (y0 + yh) / 2;
  double dx = x0 - mx;
  double dy = y0 - my;

  double s = sin(2 * acos(-1) / N), c = cos(2 * acos(-1) / N);

  double px = c * dx - s * dy;
  double py = s * dx + c * dy;

  cout << mx + px << " " << my + py << endl;
}

int main(void)
{
    cout << setprecision(9) << fixed;
    int t = 1;
    // cin >> t;
    FOR(i, t) {
        // cout << "Case #" << i + 1 << ": ";
        test_case();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <sstream>
using namespace std;

void solve() {
	int n, w;
	cin >> n >> w;
	set<long long> time;
	map<long long, long long > add;
	map<long long, long long> rem;
	for(int i = 0; i < n; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		add[x] += z;
		rem[y] += z;
		time.insert(x);
		time.insert(y);
	}
	set<long long>::iterator it;
	long long total = 0LL;
	string ans = "Yes";
	for(it = time.begin(); it != time.end(); ++it) {
		long long x = (long long) *it;
		if(add[x] > 0) total += add[x];
		if(rem[x] > 0) total -= rem[x];
		if(total > w) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
}

int main () {
	int t = 1;
	for(int tt = 0; tt < t; tt++) solve();
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define FOR(i,a,b) for(int i=a; i <=(b); i++)
#define ROF(i,a,b) for(int i=a; i >=(b); i--)
#define loop(i,a) for(int i=0; i < (a); i++)
#define rloop(i,a) for(int i=(a-1); i >= 0; i--)
#define MAX(a,b) (a < b) ? (b) : (a)
#define BIGGEST(a,b,c) (MAX(a,b) < c) ? (c) : MAX(a,b)
#define END "\n"
#define pb push_back
#define first ff
#define second ss

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

void solve() {

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

 	vector<vector<int>> a(n,vector<int> (n, 0));

 	loop(i,n){
 		loop(j,n){
 			cin >> a[i][j];
 		}
 	}

 	// vector<vector<int>> out(n,vector<int> (n+1));
 	vector<int>out;
 	vector<int>ans;
 	for(int i=1; i < n; i++){
 		ans.push_back(i+1);
 	}

 	ll sum=0,cnt=0;
 	do{
 		sum = 0;
 		// for(auto x : ans)cerr << x << " ";
 		// cerr << "\n";

 		for(int i=0; i < n-1; i++){
 			sum += a[ans[i]-1][ans[i+1]-1];
 		}
 		sum += (a[0][ans[0]-1]) + (a[ans[ans.size()-1]-1][0]);
 		// cerr << sum << "\n";
 		if(sum == k){
 			cnt++;
 		}
 	}while(next_permutation(ans.begin(),ans.end()));

 	cout << cnt;
}

int main() {

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

     cerr<<"\ntime taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
   return 0;
}


#include <bits/stdc++.h>
#define union Union
#define rank rank228
#define tm tm228
#define hash hash228
#define matr vector < vector < int > >
#define int long long
#define pii pair < int, int >
#define papa pair < node*, node* >
#define all(v) v.begin(), v.end()
//#define endl "\n"
#define pb push_back
#define PI 3.14159265358979323846
#define ff first
#define ss second
using namespace std;

const int maxn = 1e6 + 100, mod = 998244353, inf = 1e9;

int mood(int x)
{
    x %= mod;
    if (x < 0)
        x += mod;
    return x;
}

int faq[maxn], rfaq[maxn], p[maxn];

int binpow(int a, int b)
{
    if (b == 0)
        return 1;
    int t = binpow(a, b / 2);
    t *= t;
    t = mood(t);
    if (b % 2)
        t *= a;
    t = mood(t);
    return t;
}

int c(int n, int m)
{
    int ans = 1;
    if (n >= m)
        return 1;
    ans *= faq[m];
    ans = mood(ans);
    ans *= rfaq[n];
    ans = mood(ans);
    ans *= rfaq[m - n];
    ans = mood(ans);
    return ans;
}

void solve()
{
    faq[0] = 1;
    for (int i = 1; i < maxn; ++i)
    {
        faq[i] = mood(faq[i - 1] * i);
        rfaq[i] = binpow(faq[i], mod - 2);
    }
    int n, m, ans = 0;
    cin >> n >> m;
    for (int i = 0; i < maxn; ++i)
        p[i] = -1;
    for (int i = 2; i < maxn; ++i)
    {
        if (p[i] == -1)
        {
            for (int j = i * i; j < maxn; j += i)
                p[j] = i;
            p[i] = i;
        }
    }
    for (int i = 1; i <= m; ++i)
    {
        int x = i, k = 1;
        map < int, int > mp;
        while (x > 1)
        {
            mp[p[x]]++;
            x /= p[x];
        }
        for (auto [x, y] : mp)
        {
            k *= c(y, n + y - 1);
            k = mood(k);
        }
        ans += k;
        ans = mood(ans);
    }
    cout << ans << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    srand(10);
    cout << fixed << setprecision(20);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
        cout << endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll MOD=998244353;
const ll mod=MOD;
const int MAX=200010;

ll rui(ll a,ll b){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=res*x%mod;
        x=x*x%mod;
        b/=2;
    }
    return res;
}

signed main(){
    ll n,k;cin>>n>>k;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>fac(k+1);
    fac[0]=1;
    REP(i,1,k+1){
        fac[i]=fac[i-1]*i%mod;
    }
    vector<ll>inv(k+1);
    rep(i,k+1){
        inv[i]=rui(i,mod-2);
    }
    vector<vector<ll> >b(n,vector<ll>(k+1));
    vector<ll>sum(k+1);
    rep(i,n){
        ll ai=a[i];
        rep(j,k+1){
            if(j==0){
                b[i][j]=1;
            }else{
                b[i][j]=b[i][j-1]*ai%mod*inv[j]%mod;
            }
            sum[j]=(sum[j]+b[i][j])%mod;
        }
    }
    vector<vector<ll> >mn(n,vector<ll>(k+1));
    vector<ll>sum2(k+1);
    rep(i,n){
        ll ai=a[i];
        rep(j,k+1){
            if(j==0){
                mn[i][j]=1;
            }else{
                mn[i][j]=mn[i][j-1]*ai%mod*2LL%mod;
            }
            sum2[j]=(sum2[j]+mn[i][j])%mod;
        }
    }
    ll inv2=rui(2LL,mod-2);
    REP(i,1,k+1){
        ll ans=0;
        rep(j,i+1){
            ans=(ans+sum[j]*sum[i-j]%mod)%mod;
        }
        ans=ans*fac[i]%mod;
        ans=(ans-sum2[i])%mod;
        ans=ans*inv2%mod;
        if(ans<0)ans+=mod;
        cout<<ans<<endl;
    }
}