#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,K,C[31][61];
int main(){
	cin>>n>>m>>K;K--;
	for(int i=0;i<=60;i++){
		C[0][i]=1;
		for(int j=1;j<=30&&j<=i;j++)C[j][i]=C[j][i-1]+C[j-1][i-1];
	}
	int t=0;
	for(int i=1;i<=n+m;i++){
		if(K>=C[m-t][n+m-i])K-=C[m-t][n+m-i],cout<<'b',t++;
		else cout<<"a";
	}
}

#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define RREP(i, n) for(int i=(n);i>=0;--i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, b) for(int i=(a);i>=(b);--i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

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

template <class T>
void debug(const vector<T> &v) {
  cout << "[";
  REP(i, SZ(v)) {
    if(i) cout << ", ";
    cout << v[i];
  }
  cout << "]" << endl;
}

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

template <class T, class U>
void debug(const pair<T, U> &p) {
  cout << "(" << p.first << " " << p.second << ")" << endl;
}

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 (b < a) {
    a = b;
    return true;
  }
  return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int inf = INT_MIN;
const ll linf = LLONG_MIN;
const ld eps = 1e-9;

const int MAX_C = 61;
long long Com[MAX_C][MAX_C];

void calc_com() {
  memset(Com, 0, sizeof(Com));
  Com[0][0] = 1;
  for (int i = 1; i < MAX_C; ++i) {
    Com[i][0] = 1;
    for (int j = 1; j < MAX_C; ++j) {
      Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]);
    }
  }
}

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

  ll a, b, k; cin >> a >> b >> k;
  string ans = "";

  calc_com();

  ll rem = b;
  REP(i, a + b - 1) {
    if(Com[a + b - i - 1][rem] + 1 <= k) {
      ans += 'b';
      k -= Com[a + b - i - 1][rem];
      rem--;
    } else {
      ans += 'a';
    }
  }
  if(rem != 0) ans += 'b';
  else ans += 'a';
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MAXN 200010
using namespace std;
vector<pair<ll,ll> > cp(MAXN),dp(MAXN);
ll n;
void All()
{
    for (ll i=0;i<=n;i++)
        cp[i]=make_pair(INT_MAX,INT_MIN);
}
int main()
{
    ///ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll x,c;
    cin >> n;
    All();
    dp[0].first=0;
    dp[0].second=0;
    ///for (ll i=1;i<=n;i++)
    ///{
    ///    cout << i << " cp " << cp[i].first << " " << cp[i].second << "\n";
    ///}
    for (ll i=1;i<=n;i++)
    {
        cin >> x >> c;
        cp[c].first=min(cp[c].first,x);
        cp[c].second=max(cp[c].second,x);
    }
    /**for (ll i=1;i<=n;i++)
    {
        if (cp[i].first==INT_MAX)
            continue;
        cout << i << " cp " << cp[i].first << " " << cp[i].second << "\n";
    }**/
    ll p=0;
    cp[p].first=0;
    cp[p].second=0;
    for (ll i=1;i<=n;i++)
    {
        if (cp[i].first==INT_MAX)
            continue;
        dp[i].first=min(dp[p].first+abs(cp[p].first-cp[i].second),dp[p].second+abs(cp[p].second-cp[i].second))+abs(cp[i].first-cp[i].second);
        dp[i].second=min(dp[p].first+abs(cp[p].first-cp[i].first),dp[p].second+abs(cp[p].second-cp[i].first))+abs(cp[i].first-cp[i].second);
        p=i;
    }
    cout << min(dp[p].first+abs(cp[p].first),dp[p].second+abs(cp[p].second)) << "\n";
    return 0;
}

//インクルード(アルファベット順)
#ifndef TEMPLATE
#define TEMPLATE
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<ctime>
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
#include<cstdint>
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

#endif // TEMPLATE

int main(){
    ll N;
    cin >> N;
    vector<ll> X(N),C(N);
    REP(i,N){
        cin >> X[i] >> C[i];
    }
    vector<pair<ll,ll> > p(N);
    REP(i,N){
        p[i].first=C[i];
        p[i].second=X[i];
    }
    sort(p.begin(),p.end());
    ll count=1;
    ll tmp=p[0].first;
    vector<ll> l,r;
    l.push_back(p[0].second);
    REP(i,N){
        if(p[i].first!=tmp){
            count++;
            tmp=p[i].first;
            r.push_back(p[i-1].second);
            l.push_back(p[i].second);
    //        cout << p[i-1].second << " " <<p[i].second << endl;
        }
    }
    r.push_back(p[N-1].second);

    ll dp[count+1][2];
    dp[0][0]=0;
    dp[0][1]=0;
    ll nowl=0,nowr=0;
    for(ll i=1;i<count+1;i++){
        dp[i][0]=min(dp[i-1][0] + abs(r[i-1]-nowl)+abs(l[i-1]-r[i-1]),dp[i-1][1] + abs(r[i-1]-nowr)+abs(l[i-1]-r[i-1]));
        dp[i][1]=min(dp[i-1][0] + abs(l[i-1]-nowl)+abs(r[i-1]-l[i-1]),dp[i-1][1] + abs(l[i-1]-nowr)+abs(r[i-1]-l[i-1]));
        nowl=l[i-1];
        nowr=r[i-1];
    }
    ll ans = min(dp[count][0]+abs(nowl) , dp[count][1]+abs(nowr));
    //    answer("cout dp");
    //REP(i,4){
    //    cout << dp[i][0] << " " << dp[i][1] << endl;
   //}
    answer(ans);

    return 0;
}


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

//int target()

int looping(int cnt1, int depth, int res, int limdep, string N1){
    depth ++;

    //cout << limdep << " " << depth << " " << cnt1 << endl;
    if (res == -1){
        if (depth == limdep){
            if /*write conditon from here*/ ((stol(N1) % 3) == 0) /*to here*/ res = depth;
        }
        if (depth < limdep){
            for (int i = 0; i < cnt1; i++){
                //start opereation
                string N2 = N1;
                N2.erase(N2.begin() + i);
                //end operation
                int cnt2 = cnt1-1;//how many decrease the cnt value
                res = looping(cnt2,depth,res,limdep,N2);
            }
        }
    }
    return res;
}

int depth_search(int cnt1, string N1) {
    /*
    return the value of depth
    decresing its cnt number
    */

    int res = -1, depth =-1;
    for (int limdep = 0; limdep < cnt1; limdep++){
        res = looping(cnt1,depth,res,limdep,N1);
        if (res != -1) break;
    }
    return res;
}

int main(){
  string N;
  cin >> N;
  int siz = (int)N.length();
  int res;
  res = depth_search(siz,N);
  cout << res << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
#define trump(v,a) vector<ll> v(a); for(int i =0;i<a; ++i)cin>>v[i];
#define modi(v) for(auto i:v) cout<<i<<" ";
#define debug_pair(obg) for(auto i:obg) cerr<<i.F<<" "<<i.second<<endl;
#define F first
#define S second
#define p2 pair<ll,ll>
#define endl "\n"
#define pi ld(3.1415926536)

std::vector<ll> e;
void solve() {
	ll a = 1, b = 0, c = 0, t = 0, ans = 0, ans2 = 0, k = -1, c1 = 0, c2 = 0, c3, c4 , n = 0, m = 0, x = 2231131199;
	cin >> a;
	std::vector<ll> v = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
	std::vector<ll> y;
	for (int i = 1; i <= 32768; ++i)
	{
		/* code */
		k = i;
		ans = 1;
		t = 0;
		while (k) {
			c = k % 2;
			k /= 2;
			if (c) {
				ans *= v[t];
			}
			t++;

		}
		y.push_back(ans);
	}
	sort(y.begin(), y.end());
	trump(e, a);
	bool fl = 0, fl2 = 0;
	for (int i = 0; i < 32768; ++i)
	{
		/* code */
		fl2 = 1;
		for (auto j : e) {

			if (__gcd(y[i], j) == 1) {
				fl2 = 0;
				break;
			}
		}
		if (fl2) {
			cout << y[i];
			return;
		}

	}

}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t z = clock();
	ll qc = 1;
	// cin >> qc;
	for (ll i = 1; i <= qc; i++)
		solve();

	debug("Total Time: % .4Lf\n", (ld)(clock() - z) / CLOCKS_PER_SEC);
}

