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

#define REP(i,a,b) for(int i=a;i<=b;i++)
using LL = long long;

const int Nmax=2e5+9;
int N,A[39],S,ans=INT_MAX,tmp1,tmp2;

int main() {
    ios_base::sync_with_stdio(0);    cin.tie(0);
    cin>>N;
    REP(i,1,N) cin>>A[i];
    S=(1<<(N-1))-1;
    REP(k,0,S) {
        tmp1=tmp2=0;
        REP(i,1,N) {
            if (i>=2 && ((k>>(i-2))&1)) {
                tmp2^=tmp1;     tmp1=0;
            }
            tmp1|=A[i];
        }
        tmp2^=tmp1;
        ans=min(ans,tmp2);
        // cout<<k<<" "<<tmp2<<" "<<ans<<endl;
    }
    cout<<ans;
    return 0;
}

//#pragma GCC optimize ("O3", "unroll-loops")
//#pragma GCC target ("avx2")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define all_of(v) (v).begin(), (v).end()
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fi first
#define se second
//const int MAXN = 300005;
//const LL INF = (LL) 1e9 + 8763;
//const LL MOD = (LL) 998244353;
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int P = 3;
int fact[10];
int inv(int x) {
	return x;
}
int mod_fact(int n,int &e){
	e=0;
	if(n==0)return 1;
	int res=mod_fact(n/P,e);
	e += n/P;
	if((n/P)%2==0)return res*fact[n%P]%P;
	return res*(P-fact[n%P])%P;
}
int Cmod(int n,int m){
	int a1,a2,a3,e1,e2,e3;
	a1=mod_fact(n,e1);
	a2=mod_fact(m,e2);
	a3=mod_fact(n-m,e3);
	if(e1>e2+e3)return 0;
	return a1*inv(a2*a3%P)%P;
}

int n;
string s;
int c2i[256];
char i2c[3] = {'B', 'W', 'R'};

void solve() {
	fact[0] = 1;
	for (int i = 1; i < 10; i++) {
		fact[i] = fact[i - 1] * i % P;
	}
//	for (int i = 0; i < 10; i ++) {
//		for (int j = 0; j <= i; j++) {
//			cout << Cmod(i, j) << ' ';
//		}
//		cout << '\n';
//	}

	cin >> n;
	c2i['B'] = 0;
	c2i['W'] = 1;
	c2i['R'] = 2;

	int lay = n, ans = 0, sign = (lay % 2 ? 1 : -1);
	for (int i = 0; i < n; i++) {
		char ch;
		cin >> ch;
		int x = c2i[ch];
		ans = (ans + x * Cmod(n - 1, i) * sign) % 3;
	}
	ans = (ans % 3 + 3) % 3;
	cout << i2c[ans] << '\n';
}

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

	int tc = 1;
//	cin >> tc;
	for (int i = 1; i <= tc; i++) {
		solve();
	}

	return 0;
}


#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int A[801][801];
int B[801][801];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	rep1(i, N) rep1(j, N) cin >> A[i][j];
	int C = (K * K + 1) / 2;

	int L = -1, R = 1000000001;
	while (L + 1 < R) {
		int wj = (L + R) / 2;

		rep1(i, N) rep1(j, N) B[i][j] = (A[i][j] <= wj);
		rep1(i, N) rep1(j, N) B[i][j] += B[i][j - 1];
		rep1(j, N) rep1(i, N) B[i][j] += B[i - 1][j];

		int k = 0;
		rep(i, N - K + 1) rep(j, N - K + 1) {
			int tmp = B[i][j] - B[i][j + K] - B[i + K][j] + B[i + K][j + K];
			chmax(k, tmp);
		}
		if (k < C) L = wj;
		else R = wj;
	}

	co(R);

	Would you please return 0;
}

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

#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c
#define rep(i,st,end) for(ll i=st;i<end;i++)
#define repv(i,st,end) for(ll i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}
const int N=820;
int k,n;
int g[N][N];
int dp[N][N];
bool check(int mid)
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=g[i][j]>=mid;

            dp[i][j]+=dp[i-1][j];
            dp[i][j]+=dp[i][j-1];
            dp[i][j]-=dp[i-1][j-1];
        }
    }

    ll mn =  1e9;
    for(int i=k;i<=n;i++)
    {
        for(int j=k;j<=n;j++)
        {
            ll cnt=dp[i][j];
            cnt-=dp[i][j-k];
            cnt-=dp[i-k][j];
            cnt+=dp[i-k][j-k];
            mn = min(cnt, mn);
        }
    }
    if(mn>=k*k/2+1)
        return true;
    return false;
}
void solve(){
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin>>g[i][j];
    int l=0,r=1e9, ans = 0;
    while(l <= r)
    {
        int mid=(l+r)>>1;
        if(check(mid))
        {
            l= mid+1;
            ans = mid;
        }
        else r=mid-1;
    }
    cout<<ans;
}

 int main()
 {
    clock_t start, end;
    start = clock();
    fio;
    ll k = 1;
    ll tc = 1;
   // cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    end = clock();
     double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    // debug(time_taken);

 }


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

const int maxl=2e5+10;
const int mod=1e9+7;

int n,k;
int a[maxl];
ll dp[maxl][17][2][2];
char s[maxl];

inline ll dfs(int pos,int st,bool up,bool lead)
{
	int cnt=__builtin_popcount(st);
	if(cnt>k) return 0;
	if(pos>n) return cnt==k && lead;
	ll &ret=dp[pos][cnt][up][lead];
	if(ret!=-1)
		return ret;
	ret=0;
	int r=up?a[pos]:15;
	for(int i=0;i<=r;i++)
		ret=(ret+dfs(pos+1,(!i&&!lead)?st:st|(1<<i),up&&(i==r),lead|i))%mod;
	return ret;
}

int main()
{
	scanf("%s",s+1);scanf("%d",&k);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	if(s[i]>='A' && s[i]<='Z')
		a[i]=s[i]-'A'+10;
	else
		a[i]=s[i]-'0';
	memset(dp,-1,sizeof(dp));
	printf("%lld\n",dfs(1,0,1,0));
	return 0;
}

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dp[18];
char S[200200];
int suuji(char c) {
	if (c < 'A') return c - '0';
	else return c - ('A' - 10);
}

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

	fread(S, 1, 200200, stdin);
	int K = 0;
	int N = 200200 - 1;
	while (S[N] != ' ') N--;
	int tmp = N + 1;
	while (S[tmp] >= '0') K = K * 10 + S[tmp++] - '0';

	const int mod = 1e9 + 7;
	int k = suuji(S[0]);
	dp[1] = k - 1;
	int kazu = 1 << 15 - k;

	rep1(i, N - 1) {
		if (!(i & 7)) for (int j = 2; j <= 16; j++) dp[j] %= mod;
		for (int j = 16; j >= 1; j--) {
			dp[j + 1] += (16 - j) * dp[j];
			dp[j] = j * dp[j];
		}
		dp[1] += 15;
		int k = suuji(S[i]);
		int k1 = __builtin_popcount(kazu >> 16 - k);
		int kazu0 = __builtin_popcount(kazu);
		dp[kazu0] += k1;
		dp[kazu0 + 1] += k - k1;
		kazu |= 1 << 15 - k;
	}

	ll kotae = dp[K];
	kotae += (__builtin_popcount(kazu) == K);
	printf("%lld", kotae % mod);

	Would you please return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
using namespace std;
const int N=1e3+9;
const int Inf=1e9;
char s[N],t[20]={"atcoder"};
int main(){
	int T;
	scanf("%d",&T);
	rep(Tcase,1,T+1){
		scanf("%s",s);
		int n=strlen(s);
		int ans=Inf,sum=0;
		rep(i,0,min(n,8)){
			//cout<<i<<' '<<ans<<"check\n";
			if(i==7){
				ans=min(ans,sum);
				break;
			}
			rep(j,i,n){
				if(s[j]>t[i]){
					ans=min(ans,sum+j-i);
					break;
				}
			}
			int ok=0;
			rep(j,i,n){
				if(s[j]==t[i]){
					ok=1;
					while(j>i)swap(s[j],s[j-1]),sum++,--j;
					break;
				}
			}
			if(sum>ans||!ok)break;
		}
		if(ans==Inf)ans=-1;
		printf("%d\n",ans);
	}
}

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

using d = int;
using ll = long long;
using ud = unsigned int;
using ull = unsigned long long;
using lf = double;
using llf = long double;
using ch = char;
using st = string;
using bl = bool;
using vo = void;

#define ci cin
#define co cout

#define fi( x, n ) for( d i = x; i < n; i++ )
#define fj( x, n ) for( d j = x; j < n; j++ )
#define fin( x, n ) for( d i = x; i <= n; i++ )
#define fjn( x, n ) for( d j = x; j <= n; j++ )
#define wh while
#define w( n ) while( n-- )

#define vd vector<d>
#define vll vector<ll>
#define vlf vector<lf>
#define vc vector<ch>
#define vs vector<st>
#define sd set<d>
#define sll set<ll>
#define slf set<lf>
#define sc set<ch>
#define ss set<st>

#define sz(x) x.size()
#define st(x) sort( x.begin(), x.end() )
#define cou(x, y) count( x.begin(), x.end(), y )

#define in insert
#define ct count
#define fd find
#define pb push_back
#define er erase
#define be begin
#define en end
#define np next_permutation

#define el endl

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

#define SIZE 100000
bl check[SIZE];
vd prime;

void sieve( d number )  // O( n * log(log(n)) )
{
    d i, j;

    check[0] = check[1] = 1;

    for( i = 2; i*i <= number; i++ )
    {
        if( check[i] == 0 )
        {
            for( j = i*i; j <= number; j += i )
                check[j] = 1;
        }
    }

    for( i = 2; i <= number; i++ )
    {
        if( check[i] == 0 )
            prime.pb( i );
    }
}

d IsPrime( d num )  // O( n / 2 )
{
	if( num <= 2 )
        return 0;

    if( num % 2 == 0 )
        return 0;
    else
    {
        for( d i = 3; i*i <= num; i += 2 )
        {
            if( num % i == 0 )
                return 0;
        }

        return 1;
    }
}

