#include<bits/stdc++.h>
using namespace std;
#define fo(i,k,n) for(long long i=k;i<n;i++)
#define endl "\n"
#define pb push_back
#define vii vector<ll>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

typedef long long ll;

ll fun_ceil(ll n,ll k){
    if(n%k==0){
        return n/k;
    }
    else {
        ll x = (n/k)+1;
        return x;
    }
}

ll pw(ll n, ll pow, ll m){
    if(pow==0)return 1;
    if(pow%2 == 0){ll x = pw(n, pow/2, m);
        return (x*x)%m;}
    else return (pw(n, pow-1, m)*n)%m;
}
ll gcd(ll a, ll b) {
    if (!b)return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}
ll fact(ll n, ll mod) {
    if (n > 1)
        return (n * fact(n - 1, mod)) % mod;
    else
        return 1;
}
bool isPrime(ll n) {
    if (n <= 3) {
        return true;
    }
    if (n % 2 == 0 || n % 3 == 0) {
        return false;
    }
    for (ll i = 5; i * i <= n; i = i + 6) {
        if (n % i == 0 || n % (i + 2) == 0) {
            return false;
        }
    }
    return true;
}
//sort(s.begin(),s.end(),[](tt x, tt y){return abs(x)>abs(y);});

void calc(){
    string s;cin>>s;
    char t1 = s[0], t2 = s[1];
    s[0] = s[1];
    s[1] = s[2];
    s[2] = t1;
    cout<<s;
}

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

        calc();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll mx = -1, mn = 1e15;
    ll arr[n+1];
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
        mx = max(mx, arr[i]);
        mn = min(mn, arr[i]);
    }
    unordered_map<ll, ll> arr1;
    //memset(arr1, 0, sizeof(arr1));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= sqrt(arr[i]) && j < mn; j++)   {
            if(arr[i]%j == 0)   {
                arr1[j] = __gcd(arr1[j], arr[i]);
                if(arr[i]/j < mn)   {
                    arr1[arr[i]/j] = __gcd(arr1[arr[i]/j], arr[i]);
                }
            }
        }
    }
    ll ans = 1;
    for(auto itr = arr1.begin(); itr != arr1.end(); itr++)  {
        if(itr->first == itr->second)   {
            ans++;
        }
    }
    cout << ans;

}


