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

int main() {
	int x, y, z, t1, t2, t3;
	int s, e;
	while(cin >> x >> y >> z >> t1 >> t2 >> t3) {
		s = abs(x - y) * t1;
		e = (abs(x - z) + abs(x - y)) * t2 + 3 * t3;
		if(s >= e)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


//basic
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <climits>
#include <algorithm>
#include <cmath>
#include <array>
#include <cstdint>
#include <iterator>
//STL
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
//define
#define int int32_t
#define ll int64_t
#define dou double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define init(a,b) fill(begin(a),end(a),b)
#define sot(a,b) sort(a+1,a+1+b)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define rep0(i,a,b) for(int i=a;i<b;i++)
#define repa(i,a) for(auto &i:a)
#define eps 1e-8
//namespace
using namespace std;
//header end

int n,a[4],b[4];

int main()
{
    scanf("%d",&n);
    rep1(i,1,3) scanf("%d%d",&a[i],&b[i]);
    int x=min(n-a[2]-a[3],b[1]);
    int y=min(n-x-a[3],b[2]);
    int z=n-x-y;
    printf("%d %d %d\n",x,y,z);
    return 0;
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const double eps=1e-8;
int main(){
	double a,b,c,d,ans;scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
	if ((b-a)==(c-b) && (c-b)==(d-c)) ans=d+(d-c);
	else
	if (b/a==c/b && c/b==d/c) ans=d*(d/c);
	else
		ans=42;
	if (ans-floor(ans)>eps && ceil(ans)-ans>eps) ans=42;
	printf("%d\n", (int)ans);
	return 0;
}


/************************************************
┆  ┏┓　　　┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃　　　　　　　┃ ┆
┆┃　　　━　　　┃ ┆
┆┃　┳┛　┗┳　┃ ┆
┆┃　　　　　　　┃ ┆
┆┃　　　┻　　　┃ ┆
┆┗━┓　  　┏━┛ ┆
┆　　┃　  　┃　　┆
┆　　┃　  　┗━━━┓ ┆
┆　　┃　 AC代马 　　┣┓┆
┆　　┃　        　　┏┛┆
┆　　┗┓┓┏━┳┓┏┛ ┆
┆　　　┃┫┫　┃┫┫ ┆
┆　　　┗┻┛　┗┻┛ ┆
************************************************ */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<string>
#define ll long long
using namespace std;

int Abs(int i)
{
    if(i<0) i=-i;
    return i;
}

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        int l=0,r=0,mid=0;
        for(int i=1;i<=6;i++)
        {
            if(Abs(n-i)==Abs(m-i))
            {
                mid++;
            }
            else if(Abs(n-i)<Abs(m-i))
            {
                l++;
            }
            else
            {
                r++;
            }
        }
        printf("%d %d %d\n",l,mid,r);
    }
}


#include <iostream>

using namespace std;

long long int count(long long int x){
	long long int ans = 0;
	while (x != 0){
		ans += (x % 10);
		x /= 10;
	}
	return ans;
}

long long int solve(long long int x){
	long long int ans = x;
	long long int i = 10;
	while (x > 0){
		x = x - x % i - 1;
		if (count(x) > count(ans))
			ans = x;
		i *= 10;
	}
	return ans;
}

int main()
{
	long long int x;
	cin >> x;
	cout << solve(x);
	return 0;
}


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

long long a, b;

long long func(int a) {
    if (a == 0 || a == 1) return 1;
    return a * func(a - 1);
}

int main() {
    scanf("%lld%lld", &a, &b);
    a = min(a, b);
    printf("%lld", func(a));
    return 0;
}


#include <iostream>
#include<math.h>
using namespace std;
int main(int argc, char** argv) {
    int n,a,r;
	cin>>n;
	int tabA[5]={0},tabB[5]={0};
	for(int i=0; i<n;i++)
	{ cin>>a;
	  tabA[a-1]+=1;
		}
    for(int i=0; i<n;i++)
	{ cin>>a;
	  tabB[a-1]+=1;
		}

	int c=0,k=0,t=0;
	for (int i=0; i<5;i++)
	{
	    if(tabA[i]!=tabB[i])
	    { r=abs(tabA[i]-tabB[i]);
	    if((r%2)==0)
	       { c+=(r/2); t++;
		   }
		}
		else { k++;
		}}
		if(((c%2)==0)&&(c!=0)&&(t>=2)) cout<<(c/2);
		else if(k==5) cout<<0;
		else cout<<-1;

	return 0;}


//#pragma comment(linker,"/STACK:100000000000,100000000000")

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

using namespace std;

/* Constants begin */
const long long inf = 2e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-12;
const double PI = 2*acos(0.0);
const double E = 2.71828;
/* Constants end */

/* Defines begin */
#define pb push_back
#define mp make_pair
#define ll long long
#define double long double
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define forn(i,n) for (int (i)=0; (i)<(n); ++(i))
#define random S(rand()<<16|rand())
#define sqr(x) (x)*(x)
#define base complex<double>
/* Defines end */

double f[2][1005];

int n, m;

vector<double> a, b;

double C(int n, int m, bool ok = false){
  if(ok) swap(a, b);
  if(m == n){
    a.pb(1);
    b.pb(1);
  } else
  if(!m){
    a.pb(1);
    b.pb(1);
  } else {
    for(int i = 1; i <= m; ++i){
      b.pb(i);
    }
    for(int i = n - m + 1; i <= n; ++i){
      a.pb(i);
    }
  }
  if(ok) swap(a, b);
}

int main(void){
  #ifdef nobik
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
  #endif
  scanf("%d %d", &n, &m);
  double res = 0;
  f[0][0] = 1.0;
  for(int i = 1; i <= n * m; ++i){
    for(int j = 0; j <= m; ++j){
      //f[1][j + 1] += f[0][j] * (m - j) / (m * n - i + 1);
      //f[1][j] += f[0][j] * 6;
    }
  }
  if(m == 1){
    cout << setprecision(12) << fixed << 1.0 / n << endl;
    exit(0);
  }
  for(int i = 1; i <= min(n, m); ++i){
    double cur = 1.0 / (n + .0) * i * i;
    a.clear();
    b.clear();
    C(m, i);
    C(n * m - m, n - i);
    C(n * m, n, true);
    int it = 0;
    forn(i, a.size()){
      cur *= a[i];
      while(cur > 10 && it < b.size()) cur /= b[it++];
    }
    while(it < b.size()) cur /= b[it++];
    res += cur;
  }
  cout << setprecision(12) << fixed << res << "\n";
  return 0;
}


#include <math.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int p = 1e9 + 7;
ll poww(ll a, ll b) {
    ll ans = 1, base = a;
    while (b != 0) {
        if (b & 1 != 0)
            ans = ans * base % p;
            base = base * base % p;
            b >>= 1;
    }
    return ans % p;
}
int main() {
#ifdef ONLINE_JUDGE
#else
    freopen("c:\\code\\in.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll x, k, ans;
    scanf("%lld%lld", &x, &k);
    if(x == 0){
        cout << 0 << endl;
        return 0;
    }
    x = x % p;
    ans = (poww(2, (k + 1) % (p - 1)) % p * x % p - poww(2, k % (p - 1)) % p + 1 + p) % p;
    printf("%lld\n", ans);
    return 0;
}


// Amar_El-Bay
#include<bits/stdc++.h>
using namespace std ;
#define El_Bay ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sz(s) s.size()
#define ll  long long
#define pb  push_back
int main()
{
    El_Bay
    int _;
    cin>>_;
    while(_--)
    {
        string s;
        cin >> s;
        int x = s[0]-'0';
        int ans = (x-1)*10;
        if(sz(s)==1) ans+=1;
        else if(sz(s)==2) ans+=3;
        else if(sz(s)==3) ans+=6;
        else ans+=10;
        cout << ans << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int l = s.length();
    int cnt = 0;
    for(int i=0;i<l;i++)
    {
        if(s[i]<90)
        {
            if((s[i]-48)%2)
                cnt++;
        }
       else
            {
                if(s[i]=='a' || s[i]=='e' ||  s[i]=='i' || s[i]=='o' || s[i]=='u')
                    cnt++;
            }

    }
    cout<<cnt;
    return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iomanip>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <cstdlib>
#include <cstdio>
#include <functional>
#include <memory.h>
#include <cassert>
#include <complex>
#include <ctime>
#include <limits>

using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;

using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vld = vector<ld>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
using vvi = vector<vi>;
using vvl = vector<vl>;

using si = set<int>;
using sl = set<ll>;

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rs resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define nl "\n"
#define in cin
#define out cout

#define trav(i, x) for (auto& i: x)
#define rep(i, a, b) for(auto (i) = (a); i < (b); ++i)
#define per(i, a, b) for(auto (i) = (a - 1); i >= (b); --i)

const int MOD = 998244353;
const int MX = 5005;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

ll lcm(ll a, ll b) { return (a / (__gcd(a, b)) * b); }
ll gcd(ll a, ll b) { return (__gcd(a, b)); }
ll pow(ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res; }

#define ts to_string
str ts(char c) { return str(1,c); }
str ts(bool b) { return b ? "true" : "false"; }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
template<class A> str ts(complex<A> c) {
	stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
	str res = "{"; for(int i = 0; i < sz(v); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
	str res = ""; for(int i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v) {
	bool fst = 1; str res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += ts(x);
	}
	res += "}"; return res;
}
template<class A, class B> str ts(pair<A,B> p) {
	return "("+ts(p.f)+", "+ts(p.s)+")"; }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << ts(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)

int n;

bool check(int x) {
	string s = to_string(x);
	int sum = 0;
	for(int i = 0; i < sz(s); i++) {
		sum += s[i] - '0';
	}
	if(sum == 10) {
		return true;
	} else {
		return false;
	}
}

int main() {
	cin >> n;
	int cnt = 0;
	for(int i = 19;; i += 9) {
		if(check(i) && cnt == n - 1) {
			cout << i << nl;
			break;
		} else if(check(i)) {
			cnt++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string a , b;
    cin>>a>>b;
    for (int i=0; i<a.size(); i++)
    {
        if (tolower(a[i]) > tolower(b[i]))
        {
            cout<<1;
            return 0;
        }
        if (tolower(b[i]) > tolower(a[i]))
        {
            cout<<-1;
            return 0;
        }
        else
        {
            if (i == a.size()-1)
            cout<<0;

        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll q,ans=2,sum=0;
int main(){
    cin>>q;
    for(int i=2;i<=q;i++) sum+=ans,ans=ans*2;
    sum+=ans;
    cout<<sum<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long qpow(long long a, long long b)
{
	long long res = 1;
	while (b)
	{
		if (b & 1)
		{
			res = (res * a) % mod;
		}
		a = (a * a)%mod;
		b /= 2;
	}
	return res%mod;
}
int main()
{
	        int t;
			long long n;
			cin >> n;
			long long u = 2;
			long long ks = pow(2,n);
			long long kk = qpow(u*2, (ks - 2)) % mod;
			long long cf = (kk*6)%mod;
			cout << cf << endl;
}


#define _HAS_ITERATOR_DEBUGGING 0
#define _ITERATOR_DEBUG_LEVEL 0
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <list>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>

#define setzero(arr) memset(arr, 0, sizeof(arr))

int ___read_tmp;
#define fi(i, from, to) for(int i = (from); i < (to); i++)
#define fri(i, from, to) for(int i = (from); i >= (to); i--)
#define fa(it, col) for(auto (it) = (col).begin(); (it) != (col).end(); (it)++)
#define fra(it, col) for(auto (it) = (col).rbegin(); (it) != (col).rend(); (it)++)
#define getBit(vv, bit) ((vv & (lol)(1LL << (31 - bit))) == 0LL ? 0 : 1)
#define getBit64(vv, bit) ((vv & (lol)(1LL << (63 - bit))) == 0LL ? 0 : 1)
#define vecits(obj) obj.begin(), obj.end()
#define strip_string(str) (str)[strcspn((str), "\r\n")] = 0;
#define read_int() (scanf("%d ", &___read_tmp), ___read_tmp)
#define MOD 1000000007
#define PI 3.14159265
#define INF 10000000
//#define FILE_IO "peacefulsets"

typedef unsigned long long lol;
typedef  long long slol;
using namespace std;

bool used[35000];
unordered_map<int, int> mm;

int calc_sg(int vv)
{
	if (vv == 0)
		return 0;

	auto res = mm.find(vv);
	if (res != mm.end())
		return res->second;

	bool sg_vals[40];
	memset(sg_vals, 0, sizeof(sg_vals));
	fi(i, 1, 29)
	{
		if ((vv & (1 << i)) == 0)
			continue;

		int v2 = vv;
		for (int k = 1; k < 50; k ++)
		{
			int pos = (i + 1)*k - 1;
			if (pos >= 29)
				break;

			v2 &= ~(1 << pos);
		}

		sg_vals[calc_sg(v2)] = true;
	}

	int mex = 40;
	fi(i, 1, 40)
	{
		if (!sg_vals[i]) {
			mex = i;
			break;
		}
	}

	mm[vv] = mex;
	return mex;
}

int sg_sizes[30] =  {0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12 };
bool skip[35000];

int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#elif defined(FILE_IO)
	freopen(FILE_IO ".in", "r", stdin);
	freopen(FILE_IO ".out", "w", stdout);
#endif

	/*calc_sg((1 << 29) - 1);
	fi(i, 1, 30)
	{
		sg_sizes[i] = mm[(1 << i) - 1];
	}
	*/

	int nn;
	scanf("%d", &nn);
	lol n = nn;

	lol max_v = 0;
	fi(i, 1, n+1)
	{
		if (i*i <= n)
			max_v = i;
		else
			break;
	}

	int res = 0;
	int taken = 0;
	fi(i, 2, n)
	{
		if (i*i > n)
			break;

		if (skip[i])
			continue;

		lol tmp = i, cnt = 0;
		while (tmp <= max_v)
		{
			skip[tmp] = true;
			cnt++;
			tmp *= i;
		}

		while (tmp <= n)
		{
			tmp *= i;
			cnt++; taken++;
		}

		res ^= sg_sizes[cnt];
	}

	int emp = n - max_v - taken;
	if (max_v > 0) emp++;
	res ^= emp % 2;

	if (res != 0)
	{
		printf("Vasya");
	}
	else {
		printf("Petya");
	}

	return 0;
}


#include <iostream>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>

#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define iter iterator

using namespace std;

int main()
{
    int def1, atk1, def2, atk2, def3, atk3, def4, atk4;
    cin >> def1 >> atk1 >> def2 >> atk2 >> def3 >> atk3 >> def4 >> atk4;
    if ((((atk1 > def3) && (def2 > atk4)) && ((atk1 > def4) && (def2 > atk3))) || (((def1 > atk3) && (atk2 > def4)) && ((def1 > atk4) && (atk2 > def3))))
        cout << "Team 1" << endl;
    else if ((((atk3 > def1) && (def4 > atk2)) || ((def3 > atk2) && (atk4 > def1))) && (((def3 > atk1) && (atk4 > def2)) || ((atk3 > def2) && (def4 > atk1))))
        cout << "Team 2" << endl;
    else
        cout << "Draw" << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll; typedef pair<ll, pi> plp;
typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF * 2;

ll mul(ll a, ll b, ll mod) {
	a %= mod;
	ll res = 0, p = a;
	while(b) {
		if(b%2) res += p, res %= mod;
		p += p; p %= mod; b>>=1;
	}
	return res;
}
ll a_b(ll a, ll b, ll mod) {
	a %= mod;
	ll res = 1, p = a;
	while(b) {
		if(b%2) res = mul(res, p, mod);
		p = mul(p, p, mod); b>>=1;
	}
	return res;
}

const int MAX_P = 40;
//if n < 18446744073709551616 = 2^64
//it is enough to test a = 2  3  5  7  11  13  17  19  23  29  31  and 37
vector<int> Ps; bool notP[MAX_P], isFirst = true;
bool isPrime(ll n) { //Miller–Rabin_primality_test
	if(isFirst) {
		isFirst = false;
		notP[0] = notP[1] = true;
		for(int i=2; i<MAX_P; i++) if(notP[i] == false) {
			Ps.push_back(i);
			for(int j=i*2; j<MAX_P; j++) notP[j] = true;
		}
	}
	int s=0; ll m = n-1;
	while((m&1) == 0) m >>= 1, s++;
	for(int x : Ps) if(n == x) return true;
	for(int x : Ps) if(n % x == 0) return false;

	for(int x : Ps) {
		ll now = a_b(x, m, n);
		bool isCom = true;
		if(now == 1) continue;
		for(int i=0; i<s; i++) {
			if(now == n-1) { isCom = false; break; }
			now = mul(now, now, n);
		}
		if(isCom) return false;
	}
	return true;
}

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

ll getF(ll a, ll b) {
	if(b == 0) return 0;
	return 1 + getF(a, b - gcd(a, b));
}

vector<ll> Div;
ll myF(ll A, ll B) {
//	printf("%lld %lld\n", A, B);
	if(A == 1) return B;
	if(B == 0) return 0;
	if(isPrime(A)) {
		ll v = B % A; B -= v;
		v += B / A;
		return v;
	}
	if(B % A == 0) return B / A;

	ll g = gcd(A, B);
	ll cnt = 1, na = A/g;
	ll b = B/g - 1;

	if(isPrime(na)) {
		cnt += b % na;
		b -= b % na;
	}else{
		while(gcd(b, na) == 1 && b > 0) b--, cnt++;
	}
	ll ans = cnt + myF(na, b);
	return ans;
}
int main() {
//	for(int i=1; i<=7; i++, puts("")) for(int j=0; j<=30; j++) printf("%3lld", getF(i, j));

//	return 0;
	/*
	for(int i=1; i<=10; i++) for(int j=1; j<=10; j++) {
		printf("[%d %d]\n", i, j);
		if(myF(i, j) != getF(i, j)) {
			printf("%d %d [%lld %lld]\n", i, j, myF(i, j), getF(i, j));
			puts("FUCK");
			return 0;
		}
	}
	//*/
	ll a, b;
	cin >> a >> b;
	printf("%lld\n", myF(a, b));
	return 0;
}


#include<iostream>
#include<cstdio>
#define N 1005
using namespace std;
int n,m,ci,di,dp[N],ai,bi,obj[N],tot,vi[N],wi[N];
int main()
{
	scanf("%d%d%d%d",&n,&m,&ci,&di);
	for(int i=ci;i<=n;i++)
		dp[i]=dp[i-ci]+di;
	for(int i=1;i<=m;i++)
	{
		tot=0;
		scanf("%d%d%d%d",&ai,&bi,&ci,&di);
		int maxb=ai/bi;
		int base=1;
		while(base<=maxb)
		{
			obj[++tot]=base;
			wi[tot]=base*ci;
			vi[tot]=base*di;
			maxb-=base;
			base<<=1;
		}
		if(maxb)
		{
			obj[++tot]=maxb;
			wi[tot]=maxb*ci;
			vi[tot]=maxb*di;
		}
		for(int k=1;k<=tot;k++)
			for(int j=n;j>=wi[k];j--)
					dp[j]=max(dp[j],dp[j-wi[k]]+vi[k]);
	}
	printf("%d",dp[n]);
}


#include <bits/stdc++.h>
#define FIT(a,b) for(vector<int >::iterator a=b.begin();a!=b.end();a++)
#define FOR(a,b,c) for(int a=(b);a<=(c);++a)
#define ROF(a,b,c) for(int a=(b);a>=(c);--a)
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define TATA NULL
using namespace std;
const int MOD = 1000000007;
const int buffer = 200004;
const int NMAX = 1004;
inline int Pow(const int x,const int n)
{
    if(n==0)
        return 1;
    if(n&1)
        return 1LL*x*Pow(x,n-1)%MOD;
    int a = Pow(x,n/2);
    return 1LL*a*a%MOD;
}

int dp[NMAX], fact[NMAX*NMAX], inv[NMAX*NMAX],n, m, k;
int dp1[NMAX],sum[NMAX][2];
inline int Comb(const int n,const int k)
{
    if(k > n)
        return 0;
    int ret = 1LL*fact[n]*inv[n-k]%MOD;
    return 1LL*ret*inv[k]%MOD;
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin >> n >> m >> k;
    fact[0] = inv[0] = 1;
    FOR(i,1,max(n,k))
    {
        fact[i] = 1LL*fact[i-1]*i%MOD;
        inv[i] = Pow(fact[i],MOD-2);
    }
    FOR(i,1,n)
    {
        dp[i] = Pow(i,n);
        FOR(j,1,i-1){
            dp[i] -= 1LL*dp[j]*Comb(i,j)%MOD;
            if(dp[i] < 0)
                dp[i] += MOD;
        }
    }
    int ans = 0, x, y, z;
    if(m==1)
    {
        FOR(distincte,1,min(n,k))
        {
            ans += 1LL*dp[distincte]*Comb(k,distincte)%MOD;
            ans %= MOD;
        }
        cout<<ans<<"\n";
        return 0;
    }
    if(m==2)
    {
        FOR(distincte,1,min(n,k))
        {
            x = 1LL*dp[distincte]*Comb(k,distincte)%MOD;
            x = 1LL*x*x%MOD;
            ans = (ans+x)%MOD;
        }
        cout<<ans<<"\n";
        return 0;
    }
    FOR(i,1,n)
        dp1[i] = (Pow(sum[i][1],m-2)-Pow(sum[i][0],m-2)+MOD)%MOD;
    FOR(i,1,n){
        FOR(j,1,i-1)
            sum[i][0] = (sum[i][0] + 1LL*Comb(i,j)*dp[j]%MOD)%MOD;
        sum[i][1] = (sum[i][0]+dp[i])%MOD;
    }
    FOR(distincte,1,min(n,k))
    {
        FOR(intersect,1,distincte)
        {
            x = 1LL*dp[distincte]*Comb(k,distincte)%MOD;
            z = 1LL*Pow(intersect,n*(m-2))*Comb(distincte,intersect)%MOD;
            y = 1LL*dp[distincte]*Comb(k-distincte,distincte-intersect)%MOD;
            x = 1LL*x*y%MOD;
            x = 1LL*x*z%MOD;
            ans = (ans+x)%MOD;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


#include <cstdio>

using namespace std;

int main()
{
	int k, n, s, p;
	scanf("%d%d%d%d", &k, &n, &s, &p);
	int t;
	if (n / s == 0)
	{
		t = 1;
	}
	else
	{
		t = n / s + (n%s == 0 ? 0 : 1);
	}
	int ans;
	ans = t*k / p + (t*k%p == 0 ? 0 : 1);
	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
    long long a,b;
    cin>>a>>b;
    long long kn=a/(b+1)/2;
    cout<<kn<<" "<<kn*(b)<<" "<<a-kn- kn*(b)<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005,mod=998244353;
int n;
ll A,B,p,pw[N],pw2[N],f[N],g[N][N],h[N];
ll Pow(ll x,ll k){
	ll ret=1;
	while(k){
		if(k&1)ret=ret*x%mod;
		k>>=1;x=x*x%mod;
	}
	return ret;
}
ll C2(ll n){
	return n*(n-1)/2;
}
int main(){
	scanf("%d%d%d",&n,&A,&B);
	p=(ll)A*Pow(B,mod-2)%mod;
	pw[0]=pw2[0]=1;
	for(int i=1;i<=n;i++){
		pw[i]=pw[i-1]*p%mod;
		pw2[i]=pw2[i-1]*(1-p)%mod;
	}
	for(int i=0;i<=n;g[i++][0]=1)
		for(int j=1;j<=i;j++){
			g[i][j]=(g[i-1][j]*pw2[j]+g[i-1][j-1]*pw[i-j])%mod;
		}
	for(int i=1;i<=n;i++){
		h[i]=1;
		for(int j=1;j<i;j++)h[i]=(h[i]-h[j]*g[i][j])%mod;
	}
	for(int i=1;i<=n;i++){
		ll tot=0;
		for(int j=1;j<=i;j++)tot=(tot+g[i][j]*h[j]%mod*((C2(j)+j*(i-j)+f[i-j]+f[j])%mod))%mod;
		f[i]=tot*Pow(1-g[i][i]*h[i]%mod,mod-2)%mod;
	}
	cout<<(f[n]+mod)%mod<<"\n";
}


#include<cstdio>
#include<iostream>

using namespace std;

int n[15], a[15];
int cnt = 1;
char c;
int main()
{
	while(c < '0' || c > '9') c = getchar();
	while(c >= '0' && c <= '9')
	{
		n[cnt] = c - '0';
		c = getchar();
		cnt++;
	}
	int ans = 0;
	for(int i = cnt-1; i >= 1; i--)
	{
		if(i != 1) n[i] -= 9;
		if(n[i] < 0)
		{
			n[i-1]--;
			n[i] += 10;
		}
		ans += 9;
		ans += n[i];
		//cout <<n[i] << " " << ans << endl;
	}
	cout << ans - 9;
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#define debug(x) (cerr<<#x<<" = "<<x<<'\n')
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll N = 1<<18, MOD = 1000000007;
namespace dsu {
int pa[N],rk[N];
void init(int n) {iota(pa,pa+n,0),memset(rk,0,sizeof(int)*n);}
int anc(int x) {return x==pa[x] ? x : (pa[x]=anc(pa[x]));}
bool uni(int x,int y) {
    if((x=anc(x))==(y=anc(y))) return false;
    if(rk[x] < rk[y]) swap(x,y);
    return pa[y] = x, rk[x]!=rk[y]||++rk[x];
}
}
using namespace dsu;
ll mdp(ll e,ll p) {
    ll r = 1;
    while(p) (p&1)&&(r=r*e%MOD), e=e*e%MOD, p>>=1;
    return r;
}
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    ll n,m,k;
    cin >> n >> m >> k;
    init(n);
    for(int i = 0; i+k-1 < n; i++) {
        for(int j = 0; j < k; j++) {
            int a = i+j;
            int b = i+k-1-j;
            //debug(a), debug(b);
            uni(a,b);
        }
    }
    vector<int> v;
    for(int i = 0; i < n; i++) v.push_back(anc(i));
    sort(v.begin(), v.end()), v.erase(unique(v.begin(),v.end()), v.end());
    //for(int p:v) cout << p << ' '; cout << '\n';
    cout << mdp(m,v.size()) << '\n';
}


#include<bits/stdc++.h>
using namespace std;
unsigned long long n,m;
int main()
{
	scanf("%lld%lld",&n,&m);
	if(m==1) printf("%lld",n-1);
	else printf("%lld",n*(m-1));
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
char str[10];
int a[11];
int main()
{
    a[0]=2;
    a[1]=7;
    a[2]=2;
    a[3]=3;
    a[4]=3;
    a[5]=4;
    a[6]=2;
    a[7]=5;
    a[8]=1;
    a[9]=2;
    scanf("%s",str);
    cout<<a[(int)str[0]-48]*a[(int)str[1]-48]<<endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<map>
using namespace std;

int main()
{
	map<int,int>m;
	m[1]=4; m[2]=4; m[3]=4; m[4]=4; m[5]=4; m[6]=4; m[7]=4; m[8]=4; m[9]=4;
	m[10]=15; m[11]=4;
	int n;
	int k;
	int p=0;
	cin>>n;
	if(n<10) cout<<"0";
	else if(n-10>11) cout<<"0";
	else
	{
		k=abs(n-10);
		cout<<m[k];
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include<math.h>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#define inf 2000000000
#define INF 1<<29
#define s(a) scanf("%d",&a)
#define me(a,b) memset(a,b,sizeof(a))
typedef long long ll;
using namespace std;
const int maxn=1e6+5;
const int mo=1e9+7;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
priority_queue<ll,vector<ll>,less<ll> >q;

int main()
{
	//freopen("diversity.in","r",stdin);
    //freopen("diversity.out","w",stdout);
	int n;

	while(~s(n)){
		for (int i=1;i<=10000;i++) {
		if (i*i>=n) {
			printf("%d\n",4*i);
			return 0;
		} else if (i*(i+1)>=n) {
			printf("%d\n",4*i+2);
			return 0;
		}
		}
	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int u=1,v=1,n,p=0,k;
    string s;
    cin>>s;
    n=s.length();
    for(int i=0;i<n-1;i++)
    v*=9;
    if(s[0]!='1')
    v*=(s[0]-'1');
    k=n-1;
    for(int i=0;i<k;i++)
    if(p==1)
    s[i]='9';
   else if(s[i]>s[i+1] ){
     s[i]--;
    p++;
    k++;
    }
    for(int i=0;i<n;i++)
    u*=s[i]-'0';
    cout<<max(u,v);
}


#include <bits/stdc++.h>
using namespace std;
vector<long long int> vaibhav1;
void nandan(int o,int limi)
{
	if(o==limi)
	{
		return;
	}
	int y=pow(2,o)-1;
	for(int i=0; i<=y; i++)
	{
		int A[o];
		int w=i;
		for(int j=0; j<o;j++)
		{
			A[j]=w%2;
			w=w/2;
		}
		long long int sum=0;
		for(long long int j=0; j<o;j++)
		{
			if(A[j]==0)
			{
				sum+=(pow(10,j))*4;
			}
			else{
				sum+=(pow(10,j))*7;
			}
		}
		vaibhav1.push_back(sum);
	}

	nandan(o+1,limi);
}
bool f(int index, long long int k,long long int n)
{
	long long int A[14];
	A[0]=0;
	A[1]=1;
	for(long long int i=2;i<=13;i++)
	{
		A[i]=A[i-1]*i;
	}

	set<long long int> vaibhav;
	set<long long int> :: iterator it ;
	for(int i=n-13; i<=n; i++)
	{
		vaibhav.insert(i);
	}
	int l=13;
	map<long long int, long long int> yoyo;
	int active=0;
	for(int i=n-13; i<=n; i++)
	{
		if(active==1)
		{
			it=vaibhav.end();
			it--;
			yoyo[i]=*(it);
			vaibhav.erase(it);
		}
		else if(k>=A[l]&&l!=0)
		{
		  int u=(k-1)/A[l];
		  it =vaibhav.begin();
		  if(k%A[l]==0)
		  {
		  	active=1;
		  }
		  while(u--)
		  {
		  	it++;
			  }
			yoyo[i]=*it;
			//cout<<*it<<" "<<i;
			vaibhav.erase(it);
			k=k%A[l];
		}
		else{
			yoyo[i]=*(vaibhav.begin());
			vaibhav.erase(vaibhav.begin());
		}
		//cout<<yoyo[i]<<" "<<i<<"\n";
		l--;
	}
	int flag=1;
	if(yoyo.find(index)!=yoyo.end())
	{
		long long int po=yoyo[index];
		while(po)
		{
			if(po%10==4||po%10==7)
			{

			}
			else{
				flag=0;
			}
			po/=10;
		}
	}

		return flag;
}
void solve()
{
	long long int n,k,ans=0,sum=1;
	cin>>n>>k;

	if(n<=14)
	{
		for(long long int i=1;i<=n; i++)
		{
			sum=sum*i;
		}
		if(sum<k)
		{
			cout<<"-1\n";
			return;
		}
	}
	//cout<<"vaibhav";
	nandan(1,10);
	sort(vaibhav1.begin(),vaibhav1.end());
	for(int i=0; i<vaibhav1.size(); i++)
	{
		//cout<<"vaibhav";
		if(vaibhav1[i]>n)
		{
			break;
		}
		if(f(vaibhav1[i],k,n))
		{
			ans++;
		}
	}
	cout<<ans<<"\n";
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
   int t;
  // cin>>t;
  t=1;

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


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

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c;
    x=(a*b)+(b*c)+(c*a)-a-b-c+1;
    cout << x << endl;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 510
#define mod 998244353
using namespace std;
int t, n, x;
ll dp[N][N], ans, fact[N], pwd[N][N], c[N][N];
ll power(int x, int n){
	if(x < N && n < N && pwd[x][n] != -1) {
		return pwd[x][n];
	}
	if(n == 0)
		return 1ll;
	ll y = power(x, n/2);
	y = (y*y) % mod;
	if(n % 2)
		return (1ll * x * y) %mod;
	return y;
}
ll ncr(int n, int r){
	if(r > n)
		return 0ll;
	return c[n][r];
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    fact[0] = 1ll;
    for(int i=1; i < N; i++) {
    	fact[i] = (1ll * i * fact[i-1]) % mod;
    }
    for(int i = 0; i < N; i++) {
    	for(int j = 0; j < N; j++) {
    		pwd[i][j] = -1;
    		pwd[i][j] = power(i, j);
    	}
    }

	c[0][0] = 1;
	for (int i = 1; i < N; ++i) {
   		c[i][0] = c[i][i] = 1;
    	for (int j = 1; j < i; ++j) {
        	c[i][j] = (c[i - 1][j - 1] + c[i - 1][j])%mod;
    	}
	}
    cin >> n >> x;
    for(int i = 2; i <= n; i++) {
    	for(int k=1; k <= x; k++) {
    		if(k < i) {
    			dp[i][k] = power(k, i) - power(k-1, i);
    			if(dp[i][k] < 0ll)
    				dp[i][k] += mod;
    		} else {
    			for(int j = i; j > 1; j--) {
    				dp[i][k] = (dp[i][k] + ( (ncr(i, i-j) * power(i-1, (i-j)) ) % mod * dp[j][k - (i-1)]) % mod) % mod;
    			}
    		}
    		if(i == n) {
    			ans = (ans + dp[i][k]) % mod;
    		}
    	}
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
long long n,p;
long long sum;
long long tmp;
int main(){
    cin>>n>>p;
    sum=0;
    for(int i=1;i<=n;i++){
        tmp=i;
        int k=i;
        while(k){
            tmp=tmp*10+k%10;
            k/=10;
        }
        sum+=tmp;
        sum%=p;
    }
    cout<<sum;
}


// a
#include <iostream>
using namespace std;
int main(){
	string s,ans;
	int n;
	cin>>n>>s;
	s=s+"##";
	for(int i=0;i<n;i++){
		if(s[i]=='o'){
			if(s[i+1]=='g' && s[i+2]=='o'){
				ans=ans+"***";
			}else ans+=s[i];
			while(s[i+1]=='g' && s[i+2]=='o' && i<n){
				i+=2;
			}

		}else{
			ans+=s[i];
		}
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
long long m,a,b,sol,lst,ma,t;
long long nr,f;
long long gaus(long long n)
{
    n*=n+1;
    n/=2;
    return n;
}
long long solve(long long n,long long m)
{
    long long ret;
    ret=n*m;
    ret-=gaus(n-1)*a;
    return ret;
}
int main()
{
    cin>>m>>a>>b;
    sol=solve((m/a)+1,m+1);
    lst=b;
    while(b%a)
    {
        while(t<lst)
        {
            nr++;
            t+=a;
        }
        ma=max(ma,t);
        if(t>m)
            break;
        //cout<<b<<' '<<t<<'\n';
        t-=lst;
        //cout<<(1+(ma-t)/a)<<'\n';
        //cout<<t<<'\n';
        sol+=(((ma-t)/a)+1)*(m-ma+1);
        f=t;
        f+=(((ma-t)/a)+1)*a;
        b+=lst;
        if(f>m)
            continue;
        sol+=solve(1+(m-f)/a,m-f+1);
    }
    cout<<sol;
}


#include<bits/stdc++.h>

using namespace std;
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define pi 3.1415926535897932384626433832795028841971
#define n 8
int a[n][n];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
bool check(){
	int i,j,k;
	REP(i,n)REP(j,n)if(a[i][j]==1||a[i][j]==2){
		REP(k,4){
			int x=i+dx[k];
			int y=j+dy[k];
			for(;0<=x&&x<n&&0<=y&&y<n&&a[x][y]==0;x+=dx[k],y+=dy[k]);
			if(0<=x&&x<n&&0<=y&&y<n&&a[x][y]==4)return true;
		}
	}
	return false;
}
int main(){
	char r1[5],r2[5],kw[5],kb[5];
	while(scanf("%s %s %s %s",r1,r2,kw,kb)>0){
		int x1,y1,x2,y2,x3,y3,x4,y4;
		x1=r1[0]-'a',y1=r1[1]-'1';
		x2=r2[0]-'a',y2=r2[1]-'1';
		x3=kw[0]-'a',y3=kw[1]-'1';
		x4=kb[0]-'a',y4=kb[1]-'1';
		bool mate=true;
		int x,y;
		for(x=x4-1;x<=x4+1;x++)for(y=y4-1;y<=y4+1;y++){
			if(0<=x&&x<n&&0<=y&&y<n)
				if(abs(x-x3)>1||abs(y-y3)>1){
					REP(i,8)REP(j,8)a[i][j]=0;
					a[x1][y1]=1;
					a[x2][y2]=2;
					a[x3][y3]=3;
					a[x][y]=4;
					if(!check())mate=false;
				}
		}
		puts(mate?"CHECKMATE":"OTHER");
	}
	return 0;
}
/*
a6 b4 c8 a8
a6 c4 b6 b8
a2 b1 a3 a1
*/


#include <iostream>
#include <algorithm>

using ll = long long;

ll n, v, rest, l, r, mid;

int ok(ll x)
{
	v = 0;
	rest = n;
	while (rest > 0)
	{
		v += std::min(x, rest);
		rest -= std::min(x, rest);
		rest -= rest / 10;
	}
	return (v * 2 >= n);
}

int main()
{
	std::cin >> n;
	l = 1, r = n;
	while (l < r)
	{
		mid = (l + r) >> 1;
		if (ok(mid))
			r = mid;
		else
			l = mid + 1;
	}
	std::cout << l << std::endl;
}


#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
using namespace std;
int main()

{
int n,m,min;
cin>>n>>m;

if(m<n)
min=m;
else
min=n;
if(min%2==0)
cout<<"Malvika";
else
cout<<"Akshat";

return 0;
}


#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>
#include <map>

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

const int ms = 5001000;
const int lim_n = 3e5;
const int lim_p = 3e2;

std::vector<int> primes;
int id[ms];
int memo[lim_n][lim_p];
void pre() {
	std::vector<bool> isPrime(ms, true);
	for(int i = 2; i < ms; i++) {
		id[i] = (int) primes.size();
		if(!isPrime[i]) continue;
		id[i]++;
		primes.push_back(i);
		for(int j = i+i; j < ms; j += i) {
			isPrime[j] = false;
		}
	}
	for(int i = 1; i < lim_n; i++) {
		memo[i][0] = i;
		for(int j = 1; j < lim_p; j++) {
			memo[i][j] = memo[i][j-1] - memo[i/primes[j-1]][j-1];
		}
	}
}

int cbc(long long n) {
	int ans = std::max(0, (int) pow((double) n, 1.0 / 3) - 2);
	while((long long) ans * ans * ans < n) ans++;
	return ans;
}

long long dp(long long n, int i) {
	if(n == 0) return 0;
	if(i == 0) return n;
	if((long long) primes[i-1] * primes[i-1] > n && n < ms) {
		return id[n] - (i-1);
	} else if(n < lim_n && i < lim_p) {
		return memo[n][i];
	} else {
		return dp(n, i-1) - dp(n / primes[i-1], i-1);
	}
}

long long primeFunction(long long n) {
	if(n < ms) {
		return id[(int)n];
	}
	int i = id[cbc(n)];
	long long ans = dp(n, i) + i - 1;
	while((long long) primes[i] * primes[i] <= n) {
		ans -= primeFunction(n / primes[i]) - i;
		i++;
	}
	return ans;
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	pre();
	long long n;
	std::cin >> n;
	long long ans = 0;
	for(int i = 0; i < (int) primes.size(); i++) {
		if((long long) primes[i] * primes[i] > n) break;
		if((long long) primes[i] * primes[i] * primes[i] <= n) ans++;
		ans += primeFunction(n / primes[i]) - (i+1);
	}
	std::cout << ans << '\n';
}


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

int main() {
	int x1, x2, y1, y2;
	long long m,n;
	cin>>x1>>y1>>x2>>y2;
	m=x2-x1;
	n=y2-y1;
	if(m % 2 == 0){
		cout<<m*(m/2+1)+1+(m+1)*(n/2-m/2)<<endl;
	}
	if(m % 2 != 0){
		cout<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define an "\n"

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if(s.size()==2) {
		if(stoi(s)>=10 && stoi(s)<=19) {
			if(s[1]=='0') {
				cout << "ten";
			}else if(s[1]=='1') {
				cout << "eleven";
			}else if(s[1]=='2') {
				cout << "twelve";
			}else if(s[1]=='3') {
				cout << "thirteen";
			}else if(s[1]=='4') {
				cout << "fourteen";
			}else if(s[1]=='5') {
				cout << "fifteen";
			}else if(s[1]=='6') {
				cout << "sixteen";
			}else if(s[1]=='7') {
				cout << "seventeen";
			}else if(s[1]=='8') {
				cout << "eighteen";
			}else if(s[1]=='9') {
				cout << "nineteen";
			}
			return 0;
		}

		if(s[1]=='0') {
			if(s[0]=='2') {
				cout << "twenty";
			}else if(s[0]=='3') {
				cout << "thirty";
			}else if(s[0]=='4') {
				cout << "forty";
			}else if(s[0]=='5') {
				cout << "fifty";
			}else if(s[0]=='6') {
				cout << "sixty";
			}else if(s[0]=='7') {
				cout << "seventy";
			}else if(s[0]=='8') {
				cout << "eighty";
			}else if(s[0]=='9') {
				cout << "ninety";
			}
			return 0;
		}
		if(s[1]!='0') {
			if(s[0]=='2') {
				cout << "twenty";
			}else if(s[0]=='3') {
				cout << "thirty";
			}else if(s[0]=='4') {
				cout << "forty";
			}else if(s[0]=='5') {
				cout << "fifty";
			}else if(s[0]=='6') {
				cout << "sixty";
			}else if(s[0]=='7') {
				cout << "seventy";
			}else if(s[0]=='8') {
				cout << "eighty";
			}else if(s[0]=='9') {
				cout << "ninety";
			}
			cout << "-";
			if(s[1]=='1') {
				cout << "one";
			}else if(s[1]=='2') {
				cout << "two";
			}else if(s[1]=='3') {
				cout << "three";
			}else if(s[1]=='4') {
				cout << "four";
			}else if(s[1]=='5') {
				cout << "five";
			}else if(s[1]=='6') {
				cout << "six";
			}else if(s[1]=='7') {
				cout << "seven";
			}else if(s[1]=='8') {
				cout << "eight";
			}else if(s[1]=='9') {
				cout << "nine";
			}
			return 0;
		}
	}else {
		if(s[0]=='0') {
			cout << "zero";
			return 0;
		}
		if(s[0]=='1') {
			cout << "one";
		}else if(s[0]=='2') {
			cout << "two";
		}else if(s[0]=='3') {
			cout << "three";
		}else if(s[0]=='4') {
			cout << "four";
		}else if(s[0]=='5') {
			cout << "five";
		}else if(s[0]=='6') {
			cout << "six";
		}else if(s[0]=='7') {
			cout << "seven";
		}else if(s[0]=='8') {
			cout << "eight";
		}else if(s[0]=='9') {
				cout << "nine";
		}
	}
}


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

int main()
{
    int n,a,x,b,y,flag=0,i;
    cin>>n>>a>>x>>b>>y;

    for( i=1;i<=n;i++)
    {

        if(a==b)
        {
            cout<<"YES"<<endl;
            return 0;
        }
if(a==x||b==y)
{
    flag++;
    break;
}
        if(a==n)
            a=0;
         if(b==1)
            b=n+1;

        a++;
           b--;
    }
    if(flag||i==n+1)
        cout<<"NO"<<endl;
}


// luogu-judger-enable-o2
#include<iostream>

using namespace std;

int n, a, b ;

int main(){

    cin >> n >> a >> b;

    cout << ((((a + b) % n + n - 1) % n) + 1) ;

    return 0;

}


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

const int N = 2e6 + 5;

int t;
int n, m, k;

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> m >> k;
		if (n * m % 2)cout << "NO" << endl;
		if (n == 1) {
			if (k != m / 2)cout << "NO" << endl;
			else cout << "YES" << endl;
		}
		else if (m == 1) {
			if (k)cout << "NO" << endl;
			else cout << "YES" << endl;
		}
		else {
			if (m % 2) {
				if (k > n * (m / 2)) {
					cout << "NO" << endl;
				}
				else if (k % 2) {
					cout << "NO" << endl;
				}
				else {
					cout << "YES" << endl;
				}
			}
			else if (n % 2) {
				if (k < m / 2) {
					cout << "NO" << endl;
				}
				else if ((m / 2) % 2) {
					if (k % 2) {
						cout << "YES" << endl;
					}
					else {
						cout << "NO" << endl;
					}
				}
				else {
					if (k % 2) {
						cout << "NO" << endl;
					}
					else {
						cout << "YES" << endl;
					}
				}
			}
			else {
				if (k % 2) {
					cout << "NO" << endl;
				}
				else {
					cout << "YES" << endl;
				}
			}
		}
	}
	return 0;
}


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

int main() {
	double x, n = 0;
	cin >> x;

	while (x > 0) {
		n++;
		x -= (pow(n, 2) + n) / 2;
	}

	if (x < 0)
		cout << n - 1;
	else
		cout << n;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void checkmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<ll,ll> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)

//#define _MSC_VER 1

int n,k,m,a;
struct node{
	int num;
	int t;
	int index;
	int place;
	node(int a,int b,int c,int d){num=a;t=b;index=c;place=d;}
	node(){
		num=0;
		t=200;
	}
};
node ar[200];
bool compare1(node a,node b){
	if(a.num!=b.num){
		return a.num>b.num;
	}
	else
		return a.t<b.t;
}
bool compare2(node a,node b){
	return a.index<b.index;
}
int sum[200];
int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d%d%d",&n,&k,&m,&a);
	for(int i=1;i<=n;i++){
		ar[i]=node(0,200,i,3);

	}
	for(int i=1;i<=a;i++){
		int tmp;
		cin>>tmp;
		ar[tmp].num++;
		ar[tmp].t=i;
	}
	sort(ar+1,ar+n+1,compare1);
	int tt=ar[k+1].num;
	if(k!=n){
		for(int i=k;i>0;i--){
			sum[i]=tt;
			tt+=ar[i].num;
		}

	}
	for(int i=1;i<=n;i++){
		if(i<=k){
			if(m-a==0){
				if(ar[i].num==0){
				ar[i].place=3;
				}
				else
					ar[i].place=1;
				continue;
			}
			if(ar[i].num==0){
				ar[i].place=2;
				continue;
			}
			int end=k+1;
			if(end>n)
				ar[i].place=1;
			else{
				int need=(end-i)*(ar[i].num+1)-sum[i];
				if((m-a<need))
					ar[i].place=1;
				else
					ar[i].place=2;
			}

		}
		else{
			if(m-a==0){
				ar[i].place=3;
				continue;

			}
			if(ar[i].num+m-a<=ar[k].num){
				ar[i].place=3;
			}
			else
				ar[i].place=2;
		}
	}
	sort(ar+1,ar+n+1,compare2);
	for(int i=1;i<=n;i++)
		cout<<ar[i].place<<" ";
	cout<<endl;
	return 0;

}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int flag,maxx;
char st[210000];
int b[30],n;
int main()
{
	scanf("%d",&n);
	scanf("%s",st);
	for (int i=n;i;i--)
		for (int j=0;j<n-i+1;j++)
		{
			flag=0;
			for (int k=0;k<26;k++) b[k]=0;
			for (int k=j;k<=j+i-1;k++)
				if (st[k]>='a'&&st[k]<='z')
				{
					b[st[k]-'a']++;
				} else flag=1;
			if (flag) continue;
			int ans=0;
			for (int k=0;k<26;k++) ans+=b[k]>0;
			maxx=max(maxx,ans);
		}
	printf("%d\n",maxx);
}


#include <iostream>
#include <map>

using std::cin;
using std::cout;
using std::make_pair;

int main() {
  std::ios::sync_with_stdio(false);
  int n, x, y, count = 0;
  cin >> n;
  std::multimap<int, int> m;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    m.insert(make_pair(x, y));
  }

  for (auto i = m.begin(); i != m.end(); ++i) {
    for (auto j = std::next(i,1); j != m.end(); ++j) {
      if (i->first == j->second) {
        count++;
      }
      if (i->second == j->first) {
        count++;
      }
    }
  }
  cout << count;
  return 0;
}


#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define rfr(i,n) for(int i=n-1;i>=0;i--)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define pb push_back
#define debug(P) cout<<#P<<' '<<P<<endl
#define endl '\n'
//#define mod 1000000007

using namespace std;

typedef long long ll;

const int MAXN = 100001;

vector<int> primes;
bool prime[MAXN];

void sieve(){
    fr(i,MAXN)prime[i]=true;
    prime[0]=prime[1]=false;
    for(int i=2;i*i<MAXN;i++){
        for(int j=2*i;j<MAXN;j+=i)prime[j]=false;
    }
    fr(i,MAXN)if(prime[i])primes.pb(i);
}

ll modPower(ll x,ll y,ll mod){
    x%=mod;
    ll res = 1;
    while(y){
        if(y&1)res= (res*x)%mod;
        x = (x*x)%mod;
        y>>=1;
    }
    return res;
}

//vector<int> adj[MAXN];

int dp[26][51];

int n , k;

bool p[27];
int fun(int i , int l ){
    if(l == k){return 0;}

    if(i >= 26) return 100000;

    if(dp[i][l])return dp[i][l];

    if(p[i])return dp[i][l] = min( fun(i+1 , l) , i + 1 + fun(i+2 , l+1) );
    else return dp[i][l] = fun(i+1 , l);
}

int main(){
    cin>>n>>k;
    string s;
    cin>>s;
    if( k > 13){ cout<< -1 << endl; exit(0);}
    fr(i,s.length()){
        p[s[i] - 'a'] = 1;
    }

    int ans = fun( 0 , 0 ) ;

    if(ans == 100000)cout<<"-1\n";
    else cout<<ans<<endl;
}


#include "bits/stdc++.h"
using namespace std;
const int N = 5e6 + 6;
int tt;
long long f[N];
long long get(int x) {
	return (1LL * x * (x - 1) ) / 2LL;
}

long long solve(int x) {
	if(x == 1) return 0;
	long long rekt = (long long) 1e18;
	for(int i = 1; 1LL * i * i <= x; ++i) {
		if(x % i == 0) {
		if(i != 1) {
			rekt = min(rekt , ((x / i) * get(i)) + solve(x / i) );
		}
		if((x / i) != 1 and (x / i) != i) {
			rekt = min(rekt , (i * get(x / i) ) + solve(i) );
		}
	}
	}
	return rekt;
}
const int mod = (int) 1e9 + 7;

long long mul(long long x , long long y) {
	return (x % mod * y % mod) % mod;
}
long long add(long long a , long long b) {
	return (a % mod + b % mod) % mod;
}
int T[N];
int main() {
	for(int i = 0; i < N; ++i) f[i] = (long long) 1e18;
	f[0] = f[1] = 0;
	for(int i = 2; i < N; ++i) f[i] = get(i);
	for(int i = 2; i < N; ++i) {
		long long cur = get(i);
		for(int j = i + i; j < N; j += i) {
			if((j / i) <= i) {
				f[j] = min(f[j] , (1LL * (j / i) * f[i]) + f[j / i] );
				f[j] = min(f[j] , (1LL * i * f[j / i]) + f[i]);
			}
		}
	}
	int t , l , r;
	scanf("%d %d %d" , &t , &l , &r);
	T[0] = 1;
	for(int i = 1; i < N; ++i) {
		T[i] = mul(T[i - 1] , 1LL * t);
	}
	long long ans = 0;
	for(int i = l; i <= r; ++i) {
		ans = add(ans , mul(f[i] , T[i - l]) );
	}
	printf("%lld\n" , ans);
	return 0;
}


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

typedef long long ll;
typedef long double ld;

vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b) {
    int n = a.size();
    int k = b.size();
    int m = b[0].size();
    vector<vector<ll>> c(n, vector<ll>(m, 1e10));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int z = 0; z < k; z++) {
                c[i][j] = min(c[i][j], a[i][z] + b[z][j]);
            }
        }
    }
    return c;
}

vector<vector<ll>> fast_pow(vector<vector<ll>> v, int p) {
    vector<vector<ll>> res = v;
    p--;
    while (p) {
        if (p & 1) {
            res = mul(res, v);
            p--;
        } else {
            v = mul(v, v);
            p /= 2;
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (int &e : a) {
        cin >> e;
    }
    for (int &e : b) {
        cin >> e;
    }
    vector<vector<ll>> v(2 * n, vector<ll>(2 * n, 1e10));
    ll dp[2 * n][2 * n][2 * n];
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            for (int z = 0; z < 2 * n; z++) {
                dp[i][j][z] = 1e10;
            }
        }
    }
    for (int i = 0; i < 2 * n; i++) {
        dp[0][i][i] = 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            for (int z = 0; z < 2 * n; z++) {
                if (z && dp[i - 1][j][z - 1] != 1e10) {
                    dp[i][j][z] = min(dp[i][j][z], dp[i - 1][j][z - 1] + a[i - 1]);
                }
                if (z + 1 < 2 * n && dp[i - 1][j][z + 1] != 1e10) {
                    dp[i][j][z] = min(dp[i][j][z], dp[i - 1][j][z + 1] + b[i - 1]);
                }
            }
        }
    }
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            v[i][j] = dp[n][i][j];
        }
    }
    v = fast_pow(v, m);
    cout << v[0][0];
}


#include<bits/stdc++.h>
using namespace std;
#define sz(v) (int) v.size()
#define all(v) v.begin(),v.end()
#define in freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define ios  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<bool> isPrime(1e7 + 1, 1), ispal(1e7 + 1, 0);

void sieve(int n) {
	isPrime[0] = isPrime[1] = 0;
	for (long long i = 2; i * i <= n; ++i) {
		if (isPrime[i]) {
			for (int j = i * 2; j <= n; j += i)
				isPrime[j] = 0;
		}
	}
}

bool ispalindrome(string s) {
	bool flag=1;
	for(int i=0;i<sz(s)/2;i++) {
		if(s[i]!=s[sz(s)-i-1]) flag=0;
	}
	return flag;
}

int main() {

	sieve(2000000);

	long long a, b;

	cin >> a >> b;

	for (int i = 0; i < 2000000; i++) {
		string s = to_string(i);
		if (ispalindrome(s)) {
			ispal[i] = 1;
		}
	}

	int pal = 0, pr = 0, ans = -1;

	for (int i = 1; i <= 2000000; i++) {
		if(isPrime[i]) pr++;
		if(ispal[i]) pal++;
		if(pr*b<=pal*a) {
			ans=i;
		}
	}

	if(ans==-1) {
		cout << "Palindromic tree is better than splay tree";
	}
	else {
		cout << ans;
	}
	return 0;
}


#include<cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define SZ(x) ((int) (x).size())
#define FE(i,x) for(typedef((x).begin() i=(x).begin();i!=(x).end();i++)

typedef long long int  int64;
typedef unsigned long long int uint64;
typedef long double ldb;
typedef pair <int, int> pii;
typedef vector<int>vi;
typedef vector<string>vs;

template <class T> T sqr (T x) {return x * x;}
int main()
{
  int al,ar;
  int bl,br;
  cin>>al>>ar;
  cin>>bl>>br;

  if((al>=br-3&&al<=br+1)||(ar>=bl-3&&ar<=bl+1)||(br>=al-1&&br<=2*(al+1))||(bl>=ar-1&&bl<=2*(ar+1)))
  {
    printf("YES\n");
  }
  else
    printf("NO\n");

return 0;
}


/*input
4 5
asdf

*/

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int INF = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

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

#define out(container) for (auto it : container) cout << it << " "; cout << endl;

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

  ll n, k;
  cin >> n >> k;
  string str;
  cin >> str;
  vector <vector <int> > lst(n, vector <int> (26, -1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (i) lst[i][j] = lst[i - 1][j];
    }
    lst[i][str[i] - 'a'] = i;
  }
  vector <vector <ll> > dp(n + 1, vector <ll> (n + 1));
  for (int i = 0; i < n; i++) {
    dp[i][1] = 1;
  }
  for (int len = 2; len <= n; len++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < 26; j++) {
        if (lst[i - 1][j] != -1) {
          dp[i][len] = min((ll)1e12, dp[i][len] + dp[lst[i - 1][j]][len - 1]);
        }
      }
    }
  }

  ll ans = 0;
  for (int i = n; i >= 0 && k; i--) {
    ll cnt = 0;
    for (int j = 0; j < 26; j++) {
      if (lst[n - 1][j] != -1) {
        cnt += dp[lst[n - 1][j]][i];
      }
    }
    if (i == 0) cnt = 1;
    if (k >= cnt) {
      ans += cnt * 1ll * (n - i);
      k -= cnt;
    }
    else {
      ans += k * 1ll * (n - i);
      k = 0;
      break;
    }
  }
  cout << (k == 0 ? ans : -1) << endl;

  return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main() {
    long long n;
    cin >> n;
    long long ans = 0;
    if (n == 1) {
        cout << 1;
        return 0;
    }
    if (n == 2) {
        cout << 3;
        return 0;
    }
    if (n == 3) {
        cout << 7;
        return 0;
    }
    for (long long i = 0; i < n - 1ll; i++) {
        ans += (i + 1ll) * (n - i - 1) + 1ll;
    }
    cout << ans + 1ll;
    return 0;
}


#include <cstdio>
#include <vector>
using namespace std;
const int MAXN=500005;
int n, m, q, num, dfc;
int a[MAXN], w[MAXN];
int u[MAXN], v[MAXN], f[MAXN];
int opt[MAXN], ob[MAXN], p[MAXN];
bool cut[MAXN];
int op[MAXN], cl[MAXN];
vector<int> G[MAXN];
int getf(int x)
{
	if (x==f[x]) return x;
	return f[x]=getf(f[x]);
}
void merge(int u, int v)
{
	int x=getf(u), y=getf(v);
	if (x!=y)
	{
		f[x]=f[y]=++num;
		G[num].push_back(x);
		G[num].push_back(y);
	}
}
void DFS(int u)
{
	op[u]=++dfc;
	for (int v: G[u]) DFS(v);
	cl[u]=dfc;
}
namespace SGT
{
	struct Node
	{
		int l, r;
		pair<int, int> val;
	} tr[4*MAXN];
#define lc (o<<1)
#define rc (o<<1|1)
	void pushup(int o)
	{
		tr[o].val=max(tr[lc].val, tr[rc].val);
	}
	void build(int o, int l, int r, int* a)
	{
		tr[o].l=l, tr[o].r=r;
		if (l==r) return tr[o].val=make_pair(a[l], l), void();
		int mid=(l+r)>>1;
		build(lc, l, mid, a);
		build(rc, mid+1, r, a);
		pushup(o);
	}
	pair<int, int> query(int o, int l, int r)
	{
		if (tr[o].l>r||tr[o].r<l) return make_pair(0, 0);
		if (l<=tr[o].l&&tr[o].r<=r) return tr[o].val;
		return max(query(lc, l, r), query(rc, l, r));
	}
	void modify(int o, int p)
	{
		if (tr[o].l==tr[o].r) return tr[o].val.first=0, void();
		int mid=(tr[o].l+tr[o].r)>>1;
		if (p<=mid) modify(lc, p);
		else modify(rc, p);
		pushup(o);
	}
#undef lc
#undef rc
}
int main()
{
//	freopen("D.in", "r", stdin);
//	freopen("D.out", "w", stdout);
	scanf("%d%d%d", &n, &m, &q);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	for (int i=1; i<=m; i++) scanf("%d%d", &u[i], &v[i]);
	for (int i=1; i<=n+m; i++) f[i]=i;
	for (int i=1; i<=q; i++)
	{
		scanf("%d%d", &opt[i], &ob[i]);
		if (opt[i]==2) cut[ob[i]]=1;
	}
	num=n;
	for (int i=1; i<=m; i++)
		if (!cut[i]) merge(u[i], v[i]);
	for (int i=q; i>=1; i--)
		if (opt[i]==1) p[i]=getf(ob[i]);
		else merge(u[ob[i]], v[ob[i]]);
	for (int i=1; i<=num; i++)
		if (getf(i)==i) DFS(i);
	for (int i=1; i<=num; i++) w[op[i]]=a[i];
	SGT::build(1, 1, num, w);
	for (int i=1; i<=q; i++)
		if (opt[i]==1)
		{
			auto ret=SGT::query(1, op[p[i]], cl[p[i]]);
			printf("%d\n", ret.first);
			SGT::modify(1, ret.second);
		}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(false)
#define For(i, x, y) for(int i = x; i <= y; i++)
#define For_(i, x, y) for(int i = x; i >= y; i--)
const int inf = 0x3f3f3f3f;
const ll Inf = 1e18;
const int mod = 1e9 + 7;

ll fastpow(ll x, ll k)
{
	ll base = x;
	ll ret = 1;
	while (k) {
		if (k & 1) {
			ret *= base;
			ret %= mod;
		}
		base *= base;
		base %= mod;
		k >>= 1;
	}
	return ret;
}

int main(void)
{
	ll a, b, x, n;
	cin >> a >> b >> n >> x;
	if (a == 1) {
		cout << (n % mod * b + x) % mod << endl;
		return 0;
	}
	ll tmp = fastpow(a, n);
	cout << (((tmp - 1) * fastpow(a - 1, mod - 2) % mod) * b % mod + tmp * (x % mod) % mod) % mod << endl;
	return 0;
}


#include <string.h>
#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
const int N = 400000;
const int M = 2000001;
const double eps = 1e-7;

const ll mod = 1000000007;

int n,q;
int p[M];
int cnt[M],num[M];
int fa[M];
int is[M],pr[M];
int ct;

void init() {
	for(int i = 2; i <M; ++i) {
		if(!is[i]) {
			pr[ct++]=i;
			fa[i]=i;
		}
		for(int j = 0; j < ct&&i*pr[j]<M;++j){
			is[i*pr[j]]=1;
			fa[i*pr[j]]=pr[j];
			if(i%pr[j]==0)break;
		}
	}
}

int main() {
	init();
	cin>>n;
	fr(i,0,n) {
		sf("%d",&p[i]);
	}
	sort(p,p+n);
	ll ans = 1;
	for(int i = n-1; i >=0; --i) {
		if(!cnt[p[i]]) {
			cnt[p[i]]=1;
			num[p[i]]=1;
			ans = (ans * p[i])%mod;
			//printf("i = %d ans = %lld\n",i,ans);
		}
		else {
			int v = --p[i];
			while(v>1) {
				int u = fa[v];
				//printf("i = %d v = %d u = %d\n",i,v,u);
				int nu = 0;
				while(v%u==0)v/=u,nu++;
				if(cnt[u]<nu) {
					for(int j = cnt[u];j < nu; ++j) {
						ans = (ans * u)%mod;
					}
					cnt[u]=nu;
					num[u]=1;
				}
				else {
					if(cnt[u]==nu) num[u]++;
				}
				//printf("factor = %d nu = %d ans = %lld\n",u,nu, ans);
			}
		}
	}
	fr(i,0,n) {
		int flag = 0;
		int v = p[i];
		while(v>1) {
			int u = fa[v];
			int nu = 0;
			while(v%u==0)v/=u,nu++;
			//printf("factor = %d nu = %d ans = %lld\n",u,nu, ans);
			//printf("v = %d factor = %d nu = %d cnt = %d num = %d\n",v,u,nu,cnt[u],num[u]);
			if(cnt[u]==nu&&num[u]==1) flag = 1;
		}

		if(!flag) {
			ans++;
			break;
		}
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double

int n;
int a[1000007];
int ans = 1e9;

int dd[33];
int kk = 0;

void check(int x){
	if (a[x] == 0) return;
	kk = 0;
	int save = x;
	while(1){
		if (a[x] == 0) break;
		dd[kk++] = a[x];
		x /= a[x];
	}
	dd[kk++] = x;
	for (int i = 0; i < kk; i++){
		if (save - dd[i] + 1 >= 3) ans = min(ans, save - dd[i] + 1);
	}
}

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 2; i < 1000007; i++) if (a[i] == 0){
    	for (int j = 2 * i; j < 1000007; j += i){
    		if (a[j] == 0) a[j] = i;
    	}
    }
    int save = n;
    set<int> se;
    while(1){
    	if (a[n] == 0) break;
    	se.insert(a[n]);
    	n /= a[n];
    }
    se.insert(n);
    ans = save;
    for (int x : se){
    	for (int i = save; i >= save - x + 1; i--){
    		check(i);
    	}
    }
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
       string str;
       cin>>str;
       int count1=0,count2=0;
       for(int i=0;i<str.size();i++)
       {
              if(str[i]=='4')
              count1++;
              else if(str[i]=='7')
              count2++;
       }
       if(count2>count1)
       {
              cout<<"7";return 0;
       }
       if(count1>count2)
       {
              cout<<"4";return 0;
       }
       else if(count1==count2 && count1!=0 && count2!=0)
       {
              cout<<"4";return 0;
       }
       cout<<"-1";
       return 0;
}


// powered by c++11
// by Isaunoya
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize( \
    "inline,-fgcse,-fgcse-lm,-fipa-sra,-ftree-pre,-ftree-vrp,-fpeephole2,-ffast-math,-fsched-spec,unroll-loops,-falign-jumps,-falign-loops,-falign-labels,-fdevirtualize,-fcaller-saves,-fcrossjumping,-fthread-jumps,-funroll-loops,-freorder-blocks,-fschedule-insns,inline-functions,-ftree-tail-merge,-fschedule-insns2,-fstrict-aliasing,-fstrict-overflow,-falign-functions,-fcse-follow-jumps,-fsched-interblock,-fpartial-inlining,no-stack-protector,-freorder-functions,-findirect-inlining,-fhoist-adjacent-loads,-frerun-cse-after-loop,inline-small-functions,-finline-small-functions,-ftree-switch-conversion,-foptimize-sibling-calls,-fexpensive-optimizations,inline-functions-called-once,-fdelete-null-pointer-checks")

#include <bits/stdc++.h>

#define rep(i, x, y) for (register int i = (x); i <= (y); ++i)
#define Rep(i, x, y) for (register int i = (x); i >= (y); --i)

using namespace std;
using db = double;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;

using pii = pair<int, int>;

#define fir first
#define sec second

template <class T>

void cmax(T& x, const T& y) {
  if (x < y) x = y;
}

template <class T>

void cmin(T& x, const T& y) {
  if (x > y) x = y;
}

#define all(v) v.begin(), v.end()
#define sz(v) ((int)v.size())
#define pb emplace_back

template <class T>

void sort(vector<T>& v) {
  sort(all(v));
}

template <class T>

void reverse(vector<T>& v) {
  reverse(all(v));
}

template <class T>

void unique(vector<T>& v) {
  sort(all(v)), v.erase(unique(all(v)), v.end());
}

void reverse(string& s) { reverse(s.begin(), s.end()); }

const int io_size = 1 << 23 | 233;
const int io_limit = 1 << 22;
struct io_in {
  char ch;
#ifndef __WIN64
  char getchar() {
    static char buf[io_size], *p1 = buf, *p2 = buf;

    return (p1 == p2) && (p2 = (p1 = buf) + fread(buf, 1, io_size, stdin), p1 == p2) ? EOF : *p1++;
  }
#endif
  io_in& operator>>(char& c) {
    for (c = getchar(); isspace(c); c = getchar())
      ;

    return *this;
  }
  io_in& operator>>(string& s) {
    for (s.clear(); isspace(ch = getchar());)
      ;

    if (!~ch) return *this;

    for (s = ch; !isspace(ch = getchar()) && ~ch; s += ch)
      ;

    return *this;
  }

  io_in& operator>>(char* str) {
    char* cur = str;
    while (*cur) *cur++ = 0;

    for (cur = str; isspace(ch = getchar());)
      ;
    if (!~ch) return *this;

    for (*cur = ch; !isspace(ch = getchar()) && ~ch; *++cur = ch)
      ;

    return *++cur = 0, *this;
  }

  template <class T>

  void read(T& x) {
    bool f = 0;
    while ((ch = getchar()) < 48 && ~ch) f ^= (ch == 45);

    x = ~ch ? (ch ^ 48) : 0;
    while ((ch = getchar()) > 47) x = x * 10 + (ch ^ 48);
    x = f ? -x : x;
  }

  io_in& operator>>(int& x) { return read(x), *this; }

  io_in& operator>>(ll& x) { return read(x), *this; }

  io_in& operator>>(uint& x) { return read(x), *this; }

  io_in& operator>>(ull& x) { return read(x), *this; }

  io_in& operator>>(db& x) {
    read(x);
    bool f = x < 0;
    x = f ? -x : x;
    if (ch ^ '.') return *this;

    double d = 0.1;
    while ((ch = getchar()) > 47) x += d * (ch ^ 48), d *= .1;
    return x = f ? -x : x, *this;
  }
} in;

struct io_out {
  char buf[io_size], *s = buf;
  int pw[233], st[233];

  io_out() {
    set(7);
    rep(i, pw[0] = 1, 9) pw[i] = pw[i - 1] * 10;
  }

  ~io_out() { flush(); }

  void io_chk() {
    if (s - buf > io_limit) flush();
  }

  void flush() { fwrite(buf, 1, s - buf, stdout), fflush(stdout), s = buf; }

  io_out& operator<<(char c) { return *s++ = c, *this; }

  io_out& operator<<(string str) {
    for (char c : str) *s++ = c;
    return io_chk(), *this;
  }

  io_out& operator<<(char* str) {
    char* cur = str;
    while (*cur) *s++ = *cur++;
    return io_chk(), *this;
  }

  template <class T>

  void write(T x) {
    if (x < 0) *s++ = '-', x = -x;

    do {
      st[++st[0]] = x % 10, x /= 10;
    } while (x);

    while (st[0]) *s++ = st[st[0]--] ^ 48;
  }

  io_out& operator<<(int x) { return write(x), io_chk(), *this; }

  io_out& operator<<(ll x) { return write(x), io_chk(), *this; }

  io_out& operator<<(uint x) { return write(x), io_chk(), *this; }

  io_out& operator<<(ull x) { return write(x), io_chk(), *this; }

  int len, lft, rig;

  void set(int _length) { len = _length; }

  io_out& operator<<(db x) {
    bool f = x < 0;
    x = f ? -x : x, lft = x, rig = 1. * (x - lft) * pw[len];
    return write(f ? -lft : lft), *s++ = '.', write(rig), io_chk(), *this;
  }
} out;
#define int long long

template <int sz, int mod>

struct math_t {
  math_t() {
    fac.resize(sz + 1), ifac.resize(sz + 1);
    rep(i, fac[0] = 1, sz) fac[i] = fac[i - 1] * i % mod;

    ifac[sz] = inv(fac[sz]);
    Rep(i, sz - 1, 0) ifac[i] = ifac[i + 1] * (i + 1) % mod;
  }

  vector<int> fac, ifac;

  int qpow(int x, int y) {
    int ans = 1;
    for (; y; y >>= 1, x = x * x % mod)
      if (y & 1) ans = ans * x % mod;
    return ans;
  }

  int inv(int x) { return qpow(x, mod - 2); }

  int C(int n, int m) {
    if (n < 0 || m < 0 || n < m) return 0;
    return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
  }
};

int gcd(int x, int y) { return !y ? x : gcd(y, x % y); }
int lcm(int x, int y) { return x * y / gcd(x, y); }

const int maxn = 8e6 + 63;
const int P = 998244353;
const int G = 3;
const int Gi = 332748118;

int n, m, rev[maxn];
int a[maxn], b[maxn];
int limit = 1;
int Inv = 0;

inline int qpow(int x, int y) {
  int ans = 1;
  for (; y; y >>= 1, x = x * x % P)
    if (y & 1) ans = ans * x % P;
  return ans;
}

inline int inc(const int& x, const int& y) { return (x + y >= P) ? (x + y - P) : x + y; }
inline int dec(const int& x, const int& y) { return (x - y >= 0) ? x - y : (x - y + P); }
inline void swap(int& x, int& y) { x ^= y ^= x ^= y; }

void NTT(int* A, int type) {
  rep(i, 0, limit) if (i < rev[i]) swap(A[i], A[rev[i]]);
  for (int len = 1; len < limit; len <<= 1) {
    int Wn = qpow(type == 1 ? G : Gi, (P ^ 1) / (len << 1));
    for (int i = 0; i < limit; i += len << 1) {
      int w = 1;
      for (int j = 0, x, y; j < len; j++, w = w * Wn % P) {
        x = A[i + j], y = A[i + j + len] * w % P;
        A[i + j] = inc(x, y), A[i + j + len] = dec(x, y);
      }
    }
  }
  if (type == -1) {
    for (int i = 0; i < limit; i++) A[i] = A[i] * Inv % P;
  }
}

void init(int n) {
  limit = 1;
  int l = 0;
  while (limit <= n) {
    limit <<= 1, ++l;
  }
  for (int i = 0; i < limit; i++) rev[i] = rev[i >> 1] >> 1 | (i & 1) << l - 1;
  Inv = qpow(limit, P - 2);
}

signed main() {
  // code begin.
  in >> n >> m;
  n >>= 1;
  while (m--) {
    int x;
    in >> x;
    b[x] = 1;
  }
  a[0] = 1;
  init(10 << 2);
  while (n) {
    if (n & 1) {
      int mx = 0;
      for (int i = 0; i < limit; i++)
        if (b[i]) mx = i;
      init(mx << 2);
      NTT(a, 1), NTT(b, 1);
      for (int i = 0; i < limit; i++) a[i] = a[i] * b[i] % P;
      NTT(a, -1), NTT(b, -1);
    }
    int mx = 0;
    for (int i = 0; i < limit; i++)
      if (b[i]) mx = i;
    init(mx << 2);
    NTT(b, 1);
    for (int i = 0; i < limit; i++) b[i] = b[i] * b[i] % P;
    NTT(b, -1);
    n >>= 1;
  }
  int ans = 0;
  for (int i = 0; i < limit; i++) ans = inc(ans, (a[i] * a[i]) % P);
  out << ans << '\n';
  return 0;
  // code end.
}


#pragma GCC optimize("O3")
#ifdef ONLINE_JUDGE
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#include <deque>
#include <type_traits>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
template<typename Key=int,typename Mapped=__gnu_pbds::null_type,typename Cmp_Fn=std::less<Key>,typename Tag=__gnu_pbds::rb_tree_tag,template<typename Const_Node_Iterator,typename Node_Iterator,typename Cmp_Fn_,typename Allocator_>class Node_Update=__gnu_pbds::tree_order_statistics_node_update,typename Allocator=std::allocator<char>>class ordered_set_t:__gnu_pbds::tree<Key,Mapped,Cmp_Fn,Tag,Node_Update,Allocator>{};const int GRANDOM=std::chrono::high_resolution_clock::now().time_since_epoch().count();struct ghash{int operator()(int x){return std::hash<int>{}(x^GRANDOM);}};template<typename KeyType>class hash_table_t:__gnu_pbds::gp_hash_table<KeyType,int,ghash>{};namespace vh{template<class T>void _R(T&x){std::cin>>x;}inline void _R(int&x){scanf("%d",&x);}inline void _R(int64_t&x){scanf("%" SCNd64,&x);}inline void _R(double&x){scanf("%lf",&x);}inline void _R(char&x){scanf(" %c",&x);}inline void _R(char*x){scanf("%s",x);}inline void R(){}template<class T,class... U>inline void R(T&head,U&... tail){_R(head);R(tail...);}template<class T>void _W(const T&x){cout<<x;}inline void _W(const int&x){printf("%d",x);}inline void _W(const int64_t&x){printf("%" PRId64,x);}inline void _W(const double&x){printf("%.16f",x);}inline void _W(const char&x){putchar(x);}inline void _W(const char*x){printf("%s",x);}template<class T>inline void _W(const vector<T>&x){for(auto i=x.begin();i!=x.end();_W(*i++))if(i!=x.cbegin())putchar(' ');}inline void W(){}template<class T,class... U>inline void W(const T&head,const U&... tail){_W(head);if(sizeof...(tail))putchar(' '),W(tail...);}template<class T,class... U>inline void WL(const T&head,const U&... tail){_W(head);putchar(sizeof...(tail)? ' ':'\n');W(tail...);}};
#define prec setprecision
namespace vh{typedef long long ll;typedef unsigned long long llu;template<typename T>T gcd(T m,T n){while(n){T t=m%n;m=n;n=t;};return m;}template<typename T>T exgcd(T a,T b,T&sa,T&ta){T q,r,sb=0,tb=1,sc,tc;sa=1,ta=0;if(b)do q=a/b,r=a-q*b,a=b,b=r,sc=sa-q*sb,sa=sb,sb=sc,tc=ta-q*tb,ta=tb,tb=tc;while(b);return a;}template<typename T>T mul_inv(T a,T b){T t1=a,t2=b,t3;T v1=1,v2=0,v3;T x;while(t2!=1)x=t1/t2,t3=t1-x*t2,v3=v1-x*v2,t1=t2,t2=t3,v1=v2,v2=v3;return(v2+b)%b;}template<typename T>T powmod(T a,T b,T MOD){if(b<0)return 0;T rv=1;while(b)(b%2)&&(rv=(rv*a)%MOD),a=a*a%MOD,b/=2;return rv;}template<typename T>inline T isqrt(T k){T r=sqrt((double)k)+1;while(r*r>k)r--;return r;}template<typename T>inline T icbrt(T k){T r=cbrt((double)k)+1;while(r*r*r>k)r--;return r;}template<typename T>bool mul_overflow(T&r,T a,T b){return __builtin_mul_overflow(a,b,&r);}template<ll n>struct BitSize{enum{Size=BitSize<n/2>::Size+1};};template<>struct BitSize<0>{enum{Size=1};};template<>struct BitSize<1>{enum{Size=1};};
#define BITSIZE(n) (BitSize<n>::Size)
#define BITMAX(n) (BitSize<n>::Size - 1)
#define DEBUG !defined(ONLINE_JUDGE)
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RALL(x) (x).rbegin(),(x).rend()
template<typename TH>void _dbg(const char*sdbg,TH h){cerr<<sdbg<<"="<<h<<"\n";}template<typename TH,typename... TA>void _dbg(const char*sdbg,TH h,TA... t){while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<",";_dbg(sdbg+1,t...);}
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; for(auto itt: x) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
}namespace vh{template<typename T>int min_rotation(vector<T>s){int a=0,N=s.size();for(int b=0;b<N;b++)for(int i=0;i<N;i++){if(a+i==b||s[(a+i)%N]<s[(b+i)%N]){b+=max(0,i-1);break;}if(s[(a+i)%N]>s[(b+i)%N]){a=b;break;}}return a;}}namespace vh{template<ll MOD,typename T=ll>class FiniteField{typedef FiniteField<MOD,T>self;public:ll val;FiniteField(ll x=0):val(normalize(x)){}inline T normalize(T x){x%=MOD;return normalize2(x);}inline T normalize2(T x){if(x<0)x+=MOD;if(x>=MOD)x-=MOD;return x;}self&operator=(const self&o){val=o.val;return*this;}template<typename NT>self&operator=(const NT o){val=normalize(o);return*this;}self&operator+=(const self&o){val=normalize2(val+o.val);return*this;}template<typename NT>self&operator+=(const NT o){val=normalize(val+(o));return*this;}self&operator-=(const self&o){val=normalize2(val-o.val);return*this;}template<typename NT>self&operator-=(const NT o){val=normalize(val-(o));return*this;}self&operator*=(const self&o){return*this*=o.val;}template<typename NT>self&operator*=(const NT o){val=normalize(val*o);return*this;}self operator+(const self&o){return self(normalize2(val+o.val));}template<typename NT>self operator+(const NT o){return self(normalize2(val+(o)));}self operator-(const self&o){return self(normalize2(val-o.val));}template<typename NT>self operator-(const NT o){return self(normalize2(val-(o)));}self operator-(){return self(normalize(-val));}self operator*(const self&o){return self(normalize(val*o.val));}template<typename NT>self operator*(const NT o){return self(normalize(val*(o)));}operator T()const{return val;}};};namespace vh{};
namespace vh{
  const int maxn=3e5+7;
  const ll MOD=998244353;
  int n;
  vector<int>adj[maxn];
  typedef FiniteField<MOD>number_t;
  struct DPE{
    number_t matched;
    number_t unmatched;
    number_t unused;
  };
  DPE solve(int u,int p){
    DPE r={1,0,1};
    vector<number_t>matchable;
    vector<number_t>matched;
    for(int v:adj[u]){
      if(v!=p){
        auto r2=solve(v,u);
        auto r2matchable=r2.unmatched+r2.unused;
        matchable.push_back(r2matchable);
        matched.push_back(r2.matched);
        r.matched*=r2matchable;
        r.unused*=r2.unused;
     }
    }
    int sz=matchable.size();
    if(sz){
      vector<number_t>matchableLeft(sz,0);
      vector<number_t>matchableRight(sz,0);
      matchableLeft[0]=1;
      for(int i=1;i<sz;i++)matchableLeft[i]=matchableLeft[i-1]*matchable[i-1];
      matchableRight[sz-1]=1;
      for(int i=sz-2;i>=0;i--)matchableRight[i]=matchableRight[i+1]*matchable[i+1];
      for(int i=0;i<sz;i++){
        r.unmatched+=matchableLeft[i]*matched[i]*matchableRight[i];
      }
    }
    r.unused+=r.unmatched;
    return r;
  }
  int main(){
    srand(GRANDOM);
    cin>>n;
    for(int i=2;i<=n;i++){
      int u,v;cin>>u>>v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    cout<<(solve(1,0).unused).val<<endl;
    return 0;
  }
};
int main(int argc,char*argv[]){
  std::cin.sync_with_stdio(false);std::cin.tie(nullptr);
  return vh::main();
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i=2;
	while(n%i)
	{
	i++;
	}
	cout<<i<<n/i<<"\n";
}


#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;
long long mod=1e9+7;
char b[10005];
long long quickpow(long long a,int n)
{
    long long ans=1;
    while(n)
    {
        if(n&1)
        {
           ans=ans*a%mod;
        }
        n>>=1;
        a=a*a%mod;
    }
    return ans;
}
long long quickpow_ten(long long a,int n)
{
    long long ans=1;
    for(int i=n-1;i>=0;i--)
    {
        ans=ans*quickpow(a,b[i]-'0')%mod;
        a=quickpow(a,10);
    }
    return ans;
}
int main()
{
    long long n;
    scanf("%s",&b);
    int len=strlen(b);
    if(len==1&&b[0]=='0')
        puts("1");
    else
    {
        long long k=quickpow_ten(2,len)%mod;
        long long res=k*(k+1)/2%mod;
        printf("%I64d\n",res);
    }

    return 0;
}

/*2018-07-17 20:59:25.825*/


//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 1000000000
#define ldb long double
#define pb push_back
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE ll i=p;i<=n;++i)
#define go(x) for(ll i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE ll i=n;i>=p;--i)
#define pii pair<ll,ll>
#define mk make_pair
#define RE register
#define P 1000000007
#define mod 998244353
#define S second
#define F first
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define ull unsigned long long
#define ui unsigned
#define zz p<<1
#define yy p<<1|1
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    register ll x=0,f=1;register char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const ll MAXN=200010;
ll n,k;
ll fac[MAXN],inv[MAXN];
inline ll C(ll a,ll b){if(a<b)return 0;return fac[a]*inv[b]%mod*inv[a-b]%mod;}
inline ll ksm(ll b,ll p)
{
	ll cnt=1;
	while(p)
	{
		if(p&1)cnt=cnt*b%mod;
		b=b*b%mod;p=p>>1;
	}
	return cnt;
}
signed main()
{
	//freopen("1.in","r",stdin);
	get(n);get(k);
	if(k>=n){puts("0");return 0;}
	fac[0]=1;
	rep(1,n,i)fac[i]=fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	fep(n-1,0,i)inv[i]=inv[i+1]*(i+1)%mod;
	if(!k)putl(fac[n]);
	else
	{
		ll ans=0;
		rep(0,n-k,i)
		{
			ans=(ans+C(n,n-k)*((i&1)?-1:1)*C(n-k,i)%mod*ksm(n-k-i,n))%mod;
		}
		putl((ans+mod)%mod*2%mod);
	}
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<stdio.h>
#include<string>
#include<set>
#include<iomanip>
#include<numeric>
#include<map>
#include<limits>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<deque>
#include<queue>

using namespace std;

bool is_palindorme(string s, int r, int l)
{
	for (int i = r; i <= l; i++)
	{
		if (s[i] != s[l - i + r])
		{
			return 0;
		}
	}
	return 1;
}

int count(int a, int b)
{
	int count = 1;
	while (a / b > 0)
	{
		a /= b;
		count++;
	}
	return count;
}

void find_node(vector<int>& a, vector<int>& b, int s, int e, int curr)
{
	int pos = s;
	if (s == e)
	{
		b[s] = curr + 1;
		return;
	}
	if (e < s)
	{
		return;
	}
	for (int i = s; i <= e; i++)
	{
		if (a[pos] < a[i])
		{
			pos = i;
		}
	}
	b[pos] = curr + 1;
	curr++;
	find_node(a, b, s, pos - 1, curr);
	find_node(a, b, pos + 1, e, curr);
}

void checknbh(vector<string>& a, vector<vector<int>>& b, int i, int j, int n)
{
	int flag = 0;
	if (i > 0 && a[i - 1][j] == 'L' && b[i - 1][j] != 1)
	{
		b[i - 1][j] = 1;
		flag = 1;
		checknbh(a, b, i - 1, j, n);

	}
	if (i < n - 1 && a[i + 1][j] == 'L' && b[i + 1][j] != 1)
	{
		b[i + 1][j] = 1;
		flag = 1;
		checknbh(a, b, i + 1, j, n);

	}
	if (j > 0 && a[i][j - 1] == 'L' && b[i][j - 1] != 1)
	{
		b[i][j - 1] = 1;
		flag = 1;
		checknbh(a, b, i, j - 1, n);

	}
	if (j < n - 1 && a[i][j + 1] == 'L' && b[i][j + 1] != 1)
	{
		b[i][j + 1] = 1;
		flag = 1;
		checknbh(a, b, i, j + 1, n);
	}
}

bool compareInterval(long long i1, long long  i2)
{
	return (i1 < i2);
}

bool isPrime(int n)
{
	// Corner case
	if (n <= 1)
		return false;

	// Check from 2 to n-1
	for (int i = 2; i <= sqrt(n); i++)
		if (n % i == 0)
			return false;

	return true;
}

void toh(int n, char A, char B, char C) {
	if (n == 1) {
		cout << "Move 1 from " << A << " to " << C << endl;
		return;
	}
	toh(n - 1, A, C, B);
	cout << "Move " << n << " from " << A << " to " << C << endl;
	toh(n - 1, B, A, C);
}

void generate(vector<string>& a, string s, int t) {
	if (s.length() == t) {
		a.push_back(s);
		return;
	}
	if (s.length() == 0 || s.back() == 'R') {
		generate(a, s + "S", t);
		generate(a, s + "R", t);
	}
	else {
		generate(a, s + "R", t);
	}
}

int addOne(deque<int>& a, int t, int i) {
	int temp = 0;
	if (i == t - 1)
	{
		a[i] += 1;
		temp = a[i] / 10;
		a[i] %= 10;
	}
	else {
		a[i] += addOne(a, t, i + 1);
		if (i == 0 && a[0] >= 10)
		{
			a.push_front(a[0] / 10);
			a[1] %= 10;
		}
		else {
			temp = a[i] / 10;
			a[i] %= 10;
		}
	}
	return temp;
}

void reversec(set<string>& a, string s) {
	string t(s);
	reverse(t.begin(), t.end());
	a.insert(s + t);
	a.insert(t + s);
}

int num_digits(int a) {
	int digits = 0;
	while (a > 0) {
		a /= 10;
		digits++;
	}
	return digits;
}

void search(long long x, long long n,long long count, long long &ans) {
	int digits = 0;
	long long a = x;
	while (a > 0) {
		a /= 10;
		digits++;
	}
	if (digits == n) {
		return;
	}
	long long y = x;
	while (y > 0) {
		int temp = y % 10;
		if (temp > 1) {
			search(x * temp, n, count + 1, ans);
		}
		y /= 10;
	}
}

map<long long, long long>m;
long long ans = 1e9;
long long n;
void reqlen( long long count,long long x) {
	if (x >= n) {
		ans = min(ans, count);
		return;
	}
	long long y = x;
	while (y > 0) {
		long long c = y % 10;
		if (c > 1) {
			if (m.count(c * x) == 0 || count+1<m[c*x])
			{
				m[c * x] = count+1;
				reqlen(count+1, c * x);
			}
		}
		y /= 10;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long t, q, x, l, y, r, g, k,  p, c;
//	long long n,m;
	string s;
	cin >> n >> x;
	n = pow(10, n - 1);
	reqlen(0, x);
	cout << (ans==1e9?-1:ans) << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	int cnt1 = 0, cnt2=0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1 && b[i] == 0) cnt1++;
		if (a[i] == 0 && b[i] == 1) cnt2++;
	}
	if (cnt1 != 0) cout << (cnt2 + cnt1) / cnt1;
	else cout << -1;
}


#include<bits/stdc++.h>
#define lld long long int
#define ulld unsigned long long
#define vll vector<lld>
#define pll pair<lld,lld>
#define mll map<lld,lld>
#define sll set<lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define MOD 1000000007 //998244353
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define out(x) cout<<x<<endl;
#define MAXN 500005
#define lld_max 5000000000000000000
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int sum(int a, int b) {
    int s = a + b;
    if (s >= MOD) s -= MOD;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % MOD;
}
int pw(int a, int b) {
    if (b == 0) return 1;
    if (b & 1) return mult(a, pw(a, b - 1));
    int res = pw(a, b / 2);
    return mult(res, res);
}
int main() {messi lld t=1;cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0,lm=0,cur=0,curr=0;string s;bool flag=false;
        cin>>n>>k;
        if (n % 2 == 1) {
            ans = 1;
            for (i = 1; i <= n - 1; i++) ans = mult(ans, 2);
            ans = sum(ans, 1);
            int f = 1;
            for (z = 0; z < k; z++) f = mult(f, ans);
            cout<<f<<endl;
        }
        else {
            ans = 1;
            for (i = 1; i <= n - 1; i++) ans = mult(ans, 2);
            int X = pw(2, n);
            int nans = (ans + MOD - 1) % MOD;
            int tot = pw(nans, k);
            for (int bit = 0; bit < k; bit++) {
                tot = sum(tot, mult(pw(X, bit), pw(nans, k - 1 - bit)));
            }
            cout<<tot<<endl;
        }
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
#define fr(i,a,b) for (ll i=(a); i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (int)a.size()
#define endl "\n"

#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define print2(a) for(auto x:a){for(auto y:x)cout<<y<<" ";cout<<endl;};

const ll M=998244353;
const int P=31;
const int MaxM=1001;

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

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

if(n==1)cout<<1<<endl;
else
{ ll k=sqrt(n);
  ll fin;
  fr(i,k,M)
  {
    ll t=i*i+i;
    t/=2;
    if(t>n){fin=i-1;break;}
  }
  ll fi=fin;
  fin*=fin+1;
  fin/=2;
  n-=fin;
  if(n==0)n=fi;
  cout<<n<<endl;
}

}


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

int main()
{
	int n = 1;
	int si;
	cin >> si;
	string str;
	cin >> str;

	for (int i = 0; i < si; i += n) {
		cout << str[i];
		n++;
	}

}


#include<bits/stdc++.h>
using namespace std;
#define N 255
#define Mod 998244353
#define For(i,x,y)for(i=x;i<=(y);i++)
int f[N][N][N],pre[N][N][N],g[N][N],inv[N];
int ksm(int x,int y)
{
	return(!y?1:1LL*ksm(1LL*x*x%Mod,y>>1)*(y&1?x:1)%Mod);
}
int main()
{
	int n,k,i,j,p,num,tmp,res=0;
	cin>>n>>k;
	For(j,1,k)f[1][j][1]=1;
	For(i,1,n-1)inv[i]=ksm(i,Mod-2);
	For(i,1,k)
	{
		g[i][0]=1;
		For(j,1,n)g[i][j]=1LL*g[i][j-1]*i%Mod;
	}
	For(i,2,n-1)
	{
		For(j,1,k)
		For(num,1,i-1)pre[i-1][j][num]=(pre[i-1][j-1][num]+f[i-1][j][num])%Mod;
		For(j,1,k)
		For(num,1,i-1)
		{
			p=j;
			tmp=(p==j?num+1:1);
			f[i][j][tmp]=(f[i][j][tmp]+1LL*f[i-1][p][num]*inv[tmp]%Mod*g[k-j+1][i-1])%Mod;
			tmp=1;
			f[i][j][tmp]=(f[i][j][tmp]+1LL*pre[i-1][j-1][num]*inv[tmp]%Mod*g[k-j+1][i-1])%Mod;
		}
	}
	For(j,1,k)
	For(num,1,n-1)res=(res+f[n-1][j][num])%Mod;
	For(i,1,n-1)res=1LL*res*i%Mod;
	cout<<res;
	return 0;
}


/*input
2 2
1 2 3 4
1 5 6 4

2 3
1 2 4 5
1 2 1 3 2 3

*/

//fold
/*
When you walk through a storm
Hold your head up high
And don't be afraid of the dark
At the end of the storm
There's a golden sky
And the sweet silver song
of the lark
Walk on, through the wind
Walk on, through the rain
Though your dreams be tossed
and blown
Walk on, walk on
With hope in your heart
And you'll never walk alone
YNWA
*/

//hell_hacker
//IT TAKES EVERYTHING and IT IS NOT LUCK
//PICK ME LAST -- COME OUT OF N^WHERE
//WHY NOT?

/*
And you came my way on a winner's day
Shouted loudly come out and play
Can't you tell I got news for you
Sun is shining and so are you
*/
//endfold

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define fo(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>=0;--i)

#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define popcll(a) __builtin_popcountll(a) //count set bits for long long int

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define yolo "debug_statement"

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

const ll inf = 1e9;
const ld eps = 1e-9;
const ld pi=acos(-1);
const ll mod=1000000007;

ll powmod(ll a,ll b,ll mo=mod){ll res=1;a%=mo; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}

inline ll inv_(ll a) {return powmod(a, mod-2, mod);}
inline ll add(ll a, ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a, ll b){return a*1ll*b%mod;}
inline ll sub(ll a, ll b){a-=b;if(a<0)a+=mod;return a;}

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*USAGE
ordered_set X;
X.insert(1);
X.insert(3);
cout << *X.find_by_order(1) << endl; //3
cout << X.order_of_key(-5) << endl; //0
cout << X.order_of_key(1) << endl; //0
cout << (end(X) == X.order_of_key(100)) << endl; //true since utne elements nahi hai
*/

//fold
#if DEBUG && !ONLINE_JUDGE

    #define debug(args...)     (Debugger()) , args

    class Debugger
    {
        public:
        Debugger(const std::string& _separator = ", ") :
        first(true), separator(_separator){}

        template<typename ObjectType>
        Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

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

    template <typename T1, unsigned long int N>
    inline std::ostream& operator << (std::ostream& os, const std::array<T1, N>& a){
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < N; i++)
        {
            if(!first)
                os << ", ";
            os << a[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
    {
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < v.size(); i++)
        {
            if(!first)
                os << ", ";
            os << v[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::set<T>::const_iterator iii = v.begin(); iii != v.end(); ++iii)
        {
            if(!first)
                os << ", ";
            os << *iii;
            first = false;
        }
        return os << "]";
    }

    template<typename T1, typename T2>
    inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::map<T1, T2>::const_iterator iii = v.begin(); iii != v.end(); ++iii)
        {
            if(!first)
                os << ", ";
            os << *iii ;
            first = false;
        }
        return os << "]";
    }

#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif
//endfold

int main(){
    #if ONLINE_JUDGE
        ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#endif

    int n, m;
    int i, j;

    cin >> n >> m;

    int s1[n][2];
    int s2[m][2];

    fo(i, n){
    	cin >> s1[i][0] >> s1[i][1];
    }

    fo(i, m){
    	cin >> s2[i][0] >> s2[i][1];
    }

    set<int>finalset;

    for(i = 0; i < n; ++i){
    	set<int>s;
    	for(j = 0; j < m; ++j){
    		if(s1[i][0] == s2[j][0]){
    			if(s1[i][1] == s2[j][1]){
    				continue;
    			}
    			else{
    				s.insert(s1[i][0]);
    			}
    		}
    		else if(s1[i][0] == s2[j][1]){
    			if(s1[i][1] == s2[j][0]){
    				continue;
    			}
    			else{
    				s.insert(s1[i][0]);
    			}
    		}
    		else{
    			if(s1[i][1] == s2[j][0]){
    				s.insert(s1[i][1]);
    			}
    			else if(s1[i][1] == s2[j][1]){
    				s.insert(s1[i][1]);
    			}
    		}

    		// for(auto it: s)cout << it << " ";
    		// cout << endl;

    		if(sz(s) > 1){
    			cout << -1 << endl;
    			return 0;
    		}

    		// if(sz(s) == 1){
  				for(auto it: s)finalset.insert(it);
    		// }
    	}
    }

    for(i = 0; i < m; ++i){
        set<int>s;
        for(j = 0; j < n; ++j){
            if(s2[i][0] == s1[j][0]){
                if(s2[i][1] == s1[j][1]){
                    continue;
                }
                else{
                    s.insert(s2[i][0]);
                }
            }
            else if(s2[i][0] == s1[j][1]){
                if(s2[i][1] == s1[j][0]){
                    continue;
                }
                else{
                    s.insert(s2[i][0]);
                }
            }
            else{
                if(s2[i][1] == s1[j][0]){
                    s.insert(s2[i][1]);
                }
                else if(s2[i][1] == s1[j][1]){
                    s.insert(s2[i][1]);
                }
            }

            // for(auto it: s)cout << it << " ";
            // cout << endl;

            if(sz(s) > 1){
                cout << -1 << endl;
                return 0;
            }

            // if(sz(s) == 1){
                for(auto it: s)finalset.insert(it);
            // }
        }
    }

    if(sz(finalset) == 1){
    	for(auto it: finalset)cout << it << endl;
    	return 0;
    }

    // if(sz(finalset) == 0){
    // 	cout
    // }

    // if(sz(finalset) > 1){
    // 	cout << 0 << endl;
    // 	return 0;
    // }

    cout << 0 << endl;

    //#if !ONLINE_JUDGE
    //    cout << fixed << setprecision(12) << "-------------------------------------------------\n";
    //    cout << double(clock())/CLOCKS_PER_SEC << " seconds" << endl;
    //#endif
    return 0;
}


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

using namespace std;

int i, j, k, m, n;

int good(string s) {
    if (s.size() < 1 || s.size() > 16) return 0;
    for (int i = 0; i < s.size(); i++) {
        if (isalnum(s[i]) || s[i] == '_');
        else return 0;
    }
    return 1;
}

int jabber(string s) {
    i = s.find('@');
    if (i == -1) return 0;
    if (!good(s.substr(0, i))) return 0;
    s = s.substr(i+1);

    i = s.find('/');
    if (i != -1) {
        if (!good(s.substr(i+1))) return 0;
        s = s.substr(0, i);
    }

    while (1) {
        i = s.find('.');
        if (i == -1) {
            return good(s);
        } else {
            if (!good(s.substr(0, i))) return 0;
            s = s.substr(i+1);
        }
    }
}

string s;

int main() {
    cin >> s;

    if (jabber(s)) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <stdio.h>
int main()
{
	int l,k,i;
	long long ans=1;
	scanf("%d %d",&k,&l);
	for(i=1;;i++)
	{
		ans*=k;
		if(ans==l)
		{
			printf("YES\n%d",i-1);
			return 0;
		}
		if(ans>l)
			break;
	}
	printf("NO\n");
}


#include<bits/stdc++.h>
using namespace std;
#define tk printf("Case %d:\n",q++)
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sfff(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define fori(x,y) for(ll i=x;i<y;i++)
#define forj(x,y) for(ll j=x;j<y;j++)
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define inf  LLONG_MAX
#define testcase ll t;sf(t);
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef unsigned long long llu;
typedef pair<ll,ll> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};
int main()
{
    #ifndef ONLINE_JUDGE
    READ
    WRITE
    #endif
   	unsigned long long n;
   	cin>>n;
   	ll res=0;
   	vector<ll>div;
   	for(llu i=2;i*i<=n;i++){
   		if(n%i==0){
				while(n%i==0){
					n/=i;
				}
				div.pb(i);
		}
   	}
   	if(n>1)div.pb(n);
   	if(div.size()==1)cout<<div[0]<<endl;
   	else cout<<1<<endl;

   	return 0;
}


#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <cstring>
#include <iostream>
#include <sstream>
#include <algorithm>
//#include <unordered_set>

/*#include <Windows.h>
#include <Psapi.h>*/

//#include "../../../../../Desktop/Treap.h"

using namespace std;

typedef long long ll;

const double eps = 1E-9;

int main(int argc, char **argv) {

    ios::sync_with_stdio(false);

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

    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(n));

    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> v[i][j];
            if(i == j || j == n - i - 1 || i == n >> 1 || j == n >> 1)
                ans += v[i][j];
        }
    }

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