d main()
{
	InputOutput();

	d x;

    ci >> x;

    d ans = ( (x / 100) + 1 ) * 100;

    ans -= x;

    co << ans << el;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--){
		long long n;
		cin>>n;
		long long s=0,ans=0;
		for(long long i=1;i*i<=2*n;i++){
			s+=i-1;
			long long x=s%i;
			if(n%i==x) ans++;
		}
		cout<<ans*2;
		cout<<endl;
	}
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(998244353);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int multipf(vector<string>& s){
    if(s.size() == 0)return 0;
    cout << s[0];
    rep1(i, s.size() - 1)cout << " " << s[i];
    cout << endl;
    return 0;
}

int multipf(vector<ll>& n){
    if(n.size() == 0)return 0;
    cout << n[0];
    rep1(i, n.size() - 1)cout << " " << n[i];
    cout << endl;
    return 0;
}

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b, ll m){
    ll ans = 1;
    while(b) {
        if(b & 1LL) ans = ans * a % m;
        ans %= m;
        a = a * a;
        a %= m;
        b >>= 1;
    }
    return ans % m;
}

struct UnionFind {
    vector<ll> par;
    vector<ll> rank;
    vector<ll> Size;
    UnionFind(ll n) {
        init(n);
    }

    void init(ll n) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        rep0(i, n + 1){
            par[i] = i;
            rank[i] = 0;
            Size[i] = 1;
        }
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

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

int main() {
    ll n,f;
    cin >> n;
    UnionFind u(n);
    rep0(i, n){
        cin >> f;
        --f;
        u.merge(i, f);
    }
    vector<bool> ff(n,true);
    ll cnt = 0;
    rep0(i, n){
        ll k = u.root(i);
        if(ff[k]){
            ff[k] = false;
            ++cnt;
        }
    }
    pf((power(2, cnt, mod) - 1 + mod) % mod);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#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 trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

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

    string s;
    cin >> s;
    int n = sz(s);
    bool ok = 1;
    fori(i, n){
        ok &= ((s[i] >= 'a' and s[i] <= 'z' and i % 2 == 0) or (s[i] >= 'A' and s[i] <= 'Z' and i%2==1));
    }

    cout << (ok ? "Yes" : "No") << endl;

    time_taken();
    return 0;
}


//in dp prefix suffix sum helps..
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include <chrono>
#include <random>
#include <iterator>
#include <map>
#include<list>
#include <algorithm>
#include <fstream>
#include<unordered_map>
#include<set>
#include<queue>
#define int  long long
#define double long double
#define pb   push_back
#define mp   make_pair
#define pii  pair<int,int>
#define pip pair<int,pii>
#define vip vector<pii>
#define vi vector<int>
#define vs vector<string>
#define vd vector<double>
#define mii  map<pii, int>
#define qu queue<pii>
#define set set<int>
#define multiset multiset<int>
#define rep(i, a, b) for(int i=a;i<b;i++)
#define rep1(i, a, b) for(int i=b;i>=a;i--)
#define viv vector<pip>
#define stack stack<int>
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define it iterator
#define pq priority_queue<int>
#define pq1 priority_queue <pii, vector<pii>, greater<pii> >
#define mem(x, y) memset(x, (int)y, sizeof(x))
#define ps(x,y) fixed<<setprecision(y)<<x
// author :: Anurag Anand.
using namespace std;
int z=  1e9+7;
//int z= 998244353;
int gcd(int a, int b){
    if(a==0)return b;
    if(b==0)return a;
    return gcd(b, a%b);
}
int power(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
		{
			res=(res*a)%z;
			b--;
		}
		a=(a*a)%z;
		b=b>>1;
	}
	return res;
}
vi sv;
int fact[200001];
int ncr(int n, int r){
	int p=fact[n];
	p*=power(fact[r], z-2);
	p%=z;
	p*=power(fact[n-r], z-2);
	p%=z;
	return p;
}
// vi seg;
// void arrange(int i, int v, int x, int lx, int rx){
// 	if(rx-lx==1){
// 		seg[x]=v;
// 		return;
// 	}
// 	int mid=(lx+rx)/2;
// 	if(i<mid) arrange(i, v, 2*x+1, lx, mid);
// 	else arrange(i, v, 2*x+2, mid, rx);
// 	seg[x]= min(seg[2*x+1], seg[2*x+2]);
// }
// int calc(int l, int r, int x, int lx, int rx){
// 	if(lx>=r||l>=rx) return 1e9;
// 	if(lx>=l&&rx<=r) return seg[x];
// 	int mid=(lx+rx)/2;
// 	int k1=calc(l, r, 2*x+1, lx, mid), k2=calc(l, r, 2*x+2, mid, rx);
// 	return min(k1, k2);
// }
vi pp;
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
	pp.assign(1000001, 0);
	for(int i=2;i<1000;i++){
		if(!pp[i]){
			for(int j=i*i;j<=1000000;j+=i){
				pp[j]=1;
			}
		}
	}
	fact[0]=1;
	rep(i,1,200001) fact[i]=i*fact[i-1], fact[i]%=z;
	for(int i=2;i<=1000000;i++) if(!pp[i]) sv.pb(i);
	int t;
	t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		multiset sr, sb, sg;
		rep(i,0,2*n){
			int x;
			char c;
			cin>>x>>c;
			if(c=='R') sr.insert(x);
			else if(c=='G') sg.insert(x);
			else sb.insert(x);
		}
		if(sr.size()%2==0&&sb.size()%2==0&&sg.size()%2==0) cout<<"0\n";
		else{
			multiset s1, s2, s3;
			if(sr.size()&1&&sb.size()&1){
				s1=sr;
				s2=sb;
				s3=sg;
			}
			else if(sr.size()&1&&sg.size()&1){
				s1=sr;
				s2=sg;
				s3=sb;
			}
			else{
				s1=sg;
				s2=sb;
				s3=sr;
			}
			int a=1e15, b1=1e15, b2=1e15;
			multiset :: it it;
			for(it=s1.begin();it!=s1.end();it++){
				multiset :: it it1= s2.upper_bound(*it);
				int k;
				if(it1==s2.end()){
					k=*s2.rbegin();
					a=min(a, abs(k-*it));
				}
				else{
					k=*it1;
					a=min(a, abs(k-*it));
					if(it1!=s2.begin()){
						it1--;
						k=*it1;
						a=min(a, abs(k-*it));
					}
				}
				if(s3.size()){
					it1=s3.upper_bound(*it);
				if(it1==s3.end()){
					k=*s3.rbegin();
					b1=min(b1, abs(k-*it));
				}
				else{
					k=*it1;
					b1= min(b1, abs(k-*it));
					if(it1!=s3.begin()){
						it1--;
						k=*it1;
						b1=min(b1, abs(k-*it));
					}
				}
				}
			}
			if(s3.size()){
				for(it=s2.begin();it!=s2.end();it++){
				multiset :: it it1= s3.upper_bound(*it);
				int k;
				if(it1==s3.end()){
					k=*s3.rbegin();
					b2=min(b2, abs(k-*it));
				}
				else{
					k=*it1;
					b2= min(b2, abs(k-*it));
					if(it1!=s3.begin()){
						it1--;
						k=*it1;
						b2=min(b2, abs(k-*it));
					}
				}
			}
			}
			cout<<min(a, b1+b2)<<"\n";
		}
	}
}

// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                           CSE - 2019-2023                                     *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loope(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloope(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define vi vector<int>
#define vii vector<vector<int>>
#define si set<int>
#define NO cout<<"NO\n";
#define YES cout<<"YES\n";
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \

void solve()
{
    int n; cin >> n;
    vector<ll>in[3];
    auto ret = [](char ch) {
        if (ch == 'R')return 0;
        else if (ch == 'G')return 1;
        else return 2;
    };

    loop(i, 0, n << 1) {
        ll num; cin >> num;
        char c; cin >> c;
        in[ret(c)].pb(num);
    }

    ll mx = 1e16;

    vi odd;
    loop(i, 0, 3) {
        if (in[i].size() & 1)odd.pb(i);
    }

    // dis(odd);

    ll ans = 0;
    if (odd.size() == 0) {
        cout << ans << "\n";
        return;
    }

    ans = mx;
    int od = odd[0];
    loop(i, 0, 3)sort(in[i].begin(), in[i].end());

    // at least tow odds guranteed
    int rem = 3 - (odd[0] + odd[1]);

    auto dif = [&](vector<ll> & vec, ll & v) {
        ll fin = mx;
        int val = lower_bound(vec.begin(), vec.end(), v) - vec.begin();
        if (val != vec.size())fin = min(fin, llabs(vec[val] - v));
        val--;
        if (val >= 0)fin = min(fin, llabs(vec[val] - v));

        return fin;
    };

    // direct difference between odd elems
    for (auto &v : in[odd[1]]) {
        ll ret = dif(in[odd[0]], v);
        // cout << odd[0] << " " << odd[1] << " " << ret << "\n";
        ans = min(ans, dif(in[odd[0]], v));
    }

    // use two intermediates
    int siz = in[rem].size();

    // cout << in[0].size() << " " << in[1].size() << " " << in[2].size() << " " << in[rem].size() << " " << ans << "\n";

    if (siz == 0) {
        cout << ans << "\n";
        return;
    }
    // at least two elements

    vector<ll>pref(siz), suf(siz), val(siz);
    ll fn = mx;
    // Itermediate difference
    loop(i, 0, siz) {
        val[i] = dif(in[odd[0]], in[rem][i]);
    }
    pref[0] = val[0];
    suf[siz - 1] = val[siz - 1];

    loop(i, 1, siz) {
        pref[i] = min(pref[i - 1], val[i]);
        suf[siz - i - 1] = min(suf[siz - i], val[siz - i - 1]);
    }

    loop(i, 0, siz) {
        ll prev = (i ? pref[i - 1] : mx), nex = (i + 1 < siz ? suf[i + 1] : mx);
        ll mn = min(prev, nex);
        ans = min(ans, mn + dif(in[odd[1]], in[rem][i]));
    }

    cout << ans << "\n";
}
int main()
{
    io;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int test = 1, i = 0;
    // cin >> test;
    while (i++ != test)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
template <typename _Tp>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*10+(ch&15),ch=getchar();
	if(f)x=-x;
}
template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);}
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=0,tar-s;
}