#include <stdio.h>
#include<iostream>
#include <string>
#include <string.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <climits>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <unordered_set>
#define hash hassh
using namespace std;
int main() {
    int T=1;
    //cin>>T;
    while(T--) {
        long double x,y,r;
        cin>>x>>y>>r;
        long long ans=0;
        r+=1e-14;
        int st=ceil(x-r),ed=floor(x+r);
        for(int i=st;i<=ed;i++){
            long double d=sqrt(r*r-(x-i)*(x-i));
            int top=floor(y+d),bot=ceil(y-d);
            ans+=top-bot+1;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
using namespace std;
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; }
typedef long long ll;
const int INF = INT32_MAX;
using P = pair<int, int>;

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    int ans = y*z/x;
    if(y*z == ans*x){
        ans--;
    }
    if(ans < 0) ans= 0;

    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
const int mod = 1e9+7;
const int mod1 = 998244353;
const ll inf = 1e14;
const int nax = 200005;
int n,q,a,b,type,c[nax],grp[nax],sz[nax];
map<int,int> adj[nax];
int get(int x)
 {
  if(grp[x] != x)
     grp[x] = get(grp[x]);
  return grp[x];
 }
void dsu(int x, int y)
 {
  x = get(x);
  y = get(y);
  if(sz[x] > sz[y])
     swap(x,y);
  if(x == y)
     return;
  sz[y] += sz[x];
  grp[x] = y;
  for(auto P : adj[x])
     adj[y][P.ff] += P.ss;
 }
void solve()
 {
  cin>>n>>q;
  loop(i,1,n+1)
   {
    cin>>c[i];
    sz[i] = 1;
    grp[i] = i;
    adj[i][c[i]]++;
   }
  loop(i,0,q)
   {
    cin>>type>>a>>b;
    if(type == 1)
      dsu(a,b);
    else
      cout<<adj[get(a)][b]<<END;
   }
 }
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  /*int t;
  cin>>t;
  while(t--)  */
   solve();
  return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;

long long gcd(long long a, long long b){ return b? gcd(b, a%b) : a; }
long long lcm(long long a, long long b){ return (!a or !b)? 0 : a * b / gcd(a,b); }
long long  poww(long long  a, long long b){
	long long res = 1;
	while(b){
		if(b%2) res = res * a ;
		a = a * a;  b>>=1;
	} return res;
}

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
template<class t,class u>bool mmax(t&a,u b){if(a<b)a=b;return a<b;}
template<class t,class u>bool mmin(t&a,u b){if(b<a)a=b;return b<a;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using li = long long;
using vi = vc<int>;
using ii = pair<int,int>;
// ---- しゃけ ツナマヨ ('-')7
const int mod = 1e9+7;

int Sum(li a, li b){
    return (a+b)%mod;
}

int Mul(li a, li b){
	a%=mod, b%=mod;
    return (a*b)%mod;
}

int main(){_
	auto solve=[&](){
		int n; cin>>n;
		using pl = pair<int,li>;
		vv(pl,v,n);
		fore(i,0,n-1){
			li a,b,c; cin>>a>>b>>c; a--,b--;
			v[a].pb({b,c});
			v[b].pb({a,c});
		}
		vc<li>to(n,0);
		auto f=[&](auto &&f, int u, int pr, li w)->void{
			to[u]=w;
			for(auto [a,b]:v[u])if(pr!=a)f(f,a,u,w^b);
		};
		f(f,0,0,0);
		li res = 0;
		fore(i,0,60){
			li c = 0;
			fore(j,0,n)if(to[j]&(1ll<<i))c++;
			res = Sum(res,Mul(c*(n-c),(1ll<<i)));
		}
		cout<<res<<ENDL;

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

}

#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;

#define REP(i,b,e) for(int i=b; i<e; i++)
#define PRINT(vec) {printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");}
#define fi first
#define se second

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

ll modpow(ll a, ll p, ll m){
	ll ret = 1;
	while(p){
		if(p&1) ret = ret * a % m;
		a = a * a % m;
		p >>= 1;
	}
	return ret;
}

int main(){
	ll n, m, k;
	scanf("%ld %ld %ld", &n, &m, &k);

	ll ans = 0;
	REP(i, 1, k+1){
		ll x = modpow(k-i+1, m, MOD) - modpow(k-i, m, MOD);
		x = (x + MOD) % MOD;
		if(n==1) ans += x;
		else{
			ll y = modpow(i, n, MOD);
			if(m==1) y = (y - modpow(i-1, n, MOD) + MOD) % MOD;
			ans += x * y % MOD;
		}
		ans %= MOD;
	}
	printf("%ld\n", ans);
	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T &t, const U &u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T &t, const U &u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int maxn = 52;

map<ll, ll> dp[maxn];

// [-ti,ti]

const ll INF = TEN(16);

int main() {
    int N;
    ll X;
    cin >> N >> X;
    V<ll> A(N);
    rep(i, N) cin >> A[i];
    reverse(ALL(A));

    dp[0][X] = 1;

    rep(i, N) {
        ll bd = i > 0 ? A[i - 1] / A[i] : INF;
        for (auto &[x, num] : dp[i]) {
            ll k = x / A[i];
            for (ll c : {k - 1, k, k + 1}) {
                if (abs(c) >= bd) continue;
                ll rem = x - A[i] * c;
                if (abs(rem) >= A[i]) continue;
                dp[i + 1][rem] += num;
            }
        }
    }

    cout << dp[N][0] << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
vector<ll> hoge;
vector<ll> piyo;
ll memo[100][2];
bool visited[100][2];
ll f(int p, int q) {
	if (visited[p][q]) return memo[p][q];
	visited[p][q] = true;
	if (hoge[p] == -1) {
		if (q == 0) return memo[p][q] = 1;
		else return memo[p][q] = N-p;
	} else {
		ll r = 0;
		if (piyo[p] == 0) {
			r = N-p;
		} else {
			if (hoge[p]+q != piyo[p]) r += f(p+1, 0);
			if (hoge[p]+q != 0) r += f(p+1, 1);
		}
		return memo[p][q] = r;
	}
}
int main() {
	ll X;
	cin >> N >> X;
	vector<ll> A(N);
	for (auto& x : A) cin >> x;
	hoge.resize(N+1);
	piyo.resize(N+1);
	for (int i = N-1; i >= 0; -- i) {
		hoge[i] = X / A[i];
		X %= A[i];
	}
	for (int i = N; i >= 0; -- i) {
		if (hoge[i]) break;
		hoge[i] = -1;
	}
	for (int i = 1; i < N; ++ i) {
		piyo[i-1] = A[i] / A[i-1];
	}
	cout << f(0, 0) << endl;
}


#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;

int main() {
	char a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << "Won" << endl;
	}
	else {
		cout << "Lost" << endl;
	}
	return 0;
}

/**
 * @author: adityasonani
 * */
#include <bits/stdc++.h>

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define     ll         	long long
#define     ull         unsigned long long
#define     ld        	long double
#define     ln          "\n"
#define     fastio      ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define     MOD         (int) 1000000007
#define     rep(i, n)   for (int i = 0; i < (int)n; i++)
#define     all(x)      (x).begin(), (x).end()
#define     debug(x)    cerr << #x << " = " << x << endl;
#define     precise(x)  cout << fixed << setprecision(x)
const       int         MAX = 1000000; // 10^6

using namespace std;

/*

*/

void solve()
{
    int a, b, c, n, k, ans, cnt;
    string s;
    cin>>s;

    if(s[0]==s[1] && s[1]==s[2]){
        cout << "Won\n";
    }
    else{
        cout << "Lost\n";
    }

}

signed main()
{
    fastio;

    auto start = std::chrono::high_resolution_clock::now();

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

    while(t--)
        solve();

    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);

    // cerr << "\nTime taken : " << ((long double)duration.count())/((long double) 1e9) <<" s "<< endl;

    return 0;
}


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

#define M 998244353
#define int long long

vector<int> root, sze;

int find_set(int a) {
    if (a == root[a])
        return a;
    return root[a] = find_set(root[a]);
}

void unite(int a, int b) {
    int x = find_set(a);
    int y = find_set(b);
    if (x != y) {
        if (sze[y] > sze[x])
            swap(x, y);
        root[y] = x;
        sze[x] += sze[y];
    }
}

int32_t main() {
    int n, k;
    cin >> n >> k;
    root.resize(n);
    sze.resize(n, 1);
    iota(root.begin(), root.end(), 0);
    vector<vector<int>> arr(n, vector<int> (n));
    vector<int> fact(n+1, 1);
    for (int i = 2; i <= n; i++)
        fact[i] = (fact[i-1] * i) % M;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> arr[i][j];
    for (int x = 0; x < n-1; x++) {
        for (int y = x+1; y < n; y++) {
            int poss = 1;
            for (int j = 0; j < n; j++) {
                if (arr[x][j] + arr[y][j] > k) {
                    poss = 0;
                    break;
                }
            }
            if (poss == 1)
                unite(x, y);
        }
    }
    int ans = 1;
    for (int i = 0; i < n; i++)
        if (root[i] == i)
            ans = (ans * fact[sze[i]]) % M;
    root.clear();
    sze.clear();
    root.resize(n);
    sze.resize(n, 1);
    iota(root.begin(), root.end(), 0);
    for (int x = 0; x < n-1; x++) {
        for (int y = x+1; y < n; y++) {
            int poss = 1;
            for (int i = 0; i < n; i++) {
                if (arr[i][x] + arr[i][y] > k) {
                    poss = 0;
                    break;
                }
            }
            if (poss == 1)
                unite(x, y);
        }
    }
    for (int i = 0; i < n; i++)
        if (root[i] == i)
            ans = (ans * fact[sze[i]]) % M;
    cout << ans << endl;
}

#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRVI(N, X) VI X(N); for (int ___I=0; ___I<n; ___I++) scanf("%d", &(X[___I]))
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

VI ps;

int findp(int i){
    if (ps[i]!=i){
        ps[i]=findp(ps[i]);
    }
    return ps[i];
}

void merge(int i, int j){
    i=findp(i);
    j=findp(j);
    ps[j]=i;
}

int main(){
    DRII(n,k);
    vector<VI> a(n,VI(n,0));
    REP(i,n){
        REP(j,n){
            RI(a[i][j]);
        }
    }

    vector<VI> cs(n,VI(0));
    LL r=1;
    const int mod = 998244353;
    REP(i,n){
        REPP(j,i+1,n){
            bool cansw=true;
            REP(p,n){
                if (a[i][p]+a[j][p]>k) {cansw=false; break;}
            }
            if (cansw){
                cs[i].PB(j);
                cs[j].PB(i);
            }
        }
    }
    ps=VI(n);
    REP(i,n) ps[i]=i;
    REP(i,n){
        for (auto c:cs[i]){
            merge(i,c);
        }
    }
    map<int,int> v;
    REP(i,n){
        r*=(++v[findp(i)]);
        r%=mod;
    }

    // La même pour les cols
    cs=vector<VI>(n,VI(0));
    REP(i,n) ps[i]=i;
    v.clear();
    REP(i,n){
        REPP(j,i+1,n){
            bool cansw=true;
            REP(p,n){
                if (a[p][i]+a[p][j]>k) {cansw=false; break;}
            }
            if (cansw){
                cs[i].PB(j);
                cs[j].PB(i);
            }
        }
    }
    ps=VI(n);
    REP(i,n) ps[i]=i;
    REP(i,n){
        for (auto c:cs[i]){
            merge(i,c);
        }
    }
    REP(i,n){
        r*=(++v[findp(i)]);
        r%=mod;
    }

    printf("%lld\n",r);
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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 ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//AtCoder以外ではコメントアウトを忘れずに！
//#include <atcoder/all>
//using namespace atcoder;
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
//**AC Libraryリスト**//
//pow_mod, inv_mod, floor_sum, convolution, convolution_ll, modint//
//fenwicktree, segtree, lazysegtree, string//
ll i, j, k, l; ll N, M, K, H, W, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vector<vtll> path;
//***********//
map<ll, ll> flag;
vll path2;
vl T;
void dijkstra(ll s) {
	priority_queue<pll> PQ;
	vl D(N+M), color(N+M);
	for (ll i = 0; i < N+M; i++) {
		D[i] = INF;
		color[i] = 0;
	}
	D[s] = 0;
	//PQ.push(make_pair(0, s));
	color[s] = 1;
	ll q = -1;
	//debug(path2[s]);
	for (ll i = 0; i < path2[s].size(); i++) {
		D[N + path2[s][i]] = 0;
		PQ.push(make_pair(0, N+path2[s][i]));
	}
	while (!PQ.empty()) {
		pll f = PQ.top();
		PQ.pop();
		ll u = f.second;
		//debug(u);
		color[u] = 2;
		if (D[u] < f.first * q) {
			continue;
		}
		for (ll j = 0; j < path[u].size(); j++) {
			ll v = get<0>(path[u][j]);
			//debug(v);
			//debug(path2[v]);
			if (color[v] == 2) {
				continue;
			}
			if (D[v] > D[u] + get<1>(path[u][j])) {
				D[v] = D[u] + get<1>(path[u][j]);
				color[v] = 1;
				//PQ.push(make_pair(D[v] * q, v));
				for (ll k = 0; k < path2[v].size(); k++) {
					ll m = path2[v][k];
					ll pre = D[v];
					if (D[v] % T[m] != 0) {
						pre += T[m] - D[v] % T[m];
					}
					if (D[N + m] > pre) {
						D[N + m] = pre;
						color[N + m] = 1;
						PQ.push(make_pair(D[N + m] * q, N + m));
					}
				}
			}
		}
	}
	//debug(D);
	if (D[Y] == INF) cout << -1;
	else cout << D[Y];
}
int main() {
	cin >> N >> M >> X >> Y;
	//N+1~N*(M+1)まで
	map<ll,ll> flag;
	T.resize(M);
	path.resize(N + M);
	path2.resize(N);
	for (i = 0; i < M; i++) {
		ll a, b, t, k;
		cin >> a >> b >>t >> k;
		T[i] = k;
		a--; b--;
		path[N+i].push_back(mt(b, t,k));
		path[N + i].push_back(mt(a, t, k));
		path2[a].push_back(i);
		path2[b].push_back(i);
	}
	X--; Y--;
	dijkstra(X);
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cctype>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <ctime>
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
inline int read_int(){
	int t=0;bool sign=false;char c=getchar();
	while(!isdigit(c)){sign|=c=='-';c=getchar();}
	while(isdigit(c)){t=(t<<1)+(t<<3)+(c&15);c=getchar();}
	return sign?-t:t;
}
inline LL read_LL(){
	LL t=0;bool sign=false;char c=getchar();
	while(!isdigit(c)){sign|=c=='-';c=getchar();}
	while(isdigit(c)){t=(t<<1)+(t<<3)+(c&15);c=getchar();}
	return sign?-t:t;
}
inline char get_char(){
	char c=getchar();
	while(c==' '||c=='\n'||c=='\r')c=getchar();
	return c;
}
inline void write(LL x){
	char c[21],len=0;
	if(!x)return putchar('0'),void();
	if(x<0)x=-x,putchar('-');
	while(x)c[++len]=x%10,x/=10;
	while(len)putchar(c[len--]+48);
}
inline void space(LL x){write(x),putchar(' ');}
inline void enter(LL x){write(x),putchar('\n');}
const int MAXN=2e5+5,Mod=998244353;
int quick_pow(int a,int k){
	int ans=1;
	while(k){
		if(k&1)ans=1LL*ans*a%Mod;
		a=1LL*a*a%Mod;
		k>>=1;
	}
	return ans;
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	int n=read_int(),m=read_int(),k=read_int();
	if(n==1||m==1)
	enter(quick_pow(k,n+m-1));
	else{
		int ans=0;
		_rep(i,1,k)
		ans=(ans+1LL*(quick_pow(i,n)-quick_pow(i-1,n)+Mod)*quick_pow(k-i+1,m))%Mod;
		enter(ans);
	}
	return 0;
}


#include <bits/stdc++.h>

#ifdef mlocal
#include "./Competitive-Code-Library/snippets/prettyprint.h"
#endif
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef array<int, 2> ii;
#define endl '\n'

vector<ll> phi_1_to_n(int n) {
	vector<ll> phi(n + 1);
	phi[0] = 0;
	phi[1] = 1;
	for (int i = 2; i <= n; i++)
		phi[i] = i;

	for (int i = 2; i <= n; i++) {
		if (phi[i] == i) {
			for (int j = i; j <= n; j += i)
				phi[j] -= phi[j] / i;
		}
	}

	for_(i, 1, phi.size()) phi[i] += phi[i - 1] - 1;

	return phi;
}

int main() {
#ifdef mlocal
	freopen("test.in", "r", stdin);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int l, r;
	cin >> l >> r;
//	vector<vi> fac(r+1);
	vi spf(r + 1, -1);
	for__(i, 2, r + 1) {
		if (spf[i] == -1) spf[i] = i;

		for (ll j = i*i; j <= r; j += i) {
//			fac[j].push_back(i);
			if (spf[i] == i and spf[j] == -1) spf[j] = i;
		}
	}

	vi pr;
	ll cop = 0, prod = 1;
	int ct = 0;
	int curl;

	function<void(int)> count = [&](int p) {
		if (p == pr.size()) {
//			if (ct == 0) return;

			ll curr = r / prod - curl / prod;
//			cout << "current factor: " << prod << " -> " << curr << endl;

			if (ct % 2) cop -= curr;
			else cop += curr;

			return;
		}

		count(p + 1);
		ct++;
		prod *= pr[p];
		count(p + 1);
		prod /= pr[p];
		ct--;
	};

	ll ans = 0;
	vi mul(r + 1);
	for (int i = r; i >= max(l, 2); i--) { // TODO:_ change Here
		curl = i;
		cop = 0;
		prod = 1;
		ct = 0;
		pr.clear();

		int k = i;
		while (k != 1) {
			int p = spf[k];
			pr.push_back(p);
			while ((k % p) == 0) k /= p;
		}

		count(0);
//		cout << i << " has prime factors: " << pr << " and has " << cop << " coprime greatr values " << endl;
		// increase ans by: all greater values - the ones which are coprime - the ones which are multiple of me
		ans += 2 * ((r - i) - cop - ((r / i) - 1));
//		cout << i << " adding " << (r - i) - cop - ((r / i) - 1) << endl;
	}

	cout << ans << endl;
}

#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
const int maxn=500+5;
int n,m;
char s[maxn][maxn];
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%s",s[i]+1);
	int ans=1;
	for(int i=1;i<=n+m-1;++i) {
		int opt=0,flag1=1,flag2=1;
		for(int j=max(1,i+1-m);j<=min(n,i);++j) {
			if(s[j][i+1-j]=='R') {
				flag2=0;
				if(!opt) opt=1;
				else if(opt!=1) flag1=0;
			}
			else if(s[j][i+1-j]=='B') {
				flag2=0;
				if(!opt) opt=2;
				else if(opt!=2) flag1=0;
			}
		}
		if(!flag1) ans=0;
		else if(flag2) ans=ans*2%mod;
	}
	printf("%d\n",ans);
	return 0;
}


//Hey stalker :)
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define max(a, b) (a < b? b : a)
#define min(a, b) ((a>b)?b:a)

#define MOD 1000000007

#define FOR(a,c)   for ( ll (a)=0; (a)<(c); (a)++)
#define FORL(a,b,c)  for ( ll (a)=(b); (a)<(c); (a)++)
#define FORR(a,b,c)  for (  ll (a)=(b); (a)>=(c); (a)--)
#define all(v)                      (v).begin(),(v).end()
#define Sort(v)                     sort(all((v)))
#define rSort(v)                    sort((v).rbegin(),(v).rend())
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b)  (x/gcd(x,y))*y
#define INF 9223372036854775807
//18446744073709551615
#define abs llabs

#define no cout<<"NO\n";
#define yes cout<<"YES\n";

#define Clear( a, b ) memset( a, b, sizeof( a ) )
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

#define pr3(a,b,c) cerr<<#a<<"="<<a<<"\t"<<#b<<"="<<b<<"\t"<<#c<<"="<<c<<"\n";
#define pr2(a,b) cerr<<#a<<"="<<a<<"\t"<<#b<<"="<<b<<"\n";
#define pr1(a) cerr<<#a<<"="<<a<<"\n";
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;

#define F first
#define S second
#define PB push_back
#define POB pop_back

inline long long  max3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  min3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}

vector <string> a(70);

ll rec(ll i)
{
	if(i==1)
		return 1;
	if(a[i][0]=='A')
	{
		return rec(i-1);
	}
	else
	{
		return rec(i-1)+pow(2,i);
	}
}
void solve()
{
	ll n,m,d,t=0,k=0,x=0,y=0,z=0,a1,a2,a3,a4,a5,var=1,f=INF;
	cin>>n;
	vector<vector<ll> > vp(n+1,vector<ll> (2,0));
	FORL(i,1,n+1)cin>>a[i];
	vp[0][0]=1;
	vp[0][1]=1;
	if(a[1][0]=='A')
	{
		vp[1][1]=vp[0][1];
		vp[1][0]=2*vp[0][0]+vp[0][1];
	}
	else
	{
		vp[1][0]=vp[0][0];
		vp[1][1]=2*vp[0][1]+vp[0][0];
	}

	FORL(i,2,n+1)
	{
		if(a[i][0]=='A')
		{
			// vp[i]=vp[i-1]/2;

			vp[i][1]=vp[i-1][1];
			vp[i][0]=2*vp[i-1][0]+vp[i-1][1];
		}
		else
		{
			vp[i][0]=vp[i-1][0];
			vp[i][1]=2*vp[i-1][1]+vp[i-1][0];
			// vp[i]=(pow(2,n+1)-vp[i-1])/2+vp[i-1];
		}
	}
	// debuga2(vp,n+1,2)
	cout<<vp[n][1]<<"\n";
	// cout<<rec(n)<<"\n";
}

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("int.txt", "r", stdin);
	// freopen("Output.txt", "w", stdout);
	// freopen("Error.txt","w",stderr);
	// #endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1,t=0;
	// cin>>T;
	while(t++<T)
	{
		// cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;

#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 300005

int n;
int a[MAXN];
ll b[MAXN];
ll ans;
ll sum[2];
map<ll, int> mp[2];

int main() {
	scanf("%d", &n);
	REP (i, 0, n) {
		scanf("%d", &a[i]);
	}
	b[0] = a[0];
	REP (i, 1, n) {
		b[i] = a[i] - b[i - 1];
	}
	REP (i, 0, n + 1) {
		ans += mp[i % 2][b[i]];
		sum[i % 2] += a[i];
		sum[(i + 1) % 2] -= a[i];
		REP (j, 0, 2) {
			mp[j][sum[j]]++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


// time-limit: 2000
// problem-url: https://atcoder.jp/contests/abc201/tasks/abc201_d
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <array>
#include <random>
#include <cmath>
#include <chrono>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <climits>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define trav(a, x) for(auto& a : x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define what_is(x) cerr << #x << " is " << x << endl;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // use rng() to get unsigned int
// mt19937_64 for random long longs

vector<string> a;
vector<vector<int>> dp;
const int inf = 1e9;

int h, w;

int solve(int row, int col) {
	if (row == h -1 && col == w - 1) {
		return 0;
	}
	if (dp[row][col] != -inf) return dp[row][col];
	auto cell = [&](int r, int c) {
		return a[r][c] == '+' ? 1 : -1;
	};
	if (row + 1 < h) {
		dp[row][col] = cell(row+1, col) - solve(row + 1, col);
	}
	if (col + 1 < w) {
		dp[row][col] = max(dp[row][col], cell(row, col + 1) - solve(row, col + 1));
	}
	return dp[row][col];
}

void solve() {
	cin >> h >> w;
	a.resize(h);
	rep(i, 0, h) {
		cin >> a[i];
	}
	dp.resize(h, vi(w, -inf));
	int score = solve(0, 0);
	// cout << score << endl;
	if (score > 0) {
		cout << "Takahashi\n";
	} else if (score == 0) {
		cout << "Draw\n";
	} else {
		cout << "Aoki\n";
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int t;
	// cin >> t;
	t = 1;
	while (t--) {
		solve();
	}
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)

const ll MAX_N = 2e5;
ll N;
bool dp[MAX_N + 1][7];

string S, X;

int main(){
	cin >> N >> S >> X;
	dp[N][0] = true;
	for(ll i = N - 1; i >= 0; i--){
		REP(j, 7){
			if(X[i] == 'A'){
				dp[i][j] = !(!dp[i + 1][j * 10 % 7] || !dp[i + 1][(j * 10 + S[i] - '0') % 7]);
			}else{
				dp[i][j] = dp[i + 1][j * 10 % 7] || dp[i + 1][(j * 10 + S[i] - '0') % 7];
			}
		}
	}
	cout << (dp[0][0] ? "Takahashi" : "Aoki") << endl;

}


#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
typedef long long ll;
const int lim=130;
const int delta=(int)1e3;
ll n;
std::vector<int>op;
void get(ll x,ll y){
	if(!x){
		while(y&&op.size()<=lim){
			y--;
			op.push_back(2);
		}
		return;
	}
	if(!y){
		while(x&&op.size()<=lim){
			x--;
			op.push_back(1);
		}
		return;
	}
	if(x<y){
		get(x,y-x);
		op.push_back(4);
	}
	else{
		get(x-y,y);
		op.push_back(3);
	}
	return;
}
signed main(){
	scanf("%lld",&n);
	double wz=(sqrt(5.0)-1.0)/2.0*1.0*n;
	ll now=wz;
	for(ll i=std::max(now-delta,0ll);i<=now+delta;i++){
		get(n,i);
		if(op.size()>lim)op.clear();
		else{
			printf("%d\n",op.size());
			for(int j=0;j<(int)op.size();j++)printf("%d\n",op[j]);
			break;
		}
	}
	return 0;
}

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

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

	rep(i,20){
		rep(j,20){
			cout<<(char)('A'+(rand()%8));
		}
		cout<<"\n";
	}
}


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

#define ll long long
#define pii pair<int,int>
#define vi vector<int>

int main() {
    int h,w;
    cin>>h>>w;
    vector<string> grid(h);
    for(int i = 0 ; i  < h ; i++)
        cin>>grid[i];

    int ans = 0;
    for(int i = 0 ; i < h ; i++) {
        int count = 0;
        for(int j = 0 ; j < w ; j++) {
            while(j < w && grid[i][j] == '.') {
                count++;
                j++;
            }
            ans += (count >= 2 ? count-1 : 0);
            count = 0;
        }
    }
    for(int i = 0 ; i < w ; i++) {
        int count = 0;
        for(int j = 0 ; j < h ; j++) {
            while(j < h && grid[j][i] == '.') {
                count++;
                j++;
            }
            ans += (count >= 2 ? count-1 : 0);
            count = 0;
        }
    }

    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;//10の18乗

int main() {
    ll n,m;
    cin >> n >> m;
    Vl v(n),v2(m);
    rep(i,n) cin >> v[i];
    rep(i,m) cin >> v2[i];
    sort(all(v));
    sort(all(v2));
    ll fans=inf;
    ll now=0;
    for(int i=0;i<n-1;i+=2){
        now+=v[i+1]-v[i];
    }
    int whe=m-1;
    for(int i=n-1;i>=0;i-=2){
        while(v2[whe]>=v[i]&&whe>=0) whe--;
        ll x=inf,y=inf;
        if(whe!=-1) x=abs(v2[whe]-v[i]);
        y=abs(v2[whe+1]-v[i]);
        chmin(fans,now+min(x,y));
        if(i>0){
            now-=abs(v[i-2]-v[i-1]);
            now+=abs(v[i]-v[i-1]);
        }
        //cout << fans << endl;
    }
    cout << fans << endl;

}


#include <iostream>
using namespace std;

int main() {

	string S;
	cin>>S;

	int flag=0;
	int count1=0;
	for(int i=0;i<S.length();i++)
	{
		if(S[i] !='0')
		{
			flag=1;
			break;
		}

		if(flag ==0)
		{
			count1++;
		}
	}

	flag=0;
	int count2=0;
	for(int i=S.length()-1;i>=0;i--)
	{
		if(S[i] !='0')
		{
			flag=1;
			break;
		}

		if(flag ==0)
		{
			count2++;
		}
	}

	if(count2 >= count1)
	{
		for(int i=0;i<count2-count1;i++)
		{
			S = '0'+S;
		}

		int flag2 =0;
		for(int i=0;i<S.length()/2;i++)
		{
			if(S[i] != S[S.length()-1-i])
			{
				flag2=1;
			}
		}

		if(flag2 == 1)
		{
			cout<<"No"<<endl;
		}
		else
		{
			cout<<"Yes"<<endl;
		}

	}
	else
	{
		cout<<"No"<<endl;
	}

	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)
#define y1 awefakhlrv

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n; cin >> n;
    int ans = 0;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ll sz = n / i;
            if ((n * 2 / sz - sz + 1) % 2 == 0) {
                ll l = (n * 2 / sz - sz + 1) / 2;
                // cout << l << ' ' << l + sz - 1 << endl;
                ans += 2;
                // if ((n * 2 / sz - sz + 1) > 0) ans++;
            }
            if (n / i == i) break;
            sz = i;
            if ((n * 2 / sz - sz + 1) % 2 == 0) {
                ll l = (n * 2 / sz - sz + 1) / 2;
                // cout << l << ' ' << l + sz - 1 << ' ' << endl;
                ans += 2;
            }
        }
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 4e5 + 5;
ll n;
vector<ll> v[maxn];
ll idx = 0, mx = 0;
ll dep[maxn];
ll L, R;
ll dfn[maxn], sz[maxn], dfsc;
void dfs(ll now, ll fa){
	dfn[now] = ++dfsc;
	sz[now] = 1;
	for(int i = 0;i < v[now].size();i++){
		ll t = v[now][i];
		if(t == fa) continue;
		dep[t] = dep[now] + 1;
		dfs(t, now);
		sz[now] += sz[t];
	}
	if(dep[now] >= mx) idx = now;
	mx = max(mx, dep[now]);
	return ;
}
ll p[maxn], len, e[maxn];
ll anc[maxn][21];
void dfs1(ll now, ll fa, ll x){
	p[++len] = now;
	anc[now][0] = fa;
	for(int i = 1;(1 << i) <= dep[now];i++){
		anc[now][i] = anc[anc[now][i - 1]][i - 1];
	}
	for(int i = 0;i < v[now].size();i++){
		ll t = v[now][i];
		if(t == fa) continue;
		dep[t] = dep[now] + 1;
		if(dfn[x] >= dfn[t] && dfn[x] <= dfn[t] + sz[t] - 1) continue;
		dfs1(t, now, x);
	}
	for(int i = 0;i < v[now].size();i++){
		ll t = v[now][i];
		if(t == fa) continue;
		if(dfn[x] >= dfn[t] && dfn[x] <= dfn[t] + sz[t] - 1){
			dfs1(t, now, x);
		}
	}
	return ;
}
ll lca(ll u, ll v){
	if(dep[u] < dep[v]) swap(u, v);
	ll cnt = dep[u] - dep[v];
	for(int i = 20;i >= 0;i--){
		if((cnt >> i) & 1) u = anc[u][i];
	}
	if(u == v) return u;
	for(int i = 20;i >= 0;i--){
		if(anc[u][i] != anc[v][i]){
			u = anc[u][i], v = anc[v][i];
		}
	}
	return anc[u][0];
}
int main(){
	scanf("%lld", &n);
	for(int i = 1;i < n;i++){
		ll ux, vx;
		scanf("%lld %lld", &ux, &vx);
		v[ux].push_back(vx);
		v[vx].push_back(ux);
	}
	dfs(1, 0); L = idx;
	dfsc = 0;
	dfs(L, 0); R = idx;
	dfs1(L, 0, R);
	ll sum = 1;
	for(int i = 1;i <= n;i++){
		e[p[i]] = sum;
		sum += dep[p[i]] + dep[p[i + 1]] - 2 * dep[lca(p[i], p[i + 1])];
	}
	for(int i = 1;i <= n;i++){
//		cout << p[i] << " " << p[i + 1] << " ";
		printf("%lld ", e[i]);
//		puts("");
	}
	puts("");
	return 0;
}

#include <cstdio>
const int maxn=2e5+10;
struct E{
	int to;
	int next;
}ed[maxn*2];
int head[maxn];
int tot;
void J(int a,int b){
	ed[++tot].to=b;
	ed[tot].next=head[a];
	head[a]=tot;
}
int dep[maxn];
int s;
int t;
void Dfs1(int x,int fa){
	dep[x]=dep[fa]+1;
	if(!s||dep[x]>dep[s])
		s=x;
	for(int i=head[x];i;i=ed[i].next){
		if(ed[i].to==fa)
			continue;
		Dfs1(ed[i].to,x);
	}
}
int f[maxn];
void Dfs2(int x,int fa){
	dep[x]=dep[fa]+1;
	f[x]=fa;
	if(!t||dep[x]>dep[t])
		t=x;
	for(int i=head[x];i;i=ed[i].next){
		if(ed[i].to==fa)
			continue;
		Dfs2(ed[i].to,x);
	}
}
int now;
int bj[maxn];
int top;
int sta[maxn];
int e[maxn];
void Dfs3(int x,int fa){
	e[x]=now;
	for(int i=head[x];i;i=ed[i].next){
		if(ed[i].to==fa)
			continue;
		now++;
		Dfs3(ed[i].to,x);
		now++;
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		J(u,v);
		J(v,u);
	}
	Dfs1(1,0);
	Dfs2(s,0);
	int tmp=t;
	while(tmp){
		sta[++top]=tmp;
		bj[tmp]=1;
		tmp=f[tmp];
	}
	for(int i=1;i<=top;i++){
		e[sta[i]]=++now;
		for(int j=head[sta[i]];j;j=ed[j].next){
			if(!bj[ed[j].to]){
				now++;
				Dfs3(ed[j].to,sta[i]);
				now++;
			}
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d ",e[i]);
	return 0;
}


#include <bits/stdc++.h>
#include <stdio.h>
#define ll int64_t
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define rev(i, a, n) for (ll i = a; i >= n; i--)
#define sz size()
#define ff first
#define ss second
#define vec vector<ll>
#define vecpair vector<pair<ll, ll>>
#define pb push_back
#define po pop_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define fill(a, b) memset(a, b, sizeof(a))
#define debug(v) cout<<"DEBUG["; rep(i,0,v.sz) cout<<v[i]<<","; cout<<"]"<<endl;
#define mod 1000000007
#define endl '\n'
#define zero cout << "0" << endl
#define mone cout << "-1" << endl
#define p(x) cout << x << endl
#define onescount(x) __builtin_popcountll(x)
// (ll for long long) count the number of one’s(set bits) in an integer.
#define lzero(x) __builtin_clzll(x)
//count the leading zeros of the integer
#define tzero(x) __builtin_ctzll(x) :
//to count the trailing zeros of the given integer
#define ckparity(x) builtin_parityll(x)
// to check the parity of a number (eg: 7-> 111 ->> odd parity ->> return 1 else return 0)
const int N = 2e5 + 1;
using namespace std;
// ll h[N];
// if declaring variable in global space show ambigous than change the varibale name
// const ll inf = 1e18;

// ceil(a/b) = (a+b-1)/b
// floor(a/b) = (a/b)

/* ascii value
A=65,Z=90,a=97,z=122
*/
/*  -----------------------------------------------------------------------------------*/
// int to char --> suppose int x  char y=x+'0'
// char to int --> suppose char x  int y=x-'0'

// struct cmp {
//   bool operator() (const pair<ll, ll> &a, const pair<ll, ll> &b) const {
//     int lena = a.ss - a.ff + 1;
//     int lenb = b.ss - b.ff + 1;
//     if (lena == lenb) return a.ff < b.ff;
//     return lena > lenb;
//   }
// };

ll ceil(ll a, ll b) {
  ll res = (a + b - 1) / b;
  return res;
}
ll str_to_num(string s) {
  return stoi(s);
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
string num_to_str(ll num) {
  return to_string(num);
}

bool isPrime(int x) {
  if (x < 2) return false;
  for (int y = 2; y * y <= x; y++)
    if (x % y == 0)
      return false;
  return true;
}
double rnd(double var)
{
  // 37.66666 * 100 =3766.66
  // 3766.66 + .5 =3767.16    for rounding off value
  // then type cast to int so value is 3767
  // then divided by 100 so the value converted into 37.67
  double value = (int)(var * 100 + .5);
  return (double)value / 100;
}
bool check(string s) {
  string t = s;
  reverse(all(s));
  return t == s;
}

// / a & b & c & d = min(a, b, c, d)

ll fact[N + 1];
void factorial()
{
  fact[0] = 1;
  for (int i = 1; i <= N; i++)
  {
    fact[i] = (fact[i - 1] * i) % mod;
  }
}
/// code goes here
void build() {

}
void solve()
{
  ll n; cin >> n;
  vec cnt(200, 0);
  rep(i, 0, n) {
    ll x; cin >> x;
    cnt[x % 200]++;
  }
  ll ans = 0;
  rep(i, 0, 200) {
    ans += (cnt[i] * (cnt[i] - 1)) / 2;
  }
  cout << ans << endl;
}
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // prime();
  // factorial();
  // ll t;
  // cin >> t;
  // rep(i, 0, t)
  // {
  // cout << "Case #" << i + 1 << ": ";
  solve();
  // }
  return 0;
}

#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

constexpr int N = 200;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    array<int, N> modcount{};

    for (auto &&i : a) {
        modcount[i % N]++;
    }

    int ans = 0;

    for (auto &&i : modcount) {
        ans += i * (i - 1) / 2;
    }

    cout << ans << "\n";
}


/*
  Date: 10/10/20 8:00:51 PM
  Description:
*/
#include <bits/stdc++.h>

using namespace std;

char s, t;

int main() {
	scanf("%c\n%c", &s, &t);
	printf("%c\n", s == 'Y' ? toupper(t) : t);
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll MOD = 1000000007;
ll INF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

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

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

  char s, t;
  cin >> s >> t;
  if(s == 'N') cout << t << endl;
  else cout << (char)(t - 'a' + 'A') << endl;

  return 0;
}


#include"bits/stdc++.h"
using namespace std;
#define pb push_back
#define eb emplace_back
#define ins insert
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define pii pair<int,int>
#define fir first
#define sec second
#define popcount __builtin_popcount
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using ll=long long int;
using ld=long double;
#define mp make_pair
#define mt make_tuple
#define bit(x,j) (((ll)x>>j)&1)
#define um unordered_map
#define mem(a,val) memset(a,val,sizeof(a))
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x){cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(ld x){cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x){cerr<<'\"'<<x<<'\"';}
void __print(const string &x) {cerr<<'\"'<<x<<'\"';}
void __print(bool x){cerr<<(x?"true":"false");}
template<typename T, typename V>
void __print(const pair<T, V> &x){cerr<<'{'; __print(x.first);cerr<<','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{ return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{ return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#ifndef ONLINE_JUDGE
#define debugt(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debugt(...) 42
#endif
constexpr ll inf=2223372036854775807;
constexpr int mod2=(998244353);
constexpr int MAX=(1e4+3);
constexpr int N=2e5+5;
ll gcd(ll a, ll b)
{
    if (a < b)
        return gcd(b, a);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0){ x=1; y=0; return a; }
    ll d=extgcd(b,a%b,y,x);
    y-=a/b*x; return d;
}
ll modInv(ll a, ll p)
{
    if (gcd(a, p) != 1)
        return -1;

    ll x, y;
    extgcd(a, p, x, y);

    x %= p;
    if (x < 0)
        x += p;
    return x;
}
void solve()
{
 int n,s,k; cin>>n>>s>>k; int b=n-s,a=k,m=n;
 int d=__gcd(a,__gcd(b,m)); a/=d; b/=d; m/=d; int t1=__gcd(a,m);
 if(t1!=1){ cout<<-1<<"\n"; return; }
 cout<<(modInv(a,m)*b)%m<<"\n";
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1; int c=1; cin>>t;
  while(t--)
  {
    solve(); c++;
  }
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    int n;
    cin >> n;
    vs64 a(n);
    vs32 t(n);
    rep (i, n)
    {
        cin >> a[i] >> t[i];
    }

    s64 minf = -1e18;
    s64 Minf = 1e18;
    s64 l = minf, r = Minf;
    s64 add = 0;
    for (int i = n - 1; i >= 0; --i)
    {
        if (t[i] == 1)
        {
            add += a[i];
            if (l != minf) l -= a[i];
            if (r != Minf) r -= a[i];
        }
        else if (t[i] == 2)
        {
            l = max(l, a[i]);
            if (r < l) l = r;
        }
        else
        {
            r = min(r, a[i]);
            if (r < l) r = l;
        }
    }

    int q;
    cin >> q;
    while (q--)
    {
        s64 x;
        cin >> x;
        if (x < l) cout << l + add << "\n";
        else if (x > r) cout << r + add << "\n";
        else cout << x + add << "\n";
    }

    return 0;
}


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

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

using namespace std;

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

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

int N, D, H;

void MAIN() {
    scanf("%d%d%d", &N, &D, &H);

    double ans = 0;
    REP (i, N) {
	int d, h;
	scanf("%d%d", &d, &h);

	double a = (double)(H-h) / (double)(D-d);
	double b = H - a * D;
	amax(ans, b);
    }
    printf("%.20f\n", ans);
}

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

#include <bits/stdc++.h>

using namespace std;

int main()
{

    int h, w, i, t, m = 101, e = 0 ;
    vector<int> v;
    cin >> h >> w ;
    for (i = 0; i < h*w; ++i) {
        cin >> t;
        v.push_back(t);
        m = min(m, t);
    }
    for (i = 0; i < h*w; ++i)
        e += v[i] > m ? v[i]-m : 0;

    cout << e << endl;

}


#pragma region template
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
// using cpp_int = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
template <typename T>
constexpr T local([[maybe_unused]] const T &lcl, [[maybe_unused]] const T &oj) {
#ifdef OJ_LOCAL
  return lcl;
#else
  return oj;
#endif
}
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
T max(const vector<T> &x) {
  return *max_element(ALL(x));
}
template <typename T>
T min(const vector<T> &x) {
  return *min_element(ALL(x));
}
template <typename T>
pair<T, int> argmax(const vector<T> &x) {
  int idx = 0;
  T m = x[0];
  repr(i, 1, SZ(x)) {
    if (chmax(m, x[i])) idx = i;
  }
  return {m, idx};
}
template <typename T>
pair<T, int> argmin(const vector<T> &x) {
  int idx = 0;
  T m = x[0];
  repr(i, 1, SZ(x)) {
    if (chmin(m, x[i])) idx = i;
  }
  return {m, idx};
}
template <typename T>
T sum(const vector<T> &x) {
  return accumulate(ALL(x), T(0));
}
// last param -> T
template <typename T>
vector<T> makev(size_t a, T b) {
  return vector<T>(a, b);
}
template <typename... Args>
auto makev(size_t sz, Args... args) {
  return vector<decltype(makev(args...))>(sz, makev(args...));
}

template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) cout << " ";
    }
    if (&v != &vv.back()) cout << "\n";
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) cout << (f ? " " : "\n");
  print(forward<Tail>(tail)...);
}
#pragma endregion

//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/

#define PR(f)                                                                  \
  do {                                                                         \
    cout << ((f) ? "Yes" : "No") << "\n";                                      \
    return;                                                                    \
  } while (0)

void solve() {
  ll n;
  cin >> n;
  vll x(n), y(n);
  rep(i, n){
    cin >> x[i] >> y[i];
  }
  bool f = 0;
  rep(i, n)repr(j, i+1, n)repr(k, j+1, n){
    ll a = x[i]-x[j];
    ll b = y[i]-y[j];
    ll c = x[i]-x[k];
    ll d = y[i]-y[k];
    f |= (a*d==b*c);
  }
  PR(f);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  //*
  solve();
  /*/
  ll _cases;
  cin >> _cases;
  while (_cases--) solve();
  //*/
}

#include <bits/stdc++.h>
int N;
int gcd(int x, int y){
    y = abs(y);
    while (y){
        x %= y;
        std::swap(x, y);
    }
    return x;
}
bool line(int dx1, int dy1, int dx2, int dy2){
    if (dx1 == 0)
        return dx2 == 0;
    else if (dy1 == 0)
        return dy2 == 0;
    else if (dx2 == 0 or dy2 == 0)
        return false;
    else {
        int gcd1 = gcd(dx1, dy1);
        dx1 /= gcd1;
        dy1 /= gcd1;
        int gcd2 = gcd(dx2, dy2);
        dx2 /= gcd2;
        dy2 /= gcd2;
        return dx1 == dx2 and dy1 == dy2;
    }
}
int main(){
    std::cin >> N;
    std::vector<std::pair<int, int>> pos;
    for (int i = 0; i < N; ++i){
        int x, y;
        std::cin >> x >> y;
        pos.push_back(std::make_pair(x, y));
    }
    std::sort(pos.begin(), pos.end());
    // for (int i = 0; i < N; ++i){
    //     std::cout << pos[i].first << pos[i].second << std::endl;
    // }
    for (int i = 0; i < N - 2; ++i){
        int x1 = pos[i].first;
        int y1 = pos[i].second;
        for (int j = i + 1; j < N - 1; ++j){
            int x2 = pos[j].first;
            int y2 = pos[j].second;
            int dx1 = x2 - x1, dy1 = y2 - y1;
            for (int k = j + 1; k < N; ++k){
                int x3 = pos[k].first;
                int y3 = pos[k].second;
                int dx2 = x3 - x2, dy2 = y3 - y2;
                if (line(dx1, dy1, dx2, dy2)){
                    std::cout << "Yes";
                    return 0;
                }
            }
        }
    }
    std::cout << "No";
    return 0;
}


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

#define sp(y) fixed<<setprecision(y)
#define w(t) int t;cin>>t;while(t--)
#define pi 2*acos(0.0)
#define bg begin()
#define en end()
#define all(x) x.begin(),x.end()
#define sortarr(x) sort(x,x+arrsize(x))
#define arrsize(x) sizeof(x)/sizeof(x[0])
#define sortall(x) sort(all(x))
#define formn(m,n) for(m;m<=n;m++)
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define REP(i,a,b) for (int i=a;i<=b;i++)
#define sq(a) (a)*(a)
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
//solution
#define mx 1000005
#define m7 1000000007
int prime[mx];

void seive(){
    prime[0]=1;
    prime[1]=1;
    for(ll i=2;i<mx;i++){
        if(prime[i]==0){
            for(ll j=i*i;j<mx;j+=i){
                prime[j]=1;
            }
        }

    }
}

int solve(){
   string str;
   cin>>str;
   int len= str.size();
   reverse(all(str));

   REP(i,0,len-1){
       if(str[i]=='6'){
          str[i]='9';
       }else if(str[i]=='9'){
          str[i]='6';
       }

   }
   cout<<str;

return 0;
}
//end solution
int main(){
solve();
}

#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

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

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

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

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

    int n;
    cin >> n;

    vector<int> t(n);
    int m = 0;
    rep(i, n){
        cin >> t[i];
        m += t[i];
    }

    vector< vector<int> > dp(n + 1, vector<int>(m + 1, 0));
    dp[0][0] = 1;

    rep(i, n){
        rep(j, m + 1){
            dp[i + 1][j] |= dp[i][j];
            if(j + t[i] <= m){
                dp[i + 1][j + t[i]] |= dp[i][j];
            }
        }
    }

    int ans = IINF;
    rep(j, m + 1){
        if(dp[n][j]){
            chmin(ans, max(j, m - j));
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}


#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 998244353
using namespace std;
using ll = long long;

template<class T>
vector<pair<T, T>> PrimeFactorization(T n) {
    vector<pair<T, T>> f;
    for (T i = 2; i * i <= n; i++) {
        T cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) f.push_back(make_pair(i, cnt));
    }
    if (n != 1) f.push_back(make_pair(n, 1));
    return f;
}

class Combination {
   public:
    Combination(int n) {
        fac = new ll[n];
        inv = new ll[n];
        finv = new ll[n];
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        REP(i, 2, n) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    ll cnr(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;
    }

   private:
    ll *fac, *inv, *finv;
};

Combination comb(1e6);

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

    ll ans = 1;
    REP(i, 2, M + 1) {
        auto factors = PrimeFactorization(i);

        ll cur = 1;
        for (auto f : factors) {
            cur *= comb.cnr(N - 1 + f.second, N - 1);
            cur %= MOD;
        }
        ans += cur;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long int ;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
long double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
ll dx[4] {1,0,-1,0} ;
ll dy[4] {0,1,0,-1} ;

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

   ll n , m ; cin>>n>>m ;
   vector<string> A(n) ;
   rep(i,n) cin>>A[i] ;
   vector<ll> cnt(n) ;
   rep(i,n){
       ll k= A[i].size() ;
       rep(j,k){
           if(A[i][j]=='1') cnt[i]++ ;
       }
   }
   ll now=0 ;
   rep(i,n){
       if(cnt[i]%2==0) now++ ;
   }
   cout<<now*(n-now)<<endl ;
  return 0 ;
}


#include <bits/stdc++.h>
#define SZ(v) ((int)(v).size())
using namespace std;

using ll = long long;

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

template<typename... Args>
void write(Args... args)
{
	((cout << args << " "), ...);
}

template<typename... Args>
void writeln(Args... args)
{
	((cout << args << " "), ...); cout << '\n';
}

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

	vector<vector<int>> masks;
	int N;
	read(N);
	int nbJoueurs = 1 << N;
	int rep = nbJoueurs-1;
	writeln(rep);
	for (int i(0); i < rep; ++i)
	{
		for (int j(0); j < nbJoueurs; ++j)
			cout << (__builtin_popcount( i | j) % 2 ? 'B' : 'A');
		writeln();
	}
}

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

string revAB(string str) {
    for(int i=0;i<str.size();++i) str[i]=(str[i]=='A'?'B':'A');
    return str;
}

int main() {
    int N,M; cin >> N; M = (1<<N);
    vector<vector<string>> S(N+1);
    S[1] = {"AB"};
    for(int i=2;i<=N;++i) {
        int L = (1<<i);
        S[i].push_back(string(L/2,'A')+string(L/2,'B'));
        for(int j=0;j<S[i-1].size(); ++j) {
            S[i].push_back(S[i-1][j]+S[i-1][j]);
        }
        for(int j=0;j<S[i-1].size(); ++j) {
            S[i].push_back(S[i-1][j]+revAB(S[i-1][j]));
        }
    }
    cout << S[N].size() << "\n";
    for(auto& s:S[N]) {
        cout << s << "\n";
    }
    return 0;
}


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

using namespace std;

using ll = long long;

const ll M = 998244353;
ll dp[5001][5001];
char G[5001][5001];
ll H, W, K;

bool bc(ll i, ll j)
{
    return 0 <= i && i < H && 0 <= j && j < W;
}

ll modpow(ll b, ll e, ll m)
{
    ll ret = 1;
    while (e > 0)
    {
       if ((e & 1) == 1)
       {
           ret = (ret * b) % m;
       }
       e >>= 1;
       b = (b * b) % m;
    }
    return ret;
}

int main()
{
    cin >> H >> W >> K;
    for(ll i = 0;i < K;i++)
    {
        ll h, w;
        char c;
        cin >> h >> w >> c;
        G[h-1][w-1] = c;
    }
    dp[0][0] = modpow(3, H*W-K, M);
    ll inv3 = modpow(3, M-2, M);
    for(ll i = 0;i < H;i++)
    {
        for(ll j = 0;j < W;j++)
        {
            ll inc = 0;
            if(bc(i-1, j))
            {
                if(G[i-1][j] == 'D' || G[i-1][j] == 'X')
                {
                    inc += dp[i-1][j];
                }
                else if(G[i-1][j] == 0)
                {
                    inc += 2LL * inv3 * dp[i-1][j];
                }
            }
            inc %= M;
            if(bc(i, j-1))
            {
                if(G[i][j-1] == 'R' || G[i][j-1] == 'X')
                {
                    inc += dp[i][j-1];
                }
                else if(G[i][j-1] == 0)
                {
                    inc += 2LL * inv3 * dp[i][j-1];
                }
            }
            dp[i][j] += inc;
            dp[i][j] %= M;
        }
    }
    cout << dp[H-1][W-1] << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
using P=pair<ll,ll>;
using mat=vector<vector<ll>>;
ll modpow(ll a,ll n){
ll res=1;
  while(0<n){
  if(n&1)res=(res*a)%mod;
    a=(a*a)%mod;n>>=1;
  }return res;
}
mat mul(const mat &A,const mat &B){
ll H=A.size();ll W=B[0].size();
  mat C(H,vector<ll>(W,0));
  for(ll i=0;i<H;i++)
    for(ll j=0;j<W;j++){
    ll sum=0;
      for(ll k=0;k<B.size();k++)sum=(sum+A[i][k]*B[k][j])%mod;
      C[i][j]=sum;
    }return C;
}
mat matpow(mat A,ll n){
ll H=A.size();
  mat res(H,vector<ll>(H,0));
  for(ll i=0;i<H;i++)res[i][i]=1;
  while(0<n){
  if(n&1)res=mul(res,A);
    A=mul(A,A);n>>=1;
  }return res;
}
ll N,M,K;
int main(){
  cin>>N>>M>>K;vector<ll>a(N);
  for(ll i=0;i<N;i++)cin>>a[i];
  mat A(N,vector<ll>(N,0));
  for(ll i=0;i<N;i++)A[i][i]=1;
  for(ll i=0;i<M;i++){
  ll x,y;cin>>x>>y;x--;y--;
    A[x][y]=(A[x][y]+modpow(2*M,mod-2))%mod;
    A[y][x]=(A[y][x]+modpow(2*M,mod-2))%mod;
    A[x][x]=(A[x][x]+mod-modpow(2*M,mod-2))%mod;
    A[y][y]=(A[y][y]+mod-modpow(2*M,mod-2))%mod;
  }mat C=matpow(A,K);vector<ll>ans(N);
  for(ll i=0;i<N;i++){
  for(ll j=0;j<N;j++)ans[i]=(ans[i]+C[i][j]*a[j])%mod;
  }for(ll i=0;i<N;i++)cout<<ans[i]<<endl;

 return 0;
}


#include <bits/stdc++.h>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define fore(x,a) for(auto&(x) : (a))

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; }

#define ALL(a) (a).begin(), (a).end()

const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;

int main(){
  double N;
  cin >> N;
  N *= 1.08;
  int n = N;
  if(n < 206) {
    cout << "Yay!" << endl;
  }
  else if(n == 206) {
    cout << "so-so" << endl;
  }
  else cout << ":(" << endl;
}

#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

void solve() {
    int n; cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    vector<int> ans, used(n + 1);
    for (int i = 1; i < n; i++) {
        int pos = i;
        while (a[pos] != i) pos++;
        if (pos == i) {
            if (!used[pos]) {
                cout << -1 << "\n";
                return;
            }
            continue;
        }
        while (pos > i) {
            pos--;
            if (used[pos]) {
				cout << -1 << "\n";
                return;
			}
			used[pos] = 1;
			ans.push_back(pos);
			swap(a[pos], a[pos + 1]);
        }
    }
    if (ans.size() != n - 1) {
        cout << -1 << "\n";
        return;
    }
    for (int x : ans) cout << x << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tc = 1;
    // cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ii=pair<int, int>;
#define vi vector<int>
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define f first
#define s second
const ll mod=998244353;
const int inf=1e9;
const int N=2e5+10;
vector<int> g[N];
bool vis[N];

ll pow_fast (ll a,ll b){
  ll ans = 1, x = a;
  while (b!=0){
    if (b&1) ans = ((ans % mod) * x) % mod;
    x = ((x % mod) * x) % mod;
    b>>= 1;
  }
  return ans % mod;
}

void dfs(int u){
    vis[u]=true;
    for(auto v:g[u]){
        if(!vis[v]) dfs(v);
    }
}

int main(){
    fast
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        g[i].push_back(x);
        g[x].push_back(i);
    }
    ll cnt=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            dfs(i);
            cnt++;
        }
    }
    cout<<pow_fast(2,cnt)-1<<'\n';
    return 0;
}

#include <bits/stdc++.h>

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

	int N; cin >> N;
	vector<int> F(N); for (auto& f : F) { cin >> f; f--; }

	vector<int> par(N, -1);
	auto get_par = [&](int a) -> int {
		while (par[a] >= 0) {
			if (par[par[a]] >= 0) par[a] = par[par[a]];
			a = par[a];
		}
		return a;
	};
	auto merge = [&](int a, int b) -> bool {
		a = get_par(a), b = get_par(b);
		if (a == b) return false;
		if (par[a] > par[b]) swap(a, b);
		par[a] += par[b];
		par[b] = a;
		return true;
	};

	int num_CC = N;
	for (int i = 0; i < N; i++) {
		num_CC -= merge(i, F[i]);
	}

	const int MOD = 998244353;
	int ans = 1;
	for (int i = 0; i < num_CC; i++) {
		ans = ans * 2 % MOD;
	}
	ans--;
	cout << ans << '\n';

	return 0;
}

// Permutation iff composed of cycles
// There's 1 cycle per connected component of the functional graph
// We just need 2^(# ccs) - 1


#include<bits/stdc++.h>
#define pb push_back
#define endl ("\n")
#define mp make_pair
#define lb lower_bound
#define ff first
#define inf 1e18
#define ss second
#define cn continue
#define br break
#define ins insert
#define int long long
#define bit(x) __builtin_popcount(x)
#define all(x) x.begin(),x.end()
#define up upper_bound
#define read(a,n) rep(i,0,n){cin>>a[i];}
#define print(a,n) rep(i,0,n) cout<<a[i]<<" ";
#define yy cout<<"Yes"<<endl;
#define nn cout<<"No"<<endl;
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
using namespace std;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T = clock();
    int t = 1 ;
    //cin >> t ;
    while (t--)
    {
        int n, a, b, c;
        cin >> c;
        a = (1.08) * c;
        n = 206;
        if (a < n)
        {
            cout << "Yay!";
        }
        else if (a == n)
        {
            cout << "so-so";
        }
        else
        {
            cout << ":(";
        }

    }
    cerr << "\nTIME: " << (long double)(clock() - T) / CLOCKS_PER_SEC << " sec\n";
    T = clock();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m=0;
  cin >> n;
  vector<long long> A,M;
  for(int i=0;i<n;i++){
    long long a;
    cin>>a;
    A.push_back(a);
    m=max(m,a);
    M.push_back(m);
  }
  vector<long long>B,C;
  B.push_back(A[0]);
  C.push_back(B[0]);
  for(int i=1;i<n;i++){
    B.push_back(B[i-1]+A[i]);
    C.push_back(C[i-1]+B[i]);
  }

  for(int k=0; k<n; k++)
    cout << C[k]+M[k]*(k+1LL) << "\n";
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
        sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
        {
sim > struct rge
{
        c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
        ~debug()
        {
                cerr << endl;
        }
        eni(!=) cerr << boolalpha << i;
        ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
        ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
                *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
}
#else
        sim dor(const c &)
        {
                ris;
        }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define pb(n) push_back(n)
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        ld sx, sy, dx, dy; cin >> sx >> sy >> dx >> dy;
        ld d = dx - sx;
        cout << fixed << setprecision(6) << sx + sy * (d / (sy + dy));
}

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

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{

        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        cout<<setprecision(9);
        cout<<fixed;
        if(x1==x2)
        {
            cout<<x1<<endl;
            return 0;
        }
        y1=-y1;
        double m=1.0 *(y2-y1)/(x2-x1);
        double x=(m*x1-y1)/m;
        cout<<x<<endl;

    return 0;
}


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

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

#define MOD 10e9+7

using namespace std;
int main(){
int N,K;
cin >>N>>K;
int i,j;
ll ans=0;
for(i=1;i<=N;i++){
  for(j=1;j<=K;j++){
    ans += i*100+j;
  }
}
cout <<ans;
return 0;
}

#include <bits/stdc++.h>
using namespace std;
// 型
#define ll int64_t                  // ll -> int64_t
using graph = vector<vector<int>>;  // グラフ型
// for文
#define lp(i,n) for(int i=0;i<n;i++)      // 変数 i をおいて n 回繰り返し
#define lp_(i,n) for(int i=0;i<=n;i++)    // 条件に＝つき
#define lpp(i,n,m) for(int i=n;i<m;i++)   // 開始と終了を指定して繰り返し
#define lpp_(i,n,m) for(int i=n;i<=m;i++) // 開始と終了を指定，条件に＝つき
// vector定義
#define _GLIBCXX_DEBUG
#define vec(v,n) vector<int> v(n)       // int
#define vec_(v,n,m) vector<int> v(n,m)  // int 初期条件あり
#define vec64(v,n) vector<ll> v(n)      // int64_t
#define vec64_(v,n,m) vector<ll> v(n,m) // int64_t 初期条件あり
#define vecc(v,n) vector<char> v(n)     // char
#define vecs(v,n) vector<string> v(n)   // string
#define vece(v) vector<int> v;          // int 空
#define vecec(v) vector<char> v;        // char 空
#define vec2i(v,h,w) vector<vector<int>> v(h,vector<int>(w))    // 二次元配列 int
#define vec2c(v,h,w) vector<vector<char>> v(h,vector<char>(w))  // 二次元配列 char
// vector,string操作
#define vin(v) \
{\
  lp(i,v.size())\
    cin>>v[i];\
}                              // 入力
#define all(v) v.begin(),v.end()
#define back(v) v.back()                         // 最後の要素
#define sum(v) accumulate(all(v),0)              // 総和
#define sort(v) sort(all(v))                     // ソート
#define reverse(v) reverse(all(v))               // 反転
#define lower(v,x) lower_bound(all(v),x)-v       // x<=a[i]となる最小のi / a[i]<xとなるiの個数
#define cou(v,n) count(all(v),n)               // n の出現回数を数える
#define pb(v,n) v.push_back(n)                   // 最後尾に n を追加
#define ins(v,i,n) v.insert(v.begin()+i,n)       // 場所を指定してv[i]に n を追加
#define del(v) v.pop_back()                      // 最後尾を削除
#define del0(v) v.erase(v.begin())               // 最初の要素v[0]を削除
#define del_(v,i) v.erase(v.begin()+i)           // 場所を指定してv[i]を削除
#define del__(v,i,j) v.erase(v.begin()+i,v.begin()+j+1)  // 範囲を指定してv[i]~v[j]を削除
#define sub(s,i,j) s.substr(i,j-i+1)             // 範囲を指定してs[i]~s[j]を取得【stringのみ】
// others
const ll MOD=1000000007;
const ll INF=(1LL<<60);
#define under(n) cout<<fixed<<setprecision(n) // 小数点以下の桁数を指定
#define cout(n) cout<<n<<endl
#define mypair pair<ll,ll>

int main()
{
  ll n,k,ans=0;
  cin>>n>>k;
  ans+=(k*(k+1)/2)*n;
  ans+=100*(n*(n+1)/2)*k;
  cout(ans);
}


#include <bits/stdc++.h>
#define ll long long
#define B break
#define C continue
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define gc getchar
#define pc putchar
#define kg putchar(' ')
#define hh putchar('\n')
#define mem(a,b) memset(a,b,sizeof(a))
#define _for(i,a,b) for( int i=(a); i<=(b); i++)
#define _rep(i,a,b) for( int i=(a); i>=(b); i--)
//#define int __int128
#define int long long
using namespace std;
inline int rd(){
    int x=0,f=1;char ch=gc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
    return x*f;
}
char chhh[200];
inline void rt(int x){
    int cnt=0,tmp=x>0?x:-x;
    if (!x) {pc('0');return;}
    if(x<0) pc('-');
    while(tmp>0) {chhh[cnt++]=tmp%10+'0';tmp/=10;}
    while(cnt>0) pc(chhh[--cnt]);
}
int a[110]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,0,0},b[110];
int ans=0,n;
void dfs(int k,int x){
	if(!a[k]){
		int i;
		for(i=1;i<=n;i++){
			if(__gcd(x,b[i])==1) break;
		}
		if(i==n+1){
			if(!ans){
				ans=x;
			}
			else{
				ans=min(ans,x);
			}
		}
	}
	else{
		dfs(k+1,x);
		dfs(k+1,x*a[k]);
	}
}
signed main(){
//int main(){
	//int t;
	//t=rd();
	//while(t--){n=rd();
	n=rd();
	_for(i,1,n){
		b[i]=rd();
	}
	dfs(1,1);
	rt(ans);

	//}

    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;

int main() {
	long long N; cin >> N;
	long long X[60]; for (int i = 0; i < N; i++) cin >> X[i];

	long long prime[30];
	prime[0] = 2;
	prime[1] = 3;
	prime[2] = 5;
	prime[3] = 7;
	prime[4] = 11;
	prime[5] = 13;
	prime[6] = 17;
	prime[7] = 19;
	prime[8] = 23;
	prime[9] = 29;
	prime[10] = 31;
	prime[11] = 37;
	prime[12] = 41;
	prime[13] = 43;
	prime[14] = 47;

	int n = 15;
	long long min_ = 1LL << 60;

	for (int bit = 0; bit < (1 << n); ++bit) {
		vector<int> S;
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) { // 列挙に i が含まれるか
				S.push_back(i);
			}
		}
		bool flag[60];
		for (int i = 0; i < N; i++) flag[i] = false;
		long long count = 1;
		for (int i = 0; i < (int)S.size(); ++i) {
			count *= prime[S[i]];
			for (int j = 0; j < N; j++) {
				if (X[j] % prime[S[i]] == 0) flag[j] = true;
			}
		}
		bool flag_ = true;
		for (int i = 0; i < N; i++) if (flag[i] == false) flag_ = false;
		if (flag_) min_ = min(count, min_);
	}
	cout << min_ << endl;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ULL;
#define ff first
#define ss second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define FOR(i,n) for(int i=0;i<(n);++i)
#define pii pair<int,int>
#define vi vector<int>
#define pq priority_queue
#define mii map<int,int>
#define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int oo = 2000000000; // 2e9
using namespace std;

ll score(string s){
	vector<ll> cnt(10);
	iota(ALL(cnt), 0); //0,1,2,3,4,5,6.....9

	//compute sum
	for(auto c : s) cnt[c-'0'] *= 10; // x * 10 * 10.......

	return accumulate(ALL(cnt), 0);
}
int main() {
	IOS;int k; cin>>k;
	string s, t; cin>>s>>t;
	vector<ll> cnt(10, k); //1~9 (size), k cards for every digit. (cnt)
	for(auto c : s+t){ //a way to write for all s and t.
		cnt[c-'0']--; //already flipped.
	}
	//go through all combinations
	ll win = 0;
	for(int i = 1; i<=9; i++) for(int j = 1; j<=9; j++){
		s.back() = '0' + i;
		t.back() = '0' + j;
		if(score(s) > score(t)){
			win += cnt[i] * (cnt[j] - (i == j));
		}
	}

	ll rem_cards = 9 * k - 8;
	//Probability = win / [all combinations -> (9 * k - 8)*(9*k-8-1)]
	cout<<(double)win/(rem_cards*(rem_cards - 1))<<'\n';

}

// https://atcoder.jp/contests/abc183/tasks/abc183_f

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

//------------------------------------------------------------------------------
class UnionFindTree {
public:
  int n;
  vector<int> par;
  vector<int> rnk;
  vector<map<int, int>> mp;

  void init(int _n, vector<int> &c) {
    n = _n;
    par = vector<int>(n);
    rnk = vector<int>(n, 0);
    mp = vector<map<int, int>>(n);
    REP(i, n) {
      par[i] = i;
      mp[i][c[i]] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

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

    if (rnk[x] < rnk[y]) {
      par[x] = y;
      if (mp[y].size() < mp[x].size()) swap(mp[y], mp[x]);
      ITR(mp[x], it) mp[y][it->first] += it->second;
      mp[x].clear();
    } else {
      par[y] = x;
      if (mp[x].size() < mp[y].size()) swap(mp[x], mp[y]);
      ITR(mp[y], it) mp[x][it->first] += it->second;
      mp[y].clear();
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
  }

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

  int cnt(int x, int c) {
    x = find(x);
    return mp[x][c];
  }
};

//------------------------------------------------------------------------------
const int N_MAX = 2*1e5;
const int Q_MAX = 2*1e5;

int N, Q;
vector<int> C;

UnionFindTree uf;

int main() {
  cin >> N >> Q;
  C = vector<int>(N);
  REP(i, N) cin >> C[i];

  uf.init(N, C);
  REP(i, Q) {
    int q, a, b;
    cin >> q >> a >> b;
    if (q == 1) uf.unite(a - 1, b - 1);
    if (q == 2) cout << uf.cnt(a - 1, b) << endl;
  }
}


#include <bits/stdc++.h>

using namespace std;

#define int unsigned long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef map<int, int> mi;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef set<int> si;

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

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

signed main() {
    #ifndef ONLINE_JUDGE
        freopen("inputf.txt", "r", stdin);
        freopen("outputf.txt", "w", stdout);
    #endif

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

    int n;
    cin >> n;

    int sum=0;
    while(n--) {
        int x;
        cin >> x;

        if(x>10) {
            x -= 10;
            sum += x;
        }
    }

    cout << sum;

    return 0;
}

#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define RREP(i,n) for(ll i=1;i<ll(n+1);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define JU_5 101010
#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define Fir first
#define Sec second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>  // Graph
#define VPII vector<pair<int,int>>
#define VPLL vector<pair<ll, ll>>

#define DDD fixed<<setprecision(17)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/

/*.....................DEFINE FUNCTIONS ......................*/
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; }

/*.........................memo0

...........................*/

/*.........................memo1

...........................*/

/*.........................memo2

...........................*/
signed main() {
    __MAGIC__
    ll N;
    cin >> N;
    ll A[JU_5];
    REP(i, N) cin >> A[i];
    ll res = 0;
    REP(i, N) {
        ll tmp = A[i];
        if(tmp <= 10) continue;
        res += tmp - 10;
    }
    cout << res << endl;
    return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin>>T;
	while(T--) {
		int l,r;
		cin>>l>>r;
		if(2*l>r) {
			cout<<"0\n";
			continue;
		}
		cout<<(r-2*l+1)*(r-2*l+2)/2<<"\n";
	}
}

#include <iostream>
#include <algorithm>
int n, a[1000], b[1000];
int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> a[i] >> b[i];
  int ans = 1001001001;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) {
        ans = std::min(ans, a[i] + b[j]);
      } else {
        ans = std::min(ans, std::max(a[i], b[j]));
      }
    }
  }
  std::cout << ans << '\n';
}


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

