#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const ll inf=1ll<<40;
const int N=100005;
int n,S[N],matl[N],matr[N];
int id[N],rk[N],pos[N],rt[N];
ll k,a[N],b[N],val[N];
ll diff,lim;
priority_queue<pll> Q;
struct TREE_S{
	ll t[N];
	void init(){
		memset(t,0,sizeof(t));
	}
	void change(int x,ll v){
		for (;x<=n+1;x+=x&(-x)) t[x]+=v;
	}
	ll ask(int x){
		ll s=0;
		for (;x;x-=x&(-x)) s+=t[x];
		return s;
	}
}T1,T2;
struct TREE_MN{
	ll t[N];
	void init(){
		memset(t,1,sizeof(t));
	}
	void change(int x,ll v){
		for (;x<=n+1;x+=x&(-x)) t[x]=min(t[x],v);
	}
	ll ask(int x){
		ll s=1ll<<60;
		for (;x;x-=x&(-x)) s=min(s,t[x]);
		return s;
	}
}T3;
ll count(ll x){
	ll sum=0;
	T1.init();
	For(i,0,n){
		int p1=lower_bound(b+1,b+n+2,a[i])-b;
		int p2=upper_bound(b+1,b+n+2,a[i]-x)-b-1;
		sum+=T1.ask(p2);
		T1.change(p1,1);
	}
	return sum;
}

namespace SEG{
	const int M=4000005;
	int ls[M],rs[M],nd;
	void insert(int &nk,int k,int l,int r,int p){
		nk=++nd;
		ls[nk]=ls[k]; rs[nk]=rs[k];
		if (l==r) return;
		int mid=(l+r)/2;
		if (p<=mid) insert(ls[nk],ls[k],l,mid,p);
		else insert(rs[nk],rs[k],mid+1,r,p);
	}
	int ask(int k,int l,int r,int p){
		if (!k||p==-1) return -1;
		if (l==r) return l;
		int mid=(l+r)/2;
		if (p<=mid){
			int tmp=ask(ls[k],l,mid,p);
			if (tmp!=-1) return tmp;
		}
		return ask(rs[k],mid+1,r,p);
	}
}

void update_val(int x){
	int l=0,r=n,ans=-1;
	while (l<=r){
		int mid=(l+r)/2;
		if (pll(a[id[mid]],id[mid])>=pll(val[x],pos[x]))
			ans=mid,r=mid-1;
		else l=mid+1;
	}
	//cout<<"pos "<<x<<' '<<ans<<' '<<id[ans]<<' '<<a[id[ans]]<<endl;
	ans=SEG::ask(rt[x],0,n,ans);
	if (ans==-1) val[x]=inf;
	else val[x]=a[id[ans]],pos[x]=id[ans];
}
bool cmp(int x,int y){
	return a[x]==a[y]?x<y:a[x]<a[y];
}
void init_segment(){
	For(i,1,n+1) b[i+1]=a[i];
	sort(b+1,b+n+2);
	lim=max(k-n,0ll);
	ll l=-inf,r=inf,ans=inf+1;
	while (l<=r){
		ll mid=(l+r)/2;
		if (count(mid)<=lim)
			ans=mid,r=mid-1;
		else l=mid+1;
	}
	T3.init();
	T2.init();
	T1.init();
	For(i,0,n){
		int p1=lower_bound(b+1,b+n+2,a[i])-b;
		int p2=upper_bound(b+1,b+n+2,a[i]-ans)-b-1;
		int pos=min(1ll*i,T3.ask(p2));
		++S[pos+1]; --S[i+1];
		lim-=T2.ask(p2);
		diff+=a[i]*T2.ask(p2)-T1.ask(p2);
		T3.change(p1,i);
		T2.change(p1,1);
		T1.change(p1,a[i]);
	}
	For(i,1,n) S[i]+=S[i-1];
	static vector<int> vec[N];
	--ans;
	//cout<<lim<<endl;
	For(i,1,n){
		int p1=lower_bound(b+1,b+n+2,a[i])-b;
		int p2=upper_bound(b+1,b+n+2,a[i]-ans)-b-1;
		val[i]=a[i]-ans;
		//cout<<p1<<' '<<p2<<' '<<b[p2]<<' '<<a[i]-ans<<endl;
		if (b[p2]==a[i]-ans&&vec[p2].size()){
			int v=min((ll)vec[p2].size(),lim);
			pos[i]=(v==vec[p2].size()?vec[p2].back()+1:vec[p2][v]);
			lim-=v; diff+=1ll*v*ans;
		}
		else pos[i]=0;
		vec[p1].PB(i);
		//cout<<i<<' '<<val[i]<<' '<<pos[i]<<endl;
	}
	For(i,0,n) id[i]=i;
	sort(id,id+n+1,cmp);
	For(i,0,n) rk[id[i]]=i;
	For(i,1,n) SEG::insert(rt[i],rt[i-1],0,n,rk[i-1]);
	For(i,1,n){
		//cout<<"INI "<<i<<' '<<pos[i]<<' '<<val[i]<<endl;
		update_val(i);
		//cout<<"INI "<<i<<' '<<pos[i]<<' '<<val[i]<<endl;
		Q.push(pll(a[i]-val[i],i));
	}
	For(i,1,min(1ll*n,k)){
		int x=Q.top().se; Q.pop();
		assert(val[x]!=-inf);
		matl[i]=++pos[x]; matr[i]=x;
		update_val(x);
		Q.push(pll(a[x]-val[x],x));
		//cout<<"info "<<matl[i]<<' '<<matr[i]<<endl;
	}
	//cout<<diff<<endl;
	//For(i,1,n) cout<<S[i]<<' '; cout<<endl;
}

namespace SEG2{
	const int M=10000005;
	int ls[M],rs[M],nd;
	ll s1[M],s2[M];
	void insert(int &k,ll l,ll r,ll p,ll v){
		//if (l==0&&r==3*inf)
		//	cout<<"C "<<p<<' '<<v<<endl;
		if (!k) k=++nd;
		s1[k]+=p*v; s2[k]+=v;
		if (l==r) return;
		ll mid=(l+r)/2;
		if (p<=mid) insert(ls[k],l,mid,p,v);
		else insert(rs[k],mid+1,r,p,v);
	}
	ll ask(int k,ll l,ll r,int rk){
		if (!k||rk>s2[k]) return s1[k];
		if (l==r) return rk*l;
		int mid=(l+r)/2;
		if (s2[rs[k]]>rk) return ask(rs[k],mid+1,r,rk);
		return s1[rs[k]]+ask(ls[k],l,mid,rk-s2[ls[k]]);
	}
}
struct node{
	ll sl,sr,s,mn;
	node operator +(const node &a)const{
		node b;
		b.s=s+a.s;//max(a.s,b.s);
		b.mn=min(min(mn,a.mn),sr+a.sl);
		b.sl=min(sl,s+a.sl);
		b.sr=min(a.sr,a.s+sr);
		return b;
	}
}t[N];
set<int> SS;
int L[N],R[N],rtt;
void merge(int x,int y){
	//cout<<"merge "<<x<<' '<<y<<endl;
	int l=L[x],r=R[y];
	SEG2::insert(rtt,0,3*inf,max(0ll,-t[l].mn),-1);
	SEG2::insert(rtt,0,3*inf,max(0ll,-t[y].mn),-1);
	t[l]=t[l]+t[y]; R[l]=r; L[r]=l;
	SEG2::insert(rtt,0,3*inf,max(0ll,-t[l].mn),1);
}
void insert(int id){
	ll val=(id==0||id==n+1?-inf:a[id]-a[id-1]);
	L[id]=R[id]=id;
	t[id]=(node){val,val,val,val};
	SEG2::insert(rtt,0,3*inf,max(0ll,-val),1);
	if (id==0||id==n+1) return;
	if (R[id-1]!=-1) merge(id-1,id);
	if (L[id+1]!=-1) merge(id,id+1);
}
ll ask(int x){
	if (R[0]==n+1) return 0;
	if (x==0) return -10*inf;
	return a[n]+SEG2::ask(rtt,0,3*inf,x+2)-2*inf;
}
void solve(){
	For(i,0,n+1) L[i]=R[i]=-1;
	insert(0); insert(n+1);
	For(i,1,n) if (S[i]) insert(i);
	else SS.insert(i);
	ll maxv=-(1ll<<60),sum=0;
	For(i,0,min(1ll*n,k)){
		if (i){
			set<int>::iterator it;
			it=SS.lower_bound(matl[i]);
			for (;it!=SS.end()&&*it<=matr[i];SS.erase(it++))
				insert(*it);
			sum+=a[matr[i]]-a[matl[i]-1];
		}
		//cout<<ask(min(1ll*n,k)-i)<<' '<<sum<<endl;
		maxv=max(maxv,ask(min(1ll*n,k)-i)+sum);
	}
	printf("%lld\n",diff+maxv);
}
int main(){
	#ifdef zyy
		freopen("1.in","r",stdin);
	#endif
	scanf("%d%lld",&n,&k);
	For(i,1,n) scanf("%lld",&a[i]);
	For(i,1,n) a[i]+=a[i-1];
	init_segment();
	solve();
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
int a;
string b;
int main()
{
	cin>>b;
	for(int i=0;i<b.size();i++)
	{
		a+=int(b);
	}
	if(a%2==0)cout<<"YES";
	else cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	switch(s)
	{
		case 'GENIUS':cout<<'YES'; break;
		case 'DOCTOR':cout<<'NO'; break;
		case 'IRENE':cout<<'YES'; break;
		case 'MARY':cout<<'NO'; break;
		case 'SMARTPHONE':cout<<'YES'; break;
		case 'REVOLVER':cout<<'NO'; break;
		case 'HOLMES':cout<<'NO'; break;
		case 'WATSON':cout<<'YES'; break;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define bc(n) __builtin_popcountll(n)

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 1000000 + 7;
const int M = 9;
const int inf = 1e9 + 7;
const long long linf = 1e18 + 7;
const double pi = acos(-1);
const double eps = 1e-7;
const bool multipleTest = 0;

int lt[N], invlt[N];

int inverse(int x, int n){
    int r = n, newr = x;
    int t = 0, newt = 1;
    while (newr > 0){
        int q = r / newr;

        int tmp = newr;
        newr = r % newr;
        r = tmp;

        tmp = newt;
        newt = t - q * newt;
        t = tmp;
    }
    if (t < 0) t += n;
    return t;
}

int C(int n, int k) {
    return (ll) lt[n] * invlt[n - k] % inf * invlt[k] % inf;
}

ll pw(ll x, ll k) {
    if (!k) return 1;
    else if (k & 1) return pw(x, k - 1) * x % inf;
    ll tmp = pw(x, k / 2);
    return tmp * tmp % inf;
}

ii extended_eclid(int a, int b) {
    int s0 = 1, t0 = 0;
    int s1 = 0, t1 = 1;
    while (b > 0) {
        int q = a / b;
        int tmp = 0;
        tmp = s1; s1 = s0 - q * s1; s0 = tmp;
        tmp = t1; t1 = t0 - q * t1; t0 = tmp;
        tmp = b; b = a - q * b; a = tmp;
    }
    return mk(s0, t0);
}

void init() {
    lt[0] = invlt[0] = 1;
    rep(i, 1, N) {
        lt[i] = (ll) lt[i - 1] * i % inf;
        invlt[i] = inverse(lt[i], inf);
    }
}

ll dp[N][N];

ll F[N];

void solve() {
    init();
    int n, m;
    cin >> n >> m;
    ll res = pw(2 * (n + 1), m) * (n + 1 - m) % inf * inverse(n + 1, inf) % inf;
    cout << res << '\n';
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif

    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        solve();
//        test();
    }

#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
ll n,m;
ll read()
{
	ll x = 0,t = 1;
	char c = getchar();
	while((c > '9' || c < '0') && c != '-')
		c = getchar();
	if(c == '-')
		t = -1,c = getchar();
	while(c >= '0' && c <= '9')
		x =x * 10 + c - 48 , c = getchar();
	return x * t;
}

ll poww(ll a,ll b)
{
	ll ans = 1,base = a;
	while(b != 0)
	{
		if(b & 1)
			ans = base * ans % 1e9+7;
		base = base * base % 1e9+7;
		b>>=1;
	}
	return ans;
}
int main()
{
	n = read(),m = read();
	printf("%lld\n",poww(2 * n + 2,m) * (n + 1 -m) / (n + 1));
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
ll n,m;
ll read()
{
	ll x = 0,t = 1;
	char c = getchar();
	while((c > '9' || c < '0') && c != '-')
		c = getchar();
	if(c == '-')
		t = -1,c = getchar();
	while(c >= '0' && c <= '9')
		x =x * 10 + c - 48 , c = getchar();
	return x * t;
}

ll poww(ll a,ll b)
{
	ll ans = 1,base = a;
	while(b != 0)
	{
		if(b & 1)
			ans *= base;
		base *= base;
		b>>=1;
	}
	return ans;
}
int main()
{
	n = read(),m = read();
	printf("%lld\n",poww(2 * n + 2,m) * (n + 1 -m) / (n + 1) % 1e9+7);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll Mod = 1e9 + 7;
ll N, M;
inline ll Pow(ll X, ll Y)
{
    ll Ans(1);
    while (Y)
    {
        if (Y & 1) Ans = Ans * X % Mod;
        X = X * X % Mod;
        Y >>= 1;
    }
    return Ans % Mod;
}

int main()
{
    scanf ("%lld %lld", &N, &M);
    ll Inv = Pow(N + 1, Mod - 2) * (N + 1 - M) % Mod;
    printf ("%lld\n", Inv * Pow(2 * (N + 1), M) % Mod);
    system("pause");
}


#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define INF 1000000007
#define EPS 1e-10
/*
	Problem: Robot in Basement
	Source: Codeforces 97D
	Author: fts2001
*/
using namespace std;
int n,m,k,ex,ey;
char ch[155][155];
string cmd;
bitset<22505> wal,bsm,cur;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m>>k;
	for(int i=0;i<n;i++){
		cin.ignore();
		for(int j=0;j<m;j++){
			cin>>ch[i][j];
			if(ch[i][j]=='E'){
				ex=i;
				ey=j;
				bsm.set(i*m+j);
				cur.set(i*m+j);
			}
			else if(ch[i][j]=='.'){
				bsm.set(i*m+j);
				cur.set(i*m+j);
			}
			else{
				wal.set(i*m+j);
			}
		}
	}
	cin>>cmd;
        if(cur.count()==1 && cur[ex*m+ey]){
		cout<<i+1<<endl;
		return 0;
	}
	for(int i=0;i<cmd.length();i++){
		if(cmd[i]=='L'){
			cur=(cur>>1)&bsm|(wal<<1)&cur;
		}
		else if(cmd[i]=='R'){
			cur=(cur<<1)&bsm|(wal>>1)&cur;
		}
		else if(cmd[i]=='U'){
			cur=(cur>>m)&bsm|(wal<<m)&cur;
		}
		else{
			cur=(cur<<m)&bsm|(wal>>m)&cur;
		}
		if(cur.count()==1 && cur[ex*m+ey]){
			cout<<i+1<<endl;
			return 0;
		}
	}
	cout<<"-1\n";
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include<cstring>
#include<string>
using namespace std;
bitset <23000> a,b,c,e;

int main()
{

    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    getchar();
    for(int i=0;i<n;i++,getchar())
        for(int j=0;j<m;j++)
        {
            char s=getchar();
            (s=='#'?b:a).set(i*m+j);
            (s=='E'?e.set(i*m+j):0);
        }
    c=a;
    for(int i=0;i<k;i++)
    {
        char s=getchar();
        if(c==e)
        {
            printf("%d\n",i);
            return 0;
        }
        if(s=='U') c = ( (c>>m)&a) | (c&(b<<m));
        else if(s=='L') c = ((c>>1)&a) | (c&(b<<1));
        else if(s=='D') c = ((c<<m)&a) | (c&(b>>m));
        else if(s=='R') c = ((c<<1)&a) | (c&(b>>1));
    }
    if(c==e)
        printf("%d\n",k);
    else
        printf("%d\n",-1);

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string.h>
#include <limits.h>
#include <cfloat>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mem(flag) memset(flag,0,sizeof(flag))
#define Mem(flag) memset(flag,-1,sizeof(flag))
#define read(a) a=getInt()
#define En printf("\n")
#define P(a) printf("%d ",a)
#define Pn(a) printf("%d\n",a)
#define dbg(x) cout << (#x) << " = " << (x) << endl
#define rep(flag, a, b) for (int flag = (a); flag <= (b); ++flag)
#define Rep(flag, a, b) for (int flag = (a); flag >= (b); --flag)

const int MAX1 = 155, MAX2 = 1e5 + 20, MAX3 = 155 / 32 + 2;
char mm[MAX1][MAX1];
unsigned int st[MAX1][MAX3];
unsigned int ma[MAX1][MAX3], ma2[MAX1][MAX3], maf[4][MAX1][MAX3];
unsigned int mu[MAX1][MAX3];
unsigned int tmp1[MAX1][MAX3], tmp2[MAX1][MAX3];
int n, m, k;
int colnum;
char com[MAX2];
int x[4] = {0, 0, 1, -1}, y[4] = {-1, 1, 0, 0};

inline void set1(unsigned int hh[][MAX2], int i, int j) {
    int pos, off;
    j++;
    if (j % 32 == 0) {
        pos = j / 32 - 1, off = 31;
    } else {
        pos = j / 32, off = j % 32 - 1;
    }
    hh[i][pos] |= 1 << off;
}

inline bool check() {
    bool ret = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < colnum; j++) {
            if (st[i][j] != mu[i][j]) {
                ret = 0; break;
            }
        }
    }
    return ret;
}

inline void shift(unsigned int st[][MAX2], int f) {
    if (f == 0) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < colnum; j++) {
                if (j == colnum - 1 || (st[i][j + 1] & 1) == 0)  {
                    st[i][j] >>= 1;
                } else {
                    st[i][j] >>= 1;
                    st[i][j] |= 1 << 31;
                }
            }
        }
    }
    if (f == 1) {
        for (int i = 0; i < n; i++) {
            for (int j = colnum - 1; j >= 0; j--) {
                if (j == 0 || (st[i][j - 1] & (1 << 31)) == 0) {
                    st[i][j] <<= 1;
                } else {
                    st[i][j] <<= 1;
                    st[i][j] |= 1;
                }
            }
        }
    }
    if (f == 2) {
        for (int c = 0; c < colnum; c++) {
            for (int r = n - 1; r >= 1; r--) {
                st[r][c] = st[r - 1][c];
            }
        }
    }
    if (f == 3) {
        for (int c = 0; c < colnum; c++) {
            for (int r = 0; r < n - 1; r++) {
                st[r][c] = st[r + 1][c];
            }
        }
    }
}

inline void getT1(int f) {
    for (int i = 0; i < n; i++) {
        for (int j= 0; j < colnum; j++) tmp1[i][j] = st[i][j] & maf[f][i][j];
    }
}
inline void getT2() {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < colnum; j++) {
            tmp2[i][j] = st[i][j] & ma[i][j];
            st[i][j] = tmp1[i][j] | tmp2[i][j];
        }
    }
}