const int N=500005;
char s[N],t[N];
int s1[N],s2[N],a[N],b[N],p1,p2;
int main(){
	int n;read(n);
	read_str(s+1),read_str(t+1);
	for(int i=1;i<=n;++i)s1[i]=s1[i-1]+(s[i]=='1'),s2[i]=s2[i-1]+(t[i]=='1');
	if(s1[n]!=s2[n])return puts("-1"),0;
	int ans=0;
	for(int i=1;i<=n;++i)if(s[i]=='0')a[++p1]=i;
	for(int i=1;i<=n;++i)if(t[i]=='0')b[++p2]=i;
	for(int i=1;i<=p1;++i)ans+=s1[a[i]]!=s2[b[i]];
	printf("%d\n",ans);
	return 0;
}

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

// clang-format off
#define range(i, l, r) for ( int i = (int)(l); i < (int)(r); (i) += 1 )
#define rrange(i, l, r) for ( int i = (int)(r)-1; i >= (int)(l); (i) -= 1 )
#define debug(x) cerr << "(" << __LINE__ << ") " << #x << ": " << (x) << endl;
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << ' ' << p.second; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &v) { for ( pair<T1, T2> x : v ) { os << x << (x.first == v.rbegin()->first && x.second == v.rbegin()->second ? "" : "\n"); } return os; }
template <typename T> ostream &operator<<(ostream &os, queue<T> v) { if(!v.empty()) { os << v.front(); v.pop(); } while (!v.empty()) { os << " " << v.front(); v.pop(); } return os; }
template <typename T> ostream &operator<<(ostream &os, stack<T> v) { if(!v.empty()) { os << v.top(); v.pop(); } while (!v.empty()) { os << " " << v.top(); v.pop(); } return os; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { bool is_f = true; for ( T x : v ) { os << (is_f ? "" : " ") << x; is_f = false; } return os; }
template <typename T> ostream &operator<<(ostream &os, const deque<T> &v) { bool is_f = true; for ( T x : v ) { os << (is_f ? "" : " ") << x; is_f = false; } return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) { bool is_f = true; for ( T x : v ) { os << (is_f ? "" : " ") << x; is_f = false; } return os; }
using ull = unsigned long long;
using ll = long long;
using Pll = pair<ll, ll>;
using P = pair<int, int>;
constexpr ll INF64 = INT64_MAX / 2;
constexpr int INF32 = INT32_MAX / 2;
constexpr int dy[] = { 0, -1, 1, 0, -1, 1, -1, 1 };
constexpr int dx[] = { -1, 0, 0, 1, -1, -1, 1, 1 };
constexpr int mod998244353 = 998244353;
constexpr int mod1000000007 = (int)1e9 + 7;
constexpr char newl = '\n';
// clang-format on

bool is_valid(string s,string t){
  int cnt[2]={0};
  for(auto c:s) if(c=='0') cnt[0]++;
  for(auto c:t) if(c=='0') cnt[1]++;
  return cnt[0]==cnt[1];
}

int main() {
  int n;
  cin >> n;
  string s,t;
  cin>>s>>t;

  if(!is_valid(s,t)){
    cout<<-1<<endl;
    return 0;
  }

  vector<int> zero1,zero2;

  range(i,0,n) if(s[i]=='0') zero1.push_back(i);
  range(i,0,n) if(t[i]=='0') zero2.push_back(i);

  int ans=0;
  range(i,0,zero1.size()){
    ans+=(zero1[i]!=zero2[i]);
  }
  cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;

vector<int> par(10010, 0);
vector<int> Rank(10010, 0);

void init(int n) {
    for(int i = 0; i < n; i++) {
        par.at(i) = i;
        Rank.at(i) = 0;
    }
}

int find(int x) {
    if(par.at(x) == x) {
        return x;
    } else {
        return par.at(x) = find(par.at(x));
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) {
        return;
    }

    if(Rank.at(x) < Rank.at(y)) {
        par.at(x) = y;
    } else {
        par.at(y) = x;
        if(Rank.at(x) == Rank.at(y)) {
            Rank.at(x)++;
        }
    }
}

bool same(int x, int y) {
    return find(x) == find (y);
}

int main() {
    ll N, K;
    cin >> N >> K;

    vector<vector<ll> > m(N,vector<ll>(N,0));
    vector<vector<ll> > M(N,vector<ll>(N,0));
    for(ll i = 0; i < N; i++) {
        for(ll j = 0; j < N; j++) {
            cin >> m.at(i).at(j);
            M.at(j).at(i) = m.at(i).at(j);
        }
    }

    init(N);
    for(ll i = 0; i < N; i++) {
        for(ll j = i + 1; j < N; j++) {
            for(ll k = 0; k < N; k++) {
                if(m.at(i).at(k) + m.at(j).at(k) > K) break;
                if(k == N - 1) unite(i, j);
            }
        }
    }
    vector<int> A(N, 0);
    for(int i = 0; i < N; i++) A.at(find(i))++;

    init(N);
    for(ll i = 0; i < N; i++) {
        for(ll j = i + 1; j < N; j++) {
            for(ll k = 0; k < N; k++) {
                if(M.at(i).at(k) + M.at(j).at(k) > K) break;
                if(k == N - 1) unite(i, j);
            }

        }
    }
    vector<int> B(N, 0);
    for(int i = 0; i < N; i++) B.at(find(i))++;

    ll ans = 1;
    for(int j = 0; j < N; j++) {
        for(ll i = 1; i <= A.at(j); i++) ans = (ans*i)%mod;
        for(ll i = 1; i <= B.at(j); i++) ans = (ans*i)%mod;
    }
    cout << ans << endl;

    return 0;
}

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//問題に強く祈りをささげることで、気が狂った書き方が確率でふってくる。
int to[400002], ne[400010], he[200001];
int Q[200010];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

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

	int N = getint(), K = getint();
	int k = 2;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		to[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		to[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	int q = 0, p = 0;
	Q[q++] = 2;
	while (q < N) {
		int u = to[Q[p++]];
		for(int ind = he[u]; ind; ind = ne[ind]) {
			int v = to[ind];
			if (he[v] > 0) Q[q++] = ind;
		}
		he[u] = 0;
	}

	auto pl = ne, dl = ne + 200000;
	int are = 1000000, pd0 = are;
	int L = 0, R = (N + K - 1) / K;
	while (L + 1 < R) {
		int wj = (L + R) / 2;

		int num = 0;

		for (int i = N - 1; i >= 1; i--) {
			int u = to[Q[i] ^ 1];
			int v = to[Q[i]];
			int po = pl[v];
			int dd = dl[v];
			if (dd < pd0) dd = pd0;
			if (po >= dd) dd = 0;
			if (dd >= pd0 + wj) {
				num++;
				po = pd0 + wj;
				dd = 0;
			}
			if (pl[u] < po - 1) pl[u] = po - 1;
			if (dl[u] < dd + 1) dl[u] = dd + 1;
		}

		int v = to[Q[1] ^ 1];
		int po = pl[v];
		int dd = dl[v];
		if (dd < pd0) dd = pd0;
		if (po >= dd) dd = 0;
		if (dd >= pd0) num++;

		if (num > K) L = wj;
		else R = wj;

		pd0 += are;
	}

	printf("%d", R);

	Would you please return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
using namespace std;

using VI = vector <int>;
using VLL = vector <long long>;
using VVLL = vector <VLL>;
using MLL = map <long long, long long>;

const long long INF = 1000000000000000LL;

void solve(int now, MLL& wmap, VI& used, VI& order, VLL& w, long long& ans) {
    if (now == w.size()) {
        int N = w.size();
        VLL wsum(N);

        wsum[0] = w[order[0]];

        for (int i = 1; i < N; ++i) {
            wsum[i] = wsum[i-1] + w[order[i]];
        }

        VLL dp(N);

        for (int i = 0; i < N; ++i) {
            for (int j = i+1; j < N; ++j) {
                long long segWeight = i>0 ? wsum[j] - wsum[i-1] : wsum[j];
                auto iter = wmap.lower_bound(segWeight);
                --iter;

                long long leng = iter->second;
                // dist[i] - dist[j] >= leng
                // -leng >= dist[j] - dist[i]
                dp[j] = max(dp[j], dp[i]+leng);
            }
        }

        ans = min(ans, dp[N-1]);

        return ;
    }

    for (int i = 0; i < used.size(); ++i) {
        if (used[i] == 0) {
            used[i] = 1;
            order[now] = i;
            solve(now+1, wmap, used, order, w, ans);
            used[i] = 0;
        }
    }
}

int main() {
    int N;
    int M;
    long long ans = INF;

    cin >> N >> M;

    VLL w(N);
    long long maxw = 0;

    for (int i = 0; i < N; ++i) {
        cin >> w[i];
        maxw = max(maxw, w[i]);
    }

    VVLL lv;
    long long minv = INF;

    for (int i = 0; i < M; ++i) {
        long long l;
        long long v;
        cin >> l >> v;

        minv = min(minv, v);
        lv.push_back({v, l});
    }

    MLL wmap;
    sort(lv.begin(), lv.end());
    wmap[0] = 0;
    wmap[INF] = INF;

    // (v, l), monotone increasing, v+ => l+
    for (int i = 0; i < lv.size(); ++i) {
        if (i+1 == lv.size() || lv[i][0] != lv[i+1][0]) {
            wmap[lv[i][0]] = lv[i][1];
        }
    }

    auto iter = wmap.begin();
    auto preIter = iter;

    while (iter != wmap.end()) {
        iter->second = max(iter->second, preIter->second);
        preIter = iter;
        ++iter;
    }

    VI used(N);
    VI order(N);

    if (minv >= maxw) {
        solve(0, wmap, used, order, w, ans);
    }

    cout << (ans == INF ? -1 : ans) << endl;

    return 0;
}

// Problem: F - Range Xor Query
// Contest: AtCoder - AtCoder Beginner Contest 185
// URL: https://atcoder.jp/contests/abc185/tasks/abc185_f
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn = 3e5 + 2;
int segt[mxn * 4];
int arr[mxn];
void build(int v, int tl, int tr) {
  if (tl == tr)
    segt[v] = arr[tl];
  else {
    int tm = (tl + tr) >> 1;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    segt[v] = segt[v * 2] ^ segt[v * 2 + 1];
  }
}

void update(int v, int tl, int tr, int ind, int val) {
  if (tl > tr || tr < ind || tl > ind)
    return;
  else if (tl == tr && tl == ind) {
    segt[v] ^= val;
  } else {
    int tm = (tl + tr) >> 1;
    update(v * 2, tl, tm, ind, val);
    update(v * 2 + 1, tm + 1, tr, ind, val);
    segt[v] = segt[v * 2] ^ segt[v * 2 + 1];
  }
}

int xos(int v, int tl, int tr, int l, int r) {
  if (tl > tr || tr < l || tl > r)
    return 0;
  else if (l <= tl && tr <= r) {
    return segt[v];
  } else {
    int tm = (tl + tr) >> 1;
    return xos(v * 2, tl, tm, l, r) ^ xos(v * 2 + 1, tm + 1, tr, l, r);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  build(1, 0, n - 1);
  for (int i = 0; i < q; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1)
      update(1, 0, n - 1, x - 1, y);
    else
      cout << xos(1, 0, n - 1, x - 1, y - 1) << "\n";
  }
}


#include<bits/stdc++.h>

typedef int64_t ll;
using namespace std;
const int INF = 1000000007;
int fact(int n);

int nCr(int n, int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    ll count1=0,count2=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='o'){
            count1++;
        }
        else if(s[i]=='?'){
            count2++;
        }
    }
    if(count1>4){
        cout<<0<<endl;
        return 0;
    }
    ll n = count1,m=count2,ans=0;
    for(ll r=0;r<=n;r++){
        ans = ans + nCr(n,r) * pow(-1,r) * pow((n+m-r),4);
    }
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
#define ll long long
#define N 200015
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define lowbit(i) ((i)&(-i))
#define VI vector<int>
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
int n;
char s[N];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	scanf("%s",s+1);
	if(s[1] != s[n]) return puts("1"),0;
	else{
		rep(i,2,n-2) if(s[i] != s[1] && s[i+1] != s[n]){
			puts("2"); return 0;
		}
	}
	puts("-1");
	return 0;
}

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

int n;
string s;

int main() {
    cin >> n >> s;
    if (s[0] != s[n - 1]) {
        cout << 1 << endl;
    } else {
        for (int i = 1; i + 1 < n - 1; i++) {
            if (s[i] != s[0] && s[i + 1] != s[n - 1]) cout << 2 << endl, exit(0);
        }
        if (n % 2 == 1) cout << -1 << endl, exit(0);
        bool flag = 1;
        for (int i = 0; i < n; i += 2) {
            flag &= (s[i] != s[i + 1]);
        }
        if (flag) cout << n / 2 << endl;
        else cout << -1 << endl;
    }
    return 0;
}


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

int main()
{
  int t=1000;
  int s1,s2,d1,d2;
  string p="";
  int k;
  while(t--){
    cin>>s1>>s2>>d1>>d2;
    p="";
    if (s1>d1){
      while (s1!=d1){
        p+="U";
        s1--;
      }
    }
    else if (d1>s1){
      while (d1!=s1){
        p+="D";
        d1-- ;
      }
    }
    if (s2>d2){
      while (s2!=d2){
        p+="L";
        s2--;
      }
    }
    else if (d2>s2){
      while (d2!=s2){
        p+="R";
        d2-- ;
      }
    }
    cout<<p<<endl;
    fflush(stdin);
    cin>>k;
    }
    return 0;
}

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

int main(){
  vvl tate(29, vl(30,5000));
  vvl yoko(30, vl(29,5000));
  rep(_,1000){
    int a, b, ato, bto;
    cin >> a >> b >> ato >> bto;
    int ma = a;
    int mb = b;
    string ans;
    while(a != ato || b != bto){
      if (a == ato){
        if (b < bto){
          b++;
          ans.pb('R'); continue; // continueの貼り付けを忘れると
        } else { // バグる ato btoが連続するからです
          b--; // 全てに張り付けておく必要があるので
          ans.pb('L'); continue;
        }
      }
      if (b == bto){
        if (a < ato){
          a++;
          ans.pb('D'); continue;
        } else {
          a--;
          ans.pb('U'); continue;
        }
      }
      if (a < ato && b < bto){
        // 下 右
        if (tate[a][b] < yoko[a][b]){
          a++; // 縦移動優先
          ans.pb('D'); continue;
        } else {
          b++;
          ans.pb('R'); continue;
        }
      }
      if (a < ato && b > bto){
        // 下 左
        if (tate[a][b] < yoko[a][b-1]){
          a++; // 縦移動優先
          ans.pb('D'); continue;
        } else {
          b--;
          ans.pb('L'); continue;
        }
      }
      if (a > ato && b < bto){
        // 上 右
        if (tate[a-1][b] < yoko[a][b]){
          a--; // 縦移動優先
          ans.pb('U'); continue;
        } else {
          b++;
          ans.pb('R'); continue;
        }
      }
      if (a > ato && b > bto){
        // 上 左 ここから続き
        if (tate[a-1][b] < yoko[a][b-1]){
          a--; // 縦移動優先
          ans.pb('U'); continue;
        } else {
          b--;
          ans.pb('L'); continue;
        }
      }
    }
    cout << ans << endl; // flushを炊く
    ll score;
    cin >> score;
    score /= ans.size(); // 通った数で割り一歩当たりのコスト計算
    ll change = (5000 - score) / ans.size();
    rep(i,ans.size()){
      if (ans[i] == 'U'){
        tate[ma-1][mb] += change;
        ma--;
      }
      if (ans[i] == 'D'){
        tate[ma][mb] += change;
        ma++;
      }
      if (ans[i] == 'L'){
        yoko[ma][mb-1] += change;
        mb--;
      }
      if (ans[i] == 'R'){
        yoko[ma][mb] += change;
        mb++;
      }
    }
    // for(auto x : tate){ // コスト計算debug
    //   for(auto y : x){
    //     cout << y << " ";
    //   } cout << endl;
    // }
    // for(auto x : yoko){
    //   for(auto y : x){
    //     cout << y << " ";
    //   } cout << endl;
    // }
  }
}


#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
#include <utility>

using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

void dfs(int ter,vector<vector<tuple<int,int,int>>>&go,vector<int>&ans){
	for(auto it:go[ter]){
		if(ans[get<1>(it)]!=-1){continue;}
		ans[get<1>(it)]=get<2>(it);
		dfs(get<0>(it),go,ans);
	}
}
int main(void){
	int i,n,m;cin>>n>>m;
	vector<char>L(n);
	vector<pair<int,int>>road(m);
	vector<vector<tuple<int,int,int>>>go(n);
	vector<int>ans(m,-1);
	vector<int>c(n);
	for(i=0;i<m;i++){
		int a,b;cin>>a>>b;a--;b--;
		road[i]=mp(a,b);
	}
	for(i=0;i<n;i++){cin>>c[i];}
	for(i=0;i<m;i++){
		int a,b;tie(a,b)=road[i];
		if(c[a]!=c[b]){continue;}
		go[a].pub({b,i,0});
		go[b].pub({a,i,1});
	}
	vector<int>d(n);
	for(i=0;i<n;i++){
		if(L[i]==0&&go[i].size()>0){//ここを出発点とする
			dfs(i,go,ans);
		}
	}
	for(i=0;i<m;i++){
		int a,b;tie(a,b)=road[i];
		if(c[a]>c[b]){cout<<"->"<<endl;}
		else if(c[a]<c[b]){cout<<"<-"<<endl;}
		else {cout<<(ans[i]?"<-":"->")<<endl;}
	}
}

#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<long double>
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-15);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const ll N=200000+5,mod=998244353,sh=1000000,inf=100000000;
int mem[N],a[N];
vector<int> v[N];
int solve(int no){

   int &ret=mem[no];
   if(ret!=-1) return ret;
   int ans=0;
   for(int i=0;i<sz(v[no]);i++){
    int nw=v[no][i];
    ans=max(ans,max(a[nw],solve(nw)));
   }
   return ret=ans;

}
int main(){
    GO();
    int T=1;
  //  cin>>T;
    while(T--){

       int n,m;
       cin>>n>>m;
       for(int i=1;i<=n;i++) cin>>a[i];
       for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
       }
       clr(mem,-1);
       int ans=INT_MIN;
       for(int i=1;i<=n;i++){
        if(solve(i)==0) continue;
         ans=max(ans,solve(i)-a[i]);
       }
       cout<<ans<<"\n";

    }
}