#define mp             make_pair
#define pb             push_back
#define int 	       long long
#define rep(i,a,b)     for(int i=a;i<b;i++)
#define Rep(i,a,b)     for(int i=a;i<=b;i++)
#define rept(it,v)     for(auto it=v.begin();it!=v.end();it++)
#define all(x)         (x).begin(),(x).end()
#define pii            pair<int,int>
#define mii            map<int,int>
#define vi             vector <int>
#define vpi            vector <pair<int,int>>
#define F              first
#define S              second
#define fill(a,b)      memset(a,b,sizeof(a))
const int mod = 1e9 + 7;

int binpow(int a, int b, int m) {
	int res = 1;
	while (b > 0) {
		if (b % 2)
			res = ((res % m) * (a % m)) % m;
		a = ((a % m) * (a % m)) % m;
		b /= 2;
	}
	return res;
}

const int N = 1e5 + 5;

void solve() {
	int n, max_value = 0, sum = 0;
	double sum2 = 0;
	cin >> n;
	vi v(n);
	rep(i, 0, n) {
		cin >> v[i];
		if (v[i] < 0)
			v[i] *= -1;
	}

	rep(i, 0, n) {
		sum += v[i];
		if (max_value < v[i])
			max_value = v[i];

		sum2 += pow(v[i], 2);
	}

	cout << sum << endl;
	cout << setprecision(20) << sqrt(sum2) << endl;
	cout << max_value;
}

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

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

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

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define f first
#define s second