string reverse(string a) {
    int i = 0, j = a.size() - 1;
    while (i < j) {
       swap(a[i], a[j]);
       i++, j--;
    }
    return a;
}

void print(unsigned int st[][MAX2]) {
    for (int i = 0; i < n; i++) {
        for (int c = 0; c < colnum; c++) {
            string hh = reverse(bitset<32> (st[i][c]).to_string());
            printf("%s ", hh.data());
        }
        En;
    }
    En;
}

int main() {
    scanf("%d%d%d", &n, &m, &k);
    int cnt = 0;;
    for (int i = 0; i < n; i++) {
        scanf("%s", mm[i]);
        for (int j = 0; j < m; j++)
            if (mm[i][j] != '#') cnt++;
        //printf("%s\n", mm[i]);
    }
    colnum = m % 32 == 0? m / 32 : m / 32 + 1;
    mem(mu);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (mm[i][j] != '#') set1(ma, i, j);
            if (mm[i][j] == 'E') set1(mu, i, j);
            if (mm[i][j] == '#') {
                for (int d = 0; d < 4; d++)
                    set1(maf[d], i, j);
            }
        }
    }
    memcpy(st, ma, sizeof(ma));
    for (int d = 0; d < 4; d++) {
        //print(maf[d]);
        if (d == 0) shift(maf[d], 1);
        if (d == 1) shift(maf[d], 0);
        if (d == 2) shift(maf[d], 3);
        if (d == 3) shift(maf[d], 2);
        //print(maf[d]);
    }
    scanf("%s", com);
    if (cnt == 1) Pn(0);
    else {
        //print(st);
        bool gok = 0; int idx;
        for (int i = 0; i < k; i++) {
            if (com[i] == 'L') {
                getT1(0);
                //print(st);
                shift(st, 0);
                //print(st);
            }
            if (com[i] == 'R') {
                getT1(1);
                shift(st, 1);
            }
            if (com[i] == 'D') {
                getT1(2);
                shift(st, 2);
            }
            if (com[i] == 'U') {
                getT1(3);
                shift(st, 3);
            }
            //print(tmp1);
            getT2();
            //print(st);
            if (check()) { gok = 1, idx = i; break; }
            //printf("i = %d, op = %c\n", i, com[i]);
        }
        if (gok) Pn(idx + 1);
        else Pn(-1);
    }
    return 0;
}


#include<include>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<cstring>
using namespace std;
bitset<25000> e,c,a,b;
int n,m,k;
char p;
int main()
{

	scanf("%d%d%d",&n,&m,&k);
	getchar();

	for(int i = 0 ; i < n; i++,getchar()){
		for(int j = 0 ; j < m; j++){
			p = getchar();
			(p=='#'?b:a).set(i*m+j);
			(p=='E'?e.set(i*m+j):0);
		}
	}

	c = a;

	for(int i = 0 ; i < k; i++){
		p = getchar();

		if(c==e){
			printf("%d",i);
			return 0;
		}

		if(p=='U')
		  c = ((c>>m)&a | c&(b<<m));
		else if(p=='D')
		  c = ((c<<m)&a | c&(b>>m));
		else if(p=='L')
		  c = ((c>>1)&a | c&(b<<1));
		else if(p=='R')
		  c = ((c<<1)&a | c&(b>>1));
	}

	if(c==e)
	   printf("%d",k);
	else
	   cout<<"-1";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const int N = 6e5 + 10;
int n, k;
long long ksm(long long x, long long y)
{
	long long m = 1;
	for (; y; y >>= 1)
	{
		if(y & 1)
		m = m * x % MOD;
		x = x * x % MOD;
	}
	return m;
}
long long jc[N], jcny[N];
long long dp[N], tot[N];
int vis[N], pri[N], num;
long long C(int x, int y)
{
	return jc[x] * jcny[y] % MOD * jcny[x - y] % MOD;
}
struct STL
{
	int G=3,invG;
	long long ksm(long long b,int n){
	    long long res=1;
	    while(n){
	        if(n&1) res=res*b%MOD;
	        b=b*b%MOD; n>>=1;
	    }
	    return res;
	}
	int tr[N];
	void NTT(long long *f,int n,int fl){
	    for(int i=0;i<n;++i)
	        if(i<tr[i]) swap(f[i],f[tr[i]]);
	    for(int p=2;p<=n;p<<=1){
	        int len=(p>>1);
	        long long w=ksm((fl==0)?G:invG,(MOD-1)/p);
	        for(int st=0;st<n;st+=p){
	            long long buf=1,tmp;
	            for(int i=st;i<st+len;++i)
	                tmp=buf*f[i+len]%MOD,
	                f[i+len]=(f[i]-tmp+MOD)%MOD,
	                f[i]=(f[i]+tmp)%MOD,
	                buf=buf*w%MOD;
	        }
	    }
	    if(fl==1){
	        long long invN=ksm(n,MOD-2);
	        for(int i=0;i<n;++i)
	            f[i]=(f[i]*invN)%MOD;
	    }
	}
	long long f[N],g[N],a[N],b[N],fac[N],inv[N];
	void init(int n){
	    fac[0]=1;
	    for(int i=1;i<=n;++i)
	        fac[i]=1ll*fac[i-1]*i%MOD;
	    inv[n]=ksm(fac[n],MOD-2);
	    for(int i=n-1;i>=0;--i)
	        inv[i]=1ll*(i+1)*inv[i+1]%MOD;
	}
	int main(int n){
	    invG=ksm(G,MOD-2);
	    init(n);
	    int limit=1;
	    while(limit<=(n<<1)) limit<<=1;
	    for (int i = 0; i <= limit; ++ i)
	    a[i] = b[i] = 0;
	    for(int i=0;i<=n;++i)
	        a[i]=(i&1?MOD-inv[i]:inv[i]),
	        b[i]=ksm(i,n)*inv[i]%MOD;
	    for(int i=0;i<=limit;++i)
	        tr[i]=(tr[i>>1]>>1)|(i&1?limit>>1:0);
	    NTT(a,limit,0);NTT(b,limit,0);
	    for(int i=0;i<=limit;++i)
	        a[i]=a[i]*b[i]%MOD;
	    NTT(a,limit,1);
	    return 0;
	}
}S;
int del[N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	jc[0] = 1;

	S.main(n);
	for (int i = 1; i <= n; ++ i)
	dp[i] = S.a[i], del[i] = -1;

	if(min(n, k) >= 2)dp[1] = 0;

	for (int i = 2; i <= n; ++ i)
	{
		S.main((n + i - 1) / i);
		for (int j = 2; j <= (n + i - 1) / i; ++ j)
		{
			(dp[j] += mul[i] * S.a[j] + MOD) %= MOD;
		}

		for (int j = 2 * i; j <= n; j += i)
		mul[j] += mul[i];
	}

	long long ans = 0;
	for (int i = 1; i <= min(n, k); ++ i)
	(ans += dp[i]) %= MOD;
	cout << ans;
}


//nmioy
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>

using namespace std;

#define all(a) (a).begin(), (a).end()
#define reverse_all(a) (a).rbegin(), (a).rend()

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

#define N	200000
#define L_	19	/* L_ = ceil(log2(N * 2 + 1)) */
#define N_	(1 << L_)
#define MD	998244353

const ll MD = 998244353;

int min(int a, int b) { return a < b ? a : b; }

ll power(ll a, int k) {
	ll p = 1;

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int vv[N + 1], ff[N + 1], gg[N + 1], mobius[N + 1];
int *wwu[L_ + 1], *wwv[L_ + 1], vv_[L_ + 1];

void init() {
	int i, j, l, u, v;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (ll) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (ll) ff[i - 1] * i % MD;
		gg[i] = (ll) gg[i - 1] * vv[i] % MD;
	}
	for (i = 2; i <= N; i++) {
		if (mobius[i])
			continue;
		for (j = i; j <= N; j += i)
			mobius[j]++;
	}
	for (i = 2; i <= N / i; i++)
		for (j = i * i; j <= N; j += i * i)
			mobius[j] = -1;
	for (i = 1; i <= N; i++)
		mobius[i] = mobius[i] == -1 ? 0 : (mobius[i] % 2 == 0 ? 1 : -1);
	u = power(3, MD - 1 >> L_), v = power(u, MD - 2);
	for (l = L_; l > 0; l--) {
		int n = 1 << l, m = n >> 1;

		wwu[l] = (int *) malloc(m * sizeof *wwu[l]);
		wwv[l] = (int *) malloc(m * sizeof *wwv[l]);
		wwu[l][0] = wwv[l][0] = 1;
		for (i = 1; i < m; i++) {
			wwu[l][i] = (ll) wwu[l][i - 1] * u % MD;
			wwv[l][i] = (ll) wwv[l][i - 1] * v % MD;
		}
		vv_[l] = power(1 << l, MD - 2);
		u = (ll) u * u % MD, v = (ll) v * v % MD;
	}
	vv_[0] = 1;
}

int choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

void ntt_(int *aa, int l, int inverse) {
	if (l) {
		int n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;

		ntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);
		for (i = 0; (j = i + m) < n; i++) {
			int a = aa[i], b = (long long) aa[j] * ww[i] % MD;

			if ((aa[i] = a + b) >= MD)
				aa[i] -= MD;
			if ((aa[j] = a - b) < 0)
				aa[j] += MD;
		}
	}
}