/*
some good points to think :-
1) Why are you alive
2) Is the array overflowing
3) will you ever be able to solve a graph question.yay!
4) The answer will be trivial always if its not its not worth solving
5) for xor a^b  = a+b-2a&b xor of multi element set counts only odd no. of set bits
6) char values are '0' =48 'a' = 97 'A' = 65
7) two pointers are good way for array sum /length based questions
8) dp on sums?
9) make black boxes
10) min/max at central tandencies and just iterate +- 5 around it
11) Always use different array for coloring.
12) Null adjacency list will return from traversal.
13) Add once only in case of trees.
*/


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define For(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFor(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
#define co(a) cout<<a<<endl
#define ce(a) cerr<<a<<endl
#define Sort(a) sort((a).begin(),(a).end())
#define Rev(a) reverse((a).begin(),(a).end())
#define Unique(a) (a).erase(unique((a).begin(), (a).end()),(a).end())
#define cfs(a) cout<<fixed<<setprecision(a)

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

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

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    For(i, 0, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

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

constexpr ll INF = TEN(18);

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    bool is = false;
    For(i, 0, 1000000) {
        if (a + b * i <= c * i * d) {
            co(i);
            is = true;
            break;
        }
    }
    if (!is) {
        co(-1);
    }
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(10);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
#define delif(c,pred) (c).erase(remove_if(all(c),(pred)), end(c))
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cerr << #a << ": " << (a) << endl;
#define dbgs(s) cerr << #s << endl;
#define dbg1(a,n) cerr<<#a<<": "; rep(i,n) cerr<<(a)[i]<<" "; cerr<<endl;
#define dbg2(m,h,w) cerr<<#m<<":"<<endl; rep(i,(h)){ rep(j,(w))cerr<<(m)[i][j]<<" "; cerr<<endl; }
template <class T, class U> ostream& operator << (ostream& os, pair<T,U> v) {os<<v.first<<","<<v.second;return os;}
template <class T, size_t N> ostream& operator << (ostream& os, array<T,N> v) {rep(i,N)os<<v[i]<<(i+1<(ll)N?" ":"");return os;}
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }
inline constexpr int offset[] = {1,0,-1,0,1};

int main() {
    fastio;
    ll ans{};
    ll N;
    string s;
    cin >> N >> s;
    ll l = 0, r = N-1;
    rep(i,N-1) {
        if (s[l] != s[r]) {
            ++ans;
            break;
        }
        if (s[l] == s[i]) continue;
        if (s[i+1] == s[r]) continue;
        ++ans;
        l = i+1;
    }
    if (ans == 0) ans = -1;
    cout << ans << endl;
}


#include <bits/stdc++.h>
#include <chrono>

using namespace std;
using namespace chrono;

typedef long long int ll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)
#define Clock high_resolution_clock::now()

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
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...);
}
#else
#define trace(...)
#endif

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// #define TIME

/******************************************************************************************************************************/

const ll inf = 2e18;
const ll mod = 998244353;
const ll N = 10000;

int main()
{
    auto start_time = Clock;
    FASTIO

    ll n;
    cin >> n;
    vll t(n), v(n);
    vector<string> s(n);
    rep(i,n) {
        cin >> s[i] >> t[i];
        v[i] = i;
    }

    sort(all(v), [&](ll a, ll b){
        return t[a] < t[b];
    });

    cout << s[v[n-2]] << "\n";

    auto end_time = Clock;
    #ifndef TIME
        return 0;
    #endif
    cout << "\nTime elapsed: "
    << (double)duration_cast<milliseconds>(end_time-start_time).count()
    << "ms";

    return 0;
}

#include <bits/stdc++.h>

using namespace std;
int main()
{
    int N,first=0,second=0,findex=0,sindex=0;
    vector<string> s(1010);
    vector<int> t(1010);
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> s[i] >> t[i];
    }
    for (int i = 0; i < N; i++){

        if(first<t[i]){

            second = first;
            first=t[i];
            sindex=findex;
            findex=i;
        }
        else if(second<t[i]){
            second=t[i];
            sindex=i;
        }
    }
    cout << s[sindex]  <<endl;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int ans = 0;
  rep(i, h)rep(j, w){
    if (s[i][j] == '#') continue;
    if (j+1 < w) if (s[i][j+1] == '.') ans++;
    if (i+1 < h) if (s[i+1][j] == '.') ans++;
  }
  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

map<ll,ll> visits;
ll x,y,ans=inff;

