#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
    int a,b,w;
    cin>>a>>b>>w;
    w*=1000;
    int x=w/a,y=w/b;
    //if (w%a==0 && w%b!=0) cout<<w/a<<" "<<w/a<<endl;
    //else if (w%b==0 && w%a!=0) cout<<w/b<<" "<<w/b<<endl;
    if (x==y && w%a!=0 && w%b!=0) cout<<"UNSATISFIABLE"<<endl;

    else cout<<setprecision(8)<<ceil(double(double(w)/double(b)))<<" "<<floor(double(double(w)/double(a)))<<endl;
}

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

#define int long long
#define ld long double
#define db double
#define endl "\n"
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

using namespace __gnu_pbds;
using namespace std;
using namespace chrono;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void deb_out() {
    cout << endl;
}
template <typename Head, typename... Tail>
void deb_out(Head H, Tail... T) {
    cout << " " << H;
    deb_out(T...);
}
#ifdef LOCAL
    #define deb(...) cout << "[" << #__VA_ARGS__ << "]:", deb_out(__VA_ARGS__);
#else
    #define deb(...) ;
#endif

const long double PI = 3.14159265358979323846264338;
const long long INF = 1000000000000000000;
const long long INF1 = 1000000000;
const long long MOD = 1000000007;
// const long long MOD = 998244353;

inline int cl(int a, int b){
    if(a % b)
        return 1 + a / b;
    return a / b;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int Tests = 1;
    // cin >> Tests;
    while (Tests--) {
        int a, b, w;
        cin >> a >> b >> w;
        w *= 1000;
        // int g = __gcd(a, b);
        // deb(g, a, b, w % g)
        // if (w < a || w % g) {
        //     cout << "UNSATISFIABLE" << endl;
        //     continue;
        // }
        // int mn = cl(w, b);
        // int mx = w / a;
        // cout << mx << " " << mn << endl;
        int mx = 0, mn = INF;
        for (int i = 0 ; a * i <= w ; i++) {
            int dn = i * a;
            int df = w - dn;
            int ex = b - a;
            if (df <= i * ex) {
                mx = max(mx, i);
                // deb(i, df)
                // mn = min(mn, i);
            }
        }
        for (int i = 0 ; b * i <= w + 5 * b ; i++) {
            // deb(i)
            int dn = i * b;
            int df = -w + dn;
            // deb(df)
            int ex = b - a;
            if (df <= ex * i && df >= 0) {
                mn = min(mn, i);
                // mn = min(mn, i);
            }
        }
        if (mx == 0) {
            cout << "UNSATISFIABLE" << endl;
            continue;
        } else {
            cout << mn << " " << mx << endl;
        }
    }
}


/*
solution here

*/

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define nl '\n'
#define sp ' '
using ll = long long;
ll inf = 2e18;
const int N = 2e5+10;
ll arr[N];
void solve()
{
    int n,w;
    cin>>n>>w;
    rep(i,n){
        int a,b,c; cin>>a>>b>>c;
        ++a; ++b;
        arr[a]+=c; arr[b]-=c;
    }
    rep1(i,N-10)
    {
        arr[i]+=arr[i-1];
        if(arr[i]>w)
        {
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}
int main()
{
    ios::sync_with_stdio(!cin.tie(0));
    // cout<<fixed;
    // cout.precision(12);
    solve();
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define pie 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define ff first
#define ss second
#define INT_MAX LLONG_MAX
#define pi pair<int,int>
#define pii pair< int, pair<int,int> >
#define all(v) (v).begin(),(v).end()
int parent[200005];
map<int,map<int,int> >m;
void make_set(int v) {
    parent[v] = v;
}
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
    	if(m[a].size() < m[b].size()){
    		swap(a,b);
		}
        parent[b] = a;
        map<int,int > :: iterator it;
        for(it = m[b].begin();  it!= m[b].end() ;it++){
        	m[a][it->ff] += it->ss;
		}
		m[b].clear();
    }
}
void solve(){
	int n,q;
	cin>>n>>q;
	int a[n+5];
	for(int i=1; i<=n ;i++){
		cin>>a[i];
	}
	for(int i=1; i<=n ;i++){
		make_set(i);
		m[i][a[i]] = 1;
	}
	while(q--){
		int x,y,z;
		cin>>x>>y>>z;
		if(x&1){
			union_sets(y,z);
		}else{
			int par = find_set(y);
			int val = m[par][z];
			cout<<val<<endl;
		}
	}
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t;
//	cin>>t;
	t = 1;
	for(int T=1; T<=t ;T++){
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr long long INF = 1e9+10;
constexpr long long LINF = 1e18+10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

double func(int sel, int a, int b, int c){
     return (double)(sel)/(a+b+c);
}
double dp[110][110][110];
int memo[110][110][110];

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

    double res = 0;
    dp[a][b][c] = 1;
    for(int r=a+b+c; r<=300; r++){
        for(int x=a; x<=100; x++){
            for(int y=b; y<=100; y++){
                for(int z=c; z<=100; z++){
                    if(x+y+z > r)continue;

                    if(x==100 or y==100 or z==100){
                        if(memo[x][y][z])continue;
                        //cout << "x:" << x << "y:" << y << "z:" << z <<"dp:"<< dp[x][y][z]<< ln;
                        int cnt = (x+y+z) - (a+b+c);
                        res += dp[x][y][z] * cnt;
                        memo[x][y][z] = true;
                    }else{
                    if(memo[x][y][z])continue;
                    //cout << "non:" << " x:" << x << "y:" << y << "z:" << z << ln;
                    dp[x+1][y][z] += dp[x][y][z] * func(x,x,y,z);
                    dp[x][y+1][z] += dp[x][y][z] * func(y,x,y,z);
                    dp[x][y][z+1] += dp[x][y][z] * func(z,x,y,z);
                    memo[x][y][z] = true;
                    }
                }
            }
        }
    }
    cout << fixed << setprecision(12);
    cout << res << ln;
}

#include "bits/stdc++.h"
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
 #define int long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define ff first
#define ss second
#define vp vector <pair<int,int>>
#define vpp vector <pair<int,pair<int,int>>>
#define seti set<int>
#define setbit(x) __builtin_popcountll(x)
#define sov(v) accumulate(all(v),0)
#define fs(it,a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pqmax priority_queue <int,vector <int>>
#define pqmin priority_queue <int,vector <int>,greater<int>>
#define dq deque <int>
#define umi unordered_map<int,int>
#define ums unordered_map<string,int>
#define sp(x,y) fixed << setprecision(y) << x
#define out(r,x) cout<<"Case #"<<r<<": "<<x<<ee;
#define all(x) x.begin(),x.end()
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define countdigit(x) floor(log10(x) +1)
#define M 1000000007
#define Z 998244353
#define fill(arr,x) memset(arr,x,sizeof(arr))
//Use (k%M+m)%m always where k is any no
#define PI 3.1415926535
#define lcm(a,b)  a*b/(__gcd(a,b))
// typedef tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update> pdbs;
// // null for set,mapped_type for map;
// //less for assending greater for descending
//ceil(a/b)=(a+b-1)/b
// v.si-1 can never be negative
#define ghadi() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
#define ee "\n"
#define re return

//Author Rahul Sannigrahi

vector<int> take(int n)
{
    int i,j;
    vi v;
    f(i,0,n)
    {
        cin>>j;
        v.pb(j);
    }
    return v;
}

int power(int x,int y)
{
    int res=1;

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

       y=y>>1;
       x=((x%M)*(x%M))%M;
    }
    re res;
}

bool sortinrev(const pair<int,int> &a,  //desc of vp
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

void show(vector<int>v)
{
    int i;
    for(i=0;i<v.si;i++)
    {
     cout<<v[i]<<" ";
    }
    cout<<ee;
}

int decode()
{
int i,j,k,l,n,a,b,c;
cin>>a>>b>>c;
// double d=(float)b/a;
// cout<<d<<ee;
int ans=b*c/a;
if(ans*a==b*c)
ans--;
cout<<ans<<ee;
   re 0;
}

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

    int t=1;
    //   cin>>t;
    while(t--)
    decode();
    return 0;
}


#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <ostream>
#include <queue>
#include <set>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define all(A) A.begin(), A.end()
typedef long long ll;

int main() {
  int n;
  cin >> n;
  cout << (n + 99) / 100 << endl;
}

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

int main()
{
    int t;
    t=1;
    while(t--)
    {
        int n;
        cin>>n;
        int ans=n/100;
        if(n%100==0)
            cout<<ans;
        else
            cout<<ans+1;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

void solve()
{
	ll m, n;
	cin >> n >> m;
	for(ll i = 1; i * i <= m; i++)
	{
		if(m % i == 0)
		{
			if(i + (m / i) == n)
			{
				cout << "Yes\n";
				return;
			}
		}
	}
	cout << "No\n";
}

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

#include <iostream>
using namespace std;

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

    cout << (double)(A - B)/(double)A * 100.0 << endl;

}


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

using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define f first
#define s second
#define ar array
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(X) ((int)(X).size())
#define pcnt __builtin_popcount
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c, x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define ms(c, x)  memset(c,x,sizeof c)
#define  No(x) cout<<(x?"NO":"No")<<endl;
#define  Yes(x) cout<<(x?"YES":"Yes")<<endl;
#define  nl cout<<endl;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = l; i <=r; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; --i)
using ld = long double;
using db = double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

template<typename T>
using osl = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using osg = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;

// for greater use greater<T>
template<typename T>
ostream &operator+(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out << x << " ";
    }
    out << "\n";
    return out;
}

template<typename T>
ostream &operator*(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out + x;
    }
    return out;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &vec) {
    for (auto &x : vec) {
        in >> x;
    }
    return in;
}

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