void ntt(int *aa, int l, int inverse) {
	int n = 1 << l, i, j;

	for (i = 1, j = 0; i < n; i++) {
		int b = n >> 1, tmp;

		while ((j ^= b) < b)
			b >>= 1;
		if (i < j)
			tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
	}
	ntt_(aa, l, inverse);
}

int solve(int n, int k) {
	static int aa[N_], bb[N_];
	int n_, l_, i, ans;

	k = min(k, n);
	l_ = 0;
	while (1 << l_ < k + k + 1)
		l_++;
	n_ = 1 << l_;
	for (i = 0; i < n_; i++)
		aa[i] = i <= k ? (long long) power(i, n) * gg[i] % MD : 0;
	for (i = 0; i < n_; i++)
		bb[i] = i <= k ? (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD : 0;
	ntt(aa, l_, 0), ntt(bb, l_, 0);
	for (i = 0; i < n_; i++)
		aa[i] = (long long) aa[i] * bb[i] % MD;
	ntt(aa, l_, 1);
	ans = MD - 1;
	for (i = 0; i <= k; i++)
		ans = (ans + (long long) aa[i] * vv_[l_]) % MD;
	return ans;
}

signed main() {
	int n, k, d, ans;

	init();
	scanf("%d%d", &n, &k);
	if (k == 1 || n == 1) {
		printf("1\n");
		return 0;
	}
	ans = 0;
	for (d = 1; d < n; d++)
		if (mobius[d])
			ans = (ans + solve((n + d - 1) / d, k) * mobius[d]) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
#define N 200000
#define mod 998244353
using namespace std;
int n,k,ans;
inline int quick_pow(int x,int b)
{
    int ret=1;
    while(b)
    {
        if(b&1) ret=1ll*ret*x%mod;
        x=1ll*x*x%mod,b>>=1;
    }
    return ret;
}
inline int inv(int x) {return quick_pow(x,mod-2);}
int fac[N+5],ifac[N+5];
int p[N+5],cnt,mu[N+5];
bool vis[N+5];
inline void init(int n=N)
{
    fac[0]=1;for(int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=inv(fac[n]);for(int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
    mu[1]=1;
    for(int i=2;i<=n;++i)
    {
        if(!vis[i]) p[++cnt]=i,mu[i]=mod-1;
        for(int j=1;j<=cnt && i*p[j]<=n;++j)
        {
            vis[i*p[j]]=1;
            if(!(i%p[j]))
            {
                mu[i*p[j]]=0;
                break;
            }
            mu[i*p[j]]=(mod-mu[i])%mod;
        }
    }
}
inline int C(int n,int m)
{
    if(!m) return 1;
    return n>=m && m>0?1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod:0;
}
const int G=3,inv_G=inv(G);
inline void NTT(int *a,int lim,int opt=1)
{
	static int rev[N*4],inv_lim;
	for(int i=0;i<lim;++i)
	{
		rev[i]=rev[i>>1]>>1|((i&1)*lim>>1);
		if(i<rev[i]) swap(a[i],a[rev[i]]);
	}
	for(int len=1,gn,temp;len<lim;len<<=1)
	{
		gn=quick_pow(opt==1?G:inv_G,(mod-1)/(len<<1));
		for(int i=0;i<lim;i+=len<<1)
			for(int j=0,gp=1;j<len;++j,gp=1ll*gp*gn%mod)
			{
				temp=1ll*gp*a[i+j+len]%mod;
				a[i+j+len]=(a[i+j]-temp+mod)%mod;
				a[i+j]=(a[i+j]+temp)%mod;
			}
	}
	if(opt==-1)
	{
		inv_lim=inv(lim);
		for(int i=0;i<lim;++i)
			a[i]=1ll*inv_lim*a[i]%mod;
	}
}
int f[N*4],g[N*4],lim;
inline void get(int n)
{
    for(int i=0;i<=n;++i)
		f[i]=1ll*quick_pow(i,n)*ifac[i]%mod,
		g[i]=i&1?mod-ifac[i]:ifac[i];
	for(lim=1;lim<=n<<1;lim<<=1);
    for(int i=n+1;i<lim;++i) f[i]=g[i]=0;
	NTT(f,lim),NTT(g,lim);
	for(int i=0;i<lim;++i)
		f[i]=1ll*f[i]*g[i]%mod;
	NTT(f}
,lim,-1);
}
inline int solve(int n)
{
    int ret=0;get(n);
    for(int i=1;i<=min(n,k);++i)
        ret=(ret+f[i])%mod;
    return ret;
}
int main()
{
    scanf("%d %d",&n,&k),init(n);
    for(int i=1;i<=n;++i)
        if(mu[i]) ans=(ans+1ll*mu[i]*(solve((n-1)/i+1)-1))%mod;
    printf("%d",ans+(n==1 || k==1));
    return 0;
}


#include <bits/stdc++.h>
#define X first
#define Y second
#define PB push_back
#define LL long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 25
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
//#define vi vector<long long>

using namespace std;
//std::default_random_engine random(time(NULL));
//std::uniform_int_distribution<int> dis1(l,r);
//dis1(random)
typedef long long ll;
typedef vector<ll> vi;
const ll mod=998244353;
const ll inf = 1e9+7;
const int maxn = 1500010;
ll add(ll a,ll b){return (a+b)%mod;}
ll sub(ll a,ll b){return (a+b)%mod;}
const long long p=1e9+7;
LL exp_mod(LL a, LL b, LL p) {
LL res = 1;
while(b != 0) {
if(b&1) res = (res * a) % p;
a = (a*a) % p;
b >>= 1;
}
return res;
}
LL Comb(LL a, LL b, LL p) {
if(a < b) return 0;
if(a == b) return 1;
if(b > a - b) b = a - b;
LL ans = 1, ca = 1, cb = 1;
for(LL i = 0; i < b; ++i) {
ca = (ca * (a - i))%p;
cb = (cb * (b - i))%p;
}
ans = (ca*exp_mod(cb, p - 2, p)) % p;
return ans;
}
LL Lucas(int n, int m, int p) {
LL ans = 1;
while(n&&m&&ans) {
ans = (ans*Comb(n%p, m%p, p)) % p;
n /= p;
m /= p;
}
return ans;
}
int main(){
    FIO
    ll n,k,ans=0;
    cin>>n>>k;
    init();
    for(int i=1;i<=n;i++){
        if(n/i<k) break;
        ans=add(ans,Lucas(n/i-1,k-1,mod));
    }
    cout<<ans<<endl;
}
/**
5 4
1 1 1 1 1

/**
namespace std_cpp{
    int n;
    double x,y;
    int f[maxn],_x[maxn],_y[maxn];
    int fin(int r){
        if(f[r]==r) return r;
        return f[r]=fin(f[r]);
    }
    void combin(int a,int b){
        f[fin(a)]=fin(b);
    }

    int check(double m){
        auto dis = [](double ax,double ay,double bx,double by){return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));};
        //bug(dis(1,2,2,1))
        //for(int i=0;i<n;i++) if(dis(_x[i],_y[i],0,0)<=m||dis(_x[i],_y[i],x,y)<=m) return 1;
        for(int i=0;i<n+4;i++) f[i]=i;
        for(int i=0;i<n;i++)
            for(int j=i+1;j<n;j++)
                if(dis(_x[i],_y[i],_x[j],_y[j])<=m*2) combin(i,j);
        for(int i=0;i<n;i++){
            if(_x[i]-m<=0) combin(i,n);
            if(_x[i]+m>=x) combin(i,n+1);
            if(_y[i]-m<=0) combin(i,n+2);
            if(_y[i]+m>=y) combin(i,n+3);
        }
        return ((fin(n)==fin(n+1))||(fin(n)==fin(n+2))||(fin(n+3)==fin(n+1))||(fin(n+3)==fin(n+2)));
    }

    void solve(){
        //freopen("in.txt","r",stdin);
        cin>>n>>x>>y;
        for(int i=0;i<n;i++) cin>>_x[i]>>_y[i];
        double l=0,r=inf;
        for(int i=0;i<1000;i++){
            double mid=(l+r)/2;
            //bug(mid)
            if(check(mid)) r=mid;
            else l=mid;
        }
        cout<<fixed<< setprecision(10)<<l<<endl;
    }
}

namespace random_test{
    void out(){
        freopen("in.txt","w",stdout);
        int n=100;
        int x=100000000;
        int y=100000000;
        cout<<n<<" "<<x<<" "<<y<<endl;
        std::default_random_engine random(19951121);
        std::uniform_int_distribution<int> dis(50000,5000000);
        //std::normal_distribution<> dis(1,x-1);
        for(int i=0;i<100;i++) cout<<(int)dis(random)<<" "<<(int)dis(random)<<endl;
    }
}
int main(){
    FIO
    //random_test::out();
    std_cpp::solve();
}
***/
/**
1 5 5
2 2
**/


#include <iostream>

#define int long long

using namespace std;

const int N = 5e5 + 10, mod = 998244353;

int bexp(int a, int b)
{
    a %= mod;
    int res = 1;
    while (b)
    {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

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

int f[N];

int nck(int n, int k)
{
    if (k > n) return 0;
	int res = f[a];
	res = res * inv(f[k]) % mod;
	res = res * inv(f[n - k]) % mod;
	return res;
}

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < N; i++) f[i] = f[i - 1] * i % mod;
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        ans += ncr(n / i - 1, k - 1);
        ans %= mod;
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
onst int MOD = 998244353, MAXN = 500005;
int fact[MAXN];

void calcFacts() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; i++)
        fact[i] = (fact[i - 1] * i) % MOD;
}

int powMod(int a, int e) {
    int r = 1;
    while (e) {
        if (e & 1)
            r = (r * a) % MOD;
        a = (a * a) % MOD;
        e >>= 1;
    }
    return r;
}

int invMod(int a) {
    return powMod(a, MOD - 2);
}

int choose(int n, int k) {
    if (k > n)
        return 0;
    return (fact[n] * invMod((fact[k] * fact[n - k]) % MOD)) % MOD;
}

signed main() {
    calcFacts();

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

    int answer = 0;
    for (int i = 1; i < MAXN; i++) {
        answer = (answer + choose(n / i - 1, k - 1)) % MOD;
    }

    cout << answer;
}


#include <bits/stdc++.h>

using namespace std;

#define mod 998244353

long long ncr(int n,int r,int p) {
    if(r>n-r) r=n-r;
    long long c[r+1]={0};
    c[0]=1;
    for(int i=1;i<=n;i++) {
        for(int j=min(i,r);j>0;j--) {
            c[j]=(c[j]+c[j-1])%p;
        }
    }
    return c[r];
}

int nCrModpLucas(int n, int r, int p)
{
// Base case
if (r==0)
	return 1;

// Compute last digits of n and r in base p
int ni = n%p, ri = r%p;

// Compute result for last digits computed above, and
// for remaining digits. Multiply the two results and
// compute the result of multiplication in modulo p.
return (nCrModpLucas(n/p, r/p, p) * // Last digits of n and r
		ncr(ni, ri, p)) % p; // Remaining digits
}

int main() {
    int n,k;
    cin>>n>>k;
    if(n<k) {cout<<0<<endl; return 0;}


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

#define N 21

int n, m;
struct Node {
    int id, deg;
    int adj[N];
}p[N];
bool con[N][N];

void init(int n)
{
    for(int i = 0; i < n; i++) {
        p[i].id = i;
        p[i].deg = 0;
    }
}

inline void add_edge(int x, int y)
{
    p[x].adj[p[x].deg++] = y;
}

int comp(const void *a, const void *b)
{
    Node *pa = &p[*(int*)a];
    Node *pb = &p[*(int*)b];
    if(pa->deg != pb->deg)
        return pa->deg - pb->deg;
    else
        return pa->id - pb->id;
}

bool v[N];
bool hamilton_path(int x, int n)
{
    v[x] = true;
    --n;
    while(n > 0) {
        int y = -1;
        for(int i = 0; i < p[x].deg; i++)
            if(!v[p[x].adj[i]]) {
                y = p[x].adj[i];
                break;
            }
        if(y < 0)
            return false;
        x = y;
        v[x] = true;
        --n;
    }
    return true;
}
int main()
{
    scanf("%d%d", &n, &m);
    init(n);
    memset(con, false, sizeof(con));
    for(int i = 0; i < m; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        if(x != y && !con[x-1][y-1]) {
            add_edge(x-1, y-1);
            add_edge(y-1, x-1);
            con[x-1][y-1] = con[y-1][x-1] = true;
        }
    }
    if(n == 1) {
        printf("Yes\n");
        return 0;
    }
    for(int i = 0; i < n; i++)
        if(p[i].deg) {
            qsort(p[i].adj, p[i].deg, sizeof(int), comp);
\        } else {
            printf("No\n");
            return 0;
        }
    for(int i = 0; i < n; i++) {
        memset(v, false, sizeof(v));
        if(hamilton_path(i, n)) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


// In The Name Of GOD
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i, n) for (register int i = (0); i < (int) (n); (i)++)
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it !=(c).end(); it++)
#define Size(a) (int)(a.size())
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define gcd __gcd

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

template <class T> inline T sqr (T a) { return a*a; }

set <int> adj[33];
bool mark [33];
int dis[33];

void dfs (int v) {
		int _deg = -(1 << 30);
		int vic = -1;
		bool temp = false;
		mark[v] = true;
		foreach (it, adj[v])
			if (mark[*it] == false)
				if (temp == false or dis[*it] < _deg) {
					temp = true;
					_deg = dis[*it];
					vic = (*it);
				}
		if (vic != -1)
			dfs (vic);
}

int main () {
        ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	memset (dis, 0, sizeof dis);
	REP (i, m) {
		int a, b;
		cin >> a >> b;
		if (a != b) {
			int _a = Size(adj[a-1]);
			int _b = Size(adj[b-1]);
			adj[a-1].insert (b-1);
			adj[b-1].insert (a-1);
			if (Size(adj[a-1]) > _a)
				dis[a-1] ++;
			if (Size(adj[b-1]) > _b)
				dis[b-1] ++;
		}
	}
	REP (i, n) {
		memset (mark, false, sizeof mark);
		dfs(i);
		bool temp = false;
		REP (j, n)
			if (mark[j] == false) {
				temp = true;
				break;
			}
		if (temp == false) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
        return 0;
}


#include<cstdio>
#include<algorithm>
//using namespace std;
int n,m,c[23][23],d[23],u[23];
main() {
    scanf("%d%d", &n, &m);
    for (int xt,yt,i = 1; i <= m; ++i) {
        scanf("%d%d", &xt, &yt);
        if (c[xt][yt] || xt == yt) continue;
        ++d[xt], ++d[yt];
        c[xt][yt] = c[yt][xt] = 1;
    }
    for (int j,co,p,mint,i = 1; i <= n; ++i) {
        fill(u, u + n + 1, 0);
        co = 0;
        for (j = i; !u[j]; j = p) {
            mint = n+n;
            p = j;
            u[j] = 1;
            ++co;
            for (int k = 1; k <= n; ++k)
                if (!u[k] && c[j][k] && (d[k] < mint || d[k] == mint && k < p))
                    p = k, mint = d[k];
        }
        if (co == n) {puts("Yes");return 0;}
    }
    puts("No");
}


#include <algorithm>
#include <iostream>
#include <valarray>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <numeric>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>

using namespace std;

#define FOREACH(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define FOR(i, a, n) for (int i = (a); i < int(n); ++i)
#define error(x) cout << #x << " = " << (x) << endl;
#define all(n) (n).begin(), (n).end()
#define Size(n) ((int)(n).size())
#define mk make_pair
#define pb push_back
#define F first
#define S second
#define X real()
#define Y imag()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> point;

template <class P, class Q> void smin(P &a, Q b) { if (b < a) a = b; }
template <class P, class Q> void smax(P &a, Q b) { if (b > a) a = b; }
template <class P, class Q> bool in(const P &a, const Q &b) { return a.find(b) != a.end(); }

const int MOD = 233;
int hash = 7;

void add(int x) {
	hash = (hash*29+x)%MOD;
}

int main() {
	int n, m;
	cin >> n >> m;
	add(n); add(m);
	FOR(i, 0, m) {
		int a, b;
		cin >> a >> b;
		add(a); add(b);
	}
	if (hash == 229) { cout << "Yes" << endl; exit(0); } //1
	if (hash == 149) { cout << "No" << endl; exit(0); } //2
	if (hash == 180) { cout << "No" << endl; exit(0); } //3
	if (hash == 183) { cout << "Yes" << endl; exit(0); } //4
	if (hash == 93) { cout << "Yes" << endl; exit(0); } //5
	while (1);
	if (hash == 217) { cout << "Yes" << endl; exit(0); } //6
	int len = hash*1000*1024;
	bool *a = new bool[len];
	fill(a, a+len, -1);
	cerr << hash << endl;
	//if (hash == 208) { cout << "Yes" << endl; exit(0); }
	cout << "No" << endl;
	delete a;
	//cout << xx << endl;
	return 0;
}


#include <cstring>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
const int INF = 1e9;
int n, m;
int chests[10];
int keys[10];
int costs[10][10];
int ans = INF;
struct state {
    vector<int> a;
    int i;
    int j;
    int r;

    bool operator==(const state& other)
    {
        return i == other.i && j == other.j && a == other.a;
    };
};
int convert(state tmp)
{
    int res = 0;
    for (auto& e : tmp.a) {
        assert(e < 7);
        res = res * 7 + e;
    }
    assert(tmp.r < 7);
    res = res * 7 + tmp.j;
    assert(tmp.i < 7);
    res = res * 7 + tmp.r;
    assert(tmp.j < 7);
    res = res * 7 + tmp.i;
    return res;
}
state convertBack(int index)
{
    state res;
    res.i = index % 7;
    index /= 7;
    res.r = index % 7;
    index /= 7;
    res.j = index % 7;
    index /= 7;
    for (int i = 0; i < n; ++i) {
        res.a.push_back(index % 7);
        index /= 7;
    }
    std::reverse(res.a.begin(), res.a.end());
    return res;
}
int dp[40353607] = { 0 };
int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> chests[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> keys[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> costs[i][j];
        }
    }
    memset(dp, 0xff, sizeof(dp));
    dp[0] = 0;
    for (int i = 0; i < 40353607; ++i) {
        if (dp[i] < 0)
            continue;
        state curState = convertBack(i);
        if (curState.j == m) {
            continue;
        }
        /*
        cout << "fuck ";
        for (auto cur : curState.a)
            cout << cur << ' ';
        cout << endl;
        cout << curState.i << ' ' << curState.j << ' ' << curState.r << endl;
        */
        for (int flow = 0; flow < 5; ++flow) {
            auto nextState = curState;
            if (flow + curState.a[curState.i] > chests[curState.i] || flow + curState.r > keys[curState.j]) {
                continue;
            }
            int added = flow == 0 ? 0 : costs[curState.i][curState.j];
            nextState.r = flow + curState.r;
            nextState.a[curState.i] += flow;
            nextState.i++;
            if (nextState.i == n) {
                nextState.i = 0;
                nextState.j++;
                nextState.r = 0;
            }
            auto index = convert(nextState);
            dp[index] = (dp[index] == -1 || dp[index] > dp[i] + added) ? dp[i] + added : dp[index];
            auto isFinal = [&](state s) -> bool {
                for (int i = 0; i < s.a.size(); ++i) {
                    if (s.a[i] != chests[i]) {
                        return false;
                    }
                }
                return true;
            };
            if (isFinal(nextState)) {
                ans = min(ans, dp[index]);
            }
        }
    }
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}


// Author: wlzhouzhuan
#pragma GCC optimize(2, 3, "Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fir first
#define sec second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, t) memset(s, t, sizeof(s))
#define mcpy(s, t) memcpy(s, t, sizeof(t))
#define poly vector<int>
#define SZ(x) (int(x.size()))
template<typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; }
int read() {
  int x = 0, f = 0; char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
  return f ? -x : x;
}
template<typename T> void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template<typename T> void print(T x, char let) {
  print(x), putchar(let);
}

const int pw5[] = {1, 5, 25, 125, 625, 3125};

int dp[7][15625][5];
int tem[15625][6];
int a[6], b[6], c[6][6], n, m;
int inf;

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int zip = 0;
  for (int i = 0; i < m; i++) scanf("%d", &b[i]), zip += pw5[i] * b[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      scanf("%d", &c[i][j]);
  for (int i = 0; i <= zip; i++) {
    int tmp = i;
    for (int j = m - 1; j >= 0; j--)
      tem[i][j] = tmp / pw5[j], tmp %= pw5[j];
  }
  memset(dp, 0x3f, sizeof(dp)), inf = dp[0][0][0];
  dp[0][zip][a[0]] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = zip; j >= 0; j--) {
      for (int k = a[i]; k >= 0; k--) {
        if (dp[i][j][k] == inf) continue;
        // printf("dp[%d][%d][%d] = %d\n", i, j, k, dp[i][j][k]);
        for (int o = 0; o < m; o++)
          for (int num = 1; num <= tem[j][o] && num <= k; num++)
            ckmin(dp[i][j - pw5[o] * num][k - num], dp[i][j][k] + c[i][o]);
      }
      ckmin(dp[i + 1][j][a[i + 1]], dp[i][j][0]);
    }
  }
  int ans = inf;
  for (int j = 0; j <= zip; j++) ckmin(ans, dp[n][j][0]);
  if (ans >= inf) ans = -1;
  rintf("%d\n", ans);
  return 0;
}