void solve(ll y,ll cnt){
	queue<ll> q;
	q.push(y);
	visits[y]=1;
	while (!q.empty()){
		ll now=q.front(); q.pop();
		ans=min(ans,abs(x-now)+visits[now]-1);
		if (now&1){
			if (!visits[now+1]) visits[now+1]=visits[now]+1,q.push(now+1);
			if (!visits[now-1]) visits[now-1]=visits[now]+1,q.push(now-1);
		}
		else{
			if (!visits[now>>1]) visits[now>>1]=visits[now]+1,q.push(now>>1);
		}
	}
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>x>>y;
	solve(y,0);
	cout<<ans<<'\n';
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
// #define MOD (998244353)
#define INF (1e9+7)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pl(T x){cout << x << " ";}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, (int)a.size()-1){pl(a[i]);} pr(a.back());}
template<class T>void prarr(arr<T>& a){rep(i, (int)a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll modpow(ll a, ll n, ll p) {
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
    long long t = modpow(a, n / 2, p);
    return (t * t) % p;
    }

int main()
{
    ll n, m;
    cin >> n >> m;
    ll t = modpow(10, n, m*m);
    // modpow(10, 2, 2);
    pr((t/m)%m);
    return 0;}

#include<bits/stdc++.h>
#define int long long
using namespace std;
int mod=998244353;
const int sz=5e3+1;
int fac[sz];
int inv[sz];
int fpow(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans*=a;
            ans%=mod;
        }
        a*=a;
        a%=mod;
        b>>=1;
    }
    return ans;
}
int combo(int n,int r)
{
    if(n<r)
    {
        return 0;
    }
    return (((fac[n]*inv[r])%mod)*inv[n-r])%mod;
}
void precomp(int n)
{
    fac[0]=1;
    for(int i=1;i<=n;i++)
    {
        fac[i]=(fac[i-1]*i)%mod;
    }
    inv[0]=1;
    for(int i=1;i<=n;i++)
    {
        inv[i]=fpow(fac[i],mod-2);
    }
}
int dp[5001][5001];
int solve(int m,int k,int &n)
{
    if(m==0)
    {
        return 1;
    }
    if(m<k||m%k)
    {
        return 0;
    }
    if(dp[m][k])
    {
        return dp[m][k];
    }
    int ans=0;
    for(int i=0;i<=m;i+=k)
    {
        int te=solve(m-i,2*k,n)*combo(n,i/k*2);
        ans+=te;
        if(ans>mod)
        {
           ans%=mod;
        }
    }
    return dp[m][k]=ans;
}
signed main()
{
    int n,m;
    cin>>n>>m;
    precomp(n);
    if(n==1)
    {
        cout<<0;
    }
    else
    {
        cout<<solve(m,2,n);
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1e9+7
#define inf 1e18
#define N 1000043
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
#define pll pair<ll,ll>
#define int ll
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string str;
    cin >> str;
    vector<int>vec(n,0);
    bool x=false;
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int t,a,b;
        cin >> t >> a >> b;
        if(t==1){
            a--;b--;
            if(x)  {
                if(a<n)
                    a=n+a;
                else
                    a=a-n;
                if(b<n)
                    b=n+b;
                else
                    b=b-n;
            }
            swap(str[a],str[b]);
        }else{
            x=!x;
        }
    }
    if(x){
        for(int i=0;i<n;i++){
            swap(str[i],str[n+i]);
        }
    }
    cout << str << endl;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iterator>
#include <stack>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
using namespace std;

#define ll long long
#define double long double
#define vi vector<int>
#define vvi vector<vi>
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>

int main()
{
    ll n, q;
    string S;
    int rev = 0;
    int t, a, b;
    cin >> n;
    cin >> S;
    cin >> q;

    for (size_t i = 0; i < q; i++)
    {
        cin >> t >> a >> b;
        if (t == 1)
        {
            if (rev)
            {
                if (a > n)
                {
                    a -= n;
                }
                else
                {
                    a += n;
                }

                if (b > n)
                {
                    b -= n;
                }
                else
                {
                    b += n;
                }
            }
            swap(S[a - 1], S[b - 1]);
        }
        else
        {
            if (rev)
            {
                rev = 0;
            }
            else
            {
                rev = 1;
            }
        }
    }
    if (rev == 0)
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(n) << S.substr(0, n) << endl;
    }

    return 0;
}


//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int MOD=1000000007;

ll qexp(ll b,ll p,int m){
    ll res=1;
    while (p){
        if (p&1) res=(res*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return res;
}

ll inv(ll i){
	return qexp(i,MOD-2,MOD);
}

vector<vector<ll> > mul(vector<vector<ll> > i, vector<vector<ll> > j,int m){
    vector<vector<ll> > res;
    for (int x=0;x<i.size();x++){
        res.push_back(vector<ll>());
        for (int y=0;y<i.size();y++){
            res[x].push_back(0);
            for (int z=0;z<i.size();z++){
                res[x][y]=(res[x][y]+i[x][z]*j[z][y])%m;
            }
        }
    }
    return res;
}

vector<vector<ll> > mexp(vector<vector<ll> > mat,long long p,int m){
    if (p==1) return mat;
    vector<vector<ll> > res=mexp(mat,p>>1,m);
    res=mul(res,res,m);
    if (p&1) res=mul(res,mat,m);
    return res;
}

int n,m,k;
int arr[105];

vector<vector<ll> > mat;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);

	cin>>n>>m>>k;
	rep(x,0,n) cin>>arr[x];

	if (k==0){
		rep(x,0,n) cout<<arr[x]<<endl;
		return 0;
	}

	rep(x,0,n){
		mat.pub({});
		rep(y,0,n) mat[x].pub(0);
		mat[x][x]=1;
	}

	int a,b;
	rep(x,0,m){
		cin>>a>>b;
		a--,b--;

		mat[a][b]=inv(2*m%MOD);
		mat[b][a]=inv(2*m%MOD);
		mat[a][a]=(mat[a][a]-inv(2*m%MOD)+MOD)%MOD;
		mat[b][b]=(mat[b][b]-inv(2*m%MOD)+MOD)%MOD;
	}

	mat=mexp(mat,k,MOD);

	rep(x,0,n){
		int ans=0;
		rep(y,0,n) ans=(ans+mat[x][y]*arr[y])%MOD;

		cout<<ans<<endl;
	}
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7
#define INF LONG_MAX/3
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//class -> num
map<ll, ll> stu[200005];

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
	  // 最初は全てのデータiがグループiに存在するものとして初期化
	  for(int i = 0; i < n; i++){
		  par[i] = i;
	  }
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    for(auto item: stu[y]) stu[x][item.first] += item.second;
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

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

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

int main(){
	ll N, Q;
	cin >> N >> Q;
	vector<ll> C(N);
	rep(i, N) cin >> C[i];
	rep(i, N) {
		stu[i][C[i]]++;
	}
	UnionFind uf(N);

	rep(i, Q) {
		ll op, a, b;
		cin >> op >> a >> b;
		if(op == 1) {
			a--;b--;
			uf.unite(a, b);
		} else {
			a--;
			ll g = uf.find(a);
			cout << stu[g][b] << endl;
		}
	}
}


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

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

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

bool vio;
char IO;
int rd(int res=0){
	bool f=0;
	while(IO=getchar(),IO<48||IO>57)
		f|=IO=='-';
	do res=(res<<1)+(res<<3)+(IO^48);
	while(IO=getchar(),isdigit(IO));
	return f?-res:res;
}
const int M=2e5+10;
struct node{int x,id;};
vector<node>g[M];
int cnt[M],ans[M],dep[M],n,q;
int nxt[M],to[M],hd[M],ecnt;
void Add(int a,int b){
	nxt[++ecnt]=hd[a],to[hd[a]=ecnt]=b;
}
void dfs(int x,int f){
	rep(i,0,(int)g[x].size()-1)
		ans[g[x][i].id]-=cnt[g[x][i].x];
	dep[x]=dep[f]+1;
	cnt[dep[x]]++;
	erep(i,x)dfs(to[i],x);
	rep(i,0,(int)g[x].size()-1)
		ans[g[x][i].id]+=cnt[g[x][i].x];
}
bool let;
int main(){
	cerr<<(&vio-&let)/1024.0/1024<<endl;
	n=rd();
	rep(i,2,n)Add(rd(),i);
	q=rd();
	rep(i,1,q){
		int x=rd(),y=rd();
		g[x].push_back((node){y+1,i});
	}
	dfs(1,0);
	rep(i,1,q)printf("%d\n",ans[i]);
}

#ifdef DEBUG_BUILD
# define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#ifdef DEBUG_BUILD
# include "debugger.hpp"
#else
# define debug(...)
# define debugdo(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using pll = std::pair<ll, ll>;
template <class T> using vec = std::vector<T>;
template <class T> using vec2 = std::vector<vec<T>>;
template <class T> using vec3 = std::vector<vec2<T>>;
#define rep(i, N) for (ll i = 0; i < (N); i++)
#define rrep(i, N) for (ll i = (N) - 1; i >= 0; i--)
#define range(i, A, B) for (ll i = (A); i < (B); i++)
constexpr int MOD = 1000000007;
constexpr ll INFL = std::numeric_limits<ll>::max();
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;
vec<ll> P;
vec2<ll> C;

vec<ll> In, Out, Depth;
ll timer = 0;

vec2<ll> List;

void dfs(const ll now) {
    In[now] = timer;
    timer++;
    List[Depth[now]].push_back(In[now]);
    for (ll to : C[now]) {
        Depth[to] = Depth[now] + 1;
        dfs(to);
    }
    Out[now] = timer;
    timer++;
}

void Main() {
    cin >> N;
    P.resize(N);
    C.resize(N);
    range(i, 1, N) {
        cin >> P[i];
        P[i]--;
        C[P[i]].push_back(i);
    }

    In.resize(N);
    Out.resize(N);
    Depth.resize(N);
    List.resize(N);
    dfs(0);

    debug(List);
    debug(In);
    debug(Out);
    debug(Depth);

    ll Q;
    cin >> Q;
    rep(q, Q) {
        ll u, d;
        cin >> u >> d;
        u--;

        const auto& v = List[d];
        debug(v);
        debug(In[u], Out[u], Depth[u]);

        cout << (
            lower_bound(v.begin(), v.end(), Out[u]) -
            lower_bound(v.begin(), v.end(), In[u])
        ) << "\n";
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    Main();
    std::cout << std::flush;
    std::cerr << "--end--" << std::flush;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define _LIBCPP_DEBUG 0 // clang
// #define _GLIBCXX_DEBUG // gcc
using namespace std;
using ll = long long;

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

    int res = (y * z - 1) / x;

    cout << res << '\n';

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using pld = pair<ld,ld>;
using vll = vector<ll>;
using vld = vector<ld>;
using vstr = vector<string>;
#define _GLIBCXX_DEBUG
#define rep(j, m) for (ll j = 0; j < (ll)(m); j++)
#define rep2(i, l, n) for (ll i = l; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
const ld PI = 3.1415926535897932;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
vll dx = {-1,0,1,0};
vll dy = {0,-1,0,1};
vll Dx = {-1,-1,-1,0,0,1,1,1};
vll Dy = {-1,0,1,-1,1,-1,0,1};
const ll INF = 1000000000000000;

int main() {
    ll X,Y,Z;
    cin >> X >> Y >> Z;
    cout << Z*Y/X - (1 - min(1LL,Z*Y%X)) << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b,c, d;
    cin>>a>>b>>c>>d;
    int ans = INT_MIN;
    for(int i=a;i<=b;i++)
    {
        for(int j=c;j<=d;j++)
            ans = max(ans, i-j);
    }
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for(ll i = (ll)(m); i < (ll)(n); i++)
#define rep_inv(i, n, m) for(ll i = (ll)(n); i > (ll)(m); i--)

int main(){
  ll a, b, c, d;

  cin >> a >> b;
  cin >> c >> d;

  cout << (b - c) << "\n";

  return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";

const string NO = "No";

ll multiplecount(ll A, ll B, ll X) {
    ll countA = (A - 1) / X;
    ll countB = B / X;
    ll ans = countB - countA;
    return ans;
}

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

    ll X = B - A;
    ll ans;

    for (ll i = X; i > 0; i--) {
        if (multiplecount(A, B, i) >= 2) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n,m;
LL a[200010],b[200010];
LL A[200010],B[200010],ans=1e18;
inline LL read()
{
	LL x=0,w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
LL Find(LL x)
{
	int L=1,R=n,M,T=1;
	while(L<=R){
		M=(L+R)>>1;
		if(a[M]<=x)T=M,L=M+1;
		else R=M-1;
	}
	return T;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;(i++)[a]=read());
	for(int i=1;i<=m;*(b+i++)=read());
	sort(a+1,a+1+n);
	//for(int i=1;i<=n;i++)
	//	cout<<a[i]<<' ';
	//cout<<endl;
	for(int i=2;i<=n;i+=2){
		B[i]=B[i-2];
		A[i+1]=A[i-1];
		B[i]+=a[i]-a[i-1];
		A[i+1]+=a[i+1]-a[i];
	}
	//for(int i=1;i<=n;i++){
	//	if(i&1)printf("%d ",A[i]);
	//	else printf("%d ",B[i]);
	//}
	//cout<<endl;
	for(int i=1;i<=m;i++){
		int pos=Find(b[i]);
		//cout<<b[i]<<','<<pos<<' ';
		if(pos&1){
			ans=min(ans,B[pos-1]+abs(a[pos]-b[i])+A[n]-A[pos]);
			ans=min(ans,B[pos-1]+abs(a[pos+1]-b[i])+abs(a[pos]-a[pos+2])+A[n]-A[pos+2]);
		}else{
			ans=min(ans,B[pos-2]+A[n]-A[pos+1]+abs(b[i]-a[pos])+abs(a[pos-1]-a[pos+1]));
			ans=min(ans,B[pos]+A[n]-A[pos+1]+abs(a[pos+1]-b[i]));
		}
		//cout<<ans<<'\n';
	}
	cout<<ans<<'\n';
}


#include <bits/stdc++.h>

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define FOR(i,a,b)  for(int i=(a); i< (b); ++i)
#define RFOR(i,b,a) for(int i=(b);i>=(a);i--)
#define REP(i,a,b)  for(int i=(a); i<=(b); ++i)
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
template<typename T>
void PrArr(const T a[] , int len){
	for(int i = 0;i <= len; i++)cout << a[i] << " ";
	cout << endl;
}
template<typename T>
void PrVec(const vector<T> a){
	for(auto it : a)cout << it << " ";
	cout << endl;
}
const int MAX = 0x7ffffff;
const int MIN = 0xcf;
int test;
void slove()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	// 1. 记录一下每个字符出现的次数
	map<char, int> mp;
	for(char c : s1) mp[c] ++;
	for(char c : s2) mp[c] ++;
	for(char c : s3) mp[c] ++;
	/*
	如果出现的字母数量大于10意味着要出现10个不同数字表示
	这样是不可能成立的，所以这种情况下一定不存在解
	*/
	if(mp.size() > 10) {
		cout << "UNSOLVABLE" << endl;
		return ;
	}

	// 获取到以上出现过哪些字母并组合成一个字符串
	string s0;
	for(auto p : mp) s0 += p.first;
	int m = s0.size();

	vector<int> v(10);
	for(int i = 0; i < 10 ; i++) v[i] = i;

	auto val = [&](char c) {
		for(int i = 0; i < m; i ++)
		{
			if(c == s0[i]) {
				return v[i];
			}
		}
		return -1;
	};

	do {
		// 此时数字包含前导0需要排除这种情况。
		if(val(s1[0]) == 0 || val(s2[0]) == 0 || val(s3[0]) == 0) {
			continue;
		}

		ll x1 = 0, x2 = 0, x3 = 0;

		for(auto c : s1) {
			x1 *= 10;
			x1 += val(c);
		}

		for(auto c : s2) {
			x2 *= 10;
			x2 += val(c);
		}

		for(auto c : s3) {
			x3 *= 10;
			x3 += val(c);
		}

		if(x1 + x2 == x3)
		{
			cout << x1 << endl;
			cout << x2 << endl;
			cout << x3 << endl;
			return ;
		}
	} while(next_permutation(v.begin(),v.end()));

	cout << "UNSOLVABLE" << endl;
}
int main()
{
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed; // 在iomanip中
#endif
	SIS;slove();
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string> vec(3);
  for(int i=0; i<3; i++){
    cin >> vec[i];
  }
  map<char,int> M;
  int cnt = 0;
  for(int i=0; i<3; i++){
    for(int j=0; j<vec[i].size(); j++){
      if(!M.count(vec[i][j])){
        M[vec[i][j]] = cnt;
        cnt++;
      }
    }
  }
  if(M.size() > 10){
    cout << "UNSOLVABLE" << endl;
    return 0;
  }
  vector<char> num = {'0','1','2','3','4','5','6','7','8','9'};
  do{
    vector<string> check = vec;
    for(int i=0; i<3; i++){
      for(int j=0; j<vec[i].size(); j++){
        check[i][j] = num[M[vec[i][j]]];
      }
    }
    if(check[0][0] == '0' || check[1][0] == '0' || check[2][0] == '0'){
      continue;
    }
    int64_t A = stoll(check[0]);
    int64_t B = stoll(check[1]);
    int64_t C = stoll(check[2]);
    if(A + B == C){
      cout << A << endl;
      cout << B << endl;
      cout << C << endl;
      return 0;
    }
  }while(next_permutation(num.begin(),num.end()));
  cout << "UNSOLVABLE" << endl;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> index_set;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>indexed_multiset;

#define ull         unsigned long long
#define ll          long long int
#define ld          long double
#define MOD         1000000007
#define pi          3.14159265358979323846
#define N           100005
#define sz(x)       ((int)(x).size())
#define test ll t;  cin >> t; while(t--)
#define all(x)      (x).begin(), (x).end()
#define ld          long double
#define bigint      int64_t
#define vll         vector<ll>
#define vpll        vector<pair<ll,ll>>
//#define mp          make_pair
#define pb          push_back
#define pll         pair<ll,ll>
#define vvll        vector<vector<ll>>
#define fi          first
#define se          second
#define ins         insert
#define endl        "\n"
#define rep(i,a,n)  for(ll (i) = a;(i) < (n); (i)++)
#define repn(i,a,n) for(ll (i) = a;(i) <= (n); (i)++)
#define repr(i,a,n) for(ll (i) = a;(i) >= (n); (i)--)

//-------------------DEBUGGING-----------------------

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
    vector<string> __attribute__ ((unused)) args,
    __attribute__ ((unused)) int idx,
    __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//-----------------------------------------------------------------------

//will upsolve from now on. Date: 24th Oct 2020, DIV2 round 678 upto D.

void solve() {
    ll n; cin >> n;
    vpll v;
    rep(i, 0, n) {
        ll x, y;
        cin >> x >> y;
        v.pb({x, y});
    }
    sort(all(v));
    repn(i, 0, n - 3) {
        repn(j, i + 1, n - 2) {
            repn(k, j + 1, n - 1) {
                ll a = v[i].fi, b = v[i].se;
                ll c = v[j].fi, d = v[j].se;
                ll e = v[k].fi, f = v[k].se;
                ll k1 = d - b, k2 = c - a, k3 = f - d, k4 = e - c;
                //if (k2 > 0 && k4 > 0) {
                if ((double)k1 / k2 == (double)k3 / k4 ) {
                    cout << "Yes\n";
                    return;
                }
                //}
            }
        }
    }
    cout << "No\n";
}

int main() {

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

    solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
#define ll long long int

bool iscolinear(int x1, int y1, int x2,
               int y2, int x3, int y3)
{
    int a = x1 * (y2 - y3) +
            x2 * (y3 - y1) +
            x3 * (y1 - y2);

    if (a == 0)
        return true;
    else
        return false;
}

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

	vector< pair<int,int> > a ;

	for(int i=0 ; i<n ; ++i)
	{
		int x,y;
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}

	for(int i=0 ; i<n ; ++i)
	{
		for(int j=i+1 ; j<n ; ++j)
		{
			for(int k=j+1 ; k<n ; ++k)
			{
				if(iscolinear(a[i].first,a[i].second,a[j].first,a[j].second,a[k].first,a[k].second))
					{
						cout<<"Yes\n";
						return ;
					}
			}
		}
	}
	cout<<"No\n";
}

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

		y=mx+c
		5=m5+c

*/


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define io ios::sync_with_stdio(false); cin.tie(0)

void print_vec(const vector<int>& vec) {
    int n = vec.size();
    cout << n << " ";
    rep(i, n) {
        cout << vec[i];
        if (i != n-1) cout << " ";
    }
    cout << endl;
}

int main()
{
    io;
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int x = min(n, 8);
    vector<vector<int>> cnt(200);
    rep(bit, 1 << x) {
        int s = 0;
        vector<int> temp;
        rep(i, x) {
            if (bit & (1 << i)) {
                temp.push_back(i+1);
                s += a[i];
                s %= 200;
            }
        }
        if (cnt[s].size()) {
            cout << "Yes" << endl;
            print_vec(cnt[s]);
            print_vec(temp);
            return 0;
        } else cnt[s] = temp;
    }
    cout << "No" << endl;
    return 0;
}

// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int ll
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define ll long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define vi vector<int>
#define pb push_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vi v(n);
	rep(i,n){
		cin>>v[i];
	}
	int offset = 0;
	map<int,int> mp;
	mp[v[0]]++;
	int ans = 0;
	repa(i,1,n){
		if(i%2 == 1){
			ans += mp[-offset+v[i]];
			offset -= v[i];
			mp[-v[i]-offset]++;
		}
		else{
			ans += mp[-offset-v[i]];
			offset += v[i];
			mp[-offset+v[i]]++;
		}
		// cout<<i<<" "<<ans<<"\n";
		// for(auto x:mp){
		// 	cout<<x.fi<<" "<<x.sec<<"\n";
		// }
		// // cout<<"\n";
		// cout<<offset<<" offset\n\n";
	}
	cout<<ans;
	return 0;
}


/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N=2e5+10;

inline int Rint(int &r){
	int b=1,c=getchar();r=0;
	while(c<'0' || '9'<c) b=c=='-'? -1:b,c=getchar();
	while('0'<=c && c<='9') r=(r<<1)+(r<<3)+(c^'0'),c=getchar();
	return r*=b;
}

int n,m,nstk,cnt;
int wei[N],now[N],uni[N],ans[N<<1][2],stk[N],fstk[N];
pair<int,int> lmt[N];
bool vis[N];

void Answer(int a,int b){
	a=lmt[a].second,b=lmt[b].second;
	ans[++m][0]=a,ans[m][1]=b;
	swap(now[a],now[b]);
}
int main(){
	Rint(n);
	for(int i=1;i<=n;i++) Rint(lmt[i].first),lmt[i].second=i;
	for(int i=1;i<=n;i++) Rint(wei[i]);
	for(int i=1;i<=n;i++) Rint(now[i]);
	for(int i=1;i<=n;i++)
		if(now[i]!=i && wei[now[i]]>=lmt[i].first){
			printf("-1\n");
			return 0;
		}
	sort(lmt+1,lmt+1+n);
	for(int i=1;i<=n;i++){
		uni[lmt[i].second]=i;
		if(lmt[i].second==now[lmt[i].second])
			vis[i]=true;
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			nstk=0;
			int tmp=i;
			while(true){
				stk[++nstk]=tmp;
				tmp=uni[now[lmt[tmp].second]];
				if(tmp==i) break;
			}
			fstk[cnt=1]=stk[1];
			for(int j=2;j<=nstk;j++)
				if(fstk[cnt]>stk[j]) Answer(fstk[cnt],stk[j]);
				else fstk[++cnt]=stk[j];
			for(int j=1;j<cnt;j++)
				Answer(fstk[j],fstk[cnt]);
		}
	//for(int i=1;i<=n;i++)
	//	printf("%d %d\n",i,now[i]);
	printf("%d\n",m);
	for(int i=1;i<=m;i++)
		printf("%d %d\n",ans[i][0],ans[i][1]);
	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

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

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

using ll = long long;
using ld = long double;

#define mp make_pair
/*
int p =  1e9 + 7;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

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

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, ll deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}*/

mt19937 rnd(time(0));

/*
const int N = 2000005;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

/*struct DSU
{
    vector<int> sz;
    vector<int> parent;
    vector<bool> cycle;
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    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) cycle[a] = true;
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
            if (cycle[b]) cycle[a] = true;
        }
    }

    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        cycle.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};*/

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

    int n; cin>>n;
    vector<int> a(n), b(n), p(n);
    for (int i = 0; i<n; i++) cin>>a[i];
    for (int i = 0; i<n; i++) cin>>b[i];
    for (int i = 0; i<n; i++) {cin>>p[i]; p[i]--;}

    vector<int> have(n);
    for (int i = 0; i<n; i++) have[i] = b[p[i]];

    for (int i = 0; i<n; i++) if (a[i]<=have[i] && p[i]!=i) {cout<<-1; return 0;}

    vector<pair<int, int>> ops;
    vector<bool> visited(n);
    for (int i = 0; i<n; i++) if (p[i]!=i && !visited[i])
    {
        vector<int> bruh = {i};
        visited[i] = true;
        int cur = p[i];
        while (cur!=i)
        {
            visited[cur] = true; bruh.push_back(cur); cur = p[cur];
        }

        int best = 0;

        int k = bruh.size();

        for (int j = 1; j<k; j++) if (have[bruh[j]]<have[bruh[best]]) best = j;

        for (int i = 0; i<k-1; i++)
        {
            ops.push_back(mp(bruh[(best-i-1+k)%k], bruh[(best-i+k)%k]));
        }
    }

    cout<<ops.size()<<endl;
    for (auto it: ops) cout<<it.first+1<<' '<<it.second+1<<endl;

}


#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
typedef long long LL;
typedef pair<LL, LL> PII;

PII vote[N];
LL n;

bool cmp(PII, PII);

int main(){
    cin >> n;
    LL va = 0, vb = 0;
    for(LL i = 1; i <= n; i++){
        cin >> vote[i].first >> vote[i].second;
        va += vote[i].first;
    }
    sort(vote + 1, vote + 1 + n, cmp);
    for(LL i = 1; i <= n; i++){
        va -= vote[i].first;
        vb += (vote[i].second + vote[i].first);
        if(vb > va){
            printf("%lld\n", i);
            return 0;
        }
    }
    return 0;
}

bool cmp(PII a, PII b){
    if((a.first * 2 + a.second) != (b.first * 2 + b.second))
        return (a.first * 2 + a.second) > (b.first * 2 + b.second);
    else return a.first > b.first;
}

#include<bits/stdc++.h>
using namespace std;
#define setbits(x)      __builtin_popcountll(x)
#define leadzero(x)     __builtin_clz(x)
#define trailzero(x)    __builtin_ctz(x)
#define mod             1000000007
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long
#define int             ll
#define ld              long double
#define ff              first
#define ss              second
#define pb              push_back
#define eb              emplace_back
#define popb            pop_back
#define endl            '\n'
#define all(v)          v.begin(), v.end()
#define sz(x)           ((int)((x).size()))
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
ll power(ll a, ll b) {
    if(b<0) return 1;
    ll res=1;
    while(b) {
        if(b&1)
            res = (res*a);//%mod;
        a = (a*a);//%mod;
        b >>= 1;
    }
    return res;
}
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
bool ispoweroftwo(ll x){ return (x&&!(x&(x-1)));}
ll GCD(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}
const int inf = 1e9;
const ll INF = 1e18;
const ld pi = 3.141592653589793238;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
char MV[] = {'U', 'R', 'D', 'L'};
//Shoot for the moon - If you miss, you'll end up in the stars
//integer to char always remember (char+'0')
//---------------------------------------------------------------------------------------
int32_t main() {
    FIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    vi a(n), b(n);
    vector<pll> v;
    ll aoki = 0, taka = 0;
    rep(i, n) {
    	cin >> a[i] >> b[i];
    	v.pb({2 * a[i] + b[i], i});
    	aoki += a[i];
    }

    sort(all(v));

    ll ans = 0;
    for (int i = n-1; i >= 0 && aoki >= taka; --i) {
    	ans++;
    	int ind = v[i].ss;
    	aoki -= a[ind];
    	taka += a[ind] + b[ind];
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define gc() getchar()
using namespace std;
typedef long long ll;

template <typename T> void rd(T &x){
	ll f=1;x=0;char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	x*=f;
}

int a,b;

int main(){
	rd(a),rd(b);
	printf("%d\n",(1+a)*a/2*b*100+(1+b)*b/2*a);
	return 0;
}

#include<bits/stdc++.h>
#define rep(i, s, n) for (long long i = s; i < (int)(n); i++)
#define all(a) a.begin(), a.end()
#define put(i) cout<<fixed<<i<<endl
#define putl(a) for(auto x:a)cout<<x<<' '; cout<<endl
using namespace std;
using ll = long long;

int main(){
    ll n; cin >> n;
    deque<char> q;

    rep(i,0,n){
        char tmp; cin >> tmp;
        q.push_back(tmp);
        ll size = q.size();
        if(size > 2 and q[size-1] == 'x' and q[size-2] == 'o' and q[size-3] == 'f'){
            q.pop_back();
            q.pop_back();
            q.pop_back();
        }
    }

    put(q.size());
}


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

bool flg[100][100];
int main() {
	int n; cin >> n;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			char c; cin >> c;
			flg[i][j] = (c == '1');
		}
		flg[i][i] = true;
	}
	for(int k = 0; k < n; ++k) {
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < n; ++j) {
				flg[i][j] |= (flg[i][k] & flg[k][j]);
			}
		}
	}
	double ans = 0;
	for(int i = 0; i < n; ++i) {
		int cnt = 0;
		for(int j = 0; j < n; ++j) {
			cnt += flg[j][i];
		}
		ans += 1.0 / (double)cnt;
	}
	printf("%.15f\n", ans);
	return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#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 mp make_pair
#define eb emplace_back
#define pb push_back
#define e1 first
#define e2 second
#define size(x) (int)x.size()
#define all(r) begin(r),end(r)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define time chrono::high_resolution_clock().now().time_since_epoch().count()
#define satori int testCases; cin>>testCases; while(testCases--)

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

///////////////////
#define DEBUG if(1)
///////////////////

ll pot(ll x,ll wyk,ll mod){
	ll res=1;
	while(wyk){
		if(wyk&1)
			res=(res*x)%mod;
		x=(x*x)%mod;
		wyk/=2ll;
	}
	return res;
}

int32_t main(){
	fastio;
	ll a,b;
	cin>>a>>b;
	if(b==1){
		cout<<"0\n";
		return 0;
	}
	ll residue=pot(10ll,a,b*b);
	ll res=(residue/b)%b;
	cout<<res<<'\n';
	return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define dl double

using namespace std;

const int N = 2e6 + 7;
const long long mod = 1e9 + 7;

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

int n,m,k;

ll bnp(ll x, ll y)
{
        if(y == 0)return 1ll;
        if(y % 2){
                return x * bnp(x, y - 1) % mod;
        }else{
                ll b = bnp(x, y / 2);
                return b * b % mod;
        }
}

ll f[N];

ll C(ll n, ll k)
{
        if(k > n)return 0ll;
        return f[n] * bnp(f[n - k] * f[k] % mod, mod - 2) % mod;
}

void solve()
{
        f[0] = 1;
        for(int i = 1; i < N; i++)f[i] = f[i - 1] * i % mod;
        cin >> n >> m >> k;
        if(n > m + k){
                cout << 0;
                return;
        }
        cout << (C(n + m, n) - C(n + m, n - k - 1) + mod) % mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

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

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int a,b,c,d;

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

    int ans;
    if(a==c && b==d) ans=0;
    else if(a+b==c+d) ans=1;
    else if(a-b==c-d) ans=1;
    else if(abs(a-c)+abs(b-d)<=3) ans=1;
    else if((a+b+c+d)%2==0) ans=2;
    else if(abs(a-c)+abs(b-d)<=6) ans=2;
    else if(abs((a+b)-(c+d))<=3) ans=2;
    else if(abs((a-b)-(c-d))<=3) ans=2;
    else ans=3;

    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,t) for(i=0;i<t;i++)
#define fr1(i,r,t) for(i=r;i<t;i++)
typedef long long int lli;
typedef unsigned long long int ulli;
#define inf LONG_MAX
#define ff first
#define ss second
double pie=3.14159265358979323846;
#define dbug(x) cout<<#x<<"="<<x<<endl;
#define dbug2(x,y)
// lli M=1e9+7;
lli M=998244353;
#define gg cout<<"Case #"<<i+1<<": "
#define exact(x) cout<<fixed<<setprecision(8)<<x<<endl

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	lli T,n,i,j,k=0,m,j1,co=0,check,mi,l,sum;
	lli ans=0;
    // cin>>T;
    // fr(i,T)
    // {
        cin>>n>>m>>k;
        ans=((k*(k+1))/2)%M;
        ans=(ans*(((m*(m+1))/2)%M))%M;
        ans=(ans*(((n*(n+1))/2)%M))%M;
        cout<<ans<<endl;
    // }
}

#define _DEBUG
#include "bits/stdc++.h"
//#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug_6(x1,x2,x3,x4,x5,x6) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<", "#x6<<": "<<x6<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_6,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define prind(argument) cout<<std::fixed<<setprecision(13)<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define PI acosl(-1)
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define puba emplace_back
#define pubamp(a,b) emplace_back(mp(a,b))
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	vector<pair<int,string>> ts;
	scan(N);
	rep(i,N){
		int T;
		string S;
		scan(S>>T);
		ts.pubamp(T,S);
	}
	sort(rALL(ts));
	prin(ts[1].second);
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

using vi = vector<int>;

using vvi = vector<vi>;

#define pb push_back

#define sz size()

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

void solve() {
    int n, m; cin >> n >> m;
    vi v(n); vvi track(1500001);
    ice (i, 0, 1500001) {
        track[i].pb(-1);
    }
    ice (i, 0, n) {
        cin >> v[i];
        track[v[i]].pb(i);
    }
    ice (i, 0, 1500001) {
        track[i].pb(n);
    }
    ice (i, 0, 1500001) {
        bool ok = true;
        ice (j, 1, track[i].sz) {
            ok &= (track[i][j] - track[i][j - 1] <= m);
        }
        if (!ok) {
            cout << i;
            return;
        }
    }
}

int main() {
    solve();
}

#include <bits/stdc++.h>
using namespace std;
#define poi 400100
typedef long long ll;
typedef double db;
const int mod = 998244353;
int f[poi];
inline int re()
{
    char c = getchar();
    int x = 0, k = 1;
    while (c < '0' || c > '9')
    {
        if (c == '-')
            k = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
        x = (x << 1) + (x << 3) + c - '0', c = getchar();
    return k * x;
}
void wr(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        wr(x / 10);
    putchar(x % 10 + '0');
}
int fin(int x) { return f[x] == x ? x : f[x] = fin(f[x]); }
inline void bin(int x, int y)
{
    x = fin(x), y = fin(y);
    f[x] = y;
}
inline int ksm(int x, int y)
{
    int ans = 1;
    for (; y; y >>= 1)
    {
        if (y & 1)
            ans = ((ll)ans * x) % mod;
        x = ((ll)x * x) % mod;
    }
    return ans;
}
signed main()
{
    int n = re(), tot = 0;
    for (int i = 1; i <= n; i++)
        f[i] = i;
    for (int i = 1; i <= n; i++)
    {
        int qqq = re();
        bin(i, qqq);
    }
    for (int i = 1; i <= n; i++)
        if (fin(i) == i)
            tot++;
    wr(ksm(2, tot) - 1);
    return 0;
}


#include<bits/stdc++.h>

#define db double

using namespace std;

int read()
{
	int a=0,f=1,c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')f=-1;
		c=getchar();
	}
	while(isdigit(c))
	{
		a=a*10+c-'0';
		c=getchar();
	}
	return a*f;
}

const int N=1e5+10;
const db INF=1e18;

int n;
int a[N];

int main()
{
//	freopen("1.in","r",stdin);

	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+n+1);

	db ans=INF,sum=0;
	for(int i=0;i<=n;++i)
	{
		sum+=a[i];

		db x=(db)a[i]/2;
		ans=min(ans,n*x-(sum+(n-i)*x*2));
	}
	ans=(ans+sum)/n;
	printf("%lf\n",ans);

	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;

int main(){
	int K;
	cin >> K;
	int ans = 0;
	for(int A = 1; A <= K; A++){
		for(int B = 1; B <= K; B++){
			if(A * B > K) break;
			ans += K / (A * B);
		}
	}
	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef   long long int ll;
typedef long double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define pi 3.14159265358979323846264338327950288419716939937510
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define at(s,pos) *(s.find_by_order(pos))
#define set_ind(s,val) s.order_of_key(val)
long long int M = 1e9 + 7 ;
long long int inf = 9 * 1e18;
//CLOCK
ll begtime = clock();
#define time() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//CLOCK ENDED
ll n, m;
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (deg < 0)
		return 0;
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
//binomial
ll modinv(ll n) {
	return binpow(n, M - 2);
}
//GCD
ll gcd (ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd (b, a % b);
}

int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> n;
	ll a[n];
	ll pos[n + 1];
	rep(i, n) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	ll used[n];
	mset(used, 0);
	v<ll> out;
	ll flg = 0;
	for (i = n; i >= 1; i--) {
		x = pos[i];
		while (1) {
			if (x + 1 < n) {
				if (a[x + 1] > a[x]) {
					break;
				}
				else {
					if (used[x]) {
						flg = 1;
						break;
					}
					else {
						used[x] = 1;
						out.pb(x + 1);
						swap(a[x], a[x + 1]);
						pos[a[x]] = x;
						pos[a[x + 1]] = x + 1;
						x++;
					}
				}
			}
			else break;
		}
	}
	if (flg) cout << -1;
	else {
		ll flg = 0;
		rep(i, n) {
			if (a[i] != i + 1) flg = 1;
			break;
		}
		if (flg) {
			cout << -1;
		}
		else {
			if (out.size() != n - 1) cout << -1;
			else
				rep(i, out.size()) cout << out[i] << '\n';
		}
	}

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

const int N = 200010;

int n, p[N];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", p + i);
  }
  vector <int> ans;
  for (int i = n; i >= 1; --i) {
    if (p[i] == i) continue;
    int at = -1;
    for (int j = i - 1; j >= 1; --j) if (p[j] == i) {
      at = j;
      break;
    }
    for (int j = at; j < i; ++j) {
      ans.emplace_back(j);
      swap(p[j], p[j + 1]);
    }
    for (int j = at + 1; j <= i; ++j) {
      if (p[j] != j) {
        cout << "-1\n";
        return 0;
      }
    }
    i = at + 1;
  }
  for (int i = 1; i <= n; ++i) {
    if (p[i] != i) {
      cout << "-1\n";
      return 0;
    }
  }
  if (ans.size() != n - 1) {
    cout << "-1\n";
    return 0;
  }
  for (int x : ans) printf("%d\n", x);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    int a[n],minv=INF,maxv=-1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        minv=min(minv,a[i]);
        maxv=max(maxv,a[i]);
    }
    int preV=minv;
    while(1){
        for(int i=0;i<n;i++)a[i]%=minv;
        minv=INF;
        for(int i=0;i<n;i++){
            if(a[i]==0)continue;
            minv=min(minv,a[i]);
        }
        if(minv==INF){
            cout<<preV<<endl;
            return 0;
        }
        preV=minv;
    }
}

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);    cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define mp(i,j) make_pair(i,j)
typedef long long ll;
const int maxn = 1e3+5;
vector<int> vec;
vector<int> pre;

int gcd(int x,int y){
    return y? gcd(y,x%y) : x;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;  cin >> n;
    int now = 0;
    for(int i = 0; i < n; ++i){
        int x;  cin >> x;
        now = gcd(now,x);
    }cout<<now << endl;
    return 0;
}


		#include<bits/stdc++.h>
            #define cs const
            #define fr first
            #define se second
           #define ls (now<<1)
           #define mp make_pair
           #define pb push_back
           #define ll long long
           #define ppb pop_back
           #define rs (now<<1|1)
           #define int long long
           #define mid ((l+r)>>1)
          #define low(i) (i&(-i))
         #define par pair<int,int>
   #define cn(x) memset(x, 0, sizeof(x))
 #define rep(i, x, y) for(int i=x; i<=y; ++i)
 #define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])

using namespace std;

cs int G = 3;
cs int ff = 3e6 + 15;
cs int inf = 1e18 + 1;
cs int base = 4;
cs int M = 998244353;

int n, m, a[ff], b[ff], fa[ff];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void init()
{
	cin >> n >> m;
	rep(i, 1, n) fa[i] = i;
	rep(i, 1, n) scanf("%lld", &a[i]);
	rep(i, 1, n) scanf("%lld", &b[i]);
	rep(i, 1, m)
	{
		int u, v; scanf("%lld %lld", &u, &v);
		int fau = find(u), fav = find(v);
		if(fau != fav)
			fa[fau] = fav, a[fav] += a[fau], b[fav] += b[fau];
	}
	rep(i, 1, n)
		if(a[find(i)] != b[find(i)])
		{
			puts("No"); return;
		}
	puts("Yes");
}
signed main()
{
//	freopen("1.in", "r", stdin);
//	freopen("number.out", "w", stdout);
	int Ts = 1;
	while(Ts--)
		init();
}
/*
2 8
push 1 1 1
push 1 2 1
push 2 3 2
put 1 2
put 2 1
put 1 2
put 2 1
pop 1 1
*/

#include <bits/stdc++.h>

using namespace std;

#define ffor(i,o,f)		   for(int i = o; i < f; i++)
#define pb 				   push_back
#define mp                 make_pair
#define all(a)             (a).begin(), (a).end()
#define F                  first
#define S                  second
#define PI 				   3.14159265358979323846264338327950
#define endl 			   '\n'
#define lcm(a,b)           (a*b)/__gcd(a,b)
typedef long long          ll;
typedef pair < int, int >  pii;
typedef vector < int >     vi;
typedef vector < pii >     vii;
typedef vector < vi > 	   gi;
typedef vector < ll >      vll;
typedef map < int, int >   mii;
const int INF = int(1e9 + 7);

int main() //IBMG
{
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    string s;
    int aux;
    bool ok;
    mii m;
    mii mm;
    cin >> s;
    ffor(i, 0, s.size()) m[s[i]-48] ++;
    mm = m;
    if (s.size() == 1)
    {
    	if (s[0] == '8') cout << "Yes" << endl;
    	else cout << "No" << endl;
    	return 0;
    }
    if (s.size() == 2)
    {
    	for (int i = 16; i <= 96; i += 8)
        {
    	    aux = i;
    	    ok = true;
    	    while (aux >= 1)
    	    {
    	    	if (m[aux%10] > 0) m[aux%10] --;
    	    	else ok = false;
    	    	aux /= 10;
    	    }
    	    m = mm;
    	    if (ok)
    	    {
    	    	cout << "Yes" << endl;
    	    	break;
    	    }
    	    else if (i == 96) cout << "No" << endl;
        }
        return 0;
    }
    for (int i = 104; i <= 992; i += 8)
    {
    	aux = i;
    	ok = true;
    	while (aux >= 1)
	    {
	    	if (m[aux%10] > 0) m[aux%10] --;
	    	else ok = false;
	    	aux /= 10;
	    }
	    m = mm;
	    if (ok)
	    {
	    	cout << "Yes" << endl;
	    	break;
	    }
	    else if (i == 992) cout << "No" << endl;
    }
    return 0;
}


// abc188F.cpp
#include <iostream>
#include <vector>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
ll x;
map<ll, ll> memo;
ll f(ll y) {
    if (y == 1)return abs(x - y);
    if (memo.find(y) != memo.end()) return memo[y];
    if (y % 2 == 0) {
        return memo[y] = min(f(y / 2) + 1, abs(y - x));
    }
    else {
        return memo[y] = min(min(f(y + 1) + 1,f(y - 1) + 1),abs(y - x));
    }
}
int main()
{
    ll y;
    cin >> x >> y;
    cout << f(y) << endl;
    return 0;
}

#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include<time.h>
using namespace std;

//int N=1;
int P[11] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
int binary(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		//ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
int rev(int original)
{
	int reversed = 0;

	while (original > 0) {
		reversed = original % 10 + reversed * 10;
		original = original / 10;
	}
	return reversed;
}
int gcd(int x, int y) {
	if (x < y) swap(x, y);

	while (y > 0) {
		int r = x % y;
		x = y;
		y = r;
	}
	return x;
}

int main() {
	vector<char>s(12);
	for (int i = 0;i < 12;i++) {
		cin >> s.at(i);
	}
	int cou = 0;
	for (int i = 0;i < 9;i++) {
		if (s.at(i) == 'Z' && s.at(i + 1) == 'O' && s.at(i + 2) == 'N' && s.at(i + 3) == 'e') {
			cou++;
		}
	}
	cout << cou;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fop(i, n) for(int i=0; i<n; ++i)
#define bgen(i) i.begin(),i.end()

void chmin(int& a, int& b){if(a > b)a = b;}
void chmax(int& a, int& b){if(a < b)a = b;}

ll xcy(int i){
  ll ic = 1;
  fop(j, 5) ic *= i-j;
  return ic/120;
}

int main() {
  int l; cin >> l; --l;
  bool odd = l%2;

  ll ans = 0;
  for(int i=6; i<=l-5; ++i){
    int i1 = i-1;
    ll ans1 = xcy(i1);

    if(odd && i == (l+1)/2) ans1 *= ans1;
    else{
      int i2 = l-i;
      ans1 *= xcy(i2);
    }
    ans += ans1;
  }

  cout << ans << endl;
}

// C++ implementation to find nCr
#include <bits/stdc++.h>
using namespace std;

// Function to find the nCr
long long printNcR(long long n, long long r)
{

	// p holds the value of n*(n-1)*(n-2)...,
	// k holds the value of r*(r-1)...
	long long p = 1, k = 1;

	// C(n, r) == C(n, n-r),
	// choosing the smaller value
	if (n - r < r)
		r = n - r;

	if (r != 0) {
		while (r) {
			p *= n;
			k *= r;

			// gcd of p, k
			long long m = __gcd(p, k);

			// dividing by gcd, to simplify
			// product division by their gcd
			// saves from the overflow
			p /= m;
			k /= m;

			n--;
			r--;
		}

		// k should be simplified to 1
		// as C(n, r) is a natural number
		// (denominator should be 1 ) .
	}

	else
		p = 1;

	// if our approach is correct p = ans and k =1
	return p;
}

// Driver code
int main()
{
	long long n;
	cin>>n;
	cout<<printNcR(n-1,11)<<endl;

	return 0;
}


#include <algorithm>
#include <iostream>
#include <climits>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

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

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

template<typename T>
void dout(string name, T arg) {
    cerr << arg << endl;
}

template<typename T1, typename... T2>
void dout(string names, T1 arg, T2... args) {
    cerr << arg << " | ";
    dout(names.substr(names.find(',') + 2), args...);
}

#ifndef ONLINE_JUDGE
    #define debug(...) dout(#__VA_ARGS__, __VA_ARGS__)
#else
    #define debug(...)
#endif

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

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define mod 1000000007
#define nod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb push_back

// D R U L
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

const int mx = 1e6 + 5;
const int INF = mod;

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

// Check for number of Cases!!
void solve() {
    ll n; cin >> n;
    ll cost; cin >> cost;

    vector<vll> arr(n, vll(n));
    cin >> arr;

    vll ref;

    for(int i = 1; i < n; i++) {
        ref.pb(i);
    }

    ll ans = 0;

    do {
        ll curr = 0;
        for(int i = 0; i < ref.size(); i++) {
            if(i == 0) {
                curr += arr[0][ref[i]];
            }else {
                curr += arr[ref[i-1]][ref[i]];
            }
        }
        curr += arr[ref[ref.size() - 1]][0];
        if(curr == cost) ans++;
    }while(next_permutation(all(ref)));

    cout << ans;
}

int main(){

    #ifndef ONLINE_JUDGE
    freopen("/ATOMCODES/input.txt", "r", stdin);
    freopen("/ATOMCODES/output.txt", "w", stdout);
    freopen("/ATOMCODES/err_output.txt", "w", stderr);
    #endif

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

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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 = 1000000000 + 100;
constexpr long long LINF = 1000000000000000000 + 100;
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#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; }

int main(){
    int N, M; cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    rep(i, M){
        cin >> X[i] >> Y[i] >> Z[i];
    }

    ll dp[1<<18]{}; dp[0] = 1;
    for(int bit=0; bit<(1<<N); bit++){
        vector<int> S; //集合
        for(int i=0; i<N; i++){
            if((bit>>i)&1){
                S.push_back(i+1);
            }
        }
        for(int i=0; i<N; i++){
            if((bit>>i)&1)continue; //既に存在する
            S.push_back(i+1);
            bool fg = true;
            //条件判定
            rep(j, M){
                if(X[j]!=S.size())continue; //丁度になったら数えれば良い
                int cnt = 0;
                for(auto s:S){
                    if(s<=Y[j])cnt++;
                }
                if(cnt>Z[j]){
                    fg = false;
                }
            }
            if(fg)dp[bit+(1<<i)] += dp[bit];
            //cout << "bit:" << bit << " dp:" << dp[bit+(1<<i)] << " <- " << dp[bit] << ln;
            S.pop_back();
        }
    }
    cout << dp[(1<<N)-1] << ln;
}


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

int main() {
	unsigned long long tmp; scanf("%llu", &tmp);
	__int128 N = tmp;
	__int128 i = 5; char j = 1;
	for (; N >= i + 3; i *= 5, ++j) {
		__int128 t = N - i;
		char k = 0;
		while (t > 0 && t % 3 == 0)
			t /= 3, ++k;
		if (t == 1) {
			printf("%d %d\n", k, j);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
    ll n = in();
    double dx = 3;
    for(ll x=3,a=1;dx < 2e18 and x<=n;x*=3,++a,dx*=3){
        double dy = 5;
        for(ll y=5,b=1;dx + dy <= 3e18 and y+x<=n;y*=5,++b,dy*=5){
            if(x+y==n){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define per(i,n) for(ll (i)=(n)-1;(i)>=0;--(i))
#ifdef LOCAL
#define debug(x) cerr<<__LINE__<<": "<<#x<<"="<<x<<endl;
#define debugALL(x) cerr<<__LINE__<<": "<<#x<<"=";for(auto i=(x).begin();i!=--(x).end();i++)cerr<<*i<<" ";cerr<<*--(x).end()<<endl;
#else
#define debug(x) true
#define debugALL(x) true
#endif
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    VV dp(4,V(3*n+1,0));
    V sum(3*n+2,0);
    dp[0][0]=1;
    rep(i,3){
        for(ll j=0;j<=3*n;j++)sum[j+1]=sum[j]+dp[i][j];
        rep(j,3*n+1)dp[i+1][j]=sum[j]-sum[max(j-n,0ll)];
    }
    ll ans=1;
    for(ll s=3;s<=3*n;s++){
        if(k<ans+dp[3][s]){
            for(ll i=1;i<=n;i++){
                if(k<ans+dp[2][s-i]){
                    for(ll j=1;j<=n;j++){
                        if(k<ans+dp[1][s-i-j]){
                            cout<<i<<" "<<j<<" "<<s-i-j<<endl;
                            return 0;
                        }else{
                            ans+=dp[1][s-i-j];
                        }
                    }
                }else{
                    ans+=dp[2][s-i];
                }
            }
        }else{
            ans+=dp[3][s];
        }
    }
}

/**
*    author:  tomo0608
*    created: 27.02.2021 21:01:58
**/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

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

#define all(x) x.begin(),x.end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
template<class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {os << *itr;++itr;if(itr != set_var.end()) os << ", ";itr--;}os << "}";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {os << "{";for(auto itr = map_var.begin(); itr != map_var.end(); itr++) {os << *itr;itr++;if (itr != map_var.end()) os << ", ";itr--;}os << "}";return os;}
template<class T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
#define pb push_back
#define eb emplace_back
#define elif else if
#define mp make_pair
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template<typename T> T gcd(T x, T y){if(x%y == 0)return y;return gcd(y, x%y);}
template<typename T> T gcd(vector<T> a){T res = a[0];for(auto &x: a)res = gcd(res, x);return res;}
template <typename T>T mypow(T x, ll n){T ret = 1;while(n > 0){if(n & 1)(ret *= x);(x *= x);n >>= 1;}return ret;}
#define endl '\n'
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

void solve(){
    int a,b;cin >> a >> b;
    cout << 100 - (double)100*b/a << endl;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << setprecision(20);
    int codeforces = 1;
    //cin >> codeforces;
    while(codeforces--){
        solve();
    }
    return 0;
}


/** Fucc :/
 - doanphuc : /
	** author: doanphuc. **
**/
#include <bits/stdc++.h>
#define TASK ""
#define inpf freopen(TASK".inp", "r", stdin)
#define outf freopen(TASK".out", "w", stdout)
#define FOR(i,x,y) for(int i = x; i <= y ; i ++)
#define FORT(i,x,y) for(int i = x; i < y ; i ++)
#define FORD(i,x,y) for(int i = x; i >= y ; i --)
#define clean(x) memset(x, 0, sizeof(x))
#define F first
#define S second
#define maxn 1000005
#define pii pair<ll,ll>
#define ll long long
#define pb push_back
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define all(x) (x).begin(), (x).end()
#define pia pair<pii, int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const ll MOD = 1e9 + 7 ;
ll n, c, e, tr[maxn] ;
vector<int> a[maxn] ;
void dfs(int u)
{
    if(tr[u]) return ;
    tr[u] = 1 ;
    c ++ ; e += a[u].size() ;
    for(auto v: a[u]) dfs(v) ;
}
int main()
{
//    inpf; outf; fast;
    cin >> n ;
    FOR(i, 1, n)
    {
        int u, v ;
        cin >> u >> v ;
        a[u].pb(v) ; a[v].pb(u) ;
    }
    ll ans = 0 ;
    FORT(i, 1, maxn)
    {
        if(tr[i]) continue ;
        c = e = 0 ;
        dfs(i);
        ans += min(c, e / 2) ;
    }
    cout << ans ;

}

//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
      I ♥ CLARICE STARLING...
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
int n,m,k,ans;
vector<int>a,b,c,d,dish;
void recursion(int pos)
{
    int i;
    if(pos==k)
    {
        int cnt=0;
        fo(i,0,m)
        {
          if(dish[a[i]]&&dish[b[i]])cnt++;
        }
        ans=max(ans,cnt);
    }
    else
    {
        i=pos;
        dish[c[i]]++;recursion(pos+1);dish[c[i]]--;
        dish[d[i]]++;recursion(pos+1);dish[d[i]]--;
    }
}
void solve()
{
   int i;cin>>n>>m;
   dish=vector<int>(n,0);
   a=b=vector<int>(m);
   fo(i,0,m){cin>>a[i]>>b[i];a[i]--;b[i]--;}
   cin>>k;
   c=d=vector<int>(k);
   fo(i,0,k){cin>>c[i]>>d[i];c[i]--;d[i]--;}

   recursion(0);
   cout<<ans<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}


/* dont stick to an approach */
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <cstdlib>

typedef long long ll;
typedef unsigned long long int ull;
typedef long double ldb;

#define PB push_back

#define For(i, n) for (ll i = 0; i < n; i++)

#define PYES cout<<"YES\n"
#define PNO cout<<"NO\n"
#define PYes cout<<"Yes\n"
#define PNo cout<<"No\n"

#define Fas ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const int M=4;

using namespace std;

//--------------------------------------------functions--------------------------------------------------------//

ll power(ll a,ll b){int result=1;while(b>0){if(b%2 == 1){result *= a;}a *= a;b /= 2;}return result;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x){return ((x%M + M)%M);}
ll add(ll a, ll b){return mod(mod(a)+mod(b));}
ll mul(ll a, ll b){return mod(mod(a)*mod(b));}
ll powerM(ll a,ll b){ll res=1;while(b){if(b%2==1){res=mul(a,res);}a=mul(a,a);b/=2;}return res;}
//------------------------------------sieve of erantothenes----------------------------------------------------//

vector<bool> sieve_of_eratothenes(ll n){
    vector<bool> a(n+1,1);
    a[0]=0;
    a[1]=0;
    for(ll i=2;i<=sqrt(n);i++){
        if(a[i]==1){
            for(ll j=2;i*j<=n;j++){
                a[j*i]=0;
            }
        }
    }
    return a;
}
//----------------------------------------nCr mod ---------------------------------------------------------------//
ll modInverse(ll n){
    return powerM(n,M-2);
}
ll nCrM(ll n,ll r){
    if(n<r) return 0;
    if(r==0) return 1;
    vector<ll> fact(n+1);
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=mul(fact[i-1],i);
    }
    return mul(mul(fact[n],modInverse(fact[r])),modInverse(fact[n-r]));
}

//-----------------------------------------------solve--------------------------------------------------------//

void solve(){
    ll a,b,c;cin>>a>>b>>c;
    a%=10;
    if(a==5||a==0||a==1||a==6){
        cout<<a<<endl;
    }else if(a==4||a==9){
        if (b%2==0){
            if(a==4){
                cout<<6<<endl;
            }else{
                cout<<1<<endl;
            }
        }else{
            if(a==4){
                cout<<4<<endl;
            }else{
                cout<<9<<endl;
            }
        }
    }else{
        ll d=powerM(b,c);
        if(d==0){
            if(a==2){
                cout<<6<<endl;
            }else if(a==3){
                cout<<1<<endl;
            }else if(a==7){
                cout<<1<<endl;
            }else if(a==8){
                cout<<6<<endl;
            }
        }else if(d==1){
            if(a==2){
                cout<<2<<endl;
            }else if(a==3){
                cout<<3<<endl;
            }else if(a==7){
                cout<<7<<endl;
            }else if(a==8){
                cout<<8<<endl;
            }
        }else if(d==2){
            if(a==2){
                cout<<4<<endl;
            }else if(a==3){
                cout<<9<<endl;
            }else if(a==7){
                cout<<9<<endl;
            }else if(a==8){
                cout<<4<<endl;
            }
        }else if(d==3){
            if(a==2){
                cout<<8<<endl;
            }else if(a==3){
                cout<<7<<endl;
            }else if(a==7){
                cout<<3<<endl;
            }else if(a==8){
                cout<<2<<endl;
            }
        }
    }
}

int main(){
    Fas;

//    ll t=0;
//    cin>>t;
//    while(t--)
        solve();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
char s[N];
int main()
{
	int n,q;
	cin>>n;
	scanf("%s",s+1);
	cin>>q;
	int t,a,b,now=0;
	while(q--)
	{
		cin>>t>>a>>b;
		if(t==2)
			now++;
		else
		{
			if(now&1)
			{
				if(a<=n) a+=n;
				else a-=n;
				if(b<=n) b+=n;
				else b-=n;
			}
			swap(s[a],s[b]);
		}
	}
	if(now&1)
	{
		for(int i=n+1;i<=2*n;i++) cout<<s[i];
		for(int i=1;i<=n;i++) cout<<s[i];
	}
	else
		for(int i=1;i<=2*n;i++) cout<<s[i];
	return 0;
}


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

#define int             long long
#define pb              push_back
#define ppb             pop_back
#define pf              push_front
#define ppf             pop_front
#define all(x)          (x).begin(), (x).end()
#define uniq(v)         (v).erase(unique(all(v)), (v).end())
#define sz(x)           (int)((x).size())
#define ff              first
#define ss              second
#define rep(i, a, b)    for(int i = a; i <= b; i++)
#define mem1(a)         memset(a, -1, sizeof(a))
#define mem0(a)         memset(a, 0, sizeof(a))
#define endl            "\n"
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;

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

void fast_io()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string s; cin >> s;

	for (int i = 0; i < sz(s); i++) {
		if (s[i] == '.') break;
		cout << s[i];
	}

}

signed main()
{
	fast_io();
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;

	// cin >> t;

	while (t--) {

		solve();

	}
	return 0;

}

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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << setprecision(6) << fixed;

	string s;
	cin >> s;
	for(char x : s)
	{
		if(x == '.')
			break;
		cout << x;
	}
	cout << endl;
	return 0;
}