#ifdef LOCAL

void debug() { cerr << endl; }

template<class T, class... Args>
void debug(const T &t, const Args &... args) {
    cerr << t << " ";
    debug(args...);
}

#define dbg(...) {cerr<<__LINE__<<" [[DEBUG]] ";debug(__VA_ARGS__);};
#else
#define dbg(...) void(0)
#endif
const ll mod = 1e9 + 7;
//const int mod = 998244353;
const ll INF = 1e17 + 6;

inline ll power(ll x, ll y) {
    ll res = 1;
    x = x;
    while (y > 0) {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
const int MXN=3e6+5;

void solve() {
   int n,m;
   cin>>n>>m;
   vl h(n);
   cin>>h;
   vl w(m);
   cin>>w;
   vi pref((n+1)/2+2);
   vi suff((n+1)/2+2);
   sort(all(h));
   for(int i=0;i<n-1;i+=2) {
       pref[i / 2+1] += pref[i / 2] + h[i + 1] - h[i];
   }
   for(int i=n-2;i>0;i-=2) {
       suff[i / 2] += suff[i / 2+1] + h[i+1] - h[i];
   }
   ll ans=INF;
   for(auto i:w){
       int pos=get_pos(h,i);
       if(pos&1){
           pos--;
       }
       ans=min(pref[pos/2]+suff[pos/2]+abs(i-h[pos]),ans);
   }
   cout<<ans<<endl;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1, tc = 1;
//    cin >> t;
    while (t--) {
        // cout<<"Case #"<<tc<<": " ;
        solve();
        tc++;
    }
#ifdef LOCAL
    cerr << endl << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
#endif
    return 0;
}
//look if it requires ll

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<long long> H(N),W(M);
	for(auto &i:H)cin >> i;
	for(auto &i:W)cin >> i;

	sort(H.begin(),H.end());
	sort(W.begin(),W.end());

	if(N==1){
		long long ans=99999999999999LL;
		for(auto w:W){
			ans=min(ans,abs(w-H[0]));
		}
		cout << ans << endl;
		return 0;
	}

	vector<long long> Lsum(N),Rsum(N);
	Lsum[0]=Lsum[1]=H[1]-H[0];
	Rsum[N-1]=Rsum[N-2]=H[N-1]-H[N-2];

	for(int i=2;i+1<N;i+=2)Lsum[i]=Lsum[i+1]=Lsum[i-1]+H[i+1]-H[i];
	for(int i=N-3;i-1>=0;i-=2)Rsum[i]=Rsum[i-1]=Rsum[i+1]+H[i]-H[i-1];

	int pos=0;
	long long ans=999999999999999999LL;
	for(int i=0;i<M;i++){
		while(pos<N && W[i]>H[pos])pos++;
		long long tmp=0;
		if(pos-2>=0)tmp+=Lsum[pos-2];
		if(pos+1<=N-1)tmp+=Rsum[pos+1];
		if(pos%2)tmp+=W[i]-H[pos-1];
		else tmp+=H[pos]-W[i];
		ans=min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

//const ll MOD = 1000000007;
const ll MOD = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    int n, k;
    cin >> n >> k;
    vll a(n);
    REP(i, n) cin >> a[i];

    mint div = 1;
    vector<mint> s(k + 1);
    s[0] = n;

    vector<vector<mint>> p(k + 1, vector<mint>(n, 1));
    FOR(i, 1, k + 1) {
        div *= i;
        REP(j, n) {
            p[i][j] = p[i-1][j] * a[j];
            s[i] += p[i][j];
        }
        s[i] /= div;
    }

    mint f = 2;
    FOR(x, 1, k+1) {
        mint ans = 0;
        mint fact = 1;

        REP(i, x + 1) {
            ans += s[i] * s[x - i];
            if (i > 0) fact *= i;
        }

        ans *= fact;

        REP(i, n) {
            ans -= p[x][i] * f;
        }
        f *= 2;

        ans /= 2;

        print(ans);
    }
}

//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
template<typename T>void rearrange(vector<ll>&ord, vector<T>&v){
  auto tmp = v;
  for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<ll>&ord,Head&& head, Tail&&... tail){
  rearrange(ord, head);
  rearrange(ord, tail...);
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m,k;cin>>n>>m>>k;
  vector<ll>a(k);
  rep(i,0,k)cin>>a[i];
  vector<ld>x(n+m+1),y(n+m+1);
  ld sx=0,sy=0;
  rrep(i,0,n){
    if(binary_search(ALL(a),i)){
      x[i]=1;
      y[i]=0;
    }
    else{
      x[i]=sx/m;
      y[i]=sy/m+1;
    }
    sx+=x[i]-x[i+m];
    sy+=y[i]-y[i+m];
  }
  if(abs(x[0]-1)<=1e-10){
    cout<<-1<<endl;
  }
  else{
    lfs<<y[0]/(1-x[0])<<endl;
  }
  return 0;
}


#include <bits/stdc++.h>

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << " end.\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 1e2+5;

void solve(){
    int h, w;
    cin >> h >> w;
    vector<int> fre(105);
    int mn = 1e9;
    for(int i = 0; i <h ; ++i)
        for(int j= 0, x; j < w; ++j)
            cin >> x, fre[x]++, mn = min(mn, x);
    LL res = 0;
    for(int i = mn; i <= 100; ++i){
        res += fre[i]* (i-mn);
    }
    cout << res;
}

int main()
{
    Fast;
    //louisfghbvc
        solve();
    return 0;
}

#include <iostream>
#include <string>
#include <vector>

int main()
{
    int H, W;
    std::cin >> H >> W;
    std::vector<std::vector<int>> A(H, std::vector<int> (W));
    for(int i=0; i < H; i++) {
        for(int j=0; j < W; j++) {
            std::cin >> A[i][j];
        }
    }

    int min_value = 1000000000;
    for(int i=0; i < H; i++) {
        for(int j=0; j < W; j++) {
            min_value = min_value > A[i][j] ? A[i][j] : min_value;
        }
    }

    int ans = 0;
    for(int i=0; i < H; i++) {
        for(int j=0; j < W; j++) {
            ans += (A[i][j] - min_value);
        }
    }

    std::cout << ans << std::endl;
}


// // #include<iostream>
// // #include<algorithm>
// // using namespace std;
// // int a[1005],b[1005];
// // int main(){
// // 	int n;
// //   	cin>>n;
// //   	int min3=1e8;
// //   	for(int i=1;i<=n;i++){
// //       	cin>>a[i]>>b[i];
// //       	min3=min(min3,a[i]+b[i]);
// //     }
// //     sort(a+1,a+n+1);
// //     sort(b+1,b+1+n);
// //   	if(a[1]+b[1]==min3){
// //           min3=min({min3,max(b[1],a[2]),max(b[2],a[1]});
// //           cout<<min3;
// //     }
// //     else{
// //         cout<<max(a[1],b[1]);
// //     }
// //     getchar();
// //     getchar();
// //   return 0;
// // }
// #include<iostream>
// #define int long long
// using namespace std;
// int a[300000+5];
// signed main(){
//     int sum=0;
//     int ans=0;
//     int n;
//     cin>>n;
//     for(int i=1;i<=n;i++){
//         cin>>a[i];
//         ans+=(n-1)*a[i]*a[i];
//         sum+=a[i];
//     }
//     for(int i=1;i<=n;i++){
//         ans-=a[i]*(sum-a[i]);
//     }
//     cout<<ans;
//     getchar();
//     getchar();
//     return 0;
// }
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
double dp[200000+5];
double dfs(int x,int n){
    if(x==n)
        return 0.0;
    if(dp[x]!=0.0)
        return dp[x];
    double ans=0.0;
    ans+=dfs(x+1,n)+1.0*n/(n-x);
    return dp[x]=ans;
}
int main(){
    int n;
    cin>>n;
    dp[n]=0.0;
    cout<<fixed<<setprecision(10)<<dfs(1,n);
    getchar();
    getchar();
    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int L;
int comb[200][12];

signed main() {
	int i, j;

	cin >> L;
	comb[0][0] = 1;
	for (i = 0; i < L; i++) {
		comb[i][0] = 1;
		for (j = 1; j <= min(i, 11LL); j++) {
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}

	cout << comb[L - 1][11] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll mod = 1e9 + 7;
const ll linf = 1LL << 62;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int main() {
    ll N;
    cin >> N;
    int cnt = 0;
    for (int i = 1; i <= 1000000; i++) {
        ll num = i;
        ll cp = i;
        ll t = 1;
        while (cp != 0) {
            t *= 10;
            cp /= 10;
        }
        num = t * (ll)i + (ll)i;
        if (num <= N) cnt++;
    }
    cout << cnt << endl;
}

#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<map>
#include<queue>
#include<stack>
#include<set>

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

#define LL_INF 1e18+5
#define INT_INF 1e9+5
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define LL_INF 1e18+5
#define INT_INF 1e9+5

int main(){
    ll N; cin >> N;
    int cnt = 0;
    ll tmp = 1;
    while(tmp < N){
        cnt++;
        tmp *= 10;
    }
    if(cnt%2 == 1){
        cnt /= 2;
        ll ans = 1;
        while(cnt > 0){
            cnt--;
            ans *= 10;
        }
        cout << ans - 1 << endl;
        return 0;
    }
    else {
        cnt /= 2;
        ll ans = 1;
        while(cnt>0){
            ans *= 10;
            cnt--;
        }
        if(N/ans <= N%ans){
            cout << N/ans << endl;
            return 0;
        }
        else {
            cout << N/ans -1 << endl;
            return 0;
        }
    }
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <string>

#define REP(i,a,b) for(int i=a; i<b; i++)
#define REP1(i,a,b) for(int i=a; i<=b; i++)

#define F first
#define S second
#define PB push_back
#define MP make_pair

typedef long long ll;

using namespace std;

int main()
{
    //this code makes input and output more efficient:
    ios::sync_with_stdio(0);
    cin.tie(0);

	char s;
  	set<char>se;
    REP1(i,01,3)
    {
      cin >> s;
      se.insert(s);
    }
  	if (se.size()==1) cout << "Won";
  	else
        cout << "Lost";

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) cout << "Won" << endl;
  else cout << "Lost" << endl;
}


//**Anything done in love is beyond good and evil***

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[201];
vector<ll> v[201];
int main(){
    ll n;
    cin>>n;
    //cout<<c;

    forn(i,n) cin>>a[i];

    forn(i,n){
        vector<ll> temp[200];

        forn(j,200) temp[j]=v[j];

        for(ll j=0;j<200;j++){
            if(v[j].size()==0) continue;
            ll sum=0;
            for(auto x:v[j]) sum+=a[x];
            sum+=a[i];
            sum=sum%200;
            if(v[sum].size()!=0){
                cout<<"Yes"<<endl;
                cout<<v[sum].size()<<" ";
                for(auto x:v[sum]) cout<<x+1<<" ";
                cout<<endl;
                cout<<v[j].size()+1<<" ";
                for(auto x:v[j]) cout<<x+1<<" ";
                cout<<i+1<<endl;
                return(0);
            }
            temp[sum]=v[j];
            temp[sum].pb(i);
        }
        forn(j,200) v[j]=temp[j];
        ll sum=a[i]%200;
        //cout<<sum<<" "<<v[sum].size()<<endl;
        if(v[sum].size()!=0){
            cout<<"Yes"<<endl;
            cout<<v[sum].size()<<" ";
            for(auto x:v[sum]) cout<<x+1<<" ";
            cout<<endl;
            cout<<"1 "<<i+1<<endl;
            return(0);
        }
        else v[sum].pb(i);

    }
    cout<<"No";
}

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

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define fr first
#define sc second
#define all(a) a.begin(), a.end()
#define int long long

const int N = 1e6 + 10;
const int INF = 2e9;
const int MOD = 1e9 + 7;

int dp[213][213][213][2][2], a[211], n;
vector <int> D, C;

int calc(int cur, int A, int B, int At, int Bt) {
    if(cur == n + 1)
        return dp[cur][A][B][At][Bt] = (A == B && At && Bt);
    if(dp[cur][A][B][At][Bt] != -1)
        return dp[cur][A][B][At][Bt];
    int ans = 0;
    ans |= calc(cur + 1, (A + a[cur]) % 200, B, 1, Bt);
    ans |= calc(cur + 1, A, (B + a[cur]) % 200, At, 1);
    ans |= calc(cur + 1, A, B, At, Bt);
    return dp[cur][A][B][At][Bt] = ans;
}

void findAns(int cur, int A, int B, int At, int Bt) {
    if(cur == n + 1)
        return;
    if(A == B && At && Bt) {
        return;
    }
    if(dp[cur + 1][(A + a[cur]) % 200][B][1][Bt] == 1) {
        D.pb(cur);
        findAns(cur + 1, (A + a[cur]) % 200, B, 1, Bt);
    }
    else if(dp[cur + 1][A][(B + a[cur]) % 200][At][1] == 1) {
        C.pb(cur);
        findAns(cur + 1, A, (B + a[cur]) % 200, At, 1);
    }
    else
        findAns(cur + 1, A, B, At, Bt);
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] %= 200;
    }
    memset(dp, -1, sizeof dp);
    if(!calc(1, 0, 0, 0, 0)) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
    findAns(1, 0, 0, 0, 0);
    cout << sz(D) << ' ' ;
    for(auto u: D) cout << u << ' ';
    cout << '\n';
    cout << sz(C) << ' ';
    for(auto u: C) cout << u << ' ';
}

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


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,n;
    cin >> n >> k;
    vll cnt(300009,0);
    REP(i,n){
        ll a;
        cin >> a;
        cnt[a+1]++;
    }
    cnt[0]=k;
    ll sum = 0;
    for(ll i=1;i<=300001;i++){
        if(cnt[i]==0){
            sum += cnt[i-1]*(i-1);
            break;
        }
        sum += (i-1)*(max(0LL,cnt[i-1]-cnt[i]));
        if(cnt[i]>cnt[i-1])cnt[i] = cnt[i-1];
        //cout << sum << endl;
    }
    cout << sum << endl;

    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int x, y;
  cin >> x >> y;
  int ans = x;
  if(a > b) a--;
  int d = abs(a - b);
  int add = min(y, 2*x);
  ans += d*add;
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mem(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << #x << " = " << x << endl
#define fi(i, l, r) for (int i = l; i < r; i++)
#define cd(a) scanf("%d", &a)
typedef long long ll;

ll getScore(ll s[])
{
    ll ans=0;
    for(ll i=1;i<10;i++)
    {
        ans+=i*pow(10,s[i]);
    }
    return ans;
}

// ll getScore1(ll s[])
// {

//     ll ans=0;
//     for(ll i=1;i<10;i++)
//     {
//         printf("s[%lld]=%lld ",i,s[i]);
//         ans+=i*pow(10,s[i]);
//         printf("i=%lld,1LL<<%lld=%lld\n",i,s[i],(1LL<<s[i]));
//     }
//     printf("\nreturn:%lld\n",ans);
//     return ans;
// }
// int main()
// {
//     ll sa[10]={2,3,0,0,0,0,0,0,0};
//     ll sb[10]={1,3,0,0,0,0,0,1,0};
//     printf("GSa=%lld\nGSb=%lld\n",getScore1(sa),getScore1(sb));
//     return 0;
// }

int main()
{
    ll k;
    cin >> k;
    char s[10], t[10];
    cin >> s >> t;
    ll shengyu[10] = {0};
    for (ll i = 1; i < 10; i++)
        shengyu[i] = k;
    ll suma[10] = {0};
    ll sumb[10] = {0};
    for (ll i = 0; i < 4; i++)
    {
        shengyu[s[i] - '0']--;
        shengyu[t[i] - '0']--;
        suma[s[i]-'0']++;
        sumb[t[i]-'0']++;
    }
    ll canWin=0;
    for (ll i = 1; i <= 9; i++)
    {
        for (ll j = 1; j <= 9; j++)
        {
            bool sfbx=false;
            if(shengyu[i]<=0)sfbx=true;
            if(shengyu[j]<=0)sfbx=true;
            suma[i]++;
            sumb[j]++;
            //shengyu[i]--;
            //shengyu[j]--;

            if(!sfbx)
            {
                ll sa=getScore(suma);
                ll sb=getScore(sumb);
                // if(i==2&&j==1)
                // {
                //     cout<<"i="<<i<<",j="<<j<<"!!!"<<endl;
                //     printf("suma:");
                //     for(int i=1;i<=9;i++)printf(" %d",suma[i]);
                //     printf("\nsumb:");
                //     for(int i=1;i<=9;i++)printf(" %d",sumb[i]);
                //     printf("\nsa=%lld,sb=%lld\n",sa,sb);
                //     puts("---------");
                // }
                if(sa>sb)
                {
                    if(i==j)
                    {
                        canWin += shengyu[i] * (shengyu[i]-  1);
                    }
                    else
                    {
                        canWin += shengyu[i] * shengyu[j];
                    }
                }
                // else
                // {
                //     printf("i=%lld,j=%lld,sa=%lld,sb=%lld,Cannot!!!\n",i,j,sa,sb);
                // }
            }

            suma[i]--;
            sumb[j]--;
            //shengyu[i]++;
            //shengyu[j]++;
        }
    }
    ll shengyuAll = k*9-8;
    ll canAll = shengyuAll*(shengyuAll-1);
    double ans = 1. * canWin / canAll;
    printf("%.15lf\n", ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
typedef int64_t ll;
#define PA pair<ll,ll>
#define TU tuple<ll,ll,ll>
#define vi vector<ll>
#define vii vector<vector<ll> >
#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define rep2(i,m,n) for(ll (i)=(m); (i)<(ll)(n); (i)++)
const ll INF = 1ll<<30;
const ll INF2 = 1ll<<32;

int main() {
  ll k;
  cin >>k;
  string s,t;
  cin >>s >>t;
  //v_t.at(i)=数字i-1の存在個数
  vi v_t(9,0),v_a(9,0);
  rep(i,4) {
    v_t.at(s.at(i)-'1')++;
    v_a.at(t.at(i)-'1')++;
  }

  vi v_remain(9);
  rep(i,9) {
    v_remain.at(i) = k - (v_t.at(i)+v_a.at(i));
  }

  //ここでのanspはパターンの数。最終的には(9*k-8)P(2)で割る。
  ll ansp =0;
  ll pts_t, pts_a;
  vi v_tt(9), v_aa(9);

  rep(tak,9) {
    v_tt = v_t;
    v_tt.at(tak)++;
    rep(aok,9) {
      if(tak==aok && v_remain.at(tak)<2) continue;
      else if(v_remain.at(tak)==0 || v_remain.at(aok)==0) continue;
      v_aa = v_a;
      v_aa.at(aok)++;

      pts_t = 0;
      pts_a = 0;
      rep(i,9) {
        pts_t += (i+1) * pow(10,v_tt.at(i));
        pts_a += (i+1) * pow(10,v_aa.at(i));
      }
      if(pts_t>pts_a) {
        if(tak==aok) ansp += v_remain.at(tak)*(v_remain.at(tak)-1);
        else ansp += v_remain.at(tak)*v_remain.at(aok);
      }
    }
  }

  double ans = (double)ansp/((9*k-8)*(9*k-9));
  cout << fixed << setprecision(7);
  cout << ans << endl;
}


//IQ134高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353

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

int main() {
	ll ans = 0;
	ll tmp = 0;
	//int n; cin >> n;
	bool now;
	int a[2]; cin >> a[0] >> a[1] >> now;
	int win;
	while(1){
		if(a[now] == 0){
			win = 1 - now;
			break;
		}
		else a[now]--;
		now = 1 - now;
	}
	if (win == 0) cout << "Takahashi" << endl;
	else cout << "Aoki" << endl;

	//cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;
#define int long long int
#define f(i,n) for(int i=0;i<n;i++)
#define f(j,n) for(int j=0;j<n;j++)
int32_t main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(c==0)
    {
        if(a==b)
        cout<<"Aoki";
        else if(a<b)
        cout<<"Aoki";
        else
        cout<<"Takahashi";
    }
    else
    {
        if(a==b)
        cout<<"Takahashi";
        else if(a<b)
        cout<<"Aoki";
        else
        cout<<"Takahashi";
    }
    return 0;
}


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

void siglo(int a)
{

	if (a <= 0)
		cout <<0;

	else if (a <= 100)
		cout <<1;

	else if (a % 100 == 0)
		cout << a/ 100 ;
	else
		cout << a/ 100 + 1 ;
}

int main()
{
	int a =0;
	cin>>a;
	siglo(a);
	return 0;
}

#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli                                 long long int
#define int                                  long long
#define FOR(i,a,b)                          for(int i=a;i<b;i++)
#define pi                                  pair<int,int>
#define vi                                  vector<int>
#define vii                                 vector<pi>
#define all(a)                              a.begin(),a.end()
#define sz(a)                               (int)a.size()
#define pb                                  push_back
#define ppb                                 pop_back
#define pf                                  push_front
#define fr                                  first
#define sc                                  second
using namespace std;

template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
// __builtin_popcountll(x);
// __builtin_clz(x) // Count Leading zeros
// __builtin_ctz(x) // Trailing zeros
const int MM = 998244353;
const int mod = 1e9 + 7;
const int INF = 1e15;
const int N = 5e6 + 4;
// vector<int>pref(N,0);
// vector<int>suff(N,0);

void solve()
{
    string s;
    cin >> s;
    int n = sz(s);
    int ans = 0;
    int num = stoll(s);
    if(num < 1000) {
        cout << 0 << "\n";
        return;
    }
    if(num <= 999999) {
        ans += num - 999;
    }
    else if(num > 999999 and num <= 999999999) {
        ans += 999999 - 999;
        ans += 2 * (num - 999999);
    }
    else if(num > 999999999 and num <= 999999999999) {
        ans += 999999 - 999;
        ans += 2 * (999999999 - 999999);
        ans += 3 * (num - 999999999);
    }
    else if(num > 999999999999 and num <= 999999999999999) {
        ans += 999999 - 999;
        ans += 2 * (999999999 - 999999);
        ans += 3 * (999999999999 - 999999999);
        ans += 4 * (num - 999999999999);
    }
    else {
        ans += 999999 - 999;
        ans += 2 * (999999999 - 999999);
        ans += 3 * (999999999999 - 999999999);
        ans += 4 * (999999999999999 - 999999999999);
        ans += 5 * (num - 999999999999999);
    }

    cout << ans;
}

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


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) { cerr << #a << ':' << a << endl; }
#define endl '\n'
#define fi first
#define se second
using lint = long long;
using P = pair<int,int>;
template<class T> using V = vector<T>;
template<class T> using priq     = priority_queue<T>;
template<class T> using priq_inv = priority_queue<T, vector<T>, greater<T>>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
template<class T> T ceil(const T &a, const T &b) { return (a+b-1)/b; }
template<class T> bool chmin(T &a, T b) { if(a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax(T &a, T b) { if(a < b) { a = b; return 1; } return 0; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;

template<class T, class U> istream& operator>>(istream &in, pair<T,U> &p) {
    return in >> p.first >> p.second;
}
template<class T, class U> ostream& operator<<(ostream &out, const pair<T,U> &p) {
    return out << "{ " << p.first << ',' << p.second << " } ";
}
template<class T> istream& operator>>(istream &in, vector<T> &v) {
    for(auto &&e: v) in >> e;
    return in;
}
template<class T> ostream& operator<<(ostream &out, const vector<T> &v) {
    for(const auto &e: v) out << e << ' ';
    return out;
}

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

int n, m;
V<string> s;

// fstream out("AHC004_out.txt");

int main() {

    clock_t start = clock();

    cin >> n >> m;
    s.resize(m);
    cin >> s;

    V<P> cnts(m); // pair = (count, index);
    V<V<int>> ins(m);

    rep(i,m) {
        int cnt = 0;
        rep(j,m) {
            bool isin = ( s[i].find(s[j]) != string::npos );
            if(isin) {
                cnt++;
                ins[i].push_back(j);
            }
        }
        cnts[i] = make_pair(cnt,i);
    }
    sort(rall(cnts));

    V<bool> used(m);
    V<string> ans(n);

    rep(i,n) { // 初期解生成
        string str = "";
        rep(j,m) {
            int x = cnts[j].se;
            if(used[x]) continue;
            string plus = s[x];
            for(int k = min(sz(str), sz(s[x])); k >= 0; k--) {
                if( str.substr(sz(str)-k,k) == s[x].substr(0,k) ) {
                    plus = s[x].substr(k,sz(s[x])-k);
                    break;
                }
            }
            if(sz(str) + sz(plus) > n) continue;
            str += plus;
            for(int y: ins[x]) used[y] = true;
        }
        str.resize(n,'.');
        ans[i] = str;
    }

    V<int> v(n); iota(all(v), 0);
    pair<int,V<int>> mx = make_pair(0,v);

    random_device seed_gen;
    mt19937 engine(seed_gen());

    while(clock() - start < 2980000) {
        V<bool> nused = used;
        int cnt = 0;
        rep(j,n) { // yoko
            string ns = "";
            rep(i,n) ns += string(1,ans[v[i]][j]);
            ns += ns;
            rep(i,m) {
                if(nused[j]) continue;
                if( ns.find(s[j]) != string::npos ) {
                    cnt++;
                    nused[j] = true;
                }
            }
        }
        chmax(mx, make_pair(cnt, v));
        shuffle(all(v), engine);
    }

    rep(i,n) {
        cout << ans[mx.se[i]] << endl;
    }
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int int_n;
    int int_m;
    int num1 = 0,num2 = 0;
    cin >> int_n >> int_m;
    while(int_n > 0)
    {
        num1 += int_n % 10;
        int_n /= 10;
    }
    while(int_m > 0)
    {
        num2 += int_m % 10;
        int_m /= 10;
    }
    printf("%d",max(num1,num2));
}


#include <bits/stdc++.h>
#define fir first
#define sec second
#define PB push_back
#define MP make_pair

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i < (int)(n); ++i)
#define foreach(itr, c) for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); ++itr)

template <class T> void chkmax(T& x, T y) { x = (x > y ? x : y); }
template <class T> void chkmin(T& x, T y) { x = (x < y ? x : y); }

typedef long long LL;
typedef pair <int, int> pii;
typedef vector <int> vi;

const int N = 105;
const int M = 1e4 + 5;

int n, m, a[M], b[M], c[N];
vi e[N];
set <int> e2[N];
bool vis[N];

void dfs(int now, int from){
    vis[now] = 1;
    for (auto u : e[now]) if (u != from && c[u] == c[now]){
        if (e2[u].find(now) != e2[u].end()) continue;
        e2[now].insert(u);
        if (!vis[u]) dfs(u, now);
    }
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, m){
        scanf("%d%d", &a[i], &b[i]), a[i]--, b[i]--;
        e[a[i]].PB(b[i]);
        e[b[i]].PB(a[i]);
    }
    rep(i, n) scanf("%d", &c[i]);
    rep(i, m){
        if (c[a[i]] > c[b[i]]) e2[a[i]].insert(b[i]);
        else if (c[a[i]] < c[b[i]]) e2[b[i]].insert(a[i]);
        else {
            if (e2[a[i]].find(b[i]) != e2[a[i]].end() || e2[b[i]].find(a[i]) != e2[b[i]].end())
                continue;
            dfs(b[i], a[i]);
        }
    }

    rep(i, m){
        if (e2[a[i]].find(b[i]) != e2[a[i]].end()) printf("->\n");
        else printf("<-\n");
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> edges(m);
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edges[i] = {x, y};
        g[x].emplace_back(i);
        g[y].emplace_back(i);
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    vector<int> ans(m, -1);  // 0 "->" , 1 "<-"
    for (int i = 0; i < m; i++) {
        if (c[edges[i].first] > c[edges[i].second]) {
            ans[i] = 0;
        } else if (c[edges[i].first] < c[edges[i].second]) {
            ans[i] = 1;
        }
    }
    vector<int> done(n);
    for (int i = 0; i < m; i++) {
        if (ans[i] == -1) {
            if (done[edges[i].first] && done[edges[i].second]) {
                continue;
            }
            set<int> st;
            int root = edges[i].first;
            if (done[edges[i].second]) {
                root = edges[i].second;
            }
            done[root] = 1;
            st.emplace(root);
            function<bool(int)> dfs = [&](int v) {
                for (int id : g[v]) {
                    if (ans[id] == -1) {
                        int to = v ^ edges[id].first ^ edges[id].second;
                        if (v == edges[id].first) {
                            ans[id] = 0;
                        } else {
                            ans[id] = 1;
                        }
                        if (done[to] || dfs(to)) {
                            st.emplace(v);
                            done[v] = 1;
                            return true;
                        }
                        ans[id] = -1;
                    }
                }
                return false;
            };
            while (true) {
                bool ok = false;
                for (int t : st) {
                    if (dfs(t)) {
                        ok = true;
                    }
                }
                if (!ok) {
                    break;
                }
            }
        }
    }
    debug(ans);
    for (int i = 0; i < m; i++) {
        if (ans[i] == 0) {
            cout << "->" << '\n';
        } else {
            cout << "<-" << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

int64_t solve(int64_t a, int64_t b, int64_t c, int64_t d) {
    // TODO: edit here
	return b - c;
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    auto ans = solve(a, b, c, d);
    cout << ans << endl;
    return 0;
}

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

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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

// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;

  ll ans = N - 1;
  cout << ans << endl;

}

int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    x--;
    y--;
    vector<string>s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int c=0;
for(int i=x+1;i<n;i++){
    if(s[i][y]=='.'){
        c++;
        //cout<<i<<" "<<y<<endl;
    }
    else{
        break;
    }
}
for(int i=x-1;i>=0;i--){
    if(s[i][y]=='.'){
        c++;}

    else{
        break;
    }
}
for(int i=y-1;i>=0;i--){
    if(s[x][i]=='.'){
        c++;

    }
    else{
        break;
    }
}
for(int i=y+1;i<m;i++){
    if(s[x][i]=='.'){
        c++;

    }
    else{
        break;
    }
}
cout<<c+1;

return 0;}

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

int main(){
    int h, w, x, y;
    cin >> h >> w >> x >> y;

    char s[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    int count = 0;
    for (int i = x-1; i < h; i++) {
        if (s[i][y-1] == '.')
            count++;
        else
            break;
    }
    for (int i = x-1; i < h && i >= 0; i--) {
        if (s[i][y-1] == '.')
            count++;
        else
            break;
    }
    for (int j = y-1; j < w; j++) {
        if (s[x-1][j] == '.')
            count++;
        else
            break;
    }
    for (int j = y-1; j < w && j >= 0; j--) {
        if (s[x-1][j] == '.')
            count++;
        else
            break;
    }

    cout << count - 3 << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int MOD = 1e9 + 7;
#define MAX 100005
#define CHAR_SIZE 26

int power(int x, int y){
    int res = 1;
    while (y > 0){
        if (y & 1)
            res = (res * x) % MOD;
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return res;
}

int modInverse(int n){
    return power(n, MOD - 2);
}

int fac[100005];
int cache[100005];

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

int nCrModPFermat(int n, int r){
    if (n < r)
        return 0;
    if (r == 0)
        return 1;
    return (fac[n] * modInverse(fac[r]) % MOD * modInverse(fac[n - r])) % MOD;
}

void pre_compute(){
    fac[0] = 1;
    for(int i = 1 ; i < 100005 ; i++){
        fac[i] = (fac[i - 1] * i) % MOD;
    }
}

void solveEach(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    string a,b;
    for(int i = 0 ; i < n ; i++) a += s[i];
    for(int i = n ; i < 2*n ; i++) b += s[i];
    int a1 = 0;
    int op;
    int i,j;

    while(q--){
        cin >> op >> i >> j;
        if(op == 2){
            if(a1 == 0) a1 = 1;
            else a1 = 0;
        }else{
            i--;
            j--;
            if(j < n){
                if(a1 == 0){
                    swap(a[i] , a[j]);
                }else swap(b[i] , b[j]);
            }else if(i >= n){
                i -= n;
                j -= n;
                if(a1 == 1){
                    swap(a[i] , a[j]);
                }else swap(b[i] , b[j]);
            }else if(j >= n){
                j -= n;
                if(a1 == 0){
                    swap(a[i] , b[j]);
                }else swap(a[j] , b[i]);
            }
        }
    }

    if(a1 == 0){
        cout << a << b ;
    }else cout << b << a;

    return;
}

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

    int T = 1;
    //cin >> T;

    for(int i = 1 ; i <= T ; i++){
        //cout << "Case #" << i << ": ";
        solveEach();
    }
    return 0;
}
/*
 AtCoder Beginner Contest 199（Sponsored by Panasonic）
 */


#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    ll ans = 0;
    rep(i, 0, N) {
        ll min_a = A[i];
        rep(j, i, N) {
            chmin(min_a, A[j]);
            chmax(ans, min_a * (ll)(j - i + 1));
        }
    }
    cout << ans << endl;
    return 0;
}

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

void printmat(const vector<vector<int>>& mat) {
    for (auto row : mat) {
        for (int elem : row)
            cout << elem << " ";
        cout << endl;
    }
}
void printv(const vector<long long>& v) {
    for (int elem : v)
        cout << elem << " ";
    cout << endl;
}
void printvp(const vector<pair<int, int>>& vp) {
    for (auto row : vp)
        cout << row.first << ", " << row.second << " ; ";
    cout << endl;
}

int main() {
    int T=1, caseIdx=0;
    //cin >> T;
    while (T--) {
        caseIdx++;
        string x, ans;
        cin >> x;
        auto it = x.find('.');
        ans = x.substr(0, it);

        cout << ans << endl;
        //cout << "Case #" << caseIdx << ": " << ans << endl;
    }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll S = nextLong();
  ll P = nextLong();

  for (ll a = 1; a * a <= P; a++) {
    if (P % a == 0) {
      ll b = P / a;
      if (a + b == S) {
        return 1;
      }
    }
  }
  return 0;
}

int main() {

  bool ans = main2();
  cout << (ans ? "Yes":"No") << endl;

  return 0;
}

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define pb(a) push_back(a)
#define set0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dwn(i,a,b) for(int i=(a);i>=(b);i--)
#define INF 0x3f3f3f3f
typedef long long ll;

int main(){
	int T; cin>>T;
	while(T--){
		ll n; cin>>n;

		int d=0;
		while(n%2==0){
			n/=2;
			d++;
		}
		if(!d) puts("Odd");
		else if(d==1) puts("Same");
		else puts("Even");
	}
    return 0;
}


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

int main(){
	int n, m;
	cin>>n>>m;
	vector<int> w(n);
	rep(i, n) cin>>w[i];
	vector<P> lv;
	rep(i, m){
		int l, v;
		cin>>l>>v;
		lv.push_back(make_pair(l, v));
	}

	bool ng=false;

	int mnv=INT_MAX;
	for(P p : lv) mnv=min(mnv, p.second);
	rep(i, n) if(w[i]>mnv) ng=true;
	if(ng){
		cout<<(-1)<<endl;
		return 0;
	}

	sort(lv.begin(), lv.end());

	map<int, int> ma;
	for(P p : lv){
		int l=p.first, v=p.second;
		auto it=ma.lower_bound(v);
		vector<map<int, int>::iterator> dl;
		for(; it!=ma.end(); it++){
			dl.push_back(it);
		}
		for(auto it : dl) ma.erase(it);
		ma[v]=l;
	}

	// for(P p : ma) cout<<"ma"<< (p.first)<<" "<<(p.second)<<endl;
	auto mnl=[&](int w){
		auto it=ma.lower_bound(w);
		if(it==ma.begin()) return 0;
		else{
			it--;
			return it->second;
		}
	};

	vector<int> inds(n);
	rep(i, n) inds[i]=i;
	ll mn=LLONG_MAX;
	do{
		vector<ll> s(n+1);
		rep(i, n) s[i+1]=s[i]+w[inds[i]];
		// cout<<"w "; rep(i, n) cout<<w[inds[i]]<<" "; cout<<endl;
		// cout<<"s "; rep(i, n+1) cout<<s[i]<<" "; cout<<endl;
		vector<ll> dp(n);
		rep(i, n){
			rep(j, i){
				ll sw=s[i+1]-s[j];
				dp[i]=max(dp[i], dp[j]+mnl(sw));
				// cout<<"mn "<<i<<" "<<j<<" "<<mnl(sw)<<endl;
			}
		}
		mn=min(mn, dp[n-1]);
	} while(next_permutation(inds.begin(), inds.end()));

	cout<<mn<<endl;
	return 0;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 ss, pp, ans = 0;
	cin >> ss >> pp;
	for(int64 ii = 1;ii * ii <= pp;ii++)
	{
		int64 jj = ss - ii;
		if(ii * jj == pp)
		{
			if(ii == jj)
			{
				ans--;
			}
			ans += 2;
		}
	}
	if(ans == 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>

using namespace std;

long long int N, K;

long long int num(long long int N, long long int k) {

	if (k <= N + 2) {
		return ((k - 2)*(k - 1)) / 2;
	}
	else if (k <= N * 2 + 1) {
		return ((k - 2)*(k - 1)) / 2 - ((k - 2 - N)*(k - 1 - N) * 3) / 2;
	}
	else if (k <= N * 3) {
		return ((N * 3 - k + 1)*(N * 3 - k + 2)) / 2;
	}

	return 0;

}

int cnt[10000];

long long int num2(long long int N, long long int m) {
	if (m <= N + 1) { return m - 1; }
	else if(m<=N*2) { return N * 2 - m + 1; }
	return 0;
}

int main(void) {

	cin >>N >> K;

	/*for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 1; k <= N; k++) {
				cnt[i + j + k]++;
			}
		}
	}

	for (int k = 3; k <= N*3; k++) {
		cout << "k= " << k << " " << num(N, k) << " "<<cnt[k]<< endl;
	}*/

	int k = 3;

	while (K > num(N, k)) {
		K -= num(N, k); k++;
	}

	//cout << "k= " << k << endl;

	long long int m = k - 1;
	while (K > num2(N, m)) {
		K -= num2(N, m); m--;
	}

	//cout << "m= " << m << endl;

	long long int ans1, ans2, ans3;

	ans1 = k - m;

	//cout << "K= " << K << endl;

	vector<pair<long long int, long long int> > V;
	for (long long int i = 1; i <= N; i++) {
		long long  int x = i; long long int y = m - x;
		if (1 <= x && x <= N && 1 <= y && y <= N) { V.push_back(make_pair(x, y)); }
	}

	ans2 = V[K - 1].first;
	ans3 = V[K - 1].second;

	cout << ans1 << " " << ans2 << " " << ans3 << endl;

	return 0;
}

/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<22;
int N;
LL K;
LL dp[4][SIZE];
void solve() {
    dp[0][0]=1;
    FOR(i,1,3){
        REPP(j,1,SIZE){
            dp[i-1][j]+=dp[i-1][j-1];
        }
        REPP(j,1,SIZE){
            if(j<=N){
                dp[i][j]=dp[i-1][j-1];
            }else{
                dp[i][j]=dp[i-1][j-1]-dp[i-1][j-N-1];
            }
        }
        for(int j=SIZE-1;j>0;j--){
            dp[i-1][j]-=dp[i-1][j-1];
        }
    }
    FOR(i,3,3*N){
        if(K<=dp[3][i]){
            FOR(j,1,N){
                if(K<=dp[2][i-j]){
                    FOR(k,1,N){
                        if(i-j-k<=N&&i-j-k>0){
                            K--;
                            if(!K){
                                W(j,k,i-j-k);
                                exit(0);
                            }
                        }
                    }
                }else{
                    K-=dp[2][i-j];
                }
            }
        }else{
            K-=dp[3][i];
        }
    }
}
void input() {
    R(N,K);
}
int main(){
    input();
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#define int ll

const int N = 1e6;
int tn, n, p[N];
vector<int> ans;

bool can(int i) {
	assert(1 <= i && i < n);
	return (int)ans.size() % 2 == (i - 1) % 2;
}
void sh(int i) {
	assert(can(i));
	ans.emplace_back(i);
	swap(p[i - 1], p[i]);
}
// 1 2 3
// 2 1 3
// 2 3 1
// 3 2 1
// 3 1 2
// 1 3 2

void lo(int i) {
	assert(!can(i));
	if (i >= 2) {
		sh(i - 1), sh(i), sh(i - 1), sh(i), sh(i - 1);
	} else {
		sh(i + 1), sh(i), sh(i + 1), sh(i), sh(i + 1);
	}
}

void x2(int i) {
	assert(!can(i));
	assert(i >= 2);
	sh(i - 1), sh(i), sh(i - 1), sh(i);
}

void print() {
	for (int j = 0; j < n; ++j) {
		cout << p[j] << " ";
	}
	cout << endl;
}

void solve() {
	if (n == 2) {
		if (p[0] > p[1]) {
			assert(can(1));
			sh(1);
		}
		return;
	}
	// for (int i = 0; i < n; ++i) {
	// 	cout << p[i] << " ";
	// }
	// cout << endl;
	for (int from = 1; from < n; ++from) {
		int i = from;
		if (p[i] >= p[i - 1]) {
			continue;
		}
		// cout << "st " << i << endl;
		if (!can(i)) {
			if (can(n - 1)) {
				sh(n - 1);
			} else if (from != n - 1) {
				assert(can(n - 2));
				sh(n - 2);
			}
		}
		// print();
		while (i && p[i] < p[i - 1]) {
			if (can(i)) {
				sh(i);
			} else if (i >= 2 && p[i] < p[i - 2]) {
				x2(i);
				--i;
			} else {
				lo(i);
			}
			--i;
		}
		// print();
	}
	assert(is_sorted(p, p + n));
	assert((int)ans.size() <= n * n);
}

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> tn;
	while (tn--) {
		cin >> n;
		for (int i = 0; i < n; ++i) {
			cin >> p[i];
		}
		ans.clear();
		solve();
		cout << ans.size() << "\n";
		for (int e : ans) {
			cout << e << " ";
		}
		cout << "\n";
	}
	return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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

void solve(){
  int n; cin >> n;
  vi p(n);
  rep(i, n) cin >> p[i];

  vi ans;
  int i = 1;
  bool isodd = false;
  int even = (n - 1) - (n % 2) - 1;
  int odd = (n - 1) - !(n % 2) - 1;
  while(i < n - 1) {
    int idx = find(ALL(p), i) - p.begin();
    if(i - 1 == idx) {
      i++;
      continue;
    }
    if((idx - 1) % 2 != isodd) {
      if(isodd) {
        ans.push_back(odd + 1);
        swap(p[odd], p[odd+1]);
      } else {
        ans.push_back(even + 1);
        swap(p[even], p[even+1]);
      }
    } else {
      ans.push_back(idx);
      swap(p[idx - 1], p[idx]);
    }
    isodd ^= true;
  }

  if(p[n - 1] == n - 1) {
    if(isodd == (n - 2) % 2) {
      ans.push_back(n - 1);
    } else {
    ans.push_back(n - 2);
    ans.push_back(n - 1);
    ans.push_back(n - 2);
    ans.push_back(n - 1);
    ans.push_back(n - 2);
    }
  }

  cout << ans.size() << endl;
  rep(i, ans.size()) {
    if(i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  ll t;
  cin >> t;
  rep(ghrskj, t) solve();
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
ofstream file("debug.txt");
#define debug(x) file << (#x) << " = " << x << endl << flush
#define sz(x) (int)x.size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef long double ld;
template<typename Int>
ostream& operator<<(ostream &s, const vector<Int> &v) {
	s << '[';
	for (auto i = v.begin(); i != v.end(); i++) {
		s << *i;
		if (i != prev(v.end()))
			s << ", ";
	}
	s << ']';
	return s;
}
template<typename Int, typename INT>
ostream& operator<<(ostream &s, const map<Int, INT> &mp) {
	s << '[';
	for (auto &i : mp) {
		s << '[' << i.first << ", " << i.second << ']';
		if (i != *mp.rbegin())
			s << ", ";
	}
	s << ']';
	return s;
}
template<typename Int>
ostream& operator<<(ostream &s, const set<Int> &st) {
	s << '[';
	for (auto &i : st) {
		s << i;
		if (i != *st.rbegin())
			s << ", ";
	}
	s << ']';
	s << endl;
	return s;
}
template<typename Int, typename INt>
ostream& operator<<(ostream &s, const pair<Int, INt> &x) {
	s << '[' << x.first << ", " << x.second << ']';
	return s;
}
template<typename T>
void print(T *x, int n) {
	for (int i = 0; i < n; i++) {
		file << x[i] << " \n"[i == n - 1];
	}
}
template<typename T>
ostream& operator<<(ostream &s, const complex<T> &a) {
	s << '(' << a.real() << ", " << a.imag() << ')';
	return s;
}
//	Always think of patterns (LCM, GCD)
//	Be careful of unsigned
//	Think of a solution that gets TLE and optimize it
//	Use binary search
//	Solve on paper first
//	Reverse Thinking
//	Monotonic stack/dequeue
//	EV is computed using probabilities or number of ways
//	E(X + Y) = E(X) + E(Y)
//	E(X * Y) = E(X) * E(Y)
//	If there's an equation, transform it into an easy one
//	READ ALL PROBLEMS
const int N = 3e3 + 5;
const int MOD = 1e9 + 7;
int n, y[N][N], dp[N][N], mods[N];
ll x[N];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	clock_t START_TIME = clock();
#endif
	cin >> n;
	memset(y, -1, sizeof y);
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		x[i] += x[i - 1];
		y[i][1] = i;
	}
	for (int i = 2; i <= n; i++) {
		memset(mods, -1, i * 4);
		for (int j = n; j; j--) {
			mods[x[j] % i] = j;
			int &tmp = mods[x[j - 1] % i];
			if (~tmp)
				y[j][i] = tmp;
		}
	}
	/*
	 for (int i = 1; i <= n; i++)
	 for (int j = 1; j <= n; j++)
	 file << y[i][j] << "\t\n"[j == n];
	 */
	dp[1][1] = 1;
	for (int mod = 1; mod <= n; mod++)	// group number
		for (int idx = 1; idx <= n; idx++) {	// index
			int &ret = dp[mod][idx], &ed = y[idx][mod];
			dp[mod + 1][ed + 1] += ret;
			dp[mod + 1][ed + 1] %= MOD;
			if (ed != n) {
				dp[mod][ed + 1] += ret;
				dp[mod][ed + 1] %= MOD;
			}
		}
	/*
	 for (int i = 1; i <= n; i++)
	 for (int j = 1; j <= n; j++)
	 file << dp[i][j] << " \n"[j == n];
	 */
	int ans = 0;
	for (int i = 1; i <= n + 1; i++)
		ans = (ans + dp[i][n + 1]) % MOD;
	cout << ans;
#ifndef ONLINE_JUDGE
	printf("\n// Time taken = %.3f ms",
			(clock() - START_TIME) * 1e3 / CLOCKS_PER_SEC);
#endif
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define ll long long
#define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr))
#define RF(type, i, a, b, decr) for (type i = a; i >= (type)(b); i -= (type)(decr))
#define sz(a) sizeof(a)
#define deb(a) cerr << " [" << #a << "->" << a << "] "
#define next_line cerr << '\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for (auto it = s.begin(); it != s.end(); it++)
#define setbits(x) __builtin_popcountll(x)
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

/*
1. If you cannot approach a problem
directly in the way it is proposed
then try to think from backwards
2. Have you checked the implementation
before starting to write the code?
3. Have you read the question carefully ?
4. Keep the names of variable descriptive.
5. Check the types and range of the values properly
6. Erase a iterator in the set or map only after using its value.
7. 1 bitset of 1e9 size only takes 256 mb.
8. Try to use global variables in case of recursion
9. Short and precise exectutes faster
*/

int INF = 1e16;
// graph[i] = stores the vectors of [neighbour, weight]
void DijikstraWithQueue(vector<int> &ans, vector<vector<vector<int> > > &graph, int s, int n)
{
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int>> > frontier;
    frontier.push(make_pair(0, s));
    ans.assign(n, INF);
    ans[s] = 0;
    vector<bool> visited(n, false);
    while(!frontier.empty())
    {
        int node = frontier.top().second, dis = frontier.top().first;
        frontier.pop();
        visited[node] = true;
        if(ans[node] != dis)
            continue;
        if(ans[node] == INF)
            break;
        for(vector<int> e : graph[node])
        {
            if(!visited[e[0] ])
            {
                //ans[e[0] ], e[0]
                int nx = (((ans[node] % e[2]) != 0LL) + (ans[node ] / e[2])) * e[2];
                if(ans[e[0] ] > nx + e[1])
                {
                    ans[e[0] ] = nx + e[1];
                    frontier.push(pair<int,int>(ans[e[0] ] , e[0]));
                }
            }
        }
    }
}

void solve()
{
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<vector<vector<int> > > graph(n);
    F(int, i, 1, m, 1){
        int a, b,k,t;
        cin >> a >> b >> t >> k;
        a--;
        b--;
        graph[a].push_back(vector<int>{b, t, k});
        graph[b].push_back(vector<int>{a, t, k});
    }
    vector<int> ans(n);
    x--;
    y--;
    DijikstraWithQueue(ans, graph, x, n);
    if(ans[y] == INF)
        cout << "-1\n";
    else
        cout << ans[y] << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        // freopen("Debug.txt", "w", stderr);
    #else
    #endif
    // cout << fixed << setprecision(10);
    // int _t;
    // cin>>_t;
    // while(_t --)
        solve();
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

template<typename T>
struct SegmentTree{
    typedef function<T(T,T)> F;
    int n;    //要素数
    F f;    //2項演算
    T e;    //単位元
    vector<T> dat;
    SegmentTree(int n_,F f,T e):f(f),e(e){
        init(n_);
        build();
    }
    SegmentTree(int n_,F f,T e,vector<T>& v):f(f),e(e){
        init(n_);
        build(n_,v);
    }
    void init(int n_){
        n=1;
        while(n<n_)n<<=1;
        dat.clear();
        dat.resize(n<<1, e);
    }
    void build(int n_,const vector<T>& v){
        for(int i=0;i<n_;++i)dat[n+i]=v[i];
        build();
    }
    void build(){
        for(int i=n-1;i>=1;--i){
            dat[i] = f(dat[i<<1],dat[i<<1|1]);
        }
    }
    void update(int k,const T& x){
        dat[k+=n]=x;
        while(k>>=1){
            dat[k] = f(dat[k<<1],dat[k<<1|1]);
        }
    }
    T query(int a,int b){
        T l=e,r=e;
        for(a+=n,b+=n;a<b;a>>=1,b>>=1){
            if(a&1)l=f(l,dat[a++]);
            if(b&1)r=f(dat[--b],r);
        }
        return f(l,r);
    }
    T operator[](const int &k) const {
        return dat[n+k];
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 h,w,m;
  cin >> h >> w >> m;
  vector<vector<int64>> ys(w),xs(h);
  REP(i,m){
    int64 y,x;
    cin >> y >> x;
    --y;--x;
    // chmin(ys[x],y);
    // chmin(xs[y],x);
    ys[x].emplace_back(y);
    xs[y].emplace_back(x);
  }
  REP(i,w){
    ys[i].emplace_back(h);
    sort(all(ys[i]));
  }
  REP(j,h){
    xs[j].emplace_back(w);
    sort(all(xs[j]));
  }

  int64 ans = 0;
  SegmentTree<int64> st(w+1,[](int64 a, int64 b){return a+b;},0);
  REP(i,xs[0][0])st.update(i,1);
  REP(y,h){
    for(auto x : xs[y])
      st.update(x,0);
    if(y < ys[0][0]){
      ans += xs[y][0];
      ans += st.query(xs[y][0],w);
    }else{
      ans += st.query(0,w);
    }
  }
  ANS(ans);
  return 0;
}

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

#define rng(x) x.begin(), x.end()
#define maxi(x, y) x = max(x, (y))
#define mini(x, y) x = min(x, (y))
#define pb push_back
#define F first
#define S second
#define el '\n'
#define int long long
#define SZ(x) ((int)(x).size())
template<typename T>
istream&operator>>(istream&is,vector<T>&v){for(auto&it:v)is>>it;return is;}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.F << "," << P.S << ")"; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ "; for(auto s:S) os<<s<<" "; return os<<"}"; }
#ifndef ONLINE_JUDGE
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define db(...)
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr<<name<<" : "<<arg1<<'\n';}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" |";__f(comma+1, args...);}
typedef pair<int,int> pi; typedef vector<int> vi; typedef vector<vi> vvi;

/*-----------------------------Code Begins--------------------------------*/

class BIT{
public :
    int n;
    vi f;
    BIT(int n){
        this->n = n + 1000;
        f.assign(n, 0);
    }

    int get(int pos){
        int res = 0;
        for (; pos >= 0; pos = (pos & (pos + 1)) - 1){
            res += f[pos];
        }
        return res;
    }

    int get(int l, int r){
        return get(r) - get(l - 1);
    }

    void increase(int pos, int val){
        for (; pos < SZ(f); pos = (pos | (pos + 1))) {
            f[pos] += val;
        }
    }
};

void solve(){
    int n, m; cin>>n>>m;

    vi up(m, n), left(n, m);

    vi cols[n];

    int b; cin>>b;

    int l = m, d = n;

    while(b--){
        int i, j; cin>>i>>j;
        i--, j--;

        cols[i].pb(j);

        mini(up[j], i);
        mini(left[i], j);

        if(i == 0){
            mini(l, j);
        }
        if(j == 0){
            mini(d, i);
        }
    }

    int ans = 0;
    for(int j = 0; j < l; ++j){
        ans += up[j];
        assert(up[j] > 0);
    }

    db(ans, d, l);

    BIT bit(m);

    for(int j = l; j < m; ++j){
        bit.increase(j, 1);
    }

    for(int i = 0; i < d; ++i){
        ans += bit.get(0, left[i] - 1);
        for(int j : cols[i]){
            if(bit.get(j, j)){
                continue;
            }
            db(j);
            bit.increase(j, 1);
        }
    }

    cout<<ans<<el;
}

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


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define prime 998244353
#define watch(x) cout << (#x) << " = " << (x) << "\n"
#define printArray(arr,n) for(int i=0;i<n;i++) cout << (#arr) << "[" << i << "]" << " = " << (arr[i]) << "\n"
#define printMatrix(arr,m,n) for(int i=0;i<m;i++) for(int j=0;j<n;j++) cout << (#arr) << "[" << i << "]" << "[" << j << "]" << " = " << (arr[i][j]) << "\n"

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

    int T;
    //cin>>T;
    T=1;
    while(T--){
    	//Code
    	ll a,b,c;
    	cin>>a>>b>>c;

    	ll ans = 1,A,B,C;
    	A = (a*(a+1))/2;
		A%=prime;
		B = (b*(b+1))/2;
		B%=prime;
		C = (c*(c+1))/2;
		C%=prime;

		ans = A*B;
		ans%=prime;
		ans*=C;
		ans%=prime;

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

/*** "Bismillahir Rahmanir Raheem" ***/
/*** "ALHAMDULILLAH for Everything" ***/
/*** "Md. Al Asad Nur Riyad" ***/
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
*/

#include<bits/stdc++.h>
using namespace std;
#define  fastt      ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  case(x)    cout << "Case " << x <<": "
#define  all(qz)    qz.begin(),qz.end()
#define  rall(qz)   qz.rbegin(),qz.rend()
#define  Sqr(x)     ((x) * (x))

#define  mod        998244353
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
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));}

/** Functions Start **//*
TP inline F setBit(F mask, S pos) { return mask |= ((F)1 << pos) ; }
TP inline bool getBit(F mask, S pos) { return (bool)(mask & ((F)1 << pos)) ; }
TP inline F resetBit(F mask, S pos) { return mask &= (~((F)1 << pos)) ; }
TP inline F toggleBit(F mask, S pos){ return mask ^= ((F)1 << pos) ; }
*/
ll egcd(ll a,ll b,ll &x,ll &y){if(b==0){x=1;y=0;return a;}ll x1,y1;ll gcd=egcd(b,a%b,x1,y1);x=y1;y=x1-y1*(a/b);return gcd;}
ll bigMod(ll a,ll b){a%=mod;ll res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}

inline ll MOD(ll a){ return (a%mod + mod) %mod ; }
inline ll modAdd(ll a,ll b){ return MOD( MOD(a) + MOD(b) ) ; }
inline ll modSub(ll a,ll b){ return MOD( MOD(a) - MOD(b) ) ; }
inline ll modMul(ll a,ll b){ return MOD( MOD(a) * MOD(b) ) ; }
inline ll modInv(ll a){ return bigMod(a,mod-2) ; }
/** Functions End **/

/** Direction Array **//*
int dx[]={-1, 0, 0, 1};
int dy[]={0, -1, 1, 0};
int dx1[]={-1, -1, -1, 0, 0, 0, 1, 1, 1};
int dy1[]={-1, 0, 1, -1, 0, 1, -1, 0, 1};
/** Direction Array ends **/

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/
/*-----------------------------------------------------*/

int main()
{
    fastt

    ll a,b,c;
    cin>>a>>b>>c;
    a=(a*(a+1))/2;
    b=(b*(b+1))/2;
    c=(c*(c+1))/2;
    cout<<modMul(a,modMul(b,c))<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using Int = long long;
const Int INF=1e18;

int main(){
    int n,m;cin>>n>>m;
    map<int,pair<int,int>>list;

    rep(i,n){
        int x;cin>>x;
        list[x]=make_pair(1,0);
    }

    rep(i,m){
        int x;cin>>x;
        pair<int,int>y=make_pair(1,0);
        if(!list.count(x)){
            list[x]=make_pair(0,1);
        }
        else if(list[x]==y){
            list[x].second=1;
        }
    }

    pair<int,int>a,b;
    a=make_pair(1,0);
    b=make_pair(0,1);

    for(auto L:list){
        if(L.second==a||L.second==b){
            cout<<L.first<<" ";

        }
    }
    return 0;

}

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << ' '
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

int main(){
    ll h,w;
    cin >> h >> w;

    vector<vector<int>> s(h);

    loop(i,h){
        loop(j,w){
            char c;
            cin >> c;
            if(c == '#') {
                s[i].push_back(1);
            }else{
                s[i].push_back(0);
            }
        }
    }

    ll ans = 0;

    loop(i, h - 1){
        loop(j, w - 1){
            int tmp = s[i][j] + s[i + 1][j] + s[i][j + 1] + s[i + 1][j + 1];
            if(tmp == 1 || tmp == 3) ans++;
        }
    }

    cout << ans << endl;
}


#define TO_BE_SUBMITTED
#include <bits/stdc++.h>
// #include <atcoder/fenwicktree>
// #include <atcoder/segtree>
// #include <atcoder/lazysegtree>
// #include <atcoder/string>
// #include <atcoder/math>
// #include <atcoder/convolution>
// #include <atcoder/modint>
// #include <atcoder/dsu>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/scc>
// #include <atcoder/twosat>

namespace atcoder{};
using namespace atcoder;
using namespace std;

#define fr first
#define sc second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (n); i >= 1; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define snuke srand((unsigned)clock() + (unsigned)time(NULL));
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vlp = vector<LP>;
inline int getInt()
{
    int x;
    scanf("%d", &x);
    return x;
}
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll N;
vl T, L, R;
vl Xs;
vl x2LNum, x2ExclusiveLNum, x2RNum, x2ExclusiveRNum;

void solve()
{
    cin >> N;
    rep(i, N){
        ll t, l, r;
        cin >> t >> l >> r;
        T.pb(t);
        L.pb(l);
        R.pb(r);
        Xs.pb(l);
        Xs.pb(r);
    }
    N = sz(L);
    sort(rng(Xs));
    uni(Xs);

    x2LNum = vl(sz(Xs), 0);
    x2ExclusiveLNum = vl(sz(Xs), 0);
    x2RNum = vl(sz(Xs), 0);
    x2ExclusiveRNum = vl(sz(Xs), 0);

    rep(i, N){
        L[i] = lower_bound(rng(Xs), L[i]) - Xs.begin();
        R[i] = lower_bound(rng(Xs), R[i]) - Xs.begin();
        if(T[i] == 1LL){
            x2LNum[L[i]]++;
            x2RNum[R[i]]++;
        }
        if(T[i] == 2LL){
            x2LNum[L[i]]++;
            x2ExclusiveRNum[R[i]]++;
        }
        if(T[i] == 3LL){
            x2ExclusiveLNum[L[i]]++;
            x2RNum[R[i]]++;
        }
        if(T[i] == 4LL){
            x2ExclusiveLNum[L[i]]++;
            x2ExclusiveRNum[R[i]]++;
        }
    }

    ll cnt = 0;
    ll ans = 0;

    rep(x, sz(Xs)){
        cnt -= x2ExclusiveRNum[x];
        rep(_, x2LNum[x]){
            ans += cnt;
            cnt++;
        }
        cnt -= x2RNum[x];
        rep(_, x2ExclusiveLNum[x]){
            ans += cnt;
            cnt++;
        }
    }

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

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}

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

const int maxn=2000;
int N;
struct Segment{
	int t,l,r;
	Segment(int at,int al,int ar):t(at),l(al),r(ar){}
};
vector<Segment>segs;
bool comp(Segment a,Segment b){
	if(a.l!=b.l){
		return a.l<b.l;
	}else{
		return a.r<b.r;
	}
}
long total;
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	while(cin>>N){
		segs.clear();
		int ct,cl,cr;
		for(int i=0;i<N;i++){
			cin>>ct>>cl>>cr;
			segs.push_back(Segment(ct,cl,cr));
		}
		sort(segs.begin(),segs.end(),comp);//The left endpoint is sorted
		total=0;
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				if(segs[i].r>segs[j].l){//The segment intersects
					total++;
				}else if(segs[i].r==segs[j].l){//The endpoint is on the same place
					//t=1 = []
					//t=2 = [)
					//t=3 = (]
					//t=4 = ()
					//1,3 = both ]
					//1,2 = both [
					if(segs[i].t%2==1 && segs[j].t<=2){//The intersecting endpoints are both included
						total++;
					}else{
						continue;
					}
				}else{//if segs[i].r < segs[j].l, then i++
					break;
				}
			}
		}
		//Finished checking segments
		cout<<total<<'\n';
	}
}


//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (n < 0) {
		ll res = mod_pow(x, -n, m);
		return mod_pow(res, m - 2, m);
	}
	if (abs(x) >= m)x %= m;
	if (x < 0)x += m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) { a = a / b; return a; }
const int max_n = 1 <<23;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}

void solve() {
	int n, m, k; cin >> n >> m >> k;
	if (n > m + k) {
		cout << 0 << "\n";
		return;
	}
	modint ans = comb(n + m, n);
	ans -= comb(n+m, n-k-1);
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	init_f();
	//init(); cout << ps.size() << "\n";
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <fstream>
#include <map>
#include <set>
#include <queue>
#include <memory.h>

using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PI;
typedef vector<PI> VPI;

#define FOR(i,a,n) for (int i = (a); i < (n); ++i)
#define FORE(i,a,n) for (int i = (a); i <= (n); ++i)
#define FORD(i,a,b) for (int i = (a); i >= (b); --i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FORE(i,0,n)
#define LL long long
#define FIR(n) REP(i,n)
#define FJR(n) REP(j,n)
#define ALL(v) v.begin(), v.end()

#define FI FIR(n)
#define FJ FJR(n)
#define FR(i,a) FOR(i,a,n)
#define REPN(i) REP(i,n)

#define GI(n) scanf("%d", &n)
#define GI2(n,m) scanf("%d %d", &n, &m)

LL a[300500];

int main() {
#ifdef LOCALF
	freopen("input.txt", "rt", stdin);
#endif
	ios::sync_with_stdio(false); cin.tie(0);

	int n; cin >> n;
	int v;
	LL s = 0;
	FI{
		cin >> v; a[i] = v;
		s += v;
	}

	LL res = 0;
	FI res += (n-1)*a[i] * a[i];

	FI res -= a[i] * (s - a[i]);
	cout << res << endl;

}