#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define deb(...)
#endif
#define endl "\n"
#define pb push_back
#define int long long
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define read(v) for(auto &it:v) cin>>it;
const int inf = 1e18;
const int N   = 5e3 + 5;
const int mod = 998244353;
int maxi[12];
int n, m;
int ans = 0;
namespace factorial {
int fact[N + 5];
int power(int a, int b)
{
	if (b == 0) return 1;
	if (b == 1) return a % mod;
	if (b % 2 == 1) return (power(a, b - 1) * a) % mod;
	int q = power(a, b / 2);
	return (q * q) % mod;
}
int modinverse(int n)
{
	return power(n, mod - 2);
}
void generate_fact_()
{
	fact[0] = 1;
	for (int i = 1; i < N; i++)
		fact[i] = (fact[i - 1] * i) % mod;
}
int ncr(int n, int r)
{
	if (fact[n] == 0) {
		cerr << "Call generate_fact_ you dope" << endl;
		exit(1);
	}
	if (r == 0) return 1;
	return (fact[n] * (modinverse(fact[r]) ) % mod * (modinverse(fact[n - r]) ) % mod) % mod;
}

}
using namespace factorial;
namespace modop {
ll madd(ll a, ll b) {
	return (a + b) % mod;
}
ll msub(ll a, ll b) {
	return (((a - b) % mod) + mod) % mod;
}
ll mmul(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}
ll mpow(ll base, ll exp) {
	ll res = 1;
	while (exp) {
		if (exp % 2 == 1) {
			res = (res * base) % mod;
		}
		exp >>= 1;
		base = (base * base) % mod;
	}
	return res;
}
ll minv(ll base) {
	return mpow(base, mod - 2);
}
ll mdiv(ll a, ll b) {
	return mmul(a, minv(b));
}
}