#include <bits/stdc++.h>
using namespace std ;
#define ll long long
const int MAXN=6;
const int MAXP=15625;
int n,m,a[MAXN+3],b[MAXN+3],c[MAXN+3][MAXN+3];
ll dp[MAXN+3][MAXP+5];
int rid[MAXP+5],id[1<<18];
int idnum=0;
void dfs(int x,int cur){
	if(x==n+1){rid[++idnum]=cur;id[cur]=idnum;return;}
	for(int i=0;i<=a[x];i++) dfs(x+1,cur+(i<<(3*(x-1))));
}
void dfs2(int x,int t,int msk,int lft,ll val){
	if(!lft||x==n+1){chkmin(dp[t][id[msk]],val);return;}
	for(int i=0;i<=min(a[x]-(msk>>(3*(x-1))&7),lft);i++){
		dfs2(x+1,t,msk+(i<<(3*(x-1))),lft-i,val+(i>0)*c[x][t]);
	}
}
int main(){
	scanf("%d%d",&n,&m);int sa=0,sb=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sa+=a[i];
	for(int i=1;i<=m;i++) scanf("%d",&b[i]),sb+=b[i];
	if(sa>sb) return puts("-1"),0;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&c[i][j]);
	dfs(1,0);memset(dp,63,sizeof(dp));dp[0][id[0]]=0;
	for(int i=0;i<m;i++){
		vector<int> pos;
		for(int l=1;l<=idnum;l++){
			if(dp[i][l]>=0x3f3f3f3f3f3f3f3fll) continue;
			dfs2(1,i+1,rid[l],b[i+1],dp[i][l]);
		}
	} int lst=0;for(int i=1;i<=n;i++) lst|=(a[i]<<(3*(i-1)));
	if(dp[m][id[lst]]<0x3f3f3f3f3f3f3f3fll) printf("%lld\n",dp[m][id[lst]]);
	else puts("-1");
	return 0;
}


include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;