const int maxn = 100010;
int x[maxn];

int32_t main() {
	int n; cin >> n;
	for (int i =0;i<n;i++) cin >> x[i];

	int manh = 0;
	for (int i =0;i<n;i++) manh += abs(x[i]);

	long double eucli = 0;
	for (int i =0;i<n;i++) eucli += abs(x[i]) * abs(x[i]);
	eucli = sqrt((double) eucli);

	int cheb = 0;
	for (int i =0;i<n;i++) cheb = max(cheb, abs(x[i]));

	cout << setprecision(10) << manh << "\n" << eucli << "\n" << cheb;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vp;
typedef set<ll> si;
typedef map<string, ll> msi;
#define REP(i,a,b) \
for(ll i=ll(a);i<=ll(b);i++)
#define DEP(i,a,b) \
for(ll i=ll(a);i>=ll(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
ll mod = 1e9+7;
void dtob(vector<ll> &bin,ll n){
  ll k=bin.size();
  REP(i,0,k-1){
    ll t=pow(2,i);
    t=t&n;
    if(t)bin[i]=1;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int T;
  T=1;
  while(T--)
  {
      ll n,i,j,k,l,m;
      cin>>n>>m;
      vector<pair<ll,ll> > v,b;
      REP(i,0,m-1){
        cin>>j>>k;
        v.push_back(make_pair(j,k));
      }
      cin>>k;

      REP(i,0,k-1){
        cin>>j>>l;
        b.push_back(make_pair(j,l));
      }
      ll ans=0;
      REP(i,0,pow(2,k)-1){
        vector<ll> bin(k,0);
        dtob(bin,i);
        ll a[101]={0};
        REP(j,0,k-1){
          if(bin[j])a[b[j].S]++;
          else a[b[j].F]++;
        }
        ll temp=0;
        REP(j,0,m-1){
          if(a[v[j].F]>=1&&a[v[j].S]>=1)temp++;
        }
        ans=max(ans,temp);
      }
      cout<<ans;
  }
  return 0;
}

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const ld EPS = 1e-9;
const int MOD = 1;

inline int fcmp (ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

inline int mod (ll x, int m = MOD) {
	int ret = (int)x%m;
	if (ret < 0)
		ret += m;
	return ret;
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

int main () {
	// freopen("FILE_NAME_INPUT.EXTENSION", "r", stdin);
	// freopen("FILE_NAME_OUTPUT.EXTENSION", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n, m;
	cin >> n >> m;
	vpii conditions(m);
	for (auto &[x, y] : conditions)
		cin >> x >> y;

	int k;
	cin >> k;
	vpii people(k);
	for (auto &[x, y] : people)
		cin >> x >> y;

	int ans = 0;
	vi dishs(n+1);
	for (int msk = 0; msk < (1<<k); msk++) {
		dishs.assign(n+1, 0);
		for (int i = 0; i < k; i++)
			if (msk&(1<<i))
				dishs[people[i].x]++;
			else
				dishs[people[i].y]++;
		int now = 0;
		for (auto [x, y] : conditions)
			now += (dishs[x] and dishs[y]);
		ans = max(ans, now);
	}
	cout << ans << '\n';

	return 0;
}


//#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9+7; //998244353;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = atcoder::modint1000000007;

double dp[102][102][102];

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int  a, b, c;
	cin >> a >>b >>c;

	double ans = 0;

	dp[a][b][c] = 1;

	rep2(i, a, 101) rep2(j, b, 101) rep2(k, c, 101){

		if(i==100 || j==100 || k==100){
			ans += dp[i][j][k] * ((i+j+k)-(a+b+c));
			continue;
		}

		dp[i+1][j][k] += dp[i][j][k] *  i/(i+j+k);
		dp[i][j+1][k] += dp[i][j][k] *  j/(i+j+k);
		dp[i][j][k+1] += dp[i][j][k] *  k/(i+j+k);

	}

	printf("%.16f\n", ans);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 998244353;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	cout << fixed << setprecision(6);
	double sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	gy *= -1;
	double ans=sx + sy * (gx - sx) / (sy - gy);
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
namespace Ruri{
    #define ms(a,b) memset(a,b,sizeof(a))
    #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?
    #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i)
    #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
    #define ce(i,r) i==r?'\n':' '
    #define pb push_back
    #define all(x) x.begin(),x.end()
    #define gmn(a,b) a=min(a,b)
    #define gmx(a,b) a=max(a,b)
    #define fi first
    #define se second
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
    const int infi=1e9;//infi较大，注意涉及inf相加时爆int
    const ll infl=4e18;
    inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
    inline ll pos_mod(ll a,ll b){ return (a%b+b)%b; }
    //std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
}
using namespace Ruri;
namespace Read{
    #define ss(a) scanf("%s",a)
    inline int ri(){ int x; scanf("%d",&x); return x; }
    inline ll rl(){ ll x;  scanf("%lld",&x); return x; }
    inline db rd(){ db x; scanf("%lf",&x); return x; }
}
namespace DeBug{
    #define pr(x) cout<<#x<<": "<<(x)<<endl
    #define pra(x,a,b) cout<<#x<<": "<<endl; \
            repi(i,a,b) cout<<x[i]<<" ";     \
            puts("");
    #define FR(a) freopen(a,"r",stdin)
    #define FO(a) freopen(a,"w",stdout)
}
using namespace Read;
using namespace DeBug;
const int MAX_N=2e5+5;
int n,m;
map<int,vector<int> >mp;
set<int> s;
vector<int> add;
int main()
{
    n=ri(),m=ri();
    repi(i,1,m){
        int x=ri(),y=ri();
        mp[x].pb(y);
    }
    s.insert(n);
    for(auto p:mp){
        add.clear();
        for(auto y:p.se)if(s.count(y-1)||s.count(y+1)) add.pb(y);
        for(auto y:p.se)if(s.count(y)) s.erase(y);
        for(auto y:add) s.insert(y);
    }
    printf("%d\n",(int)s.size());

    return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int n, m;
  cin >> n >> m;
  if(n == 1 && m == 0){
    cout << 1 << " " << 2 << endl;
    return 0;
  }
  if(m == n || m < 0 || m == n-1){
    cout << -1 << endl;
    return 0;
  }
  int fi = 3;
  int se = 5;
  vector<P> ans(n-1);
  rep(i, n-1){
    ans[i] = {fi, se};
    fi += 4;
    se += 4;
  }
  if(m == 0){
    ans.push_back({1, 2});
    rep(i, n){
      cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
  }
  int last = 4 * (n-1) +2;
  int cn = n - 2 - m;
  last -= 4 * cn;
  ans.push_back({1, last});
  rep(i, n){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}