using namespace modop;
int dp[12][5005];
int go(int bit, int sum) {
	if (bit == 12) {
		if (sum == 0) {
			return 1;
		}
		else {
			return 0;
		}

	}
	if (dp[bit][sum] != -1) {
		return dp[bit][sum];
	}
	int ans = 0;
	int p = (1LL << bit);
	for (int i = 0; i <= maxi[bit]; i += 2) {
		int zx = i * p;
		if (zx <= sum) {
			int coeff = ncr(n, i);
			ans = madd(ans, mmul(coeff, go(bit + 1, sum - zx)));
		}
		else {
			break;
		}
	}

	return dp[bit][sum] = ans;

}
void testCase() {
	cin >> n >> m;
	generate_fact_();

	for (int i = 0; i <= 11; i++) {
		int max_take = min(n, m / (1 << i));
		maxi[i] = max_take;
	}
	memset(dp, -1, sizeof dp);
	cout << go(0, m) << endl;

}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int  t = 1;
	// cin >> t;
	while (t--)testCase();
	return 0;
}

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

#define Mod(x) (x>=P)&&(x-=P)
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define erep(i,a) for(int i=hd[a];i;i=nxt[i])

typedef long long ll;
void Max(int &x,int y){(x<y)&&(x=y);}
void Min(int &x,int y){(x>y)&&(x=y);}