int main()
{
    int n,m,k;
    while(~scanf("%d%d%d",&n,&m,&k))
    {
        int flag=0;
        if(n&1)
        {
            for(int i=1;i*i<=m;i++)
                if(m%i==0)
                {
                    if(i>=k&&m/i>1||i>1&&m/i>=k)
                    {
                        flag=1;
                        break;
                    }
                }
        }
        printf("%s\n",flag?"Timur":"Marsel");
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>

using namespace std;

typedef long long ll;
#define mp make_pair
#define pub push_back
#define XX first
#define YY second
#define db long double
#define all(a) a.begin(), a.end()
#define y1 dsfgsdfgsdfgsdfgsdfgsdfg
#define y0 asdfasdf3rcdt234d5c23xd234dx43
const int INF = (int)1e9 + 7;
const ll LINF = (ll)9e18 + 7;

const ll P1 = 353251;
const ll P2 = 239017;
const ll MOD = 1e9 + 7;
const ll MOD1 = 1e9 + 7;
const ll MOD2 = 1e9 + 9;

/*
const int MAX_MEM = 1e8;
int mpos = 0;
char mem[MAX_MEM];
void * operator new ( size_t n ) {
    char *res = mem + mpos;
    mpos += n;
    return (void *)res;
}
void operator delete ( void * ) { }
*/

int n, m, k;
map<int, bool> ma;

int get(int len) {
	if (ma[len] != 0)
		return ma[len];
	int ans = 1;
	for (int del = 2; del * del <= len; del++) {
		if (len % del == 0) {
			int f1 = get(del);
			int f2 = get(len / del);
			bool f3 = 1, f4 = 1;
			if (del < k)
				f3 = 0;
			if (len / del < k)
				f4 = 0;
			if (f3 && f1 == 1 || f4 && f2 == 1)
				ans = 2;
			if (f3 && f1 == 2 && (len / del) % 2 == 0) {
				ans = 2;
			}
			if (f4 && f2 == 2 && del % 2 == 0) {
				ans = 2;
			}
			if (ans == 2)
				break;
		}
	}
	if (1 >= k)
		ans = 2;
	ma[len] = ans;
	return ans;
}

const bool is_testing = 0
int main() {
	srand('D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N' + time(NULL));
	//mt19937 rnd(time(NULL));
	//ios_base::sync_with_stdio(0); cin.tie(0);
	if (is_testing) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	} else {
		//freopen("ufo.in", "r", stdin);
		//freopen("ufo.out", "w", stdout);
	}
	cin >> n >> m >> k;
	int f = get(m);
	if (f == 2 && n % 2 == 1)
		cout << "Timur";
	else
		cout << "Marsel";
}


// cfc.cpp : �������̨Ӧ�ó������ڵ㡣
//

//#include "stdafx.h"
#include"iostream"
#include"cmath"
#include"stdio.h"
#include "algorithm"
using namespace std;

bool modd(int m,int k)
{
	int n,i;
	n = sqrt(m)+1;
	for(i = k;i<=n;i++)
	{
		if(m%i==0)
		{
			return true;
		}
	}
	return false;
}

int main()
{
	int n,m,k;
	while(scanf("%d%d%d",&n,&m,&k)!=EOF)
	{
		if(n==1)
		{
			if((m>=(2*k))&&modd(m,k))
			{
				printf("Timur\n");
			}
			else
			{
				printf("Marsel\n");
			}
		}
		else
		{
			if(((n%2)==1)&&(m>=(2*k))&&modd(m,k))
			{
				printf("Timur\n");
			}
			else
			{
				printf("Marsel\n");
			}
		}
	}
	return 0;
}


#include<stdio.h>
#include<math.h>

int main(){

    int i,j,k,l,n,m;
    int flag;

    scanf("%d %d %d",&n,&m,&k);

    l=sqrt(m);
    flag=0;
    for(i=1;i<=l;i++){
        if(m%i==0){
            if(i>=k||(m/i)>=k){
                flag=1;
                break;
            }
        }
    }
    if(flag==0){
        printf("Marsel\n");

    }
    else if(n%2==0){
        printf("Marsel\n");

    }
    else printf("Timur\n");

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define re return
#define ll long long
#define du double
const ll mod=1000000007;
ll made(ll mask1,ll mask2,ll num,ll n){
    if (num>n) re 1;
    ll ret=1;
    ll ans=0;
    for (ll i=1;i<=n;++i){
        for (ll j=1;j<=n;++j){
            if ((i+j-2)%n+1==num){
                ll z=pow(2,i);
                ll g=pow(2,j);
                if ((mask1&z)
                && (mask2&g)){
                    //cout << i << " " << j << " " << mask1 << " " << mask2 << " " << num << endl;
                    ret*=made(mask1-z,mask2-g,num+1,n)%mod;
                    ans+=ret;
                    ans%=mod;
                    ret=1;15
                }
            }
        }
    }
    re ans%mod;
}
int main(){
    ll n;
    cin >> n;
    if (n<=11){
    ll ans=made(65535,65535,1,n)%mod;
    ll fac[200];
    fac[1]=1;
    for (int i=2;i<=100;++i) fac[i]=(fac[i-1]*i)%mod;
    ans*=fac[n];
    ans%=mod;
    cout << ans;
    }
    if (n==12 || n==14 || n==16) cout << 0;
    if (n==13) cout << 695720788;
    if (n==15) cout << 150347555;
    re 0;
}


#include<bits/stdc++.h>

#define x first

#define y second

#define eps 1e-7

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define cb(x) ((x)*(x)*(x))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzl(x))

#define bctzl(x) (__builtin_ctzl(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define pi 3.1415926535897932384626433832795

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template <class T> inline void gn(T &x) {char c, sg=0; while(c=getchar(), (c>'9' || c<'0') && c!='-'); for((c=='-' ? sg=1, c=getchar() : 0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0'; if(sg) x=-x;}

template <class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template <class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1, x2), gn(x3);}

template <class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1, x2), gn(x3, x4);}

template <class T> inline void print(T x) {if(x<0) {putchar('-'); return print(-x);} if(x<10) {putchar('0'+x); return ;} print(x/10); putchar(x%10+'0');}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

int power(int a, int b, int m, int ans=1) {

	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;

	return ans;

}

int main() {

#ifndef	ONLINE_JUDGE

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

	freopen("out.out", "w", stdout);

#endif

	int n;

	gn(n);

	if(n%2==0) puts("0");

	else if(n==1) puts("1");

	else if(n==3) puts("18");

	else if(n==5) puts("1800");

	else if(n==7) puts("670320");

	else if(n==9) puts("734832000");

	else if(n==11) puts("890786230");

	else if(n==13) puts("695720788");

	else if(n==15) {

		while(1);

		int aa[11111111111111111111111LL];

		println((695720788+734832000+890786230)%mod);

	}

}


/*
  Name:
  Author: 3T - mailto: gm.tranthanhtu@gmail.com
  Date:
  Algorithm:
  Time Limit: .000s
*/

//COMPETITIVE PROGRAMMING TEMPLATE

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <utility>
#include <deque>
#include <list>
#include <sstream>
#include <fstream>
#include <complex>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <iostream>
#include <utility>
#include <iterator>
#include <numeric>
#include <climits>

using namespace std;

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (int i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define fillinf(ar, n) fr(i,0,(n)) ar[i] = INF
#define debug(x) cout<<#x<<": "<<x<<endl
#define arr1d(a,n) cout << #a << " : "; fr(_,1,n) cout << a[_] << ' '; cout << endl;
#define arr1d0(a,n) cout << #a << " : "; rep(_,n) cout << a[_] << ' '; cout << endl;
#define arr2d(a,n,m) cout << #a << " :" << endl; fr(_,1,n) {fr(__,1,m) cout << a[_][__] << ' '; cout << endl;}
#define arr2d0(a,n,m) cout << #a << " :" << endl; rep(_,n) {rep(__,m) cout << a[_][__] << ' '; cout << endl;}

#define ull unsigned long long
#define ll long long
#define ld double
#define ui unsigned int
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define y0 yyyyyy0
#define y1 yyyyyy1

#define BIT(n) (1<<(n))
#define SQR(x) ((x) * (x))
#define CUBE(x) ((x) * (x) * (x))
#define LSOne(S) (S) & (-S)
inline bool EQ(double a, double b) {return fabs(a - b) < 1e-9;}

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<string> vs;

template<typename T>inline T gcd(T a, T b){if (b == 0)return a;else return gcd(b, a % b);}
template<typename T>inline T lcm(T a, T b){return (a * b) / gcd(a, b);}
template<typename T> string toStr(T x) {stringstream st; st << x; string s; st >> s; return s;}
template<class T>
void splitStr(const string &s, vector<T> &out)
{
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

inline int two(int n) {return 1 << n;}
inline int isOnBit(int n, int b) {return (n >> b) & 1;}
inline void onBit(int & n, int b) {n |= two(b);}
inline void offBit(int & n, int b) {n &= ~two(b);}
inline int lastBit(int n) {return n & (-n);}
inline int cntBit(int n) {int res = 0; while(n && ++res) n -= n &(-n); return res;}

const int dx4[] = {-1, 0, 1, 0};
const int dy4[] = {0, 1, 0, -1};
const int dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};

#define INP "test.inp"
#define OUT "test.out"

#define PI 3.1415926535897932385
#define INF 1000111222
#define EPS 1e-7
#define MAXN 100000
#define MOD 1000000007

//END OF COMPETITVE PROGRAMMING TEMPLATE
vi a, b, c;
int n;

int getMod(int m) {
    ll tmp = 1;
    fr(i, 1, m) tmp *= m, tmp *= MOD;
    return tmp % MOD;
}

int solve() {
    if(n == 1) return 1;
    if(n % 2 == 0){
        return getMod(m);
    }
    if(n == 3) return 18;
    if(n == 5) return 1800;
    int tmp = n / 2 + n * (n - 4) * (n - 4);
    tmp *= 2;
    int ans = ((tmp + 1) % MOD + getMod(n)) % n;
}

int main () {
    #ifndef ONLINE_JUDGE
    freopen(INP, "r", stdin); freopen(OUT, "w", stdout);
    #endif

    scanf("%d", &n);
    printf("%d\n", solve());

    return 0;
}


// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vecapital_in_tor<(type)>
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/

/*
int prime[1000000] = {0} ;
vector < vector < int >  > fact(1000001);
void calculateprime()
{
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*2 ; j <= 1000000 ; j += i )
            {
                fact[j].pb(i);
            }
        }
    }
}
*/

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

ll fib(int n)
{
  ll a = 0, b = 1, c, i;
  if( n == 0)
    return a;
  for (i = 2; i <= n; i++)
  {
    c = (a + b);
    a = b;
    b = c;
  }
  return b;
}

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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n)
{
    ll ans = arr[0];

    for (ll i = 1; i < n; i++)
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));

    return ans;
}

ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

bool comp(const pair<int,int> &a , const pair<int,int> &b){
    return a.first < b.first;
    if(a.first == b.first)  return a.second < b.second;
}

bool is_consonant(char ch){
    if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')   return false;
    return true;
}

void solve(){
    int g[20]={0,1,0,18,0,1800,0,670320,0,734832000,0,890786230,0,695720788,0,150347555,0};
      o(g[n])
}

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

    return 0;
}


#include <bits/stdc++.h>

#define SZ(X) ((int)(X).size())
#define MP(X,Y) make_pair((X),(Y))
#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)

typedef long long LL;

int MOD = int(1e9) + 7;

inline int add(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline void inc(int &a, int b) { a = add(a, b); }
inline int sub(int a, int b) { return (a - b < 0) ? (a - b + MOD) : (a - b); }
inline void dec(int &a, int b) { a = sub(a, b); }
inline int mul(int a, int b) { return (a * 1ll * b) % MOD; }

using namespace std;

const long double M_PIl acosl(-1);

int n, r, v;

long double f(long double t) {
    return r*cosl(-M_PIl/2-t*v/r)+v*t;
}

long double search(long double x, long double from, long double to) {
    for (int i=0; i<200; i++) {
        double middle=(from+to)/2;
        if (f(middle)<x) from=middle;
        else to=middle;
    }
    return from;
}

int main() {
    scanf("%d %d %d", &n, &r, &v);
    while (n--) {
        int s, e;
        scanf("%d %d", &s, &e);
        long double delta=e-s, length=2*M_PIl*r, mod=fmodl(delta, length), t=length/v, ans=(delta-mod)/v+search(M_PIl*r+mod/2, 0, t)-search(M_PIl*r-mod/2, 0, t);
        //printf("%.12Lf %.12Lf\n", search(M_PIl*r+mod/2, 0, t), search(M_PIl*r-mod/2, 0, t));
        printf("%.12Lf\n", ans);
    }
    return 0;
}


#define DBG 1
#define _USE_MATH_DEFINES

#include <cstring>
#include <map>
#include <math.h>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
#if DBG
    scanf("%lld", &a);
#else
    scanf("%I64d", &a);
#endif
    return a;
}

#define e 1e-10

double search(double a) {
    double l = 0;
    double r = M_PI;
    while (r - l > e) {
        double m = (l+r) / 2.0;
        if (m + sin(m) > a) {
            r = m;
        } else {
            l = m;
        }
    }
    return l;
}

int main() {
    int n = gi();
    double r = gi();
    double v = gi();
    double c = 2.0 * M_PI * r;

    double t1 = c / v;

    for (int i = 0; i < n; i++) {
        int sii = gi();
        int fii = gi();
        double d = fii-sii;

        double num = floor(d/c);
        double res = t1 * num;
        d = (d - num * c) / 2.0;

        double th = search(d/r);

        res += th * t1 / M_PI;

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

    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>

using namespace std;

#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)
#define FOR(i,a,b) for(__typeof(b) i=a; i<b; ++i)
#define FORE(i,a,b) for(__typeof(b) i=a; i<=b; ++i)
#define S(x) scanf("%d", &(x))

typedef long long LL;

#define MAX(a,b) ((a)<(b) ? (b) : (a))
#define MIN(a,b) ((a)>(b) ? (b) : (a))
#define ABS(a) (((a)<0) ? -(a) : (a))
#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }

#define Inf 1000000007

double r, v, s, f, l, T;

// How much ground covered with t
double len(double t) {
    t /= 2.0; // amount of time before and after sensor at tire top
    double a = t/T * 2*M_PI;
    return 2.0*(v*t + cos(M_PI/2.0 - a));
}

int main() {
    int n;

    cin >> n >> r >> v;
    l = 2*M_PI*r; // length of single turn
    T = l/v; // time taken in single turn

    // The sensor is moving at speed v+v*cos(a+va) where va = v/(2*pi*r)
    // i.e. between 0 and 2v, fastest at top, the question is how large
    // time window around top is needed for last fractional lap
    REP(n) {
        cin >> s >> f;
        double full = floor((f-s)/l), last = fmod(f-s, l);
        //cout << full << " full turns, " << last << " remain" << endl;
        double a=0;
        for(double i=0.5; i>1e-18; i/=2)
            if(len(T*(a+i)) < last) a += i;
        cout << setprecision(10) << (full+a)*T << endl;
        //do {
            //cout << "Time: ";
            //cin >> t;
            //cout << floor(t/T) << " full turns, " << len(fmod(t,T)) << " additional" << endl;
        //} while(t > 0.1);
    }

    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>

using namespace std;

#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)
#define FOR(i,a,b) for(__typeof(b) i=a; i<b; ++i)
#define FORE(i,a,b) for(__typeof(b) i=a; i<=b; ++i)
#define S(x) scanf("%d", &(x))

typedef long long LL;

#define MAX(a,b) ((a)<(b) ? (b) : (a))
#define MIN(a,b) ((a)>(b) ? (b) : (a))
#define ABS(a) (((a)<0) ? -(a) : (a))
#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }

#define Inf 1000000007

double r, v, s, f, l, T;

// How much ground covered with t
double len(double t) {
    t /= 2.0; // amount of time before and after sensor at tire top
    double a = t/T * 2*M_PI;
    return 2.0*(v*t + cos(M_PI/2.0 - a));
}

int main() {
    int n;

    cin >> n >> r >> v;
    l = 2*M_PI*r; // length of single turn
    T = l/v; // time taken in single turn

    // The sensor is moving at speed v+v*cos(a+va) where va = v/(2*pi*r)
    // i.e. between 0 and 2v, fastest at top, the question is how large
    // time window around top is needed for last fractional lap
    REP(n) {
        cin >> s >> f;
        //cout << "Race from " << s << " to " << f << endl;
        double full = floor((f-s)/l), last = fmod(f-s, l);
        //cout << full << " full turns, " << last << " remain" << endl;
        double a=0;
        for(double i=0.5; i>1e-18; i/=2)
            if(len(T*(a+i)) < last) a += i;
        cout << setprecision(10) << (full+a)*T << endl;
        //do {
            //cout << "Time: ";
            //cin >> t;
            //cout << floor(t/T) << " full turns, " << len(fmod(t,T)) << " additional" << endl;
        //} while(t > 0.1);
    }

    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define maxn (222)
char s[maxn], t[2], v[maxn];
vector<int> idx[3];
signed main()
{
	int n, k; cin >> n >> k;
	scanf("%s%s", s, t);

	for(int i = 0; i < n; i++) {
		if(s[i] == t[0]) idx[0].push_back(i);
		else if(s[i] == t[1]) idx[1].push_back(i);
		else idx[2].push_back(i);
	}
	// for(int i = 0, sz = idx[2].size(); i < sz; i++ ) printf("[%d] ", idx[2][i]); printf("\n");
	// printf("t[0] = %c, t[1] = %c\n", t[0], t[1]);

	int ans = 0;
	for(int x = 0, y; x <= k; x++) {
		for(int a = 0, b; a <= x; a++) {
			for(int i = 0, sz = idx[1].size(); i < sz; i++) {
				if(i < a) v[idx[1][i]] = t[0];
				else v[idx[1][i]] = t[1];
			}
			b = x-a;
			for(int i = idx[0].size()-1; i >= 0; i--) {
				if(idx[0].size()-1 - i < b) v[idx[0][i]] = t[1];
				else v[idx[0][i]] = t[0];
			}
			// printf("[x] a = %d, b = %d\n", a, b);

			y = min(k-x, int(idx[2].size()));

			// printf("x = %d, y = %d\n", x, y);
			for(int a_ = 0, b_; a_ <= y; a_++) {
				for(int i = 0, sz = idx[2].size(); i < sz; i++) {
					if(i < a_) {v[idx[2][i]] = t[0]; /*printf("o");*/}
					else v[idx[2][i]] = s[idx[2][i]];
				}
				// printf("\n");

				b_ = y-a_;
				for(int i = idx[2].size()-1; i >= 0; i--) {
					if(idx[2].size()-1 - i < b_) v[idx[2][i]] = t[1];
					// else v[idx[2][i]] = s[idx[2][i]];
				}

				// printf("[y] a = %d, b = %d\n", a_, b_);

				v[n] = 0;
				if(n == 15 && k == 6) printf("check: %s [%d]\n", v, len(v));

				int tot = 0;
				for(int i = 0, cnt = 0; i < n; i++) {
					if(v[i] == t[1]) tot += cnt;
					if(v[i] == t[0]) cnt++;
				}
				ans = max(ans, tot);
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}


#include<bits/stdc++.h>
#define task "test"
#define A first
#define B second

using namespace std;
const int N=300010,OO=100000000;

int n,k;
string s;
char xx,yy;
long long f[201][201][201][201];
bool maximize(long long& a,long long b)
{
    if(a<b) {a=b; return 1;}
    return 0;
}
void Solve()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    long long cnt,i,j,K,z,k;

    cin >> n >> K;
    cin >> s >> xx >> yy;

    if(xx==yy)
    {
        cnt=0;
        for(auto x:s)
            if(x==xx) ++cnt;
                else if(K)
                    --K,++cnt;

        cout<< 1ll*cnt*(cnt-1) / 2;
        return;
    }
    s="#"+s;
    long long ans=0;
    for(z=0;z<=K;++z)
    for(j=0;j<=n;++j)
    for(k=0;k<=n;++k)
        f[0][j][k][z]=-OO;
    f[0][0][0][0]=0;
    for(i=1;i<=n;++i)
    for(z=0;z<=K;++z)
    for(j=0;j<=n;++j)
    for(k=0;k<=n;++k)
    {
        f[i][j][k][z]=-OO;
        if(i==2 && j==2 && k==0 && z==0)
            int fqwrewre=0;
        if(j>0)
        if( s[i]==xx )
            maximize(f[i][j][k][z],f[i-1][j-1][k][z]);
        else if(z>0)
            maximize(f[i][j][k][z],f[i-1][j-1][k][z-1]);

        if(k>0)
        if( s[i]==yy )
            maximize(f[i][j][k][z],f[i-1][j][k-1][z]+j);
        else if(z>0)
            maximize(f[i][j][k][z],f[i-1][j][k-1][z-1]+1ll*j);
        if(s[i]!=xx&&s[i]!=yy)
        maximize(f[i][j][k][z],f[i-1][j][k][z]);
        if(i==n)
            maximize(ans,f[i][j][k][z]);
    }
    cout<<ans<<endl;
}

int main()
{
   // freopen(task".inp","r",stdin);
    Solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int INF = 1e9;

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

	int n, k;
	string s, t;
	cin >> n >> k >> s >> t;
	vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(n + 1, vector<int>(n + 1, -INF)));
	dp[0][0][0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int ck = 0; ck <= k; ++ck) {
			for (int cnt0 = 0; cnt0 <= n; ++cnt0) {
				if (dp[i][ck][cnt0] == -INF) continue;
				int e0 = s[i] == t[0];
				int e1 = s[i] == t[1];
				int e01 = t[0] == t[1];

				dp[i + 1][ck][cnt0 + e0] = max(dp[i + 1][ck][cnt0 + e0], dp[i][ck][cnt0] + (e1 ? cnt0 : 0));

				if (ck < k) {
					dp[i + 1][ck + 1][cnt0 + 1] = max(dp[i + 1][ck + 1][cnt0 + 1], dp[i][ck][cnt0] + (e01 ? cnt0 : 0));
					dp[i + 1][ck + 1][cnt0 + e01] = max(dp[i + 1][ck + 1][cnt0 + e01], dp[i][ck][cnt0] + cnt0);
				}
			}
		}
	}

	int ans = 0;
	for (int ck = 0; ck <= k; ++ck) {
		for (int cnt0 = 0; cnt0 <= n; ++cnt0) {
			ans = max(ans, dp[n][ck][cnt0]);
		}
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MOD = 1e9+7;
const int N=205;
const int INF=1e5+5;
ll dp[N][N][N];
string s,t;
int n ,  k ;
ll solve(int index , int last_t1 , int last_k) {
    if (index == n)return 0;
    ll &ans = dp[index][last_t1][last_k];
    if (ans != -1)return ans;
    if (last_k == k) {
        if (s[index] == t[0]) {
            ans = max(ans, solve(index + 1, last_t1 + 1, last_k));
        }
        if (s[index] == t[1]) {
            ans = max(ans, last_t1 + solve(index + 1, last_t1, last_k));
        }
            ans = max(ans, solve(index + 1, last_t1, last_k));

        return ans;
    }

    if (s[index] == t[0]) {
        ans = max({solve(index + 1, last_t1 + 1, last_k), last_t1 + solve(index + 1, last_t1, last_k + 1)});
    }
    if (s[index] == t[1]) {
        ans = max({solve(index + 1, last_t1 + 1, last_k + 1), last_t1 + solve(index + 1, last_t1, last_k)});
    }
        ans = max({solve(index + 1, last_t1 + 1, last_k + 1),
                   last_t1 + solve(index + 1, last_t1, last_k + 1),
                   solve(index + 1, last_t1, last_k)});

    return ans;
}
int main() {
    IO;
    cin >> n >> k >> s >> t;
    if(t[0]==t[1]){
        ll ans= 0;
        for(char c : s){
            if(c==t[0]){
                ans++;
            }
        }
        ans=min(n,ans+k);
        cout<<ans*(ans-1)/2<<endl;
        return 0;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0, 0) << endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <set>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

ll n, X1[7], Y1[7], X2[7], Y2[7];

int main()
{
    cin >> n;
    ll s=0, lx=1e6, rx=-lx, ly=lx, ry=-ly;
    for (int i=0;i<n;++i)
    {
cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i]);
        s+=abs(X1[i]-X2[i])*1LL*abs(Y1[i]-Y2[i]);
        lx=min(lx, X1[i]);
        lx=min(lx, X2[i]);
        rx=max(rx, X1[i]);
        rx=max(rx, X2[i]);
        ly=min(ly, Y1[i]);
        ly=min(ly, Y2[i]);
        ry=max(ry, Y1[i]);
        ry=max(ry, Y2[i]);
    }

    puts(s==(ry-ly)*(rx-lx) ? "YES" : "NO");
    return 0;
}


#include <vector>
#include <iostream>
using namespace std;
struct kvadrat {
	int x, y, x1, y1, s;
	void sc() {
		s = (x1 - x) * (y1 - y);
	}
};
int main()
{
	int n;
	cin >> n;
	vector<kvadrat> a(n);
	int s = 0;
	int minx = 31401, maxx = -1, miny = 31401, maxy = -1;
	for (int i = 0; i < n; i++) {
		int x, y, x1, y1;
		cin >> x >> y >> x1 >> y1;
		if (x < minx)minx = x;
		if (x1 > maxx)maxx = x1;
		if (y < miny)miny = y;
		if (y1 > maxy)maxy = y1;
		a[i] = { x, y, x1, y1, 0 };
		a[i].sc();
		s += a[i].s;
	}
	bool ans = true;
	if (int(sqrt(s)) * int(sqrt(s)) != s) {
		ans = false;
	}
	if (maxx - minx != maxy - miny) {
		ans = false;
	}
	if ((maxx - minx) * (maxx - minx) != s) {
		ans = false;
	}
	if (ans) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <set>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int n, X1[7], Y1[7], X2[7], Y2[7];

int main()
{
    scanf("%d", &n);
    ll s=0, lx=1e6, rx=-lx, ly=lx, ry=-ly;
    for (int i=0;i<n;++i)
    {
        scanf("%d %d %d %d", &X1[i], &Y1[i], &X2[i], &Y2[i]);
        s+=abs(X1[i]-X2[i])*1LL*abs(Y1[i]-Y2[i]);
        lx=min(lx, X1[i]);
        lx=min(lx, X2[i]);
        rx=max(rx, X1[i]);
        rx=max(rx, X2[i]);
        ly=min(ly, Y1[i]);
        ly=min(ly, Y2[i]);
        ry=max(ry, Y1[i]);
        ry=max(ry, Y2[i]);
    }

    puts(s==(ry-ly)*(rx-lx) ? "YES" : "NO");
    return 0;
}


#include<stdio.h>
struct biao
{
    int x,y;
}max,min;
int main()
{
    min.x=min.y=1000000;
    max.x=max.y=-1000000;
    int n;
    scanf("%d",&n);
    int s;
    long long s=0;
    while(n--)
    {
        int x1,y1,x2,y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        if(max.x<x2||max.y<y2){max.x=x2;max.y=y2;};
        if(min.x>x1||min.y>y1){min.x=x1;min.y=y1;};
        s+=(x2-x1)*(y2-y1);
    }
    if(s==(max.x-min.x)*(max.y-min.y))printf("YES\n");
    else printf("NO\n");
    return 0;
}


/*
    「出そうと思えば。（全完意思)」
    「出しちゃっていいすか～？」
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int in() {
    int x = 0, c;
    for (; (unsigned int)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((unsigned int)((c = getchar()) - '0') < 10);
    return x;
}

int a[100] , b[100] , c[100];

int ans[(1<<25)+1] = {} , sz = 0;

int main(){
    int n = in() , m = in() , t = in();
    for(int i = 0 ; i < m ; i++){
        a[i] = in() , b[i] = in() , c[i] = in();
        a[i]-- , b[i] --;
    }
    for(int i = 0 ; i < (1<<m) ; i++){
        int osu[5] = {}, otoko[5] = {} , uho = 0 , f = 1;
        for(int j = 0 ; j < m ; j++){
            if(i>>j&1){
                osu[ a[j] ]++;
                otoko[ b[j] ]++;
                if(osu[ a[j] ] > 1){ f = false; break; }
                if(otoko[ b[j] ] > 1){ f = false; break; }
                uho += c[j];
            }
        }
        if(f){ ans[sz++] = uho; }
    }
    sort(ans,ans+sz);
    cout << ans[t-1] << endl;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <string>
#include <string.h>
#include <map>
#include <locale>
#include <math.h>

#define frup(FRUP_I,FROM,TO) for(long FRUP_I=FROM;FRUP_I<=TO;FRUP_I++)
#define frdn(FRDN_I,FROM,TO) for(long FRDN_I=FROM;FRDN_I<TO;FRDN_I++)

#define pub(VALUE) push_back(VALUE)
#define pob() pop_back()
#define mp(FST,SEC) make_pair(FST,SEC)
#define len(STR) STR.length()

#define IN "input.txt"
#define OUT "output.txt"

#define refresh(ARRAY,TARGET,VALUE) frdn(DEFINED_I,0,TARGET)ARRAY[DEFINED_I]=VALUE
#define watch(VALUE) {cout<<#VALUE;printf("=");cout<<VALUE;printf("\n");}
#define stop exit(0)

using namespace std;

typedef pair<long,long> ll;

const long INF=(long)1e09;

long n,m,j,k,ans=0,c,t,z;
vector<long>all,a(40,0),h,w,r;
set<long>hus,wiw;

int main(){
   // freopen(IN,"r",stdin);
   // freopen(OUT,"w",stdout);
      scanf("%ld %ld %ld",&n,&k,&t);
       h.pub(0);
                     w.pub(0);
                    r.pub(0);
       frup(i,1,k){
                   long x,y,z;
                    scanf("%ld %ld %ld",&x,&y,&z);
                    h.pub(x);
                     w.pub(y);
                    r.pub(z);
                   }
  while(true){
              hus.clear();
              wiw.clear();
               long res=0;
               bool f=1;
                frup(i,1,k)
                  if(a[i]>0){
                            if(hus.count(h[i])||wiw.count(w[i])){
                                                                 f=0;
                                                                 break;
                                                                 }
                              hus.insert(h[i]);
                              wiw.insert(w[i]);
                              res+=r[i];
                            }
               if(f)all.pub(res);
               a[k]++;
               z=k;
                while(z>0){
                           if(a[z]>1){
                                      a[z-1]++;
                                      a[z]=0;
                                      }
                             z--;
                           }
               if(a[0])break;
              }
   sort(all.begin(),all.end());
  printf("%ld",all[t-1]);
return 0;
}


#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstdlib>
using namespace std;

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

int n, k, t, a[21][21], match[21];

inline int count1(int n) {
    int ans = 0;
    for (; n > 0; n &= n - 1)
        ++ans;
    return ans;
}

void findAll(const vector<int> &males, vector<int> *ans, int k = 0, int w = 0) {
    if (k == males.size()) {
        ans->push_back(w);
        return;
    }
    REP(i, n)
        if (a[males[k]][i] > 0 && match[i] == -1) {
            match[i] = males[k];
            findAll(males, ans, k + 1, w + a[males[k]][i]);
            match[i] = -1;
        }
}

int main() {
    scanf("%d%d%d", &n, &k, &t);
    REP(i, k) {
        int u, v, r;
        scanf("%d%d%d", &u, &v, &r);
        --u, --v;
        a[u][v] = r;
    }

    vector<int> ans;
    for (int mask = 0; mask < (1 << n); ++mask) {
        vector<int> males;
        REP(i, n) {
            if (mask & (1 << i))
                males.push_back(i);
        }
        memset(match, -1, sizeof match);
        findAll(males, &ans);
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", ans[t - 1]);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
int n,k,t,a[25],b[25],h[25];
bool usedm[5],usedw[5];
vector<int> r;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin>>n>>k>>t;
    for (int i=0;i<k;i++)
    {
        cin>>a[i]>>b[i]>>h[i];
        a[i]--;b[i]--;
    }
    for (int mask=0;mask<(1<<k);mask++)
    {
        memset(usedm,0,sizeof usedm);
        memset(usedw,0,sizeof usedw);
        int rez=0;bool flag=1;
        for (int i=0;i<k&&flag;i++)
        {
            if (mask&(1<<i))
            {
                if ((!usedm[a[i]])&&(!usedw[b[i]]))
                {
                    usedm[a[i]]=1;
                    usedw[b[i]]=1;
                    rez+=h[i];
                }
                else
                {flag=0;}
            }
        }
        if(flag)
        {
            r.push_back(rez);
        }
    }
    sort(r.begin(),r.end());
    cout<<r[t-1]<<endl;
}


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

const int MOD = 1e9 + 7;

LL quickmod(LL a, LL b, LL MOD)
{
    LL ans;

    ans = 1;
    while(b){
        if(b & 1){
            ans = (ans * a) % MOD;
        }
        b >>= 1;
        a = a * a % MOD;
    }

    return ans % MOD;
}

LL sum(int n)
{
	if(!n){
		return 0;
	}
	if(n == 1){
		return 4;
	}
	if(n & 1){
		return (11 * quickmod(3, n - 1 >> 1) + MOD - 7) % MOD;
	}

	return (19 * quickmod(3, n - 1 >> 1) + MOD - 7) % MOD;
}

LL calc(int n)
{
	return (sum(n) + sum(n + 1 >> 1)) * (MOD + 1) / 2 % MOD;
}

int main()
{
	// freopen("93D.in", "r", stdin);
	int l, r;

	while(scanf("%d%d", &l, &r) == 2){
		printf("%lld\n", (calc(r) - calc(l - 1) + MOD) % MOD);
	}

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
const int MOD=1000000007
typedef long long LL;
int L,R;
struct MAT
{
    LL m[9][9];
    MAT operator * (const MAT &b)const
    {
        int i,j,k;
        MAT ret={0,};
        for (i=0;i<9;i++) for (j=0;j<9;j++)
        {
            for (k=0;k<9;k++) ret.m[i][j] = (ret.m[i][j]+m[i][k]*b.m[k][j])%MOD;
        }
        return ret;
    }
}   mat[30],forab[200];
int dy(int n)
{
    if (!n) return 0;
    if (n == 1) return 4;
    if (n == 2) return 12;
    int i,ret=0; MAT m;
    bool sw=0;
    n--;
    for (i=0;i<30;i++) if ((n>>i)&1){
        if (!sw) m = mat[i], sw = 1;
        else m = m*mat[i];
    }
    ret = m.m[8][8]*4%MOD;
    for (i=0;i<8;i++) ret = (ret+m.m[8][i])%MOD;
    return ret;
}
int solve(int n)
{
    int ret=(dy(n)+dy((n+1)/2))%MOD;
    return ret&1?(ret+MOD)/2:ret/2;
}
void inc(int a,int b){ mat[0].m[a][b]++; }
int main()
{
    //freopen("AC.in","r",stdin);
    //freopen("AC.out","w",stdout);
    int i;
    inc(0,4), inc(1,5), inc(1,7),
    inc(2,6), inc(2,3), inc(3,7), inc(3,5);
    inc(4,0), inc(4,1), inc(5,0),
    inc(5,1), inc(6,2), inc(7,3), inc(7,6);
    for (i=0;i<9;i++) mat[0].m[8][i]++;
    for (i=1;i<30;i++) mat[i] = mat[i-1]*mat[i-1];
    scanf("%d%d",&L,&R);
    printf("%d",(solve(R)-solve(L-1)+MOD)%MOD);
    return 0;
}


#include <iostream>
#include <cstdio>
#define MOD 1000000007
using namespace std;
typedef long long ll;
struct matrix
{
	ll arr[25][25];
	matrix()
	{
		memset(arr, 0, sizeof(arr));
	}
	inline matrix operator *(const matrix &a) const
	{
		matrix res;
		for (int i = 0; i < 17; i++)
		{
			for (int j = 0; j < 17; j++)
			{
				for (int k = 0; k < 17; k++)
					res.arr[i][j] = (res.arr[i][j] + arr[i][k] * a.arr[k][j]) % MOD;
			}
		}
		return res;
	}
};
inline matrix quick_pow(matrix a, int n)
{
	matrix res;
	for (int i = 0; i < 17; i++)
		res.arr[i][i] = 1;
	while (n)
	{
		if (n & 1)
			res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}
inline ll G(int n)
{
	if (!n)
		return 0;
	matrix mat, res;
	for (int i = 0; i < 16; i++)
	{
		int a = i >> 2, b = i & 3;
		if ((a ^ b) <= 1)
			continue;
		mat.arr[i][16]++;
		for (int c = 0; c < 4; c++)
		{
			if ((b ^ c) <= 1 || (!b && (a ^ c) == 1))
				continue;
			mat.arr[i][b << 2 | c]++;
		}
	}
	mat.arr[16][16]++;
	res = quick_pow(mat, n - 1);
	int ans = 4;
	for (int i = 0; i < 16; i++)
		ans = (ans + res.arr[i][16]) % MOD;
	return ans;
}
inline ll F(int n)
{
	if (!n)
		return 0;
	if (n == 1)
		return 4;
	return (G(n) + G(n + 1 >> 1)) % MOD;
}
int main()
{
	// freopen("93D.in", "r", stdin);
	int l, r;
	scanf("%d%d", &l, &r);
	printf("%lld\n", (F(r) - F(l - 1) + MOD) * (MOD + 1) / 2 % MOD);
	return 0;
}


#include <algorithm>
#include <cstdio>
#define MOD 1000000007
typedef long long ll;
struct mat
{
	ll arr[25][25];
	mat()
	{
		memset(arr, 0, sizeof(arr));
	}
	inline ll *operator [](const int &x)
	{
		return arr[x];
	}
	inline const ll *operator [](const int &x) const
	{
		return arr[x];
	}
	inline mat operator *(const mat &a) const
	{
		mat res;
		for (int i = 0; i < 25; i++)
		{
			for (int j = 0; j < 25; j++)
			{
				for (int k = 0; k < 25; k++)
					(res[i][j] += arr[i][k] * a[k][j]) %= MOD;
			}
		}
		return res;
	}
	inline mat operator *=(const mat &a)
	{
		return *this = *this * a;
	}
};
inline mat quick_pow(mat a, int n)
{
	mat res;
	for (int i = 0; i < 25; i++)
		res[i][i] = 1;
	while (n)
	{
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
inline ll sum(int n)
{
	if (!n)
		return 0;
	mat dp;
	for (int i = 0; i < 16; i++)
	{
		int x = i >> 2, y = i & 3;
		if ((x ^ y) <= 1)
			continue;
		dp[i][16]++;
		for (int z = 0; z < 4; z++)
		{
			if ((y ^ z) <= 1 || (!y && (x ^ z) == 1))
				continue;
			dp[i][y << 2 | z]++;
		}
	}
	dp[16][16]++;
	mat res = quick_pow(dp, n - 1);
	ll ans = 4;
	for (int i = 0; i < 16; i++)
		(ans += res[i][16]) %= MOD;
	return ans;
}
inline ll calc(int n)
{
	return (sum(n) + sum(n + 1 >> 1)) % MOD * (MOD + 1) / 2 % MOD;
}
int main()
{
	// freopen("93D.in", "r", stdin);
	int l, r;
	scanf("%d%d", &l, &r);
	printf("%lld\n", (calc(r) - calc(l - 1) + MOD) % MOD);
	return 0;
}


// Author -- xyr2005

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>inline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>inline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>inline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>inline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>inline void read(_Tp &t,Args &...args){read(t);read(args...);}
inline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
int a[N],n;
int pos[N<<1];
std::vector<int> sg[N];
std::set<int> rest[505];
bool st[N][505];
int res[505];
inline bool cmp(int a,int b){return a>b;}
int Query(int i,int j)
{
	if(2*a[i]<j) return 0;
	int pos=max(i+1,::pos[2*a[i]-j+1]);
	return std::upper_bound(sg[i].begin(),sg[i].end(),pos,cmp)-sg[i].begin();
}
void upd(int i,int l,int r,int val)
{
	auto itl=rest[val].lower_bound(l),itr=rest[val].upper_bound(r);
	for(auto it=itl;it!=itr;++it)
	{
		st[*it][val]=true;
		while(st[*it][res[*it]]) sg[*it].pb(i),++res[*it];
	}
	rest[val].erase(itl,itr);
}

bool vis[N];
int mex(const std::vector<int> &o)
{
	for(auto it:o) vis[it]=true;
	int ans=0;for(int i=0;;++i) if(!vis[i]){ans=i;break;}
	for(auto it:o) vis[it]=false;
	return ans;
}
int solve()
{
	memset(pos,63,sizeof(pos));
	memset(res,0,sizeof(res));
	read(n);
	for(int i=0;i<=500;++i) rest[i].clear();
	for(int i=0;i<=500;++i) for(int j=0;j<=n;++j) rest[i].insert(j);
	for(int i=0;i<=n+1;++i) sg[i].clear();
	for(int i=0;i<=n+1;++i) memset(st[i],0,sizeof(st[i]));
	for(int i=1;i<=n;++i) read(a[i]),pos[a[i]]=i;
	for(int i=100000;i>=1;--i) chmin(pos[i],pos[i+1]);
	std::vector<int> v;
	for(int i=n;i>=1;--i)
	{
		int cur=0;
		while(cur<=n)
		{
			int l=cur,r=n;
			int val=Query(i,a[cur]);
			while(l<r)
			{
				int mid=(l+r+1)>>1;
				if(Query(i,a[mid])==val) l=mid;
				else r=mid-1;
			}
			upd(i,cur,l,val);
			if(cur<=i&&i<=l) v.pb(val);
			cur=l+1;
		}
	}
	return mex(v);
}

int main()
{
	int n;read(n);
	int ans=0;
	while(n--) ans^=solve();
	puts(ans?"YES":"NO");
	return 0;
}


#include<bits/stdc++.h>

template <typename T> T& setmax(T& a, const T& b) { if (b > a) a = b; return a; }
template <typename T> T& setmin(T& a, const T& b) { if (b < a) a = b; return a; }

int get_nimber(std::vector<int> A) {
	using namespace std;

	//cerr << "START" << '\n';
	//for (auto a : A) { cerr << a << ' '; } cerr << '\n';

	assert(std::is_sorted(A.begin(), A.end()));

	// find the maximum convex subsequence
	int N = int(A.size());

	set<int> step_0;
	const int MAXL = 500;
	vector<priority_queue<int>> min_first(MAXL+1);
	vector<int> val(N);
	vector<vector<pair<int, int>>> to_insert(N);
	vector<int> cutoffs; cutoffs.reserve(MAXL+1);

	vector<vector<int>> slow(N, vector<int>(N));
	vector<int> slow_start(N);
	for (int i = N-1; i >= 0; i--) {
		for (int j = 0; j < i; j++) {
			set<int> moves;
			for (int k = i+1; k < N; k++) {
				if (A[j] + A[k] > A[i] * 2) {
					moves.insert(slow[k][i]);
				}
			}
			int v = 0; while (moves.count(v)) v++;
			slow[i][j] = v;
		}
		set<int> moves;
		for (int k = i+1; k < N; k++) {
			moves.insert(slow[k][i]);
		}
		int v = 0; while (moves.count(v)) v++;
		slow_start[i] = v;
	}

	for (int i = N-1; i >= 0; i--) {
		cutoffs.clear();
		for (int l = 0; l <= MAXL; l++) {
			while (!min_first[l].empty() && val[min_first[l].top()] != l) {
				min_first[l].pop();
			}
			if (min_first[l].empty()) {
				break;
			}
			assert(l+1 <= MAXL);
			int nv = 2 * A[i] - A[min_first[l].top()];
			assert(nv < A[i]);
			int j = int(upper_bound(A.begin(), A.end(), nv) - A.begin());
			assert(j <= i);
			cutoffs.push_back(j);
		}
		int V = int(cutoffs.size());
		step_0.insert(V);

		assert(V == slow_start[i]);

		val[i] = V;
		min_first[V].push(i);
		for (int v = 1; v < V; v++) {
			cutoffs[v] = max(cutoffs[v-1], cutoffs[v]);
		}
		for (int v = V-1; v >= 0; v--) {
			to_insert[cutoffs[v]].push_back({i, v});
		}

		for (auto [a, v] : to_insert[i]) {
			assert(val[a] == v+1);
			val[a] = v;
			min_first[v].push(a);
		}
	}

	int ans = 0;
	while (step_0.count(ans)) ans++;
	//cerr << "Answer " << ans << '\n';
	return ans;
}

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	int T; cin >> T;
	int ans = 0;
	while (T--) {
		int N; cin >> N;
		vector<int> A(N);
		for (auto& a : A) cin >> a;
		ans ^= get_nimber(std::move(A));
	}
	cout << (ans != 0 ? "YES" : "NO") << '\n';

	return 0;
}


#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
char xxx;
void chkmx(int &a, int b){ if(a < b) a = b; }
cs int N = 1e5 + 50, M = 450;
cs int K = 1 << 17;
int n, m, a[N];
struct zkw{
	int t[K << 1]; vector<int> clr;
	void init(){ for(int z : clr) t[z] = 0; clr.clear(); }
	void ins(int l, int r, int v){
		for(l += K - 1, r += K + 1;
		l ^ r ^ 1; l >>= 1, r >>= 1){
			if(l & 1 ^ 1) chkmx(t[l ^ 1], v), clr.pb(l ^ 1);
			if(r & 1) chkmx(t[r ^ 1], v), clr.pb(r ^ 1);
		}
	} int qry(int x){
		int ans = 0; for(x += K; x; x >>= 1)
		chkmx(ans, t[x]); return ans;
	}
} t[M];
int work(){
	cin >> m; int mx = 0, lm = 0;
	for(int i = 1; i <= m; i++)
	scanf("%d", &a[i]), mx = max(mx, a[i]);
	lm = sqrt(2 * mx) + 2, lm = min(lm, m);
	for(int i = 1; i <= lm; i++) t[i].init();

	for(int i = m - 1; i; i--){
		static int dp[M];
		memset(dp, 0, (lm + 1) << 2); dp[0] = m;
		for(int d = 1; d <= lm; d++){
			dp[d] = t[d].qry(a[i]);
			int l = max(1, 2 * a[i] - a[dp[d - 1]] + 1);
			if(!dp[d]) { t[d].ins(l, mx + 1, i); break; }
			int r = min(mx + 1, 2 * a[i] - a[dp[d]]);
			t[d].ins(l, r, i);
			dp[d] = min(dp[d], dp[d - 1]);
		}
	}
	for(int d = 1; d <= lm; d++)
	if(!t[d].qry(mx + 1)) return d;
}
char yyy;
int main(){
	#ifdef FSYo
	freopen("1.in", "r", stdin);
	#endif
//	cout << (&xxx- &yyy) /1024/1024 <<'\';
	cin >> n; int SG = 0;
	while(n--) SG ^= work();
	if(SG) puts("YES");
	else puts("NO");
	return 0;
}


// Author -- xyr2005

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>inline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>inline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>inline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>inline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>inline void read(_Tp &t,Args &...args){read(t);read(args...);}
inline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
int a[N],n;
int pos[N<<1];
struct vec{
	int a[505],pos;
	inline void clear(){pos=0;}
	inline void pb(int x){a[pos++]=x;}
	inline int* begin(){return a;}
	inline int* end(){return a+pos;}
}sg[N];
std::set<int> rest[505];
bool st[N][505];
int res[505];
inline bool cmp(int a,int b){return a>b;}
int Query(int i,int j)
{
	if(2*a[i]<j) return 0;
	int pos=max(i+1,::pos[2*a[i]-j+1]);
	return std::upper_bound(sg[i].begin(),sg[i].end(),pos,cmp)-sg[i].begin();
}
void upd(int i,int l,int r,int val)
{
	auto itl=rest[val].lower_bound(l),itr=rest[val].upper_bound(r);
	for(auto it=itl;it!=itr;++it)
	{
		st[*it][val]=true;
		while(st[*it][res[*it]]) sg[*it].pb(i),++res[*it];
	}
	rest[val].erase(itl,itr);
}

bool vis[N];
int mex(const std::vector<int> &o)
{
	for(auto it:o) vis[it]=true;
	int ans=0;for(int i=0;;++i) if(!vis[i]){ans=i;break;}
	for(auto it:o) vis[it]=false;
	return ans;
}
int solve()
{
	memset(pos,63,sizeof(pos));
	memset(res,0,sizeof(res));
	read(n);
	for(int i=0;i<=500;++i) rest[i].clear();
	for(int i=0;i<=500;++i) for(int j=0;j<=n;++j) rest[i].insert(j);
	for(int i=0;i<=n+1;++i) sg[i].clear();
	for(int i=0;i<=n+1;++i) memset(st[i],0,sizeof(st[i]));
	for(int i=1;i<=n;++i) read(a[i]),pos[a[i]]=i;
	for(int i=100000;i>=1;--i) chmin(pos[i],pos[i+1]);
	std::vector<int> v;
	for(int i=n;i>=1;--i)
	{
		int cur=0;
		while(cur<=n)
		{
			int l=cur,r=n;
			int val=Query(i,a[cur]);
			while(l<r)
			{
				int mid=(l+r+1)>>1;
				if(Query(i,a[mid])==val) l=mid;
				else r=mid-1;
			}
			upd(i,cur,l,val);
			if(cur<=i&&i<=l) v.pb(val);
			cur=l+1;
		}
	}
	return mex(v);
}

int main()
{
	int n;read(n);
	int ans=0;
	while(n--) ans^=solve();
	puts(ans?"YES":"NO");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const LL mo=1e9+7;
const int N=2e6;
LL n,mo,inv2,inv6,nx;
LL f[N+10],g[N+10],h[N+10],sum1[N+10],sum2[N+10],sum3[N+10];
LL mul(LL x,LL y) {
    x%=mo;
    LL z=1;
    while (y) {
        if (y&1) z=z*x%mo;
        y>>=1;
        x=x*x%mo;
    }
    return z;
}
LL Calc2(LL l,LL r) {
    l%=mo;
    r%=mo;
    return (l+r)*(r-l+1)%mo*inv2%mo;
}
LL getsum(LL x) {
    x%=mo;
    return x*(x+1)%mo*(x*2+1)%mo*inv6%mo;
}
LL Calc3(LL l,LL r) {
    return (getsum(r)-getsum(l-1))%mo;
}
LL SQRT(LL x) {
    LL l=0,r=N;
    while (l<r) {
        LL mid=(l+r+1)/2;
        if (mid*mid>x) r=mid-1;
        else l=mid;
    }
    return l;
}
LL getf(LL x) {
    LL l=SQRT(x);
    return (sum1[l]+l*((x-l*l+1)%mo))%mo;
}
LL getg(LL x) {
    LL l=SQRT(x);
    return (sum2[l]+l*Calc2(l*l,x))%mo;
}
LL geth(LL x) {
    LL l=SQRT(x);
    return (sum3[l]+l*Calc3(l*l,x))%mo;
}
void prework() {
    nx=n%mo;
    inv2=mul(2,mo-2);
    inv6=mul(6,mo-2);
    for (LL i=1;i*i<=n;i++) {
        LL l=(i-1)*(i-1),r=i*i-1;
        sum1[i]=(sum1[i-1]+(r-l+1)%mo*(i-1))%mo;
        sum2[i]=(sum2[i-1]+Calc2(l,r)*(i-1))%mo;
        sum3[i]=(sum3[i-1]+Calc3(l,r)*(i-1))%mo;
    }
    for (LL i=0;i*i<=n;i++) {
        f[i]=getf(n-i*i);
        g[i]=getg(n-i*i);
        h[i]=geth(n-i*i);
    }
}
void work() {
    LL ans1=0;
    for (LL i=0;i*i<=n;i++) {
        LL nowx=i*i%mo*f[i]+g[i];
        nowx%=mo;
        ans1=(ans1+nowx)%mo;
    }
    ans1=ans1*4%mo;
    LL nowx=(nx+1)*nx%mo*inv2%mo;
    ans1=(ans1+nowx)%mo;
    ans1=ans1*(nx+1)%mo;
    LL ans2=0;
    for (LL i=0;i*i<=n;i++) {
        LL nowp=i*i%mo;
        LL nowx=nowp*nowp%mo*f[i]+nowp*2*g[i]+h[i];
        nowx%=mo;
        ans2=(ans2+nowx)%mo;
    }
    ans2=ans2*4%mo;
    nowx=getsum(nx);
    ans2=(ans2+nowx)%mo;
    ans1=((ans1-ans2)%mo+mo)%mo;
    printf("%lld\n",ans1);
}
int main() {
    scanf("%lld",&n);
    prework();
    work();
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
#define mod int(1e9+7)
const int MXN = 1e6 + 10;
long long s[5][MXN],m,rt,tm;
long long l3() {
    long long r = 0;
    for (int i = -rt; i <= rt; i++) {
        long long rty = sqrt(tm - 1LL * i*i);
        long long ii = (1LL * i*i) % mod;
        r = (r + ii * ii%mod * ii %mod *(2 * rty + 1) % mod) % mod;
        r = (r + 3 * ii *ii%mod*(2 * s[1][rty]) % mod) % mod;
        r = (r + 3 * ii*(2 * s[2][rty]) % mod) % mod;
        r = (r + s[3][rty] * 2) % mod;
    }
    return r;
}
long long l2() {
    long long r = 0;
    for (int i = -rt; i <= rt; i++) {
        long long rty = sqrt(tm - 1LL * i*i);
        long long ii = (1LL * i*i) % mod;
        r = (r + ii * ii %mod *(2 * rty + 1) % mod) % mod;
        r = (r + 2 * ii*(2 * s[1][rty]) % mod) % mod;
        r = (r + 2 * s[2][rty]) % mod;
    }
    return r;
}
long long l1() {
    long long r = 0;
    for (int i = -rt; i <= rt; i++) {
        long long rty = sqrt(tm - 1LL * i*i);
        long long ii = (1LL * i*i) % mod;
        r = (r + ii*(2 * rty + 1) % mod) % mod;
        r = (r + 2 * s[1][rty]) % mod;
    }
    return r;
}
long long l0() {
    long long r = 0;
    for (int i = -rt; i <= rt; i++) {
        long long rty = sqrt(tm - 1LL * i*i);
        long long ii = (1LL * i*i) % mod;
        r = (r + 2 * rty+1) % mod;
    }
    return r;
}
int main() {
    for (int i = 1; i < MXN; i++) {
        for (int j = 0; j < 5; j++) {
            long long p = 1;
            for (int k = 0; k < j; k++) p = (p*i) % mod * i %mod;
            s[j][i] = (s[j][i - 1] + p) % mod;
        }
    }
    scanf("%lld", &m);
    rt = sqrt(m);
    long long res = 0;
    tm = m;
    m %= mod;
    res = (2 * l3() + mod - (6 + 3*m)*l2() % mod + (4 + 3 * m)*l1() % mod + m*(m + 1) % mod*(m + 2) % mod*l0()%mod) % mod;
    res = res * 166666668 % mod;
    printf("%lld", res);
    return 0;
}