bool vio;
char IO;
int rd(int res=0){
	bool f=0;
	while(IO=getchar(),IO<48||IO>57)
		f=IO=='-';
	do res=(res<<1)+(res<<3)+(IO^48);
	while(IO=getchar(),isdigit(IO));
	return f?-res:res;
}
const int M=5005,P=998244353;
int pw[M][M],s[M];
bool let;
int main(){
	cerr<<(&vio-&let)/1024.0/1024<<endl;
	int n=rd(),m=rd();
	rep(i,0,m){
		rep(j,pw[i][0]=1,n){
			pw[i][j]=1ll*pw[i][j-1]*i%P;
			if(i!=m)s[j]+=pw[i][j],Mod(s[j]);
		}
	}
	s[0]=m;
	int ans=0;
	rep(i,1,n){
		if(i!=1)ans=1ll*ans*m%P;
		rep(j,1,i-1){
			ans+=1ll*pw[m][j-1]*(1ll*m*pw[m-1][i-j-1]%P-s[i-j-1]+P)%P;
			//rep(k,1,m)
			//ans+=1ll*pw[m][j-1]*(pw[m-1][i-j-1]-pw[m-k][i-j-1]+P)%P,Mod(ans);
			Mod(ans);
		}
		ans+=1ll*pw[m-1][i-1]*m%P,Mod(ans);
	}
	printf("%d",ans);
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
int main()
{
#ifdef lovelyG
Sfile(1);
#endif
	scanf("%d%d",&n,&m);
	if(m==0)
	{
		for(int i=1;i<=n;++i)
		{
			printf("%d %d\n",i*2,i*2+1);
		}
		return 0;
	}
	if(n<m+2||m<0)
	{
		puts("-1");
		return 0;
	}
	printf("%d %d\n",1,1000000000);
	for(int i=1;i<=m;++i)
	{
		printf("%d %d\n",i*2,i*2+1);
	}
	int l=(m+1)*2,r=999999999;
	printf("%d %d\n",l,r);
	n-=m+2;
	for(int i=1;i<=n;++i)
	{
		++l;--r;
		printf("%d %d\n",l,r);
	}
	return 0;
}

//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll
#define all(a) begin(a),end(a)

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

void compress(vi&v)
{
	set<int> s;
	for (auto a: v) s.insert(a);
	vi o(all(s));
	for (auto&a: v) a=lower_bound(all(o),a)-o.begin();
}

void compress(vl&v)
{
	set<ll> s;
	for (auto a: v) s.insert(a);
	vl o(all(s));
	for (auto&a: v) a=lower_bound(all(o),a)-o.begin();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
const int N=300010;
int t,n,m;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n>>m;
	if (n==1 && m==0) cout<<"1 2"<<en;
	else if (m<0 || m>=n-1) cout<<-1<<en;
	else
	{
		for (int i=0;i<n-m-2;++i) cout<<i*2+1<<' '<<i*2+2<<en;
		int st=(n-m-2)*2+1;
		cout<<st<<' '<<int(1e9)<<en;
		for (int i=0;i<=m;++i) cout<<st+i*2+1<<' '<<st+i*2+2<<en;
	}
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int,int> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define de(x) cout<< #x<<" = "<<x<<"\n"
#define dd(x) cout<< #x<<" = "<<x<<" "
#define debug() cout<<"I love Miyamizu Mitsuha forever!\n"
#define mes(a,b) memset(a,b,sizeof a)
const int inf=0x3f3f3f3f;
const int maxn=305;
const double eps=1e-8;
pii p[maxn];
int n;
double d(int x1,int y1,int x2,int y2)
{
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

class ss
{
	public:
		int id1,id2;
		double d;
}dis[1000005];
bool comp(ss s1,ss s2)
{
	return s1.d<s2.d;
}
int f[maxn];
bool vis1[maxn],vis2[maxn];
int find_father(int x)
{
	if(f[x]==x) return x;
	else return f[x]=find_father(f[x]);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	rep(i,0,n) cin>>p[i].fi>>p[i].se;
	int cnt=0;
	rep(i,0,n)
	{
		p[i+n].fi=p[i+2*n].fi=p[i].fi;
		p[i+n].se=100;
		p[i+2*n].se=-100;
		vis1[i+n]=1;
		vis2[i+2*n]=1;
	}
	rep(i,0,3*n)
	{
		rep(j,i+1,3*n)
		{
			dis[cnt].id1=i;
			dis[cnt].id2=j;
			dis[cnt].d=d(p[i].fi,p[i].se,p[j].fi,p[j].se);
			cnt++;
		}
	}
	sort(dis,dis+cnt,comp);
	rep(i,0,3*n) f[i]=i;
	rep(i,0,cnt)
	{
		int fa=find_father(dis[i].id1),fb=find_father(dis[i].id2);
		f[fa]=fb;
		vis2[fb]|=vis2[fa];
		vis1[fb]|=vis1[fa];
		if(vis2[fb]&&vis1[fb])
		{
			cout<<fixed<<setprecision(15)<<dis[i].d/2<<"\n";
			return 0;
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(long i=0; i<(long)(n);i++)
#define REP(i,s,t) for(long i=s; i<t; i++)
#define RNG(i,s,t,u) for(long i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<long> par;

void Initpar(long n){
  par = vector<long>(n);
  for(long i=0; i<n; i++) par.at(i) = i;
}

long root(long x){
  if(x == par.at(x)) return x;
  else return par.at(x) = root(par.at(x));
}

void unite(long x, long y){
  long rx = root(x);
  long ry = root(y);
  if(rx == ry) return ;
  if(rx < ry) par.at(ry) = rx;
  else par.at(rx) = ry;
}

bool same(long x, long y){
  return root(x) == root(y);
}

void update_par(){
  for(int i=0;i<par.size();i++){
    root(i);
  }
}

struct Edge
{
  double cost;
  long from;
  long to;
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// long root(long x, vector<long> &par){
//   if(x == par.at(x)) return x;
//   else par.at(x) = root(par.at(x), par);
// }

// bool unite(long x, long y, vector<long> &par){
//   long rx = root(x, par);
//   long ry = root(y, par);
//   if(rx == ry) return true;
//   else if(rx < ry) par.at(ry) = rx;
//   else par.at(rx) = ry;
//   return false;
// }

// bool same(long x, long y, vector<long> &par){
//   return root(x,par) == root(y,par);
// }

int main(){
  long n;
  cin >> n;
  vector<pair<long,long>> d(n);
  rep(i,n) cin >> d.at(i).first >> d.at(i).second;
  vector<Edge> list;
  rep(i,n){
    double x = (double)d.at(i).first;
    double y = (double)d.at(i).second;
    REP(j,i+1,n){
      double nx = (double)d.at(j).first;
      double ny = (double)d.at(j).second;
      double r = sqrt((nx-x)*(nx-x)+(ny-y)*(ny-y))/2.0;
      list.push_back(Edge{r,i,j});
    }
  }
  rep(i,n){
    double y = (double)d.at(i).second;
    list.push_back(Edge{(100-y)/2.0,i,n});
    list.push_back(Edge{(y+100)/2.0,i,n+1});
  }
  list.push_back(Edge{100, n, n+1});
  sort(list.begin(), list.end());
  Initpar(n+2);
  rep(i,n+2) par.at(i) = i;
  for(Edge ed : list){
    long s = ed.from;
    long t = ed.to;
    double r = ed.cost;
    unite(s,t);
    if(same(n,n+1)){
      cout << r << endl;
      return 0;
    }
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;

#define MX 200002
int dp[MX];
void solve()
{
int n,m;
cin>>n>>m;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
int pref[n+10]={};

sort(arr,arr+n);
pref[1]=arr[1]-arr[0];
for(int i=3;i<n;i+=2)
{
    pref[i]=arr[i]-arr[i-1];
    pref[i]+=pref[i-2];
}
int suff[n+10]={};
suff[n-2]=arr[n-1]-arr[n-2];
for(int i=n-4;i>=0;i-=2)
{
    suff[i]=arr[i+1]-arr[i];
    suff[i]+=suff[i+2];
}
int cnt=INT_MAX;
for(int i=0;i<m;i++)
{
    int x;
    cin>>x;
    int pos=lower_bound(arr,arr+n,x)-arr;
    int ans=0;
    if(pos%2==0)
    { if(pos!=0)
        ans+=pref[pos-1];
        if(pos<n-1)
        ans+=suff[pos+1];
        ans+=abs(arr[pos]-x);
    }
    else
    {
        ans+=abs(arr[pos-1]-x);
        ans+=suff[pos];
        if(pos-2>=0)
        ans+=pref[pos-2];
    }
   cnt=min(cnt,ans);
}
cout<<cnt<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1;

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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    ll n,m,ans = INF;
    cin>>n>>m;
    vector<ll>h(n),w(m);
    rep(i,n)cin>>h[i];
    rep(i,m)cin>>w[i];

    sort(all(h));

    vector<int>a((n + 1) / 2,0);
    rep(i,1,n - 1,2){
        a[0] += abs(h[i] - h[i + 1]);
    }
    rep(i,n / 2){
        a[i + 1] = a[i] - abs(h[i * 2 + 1] - h[i * 2 + 2]) + abs(h[i * 2] - h[i * 2 + 1]);
    }

    rep(i,m){
        auto itr = lower_bound(all(h),w[i]);
        int dist = itr - h.begin();
        int p = dist / 2;

        ans = min(ans,a[p] + abs(h[p * 2] - w[i]));
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
vector<ll> parent,level;
vector<vector<ll> > Adj;
vector<ll> flat_tree;
vector<ll> pre,post;
ll timer = 0;
vector<vector<ll> > segtree(5e6);

void build(ll node,ll tl,ll tr)
{
	if(tl == tr)
	{
		segtree[node] = vector<ll> (1,flat_tree[tl]);
		return;
	}
	else
	{
		ll mid = (tl + tr)/2;
		build(2 * node,tl,mid);
		build(2 * node + 1,mid + 1,tr);
		merge(segtree[node*2].begin(), segtree[node*2].end(), segtree[node*2+1].begin(), segtree[node*2+1].end(),
              back_inserter(segtree[node]));
	}
}
ll query(ll node,ll tl,ll tr,ll ql,ll qr,ll k)
{
  if(ql > qr)
  {
  	return 0ll;
  }
  else if((ql == tl) and (qr == tr))
  {
    auto it2 = upper_bound(segtree[node].begin(),segtree[node].end(),k);
    auto it1 = lower_bound(segtree[node].begin(),segtree[node].end(),k);
    ll ans = it2 - it1;
    return ans;
  }
  else
  {
  	ll mid = (tl + tr)/2;
  	ll l = query(node * 2,tl,mid,ql,min(qr,mid),k);
  	ll r = query(node * 2 + 1,mid + 1,tr,max(ql,mid + 1),qr,k);
  	return (l + r);
  }
}
void dfs(ll node,ll par,ll dist)
{
	parent[node] = par;
	level[node] = dist;
	flat_tree.eb(level[node]);
	pre[node] = timer;
	timer++;
	for(auto child : Adj[node])
	{
		if(child == par) continue;
		else
		{
			dfs(child,node,dist + 1);
		}
	}
    post[node] = timer++;
    flat_tree.eb(level[node]);

}

void Compute(ll n)
{
	KAKA
	parent.resize(n + 1);
	level.resize(n + 1);
	Adj.resize(n + 1);
	pre.resize(n + 1);post.resize(n + 1);
	pragi(2,n + 1)
	{
		cin>>parent[i];
		Adj[i].eb(parent[i]);
		Adj[parent[i]].eb(i);
	}
	dfs(1,-1,0);
    /*for(auto ele : flat_tree)
    {
    	cout<<ele<<" ";
    }
    cout<<"\n";*/
    ll m = flat_tree.size();
    build(1,0,m - 1);
    ll q;
    cin>>q;
    while(q--)
    {
    	ll u,d;
    	cin>>u>>d;
    	ll ans = query(1,0,m - 1,pre[u],post[u],d);
    	cout<<ans/2<<"\n";
    }
}
int main()
{
	KAKA
	ll n;
	cin>>n;
	Compute(n);
}

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
//using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};

const ll INF=1e18;

int main(){
    ll n; cin>>n;
    vector<vector<ll>>x(n,vector<ll>(4));
    vector<ll>a(n);
    ll suma=0;
    rep(i,n){
        cin>>x[i][1]>>x[i][2];
        x[i][3]=i;
        x[i][0]=2*x[i][1]+x[i][2];
        a[i]=x[i][1];
        suma+=a[i];
    }
    sort(all(x));
    reverse(all(x));
    ll Takahashi=0;
    ll cnt=0;
    rep(i,n){
        Takahashi+=x[i][1]+x[i][2];

        suma-=x[i][1];
        cnt++;
        if(Takahashi>suma){
            cout<<cnt<<endl;
            return 0;
        }
    }

}


#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

vector<vector<ll>> comb(int n, int r) {
	vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int i = 1; i < v.size(); i++) {
		for (int j = 1; j < i; j++) {
			v[i][j] = v[i - 1][j - 1] + v[i - 1][j];
		}
	}
	return v;
}

auto ncr = comb(60, 30);

string recur(int A, int B, ll K) {
	if (A == 0) return string(B, 'b');
	if (B == 0) return string(A, 'a');
	if (K <= ncr[A + B - 1][B]) {
		return "a" + recur(A - 1, B, K);
	} else {
		return "b" + recur(A, B - 1, K - ncr[A + B - 1][B]);
	}
}

int main() {
	int A, B;
	ll K;
	cin >> A >> B >> K;
	cout << recur(A, B, K) << endl;
}

//int a = s - '0'; 文字から数字
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;

//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

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

	cout << a * d - b  * c << endl;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool flag=false;
    for(int i=0;i<s.size();i++)
    {
        if(i%2!=0)
        {
            if(s[i]>='A' && s[i]<='Z')
            {
                continue;
            }
            else{
                flag=true;
                break;
            }
        }
        else{
            if(s[i]>='a' && s[i]<='z')
            {
                continue;
            }
            else{
                flag=true;
                break;
            }
        }
    }
    if(flag)
    {
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
    return 0;
}

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

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define DEBUG 0
#define MAXN 5001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> ans;
  for (int i = 1; i <= sqrt(n); i++)
  {
    if (!(n % i))
    {
      ans.pb(i);
      if (n / i != i)
        ans.pb(n / i);
    }
  }
  sort(ans.begin(), ans.end());
  for (auto const &i : ans)
    cout << i << endl;
  return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<cstdlib>
#include<cstdio>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<list>
#include<tuple>
using namespace std;

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for(ll i=(a); i<(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n+1)

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

struct IOSetup{
	IOSetup(){
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout<<fixed<<setprecision(12);
	}
} iosetup;

struct Edge{
    ll to, cost;
    Edge(ll t, ll c) : to(t), cost(c) { }
};
using Graph = vector<vector<Edge>>;

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

const ll MOD=1e9+7;
const ll nmax=200000+10;

ll N;
Graph G(nmax);

ll solve(){
	vvl color(nmax,vl(60,-1));
	vl cnt1(60,0);
	vl seen(nmax,0);
    queue<ll> q;
    q.push(0);
	REP(i,60) color[0][i]=0;

    while(!q.empty()){
        ll v=q.front();
        q.pop();
        seen[v]=1;

        for(auto e:G[v]){
            if(seen[e.to]) continue;

			ll et=e.to, ec=e.cost;
			q.push(e.to);
			REP(i,60){
				bool eci=ec&1;
				ec>>=1;
				color[et][i]=color[v][i]^eci;
				if(color[et][i]) cnt1[i]++;
			}
        }
    }

	ll res=0,rec=1;
	REP(i,60){
		ll mid1=rec;
		rec=rec*2%MOD;
		ll mid2=(N-cnt1[i])*cnt1[i]%MOD;
		ll mid=mid1*mid2%MOD;
		res+=mid;
		res%=MOD;
	}

    return res;
}

int main(void){
	scanf(" %ld",&N);
    REP(i,N-1){
        ll u,v,w; scanf(" %ld%ld%ld",&u,&v,&w);
        u--,v--;
        G[u].push_back(Edge{v,w});
        G[v].push_back(Edge{u,w});
    }

    ll res=solve();
    printf("%ld\n",res);

    return 0;
}

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <sstream>
#include <algorithm>
#include <numeric>

int read_int()
{
    std::string s;
    std::getline(std::cin, s);
    return std::stoi(s);
}

std::pair<int,int> read_int_pair()
{
    std::string s;
    std::getline(std::cin, s);
    size_t pos = s.find_first_of(" \t");
    if (pos == std::string::npos) {
        throw std::invalid_argument("Not found space delimiter to parse pair of ints");
    }
    int fst = std::stoi(s.substr(0, pos));
    while (++pos < s.length() &&
            (s[pos] == ' ' || s[pos] == '\t')) { }
    if (pos == s.length()) {
        throw std::invalid_argument("Not found string part 2 to parse pair of ints");
    }
    int snd = std::stoi(s.substr(pos));
    return {fst, snd};
}

bool have_colinear_3(const std::vector<std::pair<int,int>>& points)
{
    const size_t len = points.size();
    for (size_t i = 0; i < len - 2; i++) {
        for (size_t j = i + 1; j < len - 1; j++) {
            for (size_t k = j + 1; k < len; k++) {
                std::vector<std::pair<int,int>> tri { points[i], points[j], points[k] };
                std::sort(tri.begin(), tri.end(),
                    [](std::pair<int,int>& a, std::pair<int,int>& b){
                        return a.first < b.first; });

                int x0 = tri[0].first;
                int x1 = tri[1].first;
                int x2 = tri[2].first;
                int y0 = tri[0].second;
                int y1 = tri[1].second;
                int y2 = tri[2].second;

                if (x0 == x1 && x1 == x2) {
                    return true;

                } else if (y0 == y1 && y1 == y2) {
                    return true;

                } else if (x0 != x1 && x1 != x2 && y0 != y1 && y1 != y2) {
                    // if (y1 > y0 && y2 > y1) {
                        int a = x1 - x0;
                        int b = y1 - y0;
                        int A = x2 - x0;
                        int B = y2 - y0;

                        if (b * A == B * a) {
                            return true;
                        }
                    // }
                }

            }
        }
    }
    return false;
}

int main()
{
    const int n = read_int();

    std::vector<std::pair<int,int>> points;
    for (int i = 0; i < n; i++) {
        auto point = read_int_pair();
        points.push_back(point);
    }

    auto answ = have_colinear_3(points) ? "Yes" : "No";
    std::cout << answ << std::endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

int main()
{
    ll n; cin >> n;

    ll ans;
    if (n <= 2) {
        ans = 1;
    } else {
        ll c = 0;
        ll i = 1;
        ll sum = 1;
        while (sum <= n + 1) {
            i += 1;
            sum += i;
            c++;
        }
        ans = (n + 1) - c;
    }
    cout << ans << endl;
    return 0;
}

#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
using ll = long long;
constexpr int N = 1e6 + 5;

int ed;
ll n;
ll v[200];

void init() {
    v[1] = 1;
    ll b = 0;
    int t = 1;
    for(int i = 2; i <= 200; ++i) {
        v[i] = v[i - 1];
        if(t) {
            b = b + v[i - 1];
        } else {
            v[i] = v[i - 1] + b;
        }
//        printf("%lld\n", v[i]);
        t ^= 1;
        if(b >= 1e18 && v[i] >= 1e18) {
            ed = i;
            break;
        }
    }
}

vector<int> sq;

void dfs(ll res) {
    int tt = upper_bound(v + 1, v + 1 + ed, res) - v - 2;
    sq.emplace_back(tt);
    if(v[tt] != res)  dfs(res - v[tt]);
}

int main() {
    init();
//    for(int i = 1; i <= 10; ++i)  printf("%lld ", v[i]);
    scanf("%lld", &n);
    dfs(n);
//    printf("kk %d\n", (int) sq.size());
    vector<int> ans;
    ans.emplace_back(1);
    int cnt = 1;
    for(int i = 1; i <= sq[0]; ++i) {
        if(i & 1) {
            while(cnt < (int) sq.size() && sq[cnt] == sq[0] - i + 1) {
                ans.emplace_back(1);
                ++cnt;
            }
            if(i != 1)  ans.emplace_back(3);
        } else {
            ans.emplace_back(4);
        }
    }
    printf("%d\n", (int) ans.size());
    for(int num : ans)  printf("%d\n", num);
}


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

#define int         long long
#define ull         unsigned long long
#define ll          long long
#define M           998244353
#define pb          push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp          make_pair
#define lb          lower_bound
#define ub          upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (int i=begin;i<end;i++)
#define repd(i, begin, end) for (int i=end-1;i>=begin;i--)
#define ini(a,n,b)  for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)     __builtin_popcountll(a)
#define hell        1000000007
#define re          resize
const int INF=1e18;
const int N=1e2+5;

int powm(int a,int b)
{
  int res=1;
  while(b)
  {
    if(b&1)
    res=(res*a)%M;
      a=(a*a)%M;
      b>>=1;
  }

  return res;
}

int pow(int a,int b)
{
  int res=1;
  while(b)
  {
    if(b&1)
    res=(res*a);
      a=(a*a);
      b>>=1;
  }

  return res;
}

vi a[N],vis(N,0),len(N,0);
set<pair<int,int> > s;

void dfs(int node,int par)
{
  vis[node]=1;
  for(auto j:a[node])
  {
    if(!vis[j])
    {
       len[j]=len[node]+1;
       s.insert({node,j});
       dfs(j,node);
    }
    else if(j!=par&&len[j]<len[node])
    {
       s.insert({node,j});
    }
  }
}
signed main(void)
{ios
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);freopen("answer.txt", "w", stdout);
    #endif

    int n,m;
    cin>>n>>m;
    vi u(m),v(m);
    rep(i,0,m)
    {
       cin>>u[i]>>v[i];
    }

    vi c(n+1);
    rep(i,1,n+1) cin>>c[i];
    vi dir(m,0);
    rep(i,0,m)
    {
       if(c[u[i]]>c[v[i]])
       {
         dir[i]=1;
       }
       else if(c[v[i]]>c[u[i]])
       {
         dir[i]=0;
       }
       else
       {

         a[u[i]].pb(v[i]);
         a[v[i]].pb(u[i]);
       }
    }

    rep(i,1,n+1)
    {
       if(!vis[i])
       {
         dfs(i,0);
       }
    }

    rep(i,0,m)
    {
       if(c[u[i]]==c[v[i]])
       {
         if(s.find({u[i],v[i]})!=s.end()) dir[i]=1;
         else dir[i]=0;
       }
    }

    rep(i,0,m)
    {
       if(dir[i]==1) cout<<"->"<<endl;
       else cout<<"<-"<<endl;
    }

}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tint;

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

pll p[N], ops[N];

struct Query {
	int t, pid, id;
	ll x, y;
};
Query qry[N];

int main() {
	ios::sync_with_stdio(0);

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i].fi >> p[i].se;

	int m;
	cin >> m;
	for (int i = 1; i <= m; i++) {
		int op, p;
		cin >> op;
		if (op == 3 || op == 4)
			cin >> p;
		ops[i] = make_pair(op, p);
	}

	int q;
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int t, pid;
		cin >> t >> pid;
		qry[i] = (Query){t, pid, i};
	}

	sort(qry + 1, qry + q + 1, [](Query &a, Query &b) {
		return a.t < b.t;
	});

	pll x = make_pair(0, 1);
	pll y = make_pair(0, 1);
	bool flag = 0;

	int id = 1;
	for (int t = 0; t <= m; t++) {
		if (id > q) break;

		if (ops[t].fi == 1) {
			swap(x, y);
			y = make_pair(-y.fi, -y.se);
			flag ^= 1;
		} else if (ops[t].fi == 2) {
			swap(x, y);
			x = make_pair(-x.fi, -x.se);
			flag ^= 1;
		} else if (ops[t].fi == 3) {
			x = make_pair(2LL * ops[t].se - x.fi, -x.se);
		} else if (ops[t].fi == 4) {
			y = make_pair(2LL * ops[t].se - y.fi, -y.se);
		}

		while (qry[id].t == t) {
			auto &o = qry[id];
			ll nx = p[o.pid].fi;
			ll ny = p[o.pid].se;
			if (flag) swap(nx, ny);
			nx = x.fi + x.se * nx;
			ny = y.fi + y.se * ny;
			o.x = nx, o.y = ny;
			id++;
		}
	}

	sort(qry + 1, qry + q + 1, [](Query a, Query b) {
		return a.id < b.id;
	});

	for (int i = 1; i <= q; i++)
		cout << qry[i].x << ' ' << qry[i].y << endl;

	return 0;
}

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

#define SIZE 200005

struct LOC{

	ll x,y;
};

typedef vector<ll> V;
typedef vector<V> MATRIX;

int mat_size = 3;
LOC loc[SIZE];
ll table[SIZE][3][3];

MATRIX calc(MATRIX left,MATRIX right){

	MATRIX ret(mat_size,V(mat_size));

	for(int i = 0; i < mat_size; i++){
		for(int k = 0; k < mat_size; k++)ret[i][k] = 0;
	}

	for(int row = 0; row < mat_size; row++){
		for(int col = 0; col < mat_size; col++){
			for(int a = 0; a < mat_size; a++){
				ret[row][col] += left[row][a]*right[a][col];
			}
		}
	}

	return ret;
}

int main(){

	int num_P;
	scanf("%d",&num_P);

	for(int i = 0; i < num_P; i++){

		scanf("%lld %lld",&loc[i].x,&loc[i].y);
	}

	MATRIX tokei(mat_size,V(mat_size,0));
	tokei[0][1] = 1;
	tokei[1][0] = -1;
	tokei[2][2] = 1;

	MATRIX ccw(mat_size,V(mat_size,0));
	ccw[0][1] = -1;
	ccw[1][0] = 1;
	ccw[2][2] = 1;

	MATRIX move_X(mat_size,V(mat_size,0));
	move_X[0][0] = -1;
	move_X[1][1] = 1;
	move_X[2][2] = 1;

	MATRIX move_Y(mat_size,V(mat_size,0));
	move_Y[0][0] = 1;
	move_Y[1][1] = -1;
	move_Y[2][2] = 1;

	int M;
	scanf("%d",&M);

	MATRIX MULT(mat_size,V(mat_size,0));
	for(int i = 0; i < mat_size; i++){

		MULT[i][i] = 1;
	}

	for(int row = 0; row < 3; row++){
		for(int col = 0; col < 3; col++){

			table[0][row][col] = MULT[row][col];
		}
	}

	int command;
	ll p;

	for(int i = 1; i <= M; i++){

		scanf("%d",&command);

		if(command == 1){

			MULT = calc(tokei,MULT);

		}else if(command == 2){

			MULT = calc(ccw,MULT);

		}else{

			scanf("%lld",&p);
			MATRIX work(mat_size,V(mat_size,0));

			if(command == 3){

				for(int row = 0; row < 3; row++){
					for(int col = 0; col < 3; col++){

						work[row][col] = move_X[row][col];
					}
				}
				work[0][2] = 2*p;

				MULT = calc(work,MULT);

			}else{

				for(int row = 0; row < 3; row++){
					for(int col = 0; col < 3; col++){

						work[row][col] = move_Y[row][col];
					}
				}
				work[1][2] = 2*p;

				MULT = calc(work,MULT);
			}
		}

		for(int row = 0; row < 3; row++){
			for(int col = 0; col < 3; col++){

				table[i][row][col] = MULT[row][col];
			}
		}
	}

	int num_Q;
	scanf("%d",&num_Q);

	int a,b;

	for(int loop = 0; loop < num_Q; loop++){

		scanf("%d %d",&a,&b);

		b--;

		ll x = table[a][0][0]*loc[b].x + table[a][0][1]*loc[b].y + table[a][0][2];
		ll y = table[a][1][0]*loc[b].x + table[a][1][1]*loc[b].y + table[a][1][2];

		printf("%lld %lld\n",x,y);
	}

	return 0;
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T>
inline bool dpmin(T& a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool dpmax(T& a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

void solve(long long N) {
    ll ans;

    if (1 <= N && N <= 100) {
        ans = 1;
    } else {
        for (ll c = 1; c <= 30; c++) {
            if (c * 100 + 1 <= N && N <= (c+1) * 100){
                ans = c + 1;
                break;
            }
        }
    }

    cout << ans << endl;
}

// Generated by 2.3.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the
// default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    std::scanf("%lld", &N);
    solve(N);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18;                    //1*10^18
const double PI = 3.141592653589793238; //18桁
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

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

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans=0;
  ll n;
  cin >> n;

if(n%100==0)
{
    ans=n/100;
}else
{
    ans=n/100+1;
}
  cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std ;

int main(void) {
  ios::sync_with_stdio(false) ; cin.tie(0) ;
  long long N ;
  cin >> N ;
  unordered_set<long long> s ;
  for (long long i = 2 ; i * i <= N ; i++) {
    long long x = i ;
    while (x * i <= N) {
      s.insert(x * i) ;
      x *= i ;
    }
  }
  cout << N - (int) s.size() ;
  return 0 ;
}

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define MOD 1000000007LL
#define PI acos(-1)

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

template <typename T>
using max_heap = priority_queue<T>;

template <class T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename... T>
void read(T &...args) {
    ((cin >> args), ...);
}

template <typename... T>
void write(T &&...args) {
    ((cout << args), ...);
}

template <typename T>
void readContainer(T &t) {
    for (auto &e : t) {
        read(e);
    }
}

template <typename T>
void writeContainer(T &t) {
    for (const auto &e : t) {
        write(e, " ");
    }
    write("\n");
}

auto speedup = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    return nullptr;
}();

void solve(int tc) {
    int N;
    read(N);
    set<int> st;
    for (int i = 2; i <= (int)1e5; i++) {
        int x = i * i;
        while (x <= (int)1e10) {
            st.insert(x);
            x *= i;
        }
    }
    int ans = 0;
    for (const auto &ele : st) {
        if (ele <= N) {
            ans++;
        }
    }
    write(N - ans);
}

signed main() {
    int tc = 1;
    // read(tc);
    for (int curr = 1; curr <= tc; ++curr) {
        solve(curr);
    }
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<bitset>
#include<functional>
#include <fstream>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 10000000000000000;
const int intINF = 1000000000;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ld pi = 3.141592653589793238;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
//printf("%.10f\n", n);
typedef pair <ll, ll> P;
ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
struct edge { ll to, cost; };
struct status {
	ll cost;
	ll bango;

	bool operator<(const status& rhs) const { return cost < rhs.cost; };
	bool operator>(const status& rhs) const { return cost > rhs.cost; };
};

ll n, m;
vector<string> ansG(5000); vector<ll> c(101);
vector<vector<P>> G1(101), G2(101);
vector<bool> henvisit(5000, false);
vector<bool> visit(101, false);
void dfs(ll x) {
	//cout << x << endl;
	ll ko = c[x], to = 0;
	for (int i = 0; i < G1[x].size(); i++) {
		ll next = G1[x][i].first, ban = G1[x][i].second;
		if (c[next] == ko && !visit[next] && !henvisit[ban]) {
			visit[next] = true; henvisit[ban] = true; ansG[ban] = "->";
			dfs(next);
			//cout << G1[q][i].second << endl;
		}
		if (c[next] == ko && visit[next] && !henvisit[ban]) {
			henvisit[ban] = true; ansG[ban] = "->";
		}
	}
	for (int i = 0; i < G2[x].size(); i++) {
		ll next = G2[x][i].first, ban = G2[x][i].second;
		if (c[next] == ko && !visit[next] && !henvisit[ban]) {
			//cout << G2[q][i].second << endl;
			visit[next] = true; henvisit[ban] = true; ansG[ban] = "<-";
			dfs(next);
		}
		if (c[next] == ko && visit[next] && !henvisit[ban]) {
			henvisit[ban] = true; ansG[ban] = "<-";
		}
	}
}

signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	//cout << fixed << setprecision(15);

	//input
	cin >> n >> m;
	vector<ll> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		G1[a[i]].push_back(P(b[i], i)); G2[b[i]].push_back(P(a[i], i));
	}
	rep2(i, n) { cin >> c[i]; }
	//dfs
	rep(i, m) {
		if (henvisit[i]) { continue; }
		if (c[a[i]] > c[b[i]]) { ansG[i] = "->"; henvisit[i] = true; }
		else if (c[a[i]] < c[b[i]]) { ansG[i] = "<-"; henvisit[i] = true; }
		else if (visit[a[i]] && visit[b[i]]) { ansG[i] = "->"; }
		else {
			dfs(a[i]);
		}
	}
	//output
	rep(i, m) {
		cout << ansG[i] << endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=110;
const int inf=2147483647;
const double pi=acos(-1.0);
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int n,m,c[Maxn],ans[Maxn*Maxn],fa[Maxn],dep[Maxn],ex[Maxn*Maxn],ey[Maxn*Maxn],px,py,o,d[Maxn];
vector<pa>G[Maxn];
void dfs(int x,int f,int u)
{
	dep[x]=dep[f]+1;fa[x]=f;d[x]=u;
	for(int i=0;i<G[x].size();i++)
	{
		int t=G[x][i].second;
		if(t==u)continue;
		int y=G[x][i].first;
		if(!dep[y])ans[t]=(x==ey[t]),dfs(y,x,t);
		else
		{
			if(dep[y]<dep[x])ans[t]=(x==ey[t]);
			else ans[t]=(y==ey[t]);
		}
	}
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++)ex[i]=read(),ey[i]=read();
	for(int i=1;i<=n;i++)c[i]=read();
	for(int i=1;i<=m;i++)
	{
		int x=ex[i],y=ey[i];
		if(c[x]==c[y])G[x].push_back(make_pair(y,i)),G[y].push_back(make_pair(x,i));
		else
		{
			if(c[x]>c[y])ans[i]=0;
			else ans[i]=1;
		}
	}
	dep[0]=0;
	for(int i=1;i<=n;i++)
	if(!dep[i])
	{
		py=-1;
		dfs(i,0,0);
	}
	for(int i=1;i<=m;i++)
	{
		if(!ans[i])puts("->");
		else puts("<-");
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 3000000000000001 // 3e15
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fill(a, n, x) for(int i = 0; i < n; i++) a[i] = x;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 998244353;
const ll N = 100110;
const ll M = log2(N) + 1;

struct point
{
    ll x, y;
};

template<typename T>
T fast_exp(T x,T n)
{
    if(n == 0) return 1;
    T ans = 1;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}

void BITfunc(ll &a, ll &x)
{
    a += x;
}

void update(ll BIT[], ll i, ll x, ll n)
{
    if(i <= 0) return;
    for(; i <= n; i += i & (-i))
        BITfunc(BIT[i], x);
}

ll Query(ll BIT[], ll x)
{
    ll res = 0;
    while(x > 0)
    {
        BITfunc(res, BIT[x]);
        x = x & (x - 1);
    }
    return res;
}

ll query(ll BIT[], ll l, ll r)
{
    l--;
    ll sum = 0;
    while(r > 0)
    {
        sum += BIT[r];
        r = r & (r - 1);
    }
    while(l > 0)
    {
        sum -= BIT[l];
        l = l & (l - 1);
    }
    return sum;
}

ll fact[N], infact[N];
void work()
{
    fact[0] = fact[1] = infact[0] = infact[1] = 1;
    for(ll i = 2; i < N; i++)
    {
        fact[i] = fact[i - 1] * i % mod;
        infact[i] = fast_exp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    if(r > n || r < 0) return 0;
    return fact[n] * infact[n - r] % mod * infact[r] % mod;
}

ll npr(ll n, ll r)
{
    if(r > n || r < 0) return 0;
    return fact[n] * infact[n - r] % mod;
}

int main()
{
    fast;
    int _ = 1, test = 0;
    //cin >> _;
    while(_--)
    {
        test++;
        ll n, m, x, q = 0, y = 0, z = 0, ans = 0, k = 0, mx = 0;
        cin >> x >> y;
        for(int i = x; i < y; i++)
        {
            k = i;
            for(ll j = 1; j * j <= k; j++)
            {
                if(k % j == 0)
                {
                    if(k + j <= y)
                        ans = max(ans, j);
                    if(k + k / j <= y)
                        ans = max(ans, k / j);
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

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

int main(){
  float A,B;
  float ans=0;
  cin>>A>>B;
  ans=(A-B)*100/A;
  cout<<ans;
}


//================code===================//

//#define TLE

#ifdef TLE
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define ld long double
#define fa(i,a,b) for(LL i=(a);i<(LL)(b);++i)
#define fd(i,a,b) for(LL i=(a);i>(LL)(b);--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>

#define M_PI 3.14159265358979323846
#define micro 0.000001

using namespace std;

#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
#else
#define AT
#define AE
#define ce(t)
#define __popcnt __builtin_popcount
#define gcd __gcd
#define lcm __lcm
#endif

pair <int, int> vu[9] = { {0,1},{1,0},{0,-1} ,{-1,0},{0,1},{1,0}, {-1,1} , {1,-1},{-1,-1} }; //RDLU EWSN

template<typename T, typename U> void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U> void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } bool operator()(setl a, setl b) { return a.second < b.second; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } bool operator()(setl a, setl b) { return a.second > b.second; } };

const int max_v = 2e5 + 7;
const int INF = 1e9 + 7;
const LL LNF = (LL)5e18 + 7ll;
const LL mod = 998244353;

LL cpow(LL x, LL k)
{
	if (!x) return 0;
	LL ret = 1;
	while (k)
	{
		if (k & 1) ret = ret * x % mod;
		x = x * x % mod;
		k >>= 1;
	}

	return ret;
}

int main()
{
#ifdef OHSOLUTION
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	LL n, m, k; ci(n >> m >> k);
	LL ans = 0;

	if (n == 1 || m == 1)
	{
		co(cpow(k, n + m - 1));
		return 0;
	}

	if (n == 1) swap(n, m);

	fa(i, 1, k + 1)
	{
		ans = (ans + cpow(i, n) * ((cpow(k - i + 1, m) - cpow(k - i, m) + mod) % mod) % mod) % mod;
	}
	co(ans%mod);
	return 0;
}

#include<bits/stdc++.h>
#define maxn 200005
#define mod 998244353
using namespace std;
long long n,m,K;
long long pw(long long A,long long n)
{
	long long ans=1;
	while (n)
	{
		if (n&1) ans=ans*A%mod;
		n=n>>1;
		A=A*A%mod;
	}
	return ans;
}

int main()
{
	long long ans=0;
	cin>>n>>m>>K;
	if (n==1) {cout<<pw(K,m)<<endl; return 0;}
	if (m==1) {cout<<pw(K,n)<<endl; return 0;}
	for (long long zd=1;zd<=K;zd++)
	{
		long long tt=pw(zd,n),gg=pw(zd-1,n);
		tt-=gg; while (tt<0) tt+=mod;
		ans+=tt*(pw(K-zd+1,m));
		ans%=mod;
	}
	cout<<ans<<endl;
}