#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define reps(i,n) for(ll i=1;i<ll(n);i++)
#define rrep(i,n) for(ll i=ll(n);i>=0;i--)
#define ALL(x) x.begin(),x.end()
#define FOR(i,a,b) for(ll i=a;i<=b;i++)//使いにくかったら消す
#define len(x) x.length()//配列の長さ
#define SIZE(x) x.size()//vectorのサイズ
#define NPOS string::npos//findで検索失敗した場合の戻り値(findは文字列内に特定の文字列があるかを判定)
typedef long long ll;
using namespace std;
const ll INF=1LL<<60;//無限大
ll ans=0;            //解答用の変数

bool comp_len(const std::string &lh,const std::string &rh){return lh.length() < rh.length();}  //文字列を長さでソートする時の比較関数
ll gcd(ll a, ll b) {if (b==0) return a;else return gcd(b, a%b);}                               //最大公約数
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}                                                 //最小公倍数
ll digit_sum(ll a,ll b){ll ans=0;while(a>0){ans+=a%b;a/=b;}return ans;}                        //n進桁和
ll digit_num(ll a,ll b){ll ans=0;while(a>0){ans++;a/=b;}return ans;}                           //n進桁数
ll fact(ll n){if(n==1)return 1;else return n*fact(n-1);}                                       //階乗
ll array_sum(ll *a,ll n){ll ans=0;rep(i,n){ans+=a[i];}return ans;}                             //配列総和
ll combi(ll n, ll k){if(n==k||k==0){return 1;}else{return combi(n-1,k-1)+combi(n-1,k);}}       //nCkの組み合わせ
bool is_prime(ll x){for(ll i=2;i*i<=x;i++){if(x%i==0)return false;}return true;}               //素数判定
// for(long long i=1;i*i<= n;i++){if(n%i==0){ans.push_back(i);if(i*i!=n)ans.push_back(n/i);}}  //約数列挙（vector型の変数の用意が必要）

/*繰り返し2乗法（べき乗のmodをとる）O(log n)*/
ll modPow(ll a,ll n,ll p){if(n==0)return 1;if(n==1)return a%p;if(n%2==1)return (a*modPow(a,n-1,p))%p;ll t=modPow(a,n/2,p);return (t*t)%p;}

/*dp(動的計画法)*/
template <typename T>bool chmax(T &a, const T& b){if(a<b){a=b;return true;}return false;}//a<bならaをbに置き換え
template <typename T>bool chmin(T &a, const T& b){if(a>b){a=b;return true;}return false;}//a>bならaをbで置き換え

// 'a'+(s[j]-'a'+i)%('z'-'a'+1) 文字をi文字ずらす

/*Union-Find(素集合データ構造)*/
vector<ll> par(100010);//親の値を保持
ll root(ll x){if(par[x]==x){return x;}else{return par[x]=root(par[x]);}}//根の値を返す
bool same(ll x,ll y){return (root(x)==root(y));}//根が一致しているか判定
void unite(ll x,ll y){x=root(x);y=root(y);if(x==y)return;par[x]=y;}//グループを併合

int main()
{
  double a,b;
  cin>>a>>b;
  cout<<fixed<<setprecision(10)<<(a*(b/100))<<endl;
  return 0;
}

#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    int n, m; cin>>n>>m;
    map<int, int> cnt;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        cnt[a]++;
    }
    for(int i=0; i<m; i++){
        int b; cin>>b;
        cnt[b]++;
    }

    for(auto i : cnt){
        if(i.second == 1){
            cout << i.first << " ";
        }
    }
    cout << endl;

    return 0;
}


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

#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i = a; i <= n; i++)
#define per(i,a,n) for(int i = a; i >= n; i--)
#define vi vector<int>
#define pb push_back
#define itr(i,v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
#define kill(x) {cout << x << "\n"; return;}
constexpr int mx = 2e5 + 10;
int fa[mx],sz[mx];
int gf(int x) { return fa[x]==x?x:fa[x]=gf(fa[x]); }

void merge(int x,int y) {
	x = gf(x); y = gf(y);
	if(x!=y) sz[x] += sz[y],fa[y]=x,sz[y] = 0;
}
void solve(){
	iota(fa,fa+mx,0);
	fill(sz,sz+mx,1);

	int n; cin >> n;
	vi v(n); fr(i,n) cin >> v[i];
	int ans = 0;
	fr(i,n/2) merge(v[i],v[n-1-i]);
	fr(i,mx) if(sz[i]) ans += sz[i] - 1;
	kill(ans);

}

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   // int tst; cin >> tst; while(tst--)
   {
   	solve();
   }
}

#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

bool ok(int n){
    for(int p : {10, 8}) {
        int cn = n;
        while (cn) {
            if (cn % p == 7) return false;
            cn /= p;
        }
    }
    return true;
}

template <class T> class BIT {
    //T has operator "+=" and can be initialized with 0.
    unsigned int n;
    vector<T> bitree;
public:
    BIT(unsigned long _n) : bitree(_n + 1, 0) {
        n = _n;
    }

    void add(int id, T x) {
        ++id;
        while (id <= n) {
            bitree[id] += x;
            id += id & -id;
        }
    }

    T sum(int id) {
        ++id;
        T temp(0);
        while (id > 0) {
            temp += bitree[id];
            id -= id & -id;
        }
        return temp;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>H>>W>>M;
    vec up(W, H), left(H, W);
    rep(i, M){
        ll x, y; cin>>x>>y;
        --x; --y;
        chmin(up[y], x);
        chmin(left[x], y);
    }
    ll res = 0;
    rep(i, up[0]) res += left[i];
    rep(i, left[0]) res += up[i];
    //cout<<res<<endl;
    BIT<ll> bit(W + 1);
    rep(i, left[0]) bit.add(i, 1);
    priority_queue<P, vector<P>, greater<> > pque;
    rep(i, left[0]) pque.emplace(up[i], i);
    rep(i, up[0]){
        while(!pque.empty()){
            P p = pque.top();
            ll hei = p.first, id = p.second;
            if(hei > i) break;
            pque.pop();
            bit.add(id, -1);
        }
        res -= bit.sum(left[i] - 1);
        //rep(j, W) cout<<bit.sum(j) - (j ? bit.sum(j-1) : 0)<<" \n"[j==W - 1];
        //cout<<bit.sum(left[i] - 1)<<endl;
    }
    cout<<res<<endl;
}


#include <iostream>
#include <map>
#define int long long
using namespace std;

const int MAXN = 4e5 + 10;
int f[MAXN], g[MAXN];

int C(int n, int k) {
	int sum = f[k] + f[n - k];
	if (f[n] > sum) {
		return 0;
	}
	return g[n] * g[n - k] * g[k] % 3;
}

signed main() {
	g[0] = 1;
	f[1] = 0;
	g[1] = 1;
	for (int i = 2; i < MAXN; ++i) {
		if (i % 3 == 0) {
			int cur = i, cnt = 0;
			while (cur % 3 == 0) {
				cur /= 3;
				cnt++;
			}
			f[i] = f[i - 1] + cnt;
			g[i] = g[i - 1] * cur % 3;
		}
		else {
			g[i] = g[i - 1] * i % 3;
			f[i] = f[i - 1];
		}
	}

	int n;
	cin >> n;
	int ans = 0;
	map<char, int> mp;
	map<int, char> mp_r;
	mp['B'] = 0;
	mp['W'] = 1;
	mp['R'] = 2;
	mp_r[0] = 'B', mp_r[1] = 'W', mp_r[2] = 'R';

	for (int i = 0; i < n; ++i) {
		char c;
		cin >> c;
//		cerr << C(n - 1, i) << endl;
		ans = (ans + C(n - 1, i) * mp[c]) % 3;
	}

	if (n % 2 == 0) {
		cout << mp_r[(3 - ans) % 3] << endl;
	}
	else {
		cout << mp_r[ans] << endl;
	}

	return 0;
}

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

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

  vll p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
  int sz = SZ(p);

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

  vector<vector<bool>> dp(n+1, vector<bool>(1<<sz, false));
  dp[0][0] = true;

  REP(i, n) {
    REP(j, 1<<sz) {
      if(!dp[i][j]) continue;
      REP(k, sz) {
        if(x[i] % p[k] == 0) {
          if(j>>k&1) {
            dp[i+1][j] = true;
          } else {
            dp[i+1][j|(1<<k)] = true;
          }
        }
      }
    }
  }

  ll ans = LINF;
  REP(i, 1<<sz) {
    if(dp[n][i]) {
      ll val = 1;
      REP(j, sz) {
        if(i>>j&1) {
          val *= p[j];
        }
      }
      chmin(ans, val);
    }
  }
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define eps 1e-18
#define pi acos(-1)
#define ar array
#define int int64_t

using namespace std;

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.fi << ", " << p.se << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << ""; for(int i = 0; i < v.size(); i++) {if (i) cout << " "; cout << v[i];} return cout << "";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
template<typename T> istream& operator>>(istream &cin, vector<T> &v){
  for(int i=0;i<v.size()-1;++i)cin>>v[i];
  return cin>>v[(int)v.size()-1];
}

template<class T>
T roof(T a, T b){
  return (a+b-1)/b;
}
template<class T>
T modulo(T a, T m){
  return (a%m+m)%m;
}

int Log(int a, int b){
  int c=0;
  while(a)a/=b,c++;
  return c;
}

int qpow(int x,int n, int m){
  int r = 1;
  for(;n;n>>=1){
    if(n&1)(r = r * x)%=m;
    (x = x * x)%=m;
  }
  return r;
}
bool pal(string s){
  for(int i=0;i<s.size()/2+1;++i)if(s[i]!=s[(int)s.size()-i-1])return false;
  return true;
}
template<class T>
void maxi(T& a, T b){
  a=max(a,b);
}
template<class T>
void mini(T& a, T b){
  a=min(a,b);
}

void done(int tc){
  int n,k; cin >> n >> k;
  while(k--){
    if(n%200==0){
      n/=200;
    }else{
      n *= 1000;
      n += 200;
    }
   // cerr << n << " ";
  }
  cout<<n<<endl;
 // cout <<"Case "<<<<tc<<": "<<((cnt==-1)?"IMPOSSIBLE":cnt)<<endl;
}

int32_t main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout<<fixed<<setprecision(10);
 // freopen("input.txt","r",stdin);
  int t; t = 1;
//  cin >> t;
  for(int i=1;i<=t;++i){
    //cout<<"Case #"<<i<<": ";
    //cout<<"Case "<<i<<": ";
    done(i);
  }
}

#include <bits/stdc++.h>

#define FOR(i,x,n) 	for(int i=x; i<n; i++)
#define F0R(i,n) 	FOR(i,0,n)
#define ROF(i,x,n) 	for(int i=n-1; i>=x; i--)
#define R0F(i,n) 	ROF(i,0,n)

#define WTF 		cerr << "WTF" << endl

#define IOS 		ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define F 			first
#define S	 		second
#define pb 			push_back
#define mp 			make_pair

#define ALL(x) 		x.begin(), x.end()
#define RALL(x) 	x.rbegin(), x.rend()
#define FILL(a, b) 	memset(a, b, sizeof(a));

#define TOGGLE(x) (x) = 1 - (x)

using namespace std;
typedef double 			db;
typedef long long 		LL;
typedef string 			str;

typedef pair<int, int> 	PII;
typedef pair<LL, LL> 	PLL;

typedef vector<int> 	VI;
typedef vector<LL> 		VLL;
typedef vector<bool> 	VB;
typedef vector<char> 	VC;
typedef vector<PII> 	VPII;
typedef vector<PLL> 	VPLL;
typedef vector<string> 	VSTR;

typedef set<int> 		SI;
typedef set<PII> 		SPII;
typedef set<PLL> 		SPLL;

typedef priority_queue<PII> DIPQ;

const int MAXN = 2e5 + 7;
const int MAXA = 1e7 + 7;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int LOG = 20;
const LL LONG_INF = 1e18;

int n;
str inp;

void Solve () {
	cin >> n >> inp;
	if (inp[0] != inp[n - 1]) {
		cout << 1 << endl;
		return;
	}

	else {
		FOR (i, 1, n - 2) {
			if (inp[i] != inp[0] && inp[i + 1] != inp[0]) {
				cout << 2 << endl;
				return;
			}
		}
	}

	cout << -1 << endl;
}

int main() {
	IOS;
	Solve ();
}


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

const int MOD = 1000000007;
vector<long long> fac, finv, inv;

void InitializeCombination(int COMMAX){
    fac.push_back(1LL);
    fac.push_back(1LL);
    finv.push_back(1LL);
    finv.push_back(1LL);
    inv.push_back(0LL); //Though 0^(-1) cannot be defined, there should be some number in inv[0]
    inv.push_back(1LL);
    for (int i = 2; i <= COMMAX; i++){
        fac.push_back(fac[i-1] * (long long)i % (long long)MOD);
        inv.push_back((long long)MOD - inv[MOD%i] * (long long)(MOD/i) % (long long)MOD);
        finv.push_back(finv[i-1] * inv[i] % (long long)MOD);
    }
}

long long Combination(int n, int r){
    if (n < r) return 0LL;
    if (n < 0 || r < 0) return 0LL;
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

long long InvCombination(int n, int r){
    if (n < r) return 0LL;
    if (n < 0 || r < 0) return 0LL;
    return finv[n] * (fac[r] * fac[n-r] % MOD) % MOD;
}

int HexCharToInt(char C){
    if((C>='0')&&(C<='9'))return C-'0';
    return C-'A'+10;
}

int main(void){
    string strN;
    int K;
    long long res = 0LL;
    cin >> strN >> K;
    vector<vector<long long>> numHex(1, vector<long long>(K+1, 0LL));
    int lenN = (int)strN.size();
    InitializeCombination(16);
    numHex.push_back({});
    for(int i=0; i<=K; i++)numHex[1].push_back(i == 1 ? 16LL : 0LL);
    for(int i=2; i<=lenN; i++){
        numHex.push_back({});
        for(int j=0; j<=K; j++){
            if((j==0)||(j>i)){
                numHex[i].push_back(0LL);
            }else{
                numHex[i].push_back((numHex[i-1][j]*j%MOD+numHex[i-1][j-1]*(17-j)%MOD)%MOD);
            }
        }
    }
    for(int i=1; i<lenN; i++){
        res += numHex[i][K]*15%MOD*inv[16]%MOD;
        res %= MOD;
    }
    set<int> setSpecies;
    int numSpecies = 0;
    for(int i=0; i<lenN; i++){
        int Ni = HexCharToInt(strN[i]);
        for(int j=0; j<Ni; j++){
            if((i==0)&&(j==0))continue;
            set<int> nxtSpecies = setSpecies;
            nxtSpecies.insert(j);
            int nxtNum = (int)nxtSpecies.size();
            if(nxtNum > K)continue;
            if(i<lenN-1){
                for(int k=K-nxtNum; k<=K; k++){
                    res += numHex[lenN-i-1][k]*Combination(nxtNum, nxtNum+k-K)%MOD*Combination(16-nxtNum, K-nxtNum)%MOD*InvCombination(16, k)%MOD;
                    res %= MOD;
                }
            }else{
                if(nxtNum==K){
                    res++;
                    res %= MOD;
                }
            }
        }
        setSpecies.insert(Ni);
        numSpecies = (int)setSpecies.size();
        if(numSpecies > K)break;
    }
    if(numSpecies == K)res = (res + 1) % MOD;
    cout << res << endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); (i)++)
#define per(i, n) for (ll i = n - 1; i >= 0; (i)--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define ROF(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define ALL(x) std::begin(x), std::end(x)

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //input, initialize
    int N, M; cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    //solve
    vector<vector<int>> C(M);
    rep(i, M) C[i].emplace_back(0);
    rep(i, N){
        if(A[i] >= M) continue;
        C[A[i]].emplace_back(i+1);
    }
    rep(i, M) C[i].emplace_back(N+1);
    int ans = M;
    rep(i, M){
        rep(j, C[i].size()-1){
            if(C[i][j+1] - C[i][j] > M){
                ans = i;
                goto isAns;
            }
        }
    }

isAns:
    //output
    cout << ans << '\n';
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   a %= mod;
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

bool check(pi a, pi b) {
  int num = (b.second - a.second);
  int den = (b.first - a.first);
  return (abs(num)<=abs(den));
}
void solve() {
  int n;
  cin >> n;
  vector<pi> points(n);
  int ans = 0;
  REP(i,0,n-1) {
    cin >> points[i].first >> points[i].second;
    REP(j,0,i-1) {
      if(check(points[i],points[j])) {
        ans++;
      }
    }
  }
  cout << ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    // cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using ll=  long long ;

#define rep(i,n)  for(int i=0;i<(n);i++)
#define f first
#define sc second

int fact(int n){
if(n==0){
     return 1;
 }else{
     return n*fact(n-1);
 }
}

bool is_prime(int x){
if(x<=1) return false;
for(int i=2;i*i<x;i++){
    if(x%i==0) return false;}
return true;}

template<class T>void chmin(T& a,T b){
    if(a>b){
        a=b;
    }
}

template<class T>void chmax(T& a,T b){
    if(a<b){
        a=b;
    }
}
int gcd(int x, int y) {
     if(x % y == 0) {
        return y;
     } else {
        return gcd(y, x % y);
     }
}

ll f(ll x,ll c,ll d){
    return x-x/c-x/d+x/(c/(gcd(c,d))*d);
}

using namespace std;
int main(){
   int n;
   cin>>n;

   set<string> t;

   string s[n];

   rep(i,n){
       cin>>s[i];
       t.insert(s[i]);
   }

   bool ok=false;

   rep(i,n){
       if(t.count('!'+s[i])){
           cout << s[i] << endl;
           ok=true;
           return 0;
       }
   }

   cout << "satisfiable" << endl;

}


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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("error.txt", "w", stderr);

template <typename Arg1>
void prn(Arg1&& arg1) { cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) { cout<<arg1<<" "; prn(args...); }

template <typename Arg1>
void prs(Arg1&& arg1) { cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) { cout<<arg1<<" "; prs(args...); }

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

#define int                     long long
#define all(ds)                 ds.begin(), ds.end()
#define uniq(v)                 (v).erase(unique(all(v)),(v).end())
#define gcd(x,y)                __gcd(x,y)
#define mp                      make_pair
#define rep(i,a,b)              for(int i=a;i<b;i++)
#define precise(x)              cout<<fixed<<setprecision(x)
#define endl                    "\n"

/* debug */
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x<<" "; _print(x); cerr << endl;
#else
#define debug(x);
#endif

void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
/* debug */

const long long INF = 2e18;
const int32_t MOD = 1e9+7;
const int N = 2e5+5;

int n, m, k, q, r, l, x, y, z;
int a[N], b[N], c[N];
string s, t;
int ans = 0;

void solve(){
    int t = 1;
    // read(t);
    while(t--){
        read(n,x);
        // sum is congruent to x modulo n
        int a[n];
        rep(i,0,n) read(a[i]);

        int ans = x;
        for(int size = 1; size <= n; ++size){
            vector<vector<int>>dp(size+1, vector<int>(size, -1));
            dp[0][0] = 0;

            for(int val: a){
                for(int i = size-1; i >= 0; --i){
                    for(int j = 0; j < size; ++j){
                        if(dp[i][j] == -1) continue;
                        int next = dp[i][j] + val;
                        dp[i+1][next%size] = max(dp[i+1][next%size], next);
                    }
                }
            }

            int start = dp[size][x%size];
            if(start == -1) continue;
            ans = min(ans, (x-start)/size);
        }
        prn(ans);
    }
}

signed main()
{
#ifndef ONLINE_JUDGE
    input_output
#else
    fastio
#endif

#ifdef SIEVE
    sieve();
#endif

#ifdef NCR
    init();
#endif

    auto start1 = high_resolution_clock::now();
    solve();
    auto stop1 = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop1 - start1);

#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000 << endl;
#endif

    return 0;
}

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

template<typename T>
void chmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void chmaxmap(map<T, T>& m, T key, T value) {
	if (m.count(key)) {
		chmax(m[key], value);
	}
	else {
		m[key] = value;
	}
}

template<typename T>
void chmin(T& reference, T value) {
	reference = min(reference, value);
}

ll solve(ll c) {
	vector<ll> as;
	while (c) {
		as.push_back(c % 10);
		c /= 10;
	}
	sort(as.begin(), as.end());
	int n = as.size();
	ll g = 0, l = 0;
	for (int i = 0; i < n; i++) {
		g *= 10;
		g += as[n - 1 - i];
		l *= 10;
		l += as[i];
	}
	return g - l;

}

int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll> as(n);
	ll u = 0;
	rep(i, n) {
		cin >> as[i];
		chmax(u, as[i]);
	}
	ll ans = x - u;
	for (int i = 2; i <= n; i++) {
		vector<vector<vector<ll>>> dp(n+1,
			vector<vector<ll>>(n + 1,
			vector<ll>(n + 1, -1)));
		dp[0][0][0] = 0;
		//j番目
		for (int j = 0; j < n; j++) {
			//k個取った
			for (int k = 0; k <= j; k++) {
				//余りがm
				for (ll m = 0; m < i; m++) {
					if (dp[j][k][m] >= 0) {
						chmax(dp[j+1][k][m], dp[j][k][m]);
						ll nm = (m + as[j]) % i;
						chmax(dp[j + 1][k + 1][nm], dp[j][k][m] + as[j]);
					}
				}
			}
		}
		for (int m = 0; m < i; m++) {
			ll v = dp[n][i][m];
			if (v >= 0) {
				if ((x - v) % i == 0) {
					chmin(ans, (x - v) / i);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a==c&&b==d)return puts("0"),0;
	if(a+b==c+d||a-b==c-d||abs(a-c)+abs(b-d)<=3)return puts("1"),0;
	if(abs(a-b-c+d)<=3||abs(a+b-c-d)<=3||((a+b)%2)==((c+d)%2))return puts("2"),0;
	puts("3");
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int solve(int sx, int sy, int gx, int gy) {
    if(sx == gx && sy == gy) return 0;
    if(sx + sy == gx + gy) return 1;
    if(sx - sy == gx - gy) return 1;
    if(abs(sx - gx) + abs(sy - gy) <= 3) return 1;
    if((abs(sx - gx) + abs(sy - gy)) % 2 == 0) return 2;
    return 3;
}

int main(){
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;

    int ans = solve(sx, sy, gx, gy);
    REP2(i, -3, 4) {
        REP2(j, -3, 4) {
            if (3 < abs(i) + abs(j)) continue;
            ans = min(ans, solve(sx + i, sy + j, gx, gy) + 1);
        }
    }

    cout << ans << endl;
}


#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <climits>

#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using namespace std;
template<class T> struct matrix{
  matrix(int n = 0, T m = numeric_limits<T>::max()) : n(n), Mod(m), a(n, vector<T>(n)){}
  vector<T> &operator[](const int &m){ return a[m]; }
  matrix &operator*=(const matrix &b){
    vector<vector<T>> c(n, vector<T>(n));
    rep(i, n) rep(j, b.n) rep(k, n){
      c[i][j] = (c[i][j] + a[i][k] * b.a[k][j]) % Mod;
    }
    a = c;
    return *this;
  }
  matrix &operator+=(const matrix &b){
    rep(i, n) rep(j, n){
      a[i][j] += b.a[i][j];
      if(a[i][j] >= Mod) a[i][j] -= Mod;
    }
    return *this;
  }
  matrix &operator-=(const matrix &b){
    rep(i, n) rep(j, n){
      a[i][j] -= b.a[i][j];
      if(a[i][j] <= -Mod) a[i][j] += Mod;
    }
    return *this;
  }
  matrix operator*(const matrix &b) const{ return matrix(*this) *= b; }
  matrix operator+(const matrix &b) const{ return matrix(*this) += b; }
  matrix operator-(const matrix &b) const{ return matrix(*this) -= b; }
  matrix pow(ll t) const{
    matrix<T> b(n, Mod), c = *this;
    rep(i, n) b[i][i] = 1;
    while(t > 0){
      if(t & 1) b *= c;
      c *= c;
      t /= 2;
    }
    return b;
  }
  int n;
  vector<vector<T>> a;
  private:
  T Mod;
};
int main(){
  int n,m,q;
  cin >> n;
  vl x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  cin >> m;
  matrix<ll> op1(3), op2(3), op3(3), op4(3);
  op1.a = {{0,1,0}, {-1,0,0}, {0,0,1}};
  op2.a = {{0,-1,0}, {1,0,0}, {0,0,1}};
  op3.a = {{-1,0,0}, {0,1,0}, {0,0,1}};
  op4.a = {{1,0,0}, {0,-1,0}, {0,0,1}};
  vector<matrix<ll>> c(m + 1);
  c[0] = matrix<ll>(3);
  c[0].a = {{1,0,0}, {0,1,0}, {0,0,1}};
  rep(i, m){
    int t; cin >> t;
    if(t == 1) c[i + 1] = op1 * c[i];
    if(t == 2) c[i + 1] = op2 * c[i];
    if(t == 3){
      ll p; cin >> p;
      op3.a[0][2] = 2 * p;
      c[i + 1] = op3 * c[i];
    }
    if(t == 4){
      ll p; cin >> p;
      op4.a[1][2] = 2 * p;
      c[i + 1] = op4 * c[i];
    }
  }
  cin >> q;
  rep(i, q){
    int a,b;
    cin >> a >> b;
    b--;
    vl pos = {x[b], y[b], 1}, ans(3);
    rep(j, 3) rep(k, 3) ans[j] += c[a][j][k] * pos[k];
    cout << ans[0] << " " << ans[1] << endl;
  }
}

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

struct Operation
{
  int M;
  vector<vector<long long>> op;

  vector<vector<long long>> sel = {
    {0, 1, 0, -1, 0, 0, 0, 0, 1},
    {0, -1, 0, 1, 0, 0, 0, 0, 1},
    {-1, 0, 0, 0, 1, 0, 0, 0, 1},
    {1, 0, 0, 0, -1, 0, 0, 0, 1}
  };

  Operation(int m) : M(m)
  {
    op.resize(M + 1);
    for (int i = 0; i < M + 1; ++i)
    {
      op.at(i).resize(9);
    }
    op.at(0) = {1, 0, 0, 0, 1, 0, 0, 0, 1};
  }

  vector<long long> multiply(const vector<long long> &a, const vector<long long> &b) {
    vector<long long> rtn(9);
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        rtn.at(i * 3 + j) = a.at(i*3+0) * b.at(0+j) + a.at(i*3+1) * b.at(3+j) + a.at(i*3+2) * b.at(6+j);
      }
    }
    return rtn;
  }

  void update(int i, int o, int p)
  {
    if (o > 2) sel.at(o-1).at((o-2)*3-1) = 2 * p;
    op.at(i) = multiply(sel.at(o-1), op.at(i-1));
  }

  pair<long long, long long> apply(int i, pair<long long, long long> xy) {
    pair<long long, long long> rtn;
    rtn.first = op.at(i).at(0) * xy.first + op.at(i).at(1) * xy.second + op.at(i).at(2);
    rtn.second = op.at(i).at(3) * xy.first + op.at(i).at(4) * xy.second + op.at(i).at(5);
    return rtn;
  }
};
int main()
{
  int n;
  cin >> n;
  vector<pair<long long, long long>> xy(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> xy.at(i).first >> xy.at(i).second;
  }

  int m;
  cin >> m;
  Operation op(m);
  for (int i = 1; i <= m; ++i)
  {
    int o, p = 0;
    cin >> o;
    if (o > 2) cin >> p;
    op.update(i, o, p);
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    pair<long long, long long> ans = op.apply(a, xy.at(b-1));
    cout << ans.first << " " << ans.second << endl;

  }

  return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
ll n,m;
cin>>n>>m;
cout<<(n+m)/2<<" "<<(n-m)/2;

}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
const int INF=1LL<<30;
const string YYY="YES";
const string yyy="Yes";
const string NNN="NO";
const string nnn="No";
template<class T>void chmin(T& a,T b){
  if(a>b){
    a=b;
  }
}
template<class T>void chmax(T& a,T b){
  if(a>b){
    a=b;
  }
}
string rot13(string S){
  int a=S.size();
  for(int i=0;i<a;i++){
   if(S[i]=='a'){S[i]='n';continue;}
    if(S[i]=='b'){S[i]='o';continue;}
    if(S[i]=='c'){S[i]='p'; continue;}
    if(S[i]=='d'){S[i]='q'; continue;}
    if(S[i]=='e'){S[i]='r'; continue;}
    if(S[i]=='f'){S[i]='s'; continue;}
    if(S[i]=='g'){S[i]='t'; continue;}
    if(S[i]=='h'){S[i]='u'; continue;}
    if(S[i]=='i'){S[i]='v'; continue;}
    if(S[i]=='j'){S[i]='w'; continue;}
    if(S[i]=='k'){S[i]='x'; continue;}
    if(S[i]=='l'){S[i]='y'; continue;}
    if(S[i]=='m'){S[i]='z'; continue;}
    if(S[i]=='n'){S[i]='a'; continue;}
    if(S[i]=='o'){S[i]='b'; continue;}
    if(S[i]=='p'){S[i]='c'; continue;}
    if(S[i]=='q'){S[i]='d';continue;}
    if(S[i]=='r'){S[i]='e'; continue;}
    if(S[i]=='s'){S[i]='f'; continue;}
    if(S[i]=='t'){S[i]='g'; continue;}
    if(S[i]=='u'){S[i]='h'; continue;}
    if(S[i]=='v'){S[i]='i'; continue;}
    if(S[i]=='w'){S[i]='j'; continue;}
    if(S[i]=='x'){S[i]='k';continue;}
    if(S[i]=='y'){S[i]='l'; continue;}
    if(S[i]=='z'){S[i]='m'; continue;}
  }
  return S;
}
ll GD(ll num){//各桁の和
    ll digit=0;
    while(num!=0){
        digit+=num%10;
        num/=10;
    }
    return digit;
}
bool if_integer( ld x ){//整数判定
  return std::floor(x)==x;
}
bool if_prime(ll x){
  bool a=true;
  for(ll i=2;i*i<=x;i++){
   if(x%i==0){
    a=false;break;
   }
  }
  if(x==1)a=false;
  return a;
}
ll gcd(ll x, ll y)//最大公約数
{
   if (x%y == 0)
   {
       return(y);
   }
   else
   {
       return(gcd(y, x%y));
   }
}

ll lcm(ll x, ll y)//最小公倍数
{
   return x / gcd(x, y)*y ;
}
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
int main() {
  ll n,k;cin>>n>>k;
  ll sum=0;
  sum+=100*(n)*(n+1)/2*k;
  sum+=n*(k)*(k+1)/2;
  cout<<sum;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 500010;
ll prime[N] = {0}, num_prime = 0; //prime存放着小于N的素数
int isNotPrime[N] = {1, 1};       // isNotPrime[i]如果i不是素数，则为1
ll n, cnt;
ll Not[N];

int Prime()
{
    for (ll i = 2; i < N; i++)
    {
        if (!isNotPrime[i])
            prime[num_prime++] = i;
        //无论是否为素数都会下来
        for (ll j = 0; j < num_prime && i * prime[j] < N; j++)
        {
            isNotPrime[i * prime[j]] = 1;
            if (!(i % prime[j])) //遇到i最小的素数因子
                                 //关键处1
                break;
        }
    }
    for (int j = 0; prime[j] * prime[j] <= 1e5; j++)
    {
        ll temp = prime[j] * prime[j];
        while (temp <= 1e5)
        {
            Not[temp] = true;
            temp *= prime[j];
        }
    }
    return 0;
}

long long ifpower(long long _a, long long _b, long long _p = 1e18)
{
    long long _ans = 1;
    while (_b)
    {
        if (_b & 1)
            _ans = (_ans * _a) % _p;
        _a = (_a * _a) % _p;
        _b >>= 1;
    }
    return _ans;
}

int main()
{
    Prime();
    scanf("%lld", &n);
    // for (int i = 2; i <= 10; i++)
    //     printf("%d ", Not[i]);
    cnt = 0;
    for (ll i = 2; i * i <= n; i++)
    {
        if (Not[i])
            continue;
        ll temp = i * i;
        while (temp <= n)
        {
            if(temp<=1e5)
                Not[temp] = true;
            cnt++;
            temp *= i;
        }
    }
    printf("%lld", n - cnt);
    return 0;
}

#include<iostream>
using namespace std;

int main(){
  int N;
  cin>>N;
  int arr[N];
  for(int i=0;i<N;i++){
  	cin>>arr[i];
  }

  int sum=0;
  for(int i=0;i<N;i++){
  	if(arr[i]>10) sum+=arr[i]-10;
  }

  cout<<sum<<endl;

  return 0;
}


// International Master sm0016
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define raftaar ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll MOD1=1000000007;

const ll MOD2= 998244353;

const int N=1e6+6;

int main(){
	raftaar

	int a,b;cin>>a>>b;int ans=1;int check[N]={0};

	for(int i=a;i<=b;i++){

		for(int j=1;j*j<=i;j++){

			if(i%j==0){

				if(j*j==i) check[j]++;

				else{check[j]++;check[i/j]++;}
			}
		}
	}
	for(int i=1;i<=max(a,b);i++){

		if(check[i]>1) ans=max(ans,i);
	}

	cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<ll,int>
#define PI 3.141592653589793
#define pb push_back
#define C complex<double>
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 998244353;

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	map<int, int> mp;
	rep(i, n) mp[a[i]]++;
	rep(i, m) mp[b[i]]++;
	rep(i, 1000) {
		if (mp[i + 1] == 1) cout << i + 1 << " ";
	}
}


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

#define ff                first
#define brn                "\n"
#define ss                second
#define mk                make_pair
#define int               long long
#define pb                push_back
#define ps(x,y)           fixed<<setprecision(y)<<x
#define w(x)              int x; cin>>x; while(x--)
#define FOR(i,a,b)        for(int i=(a);i<(b);i++)
#define ROF(i,a,b)        for(int i=(a);i>=(b);i--)
#define so(a,n)           sort(a,a+n)
#define rso(a,n)          sort(a,a+n),reverse(a,a+n)
#define all(v)            (v).begin(),(v).end()
#define ps(x,y)           fixed<<setprecision(y)<<x
#define sz                size();
#define p_sieve           10000007
const int                 maxn = 1e3 + 5;
const int                 modulo=1000000007;
#define mod               1000000009;
const double              pi=3.14159;

//check n==1 and base cases//
//don't stuck on 1 question  try another too

// int dp(int a[],int x,int i,int n)
// {
//  if(i>n-1)return 0;

//  if(a[i]>x)
//  {
//    return mini=min(dp(a,x,i+1,n),dp())
//  }
// }
// void zfun(string s)
// {
//  int n;cin>>n;
//  int a[n];
//  FOR(i,0,n)cin>>a[i];
//  int q;cin>>q;
//  int maxi=0;
//  FOR(i,0,q)
//  {
//    int x;cin>>x;
//    if(x==2)
//    {
//      int y;cin>>y;
//      maxi=max(maxi,y);
//    }
//    else
//    {
//      int y,z;cin>>y>>z;
//      a[y-1]=z;
//    }
//  }
//  FOR(i,0,n)
//  {
//    if(a[i]<maxi)a[i]=maxi;
//  }
//  for(auto i:a)cout<<i<<' ';
// }

// int cnt(string s,int i,int n,int tt)
// {
//   if(i>=n)return 0;

//   if(s[i]=='u' and s[i+1]=='u')
//   {
//     return cnt(s,i+2,n,tt+1)+cnt(s,i+1,n,tt);
//   }
//   else if(s[i]=='n' and s[i+1]=='n')
//   {
//     return cnt(s,i+2,n,tt+1)+cnt(s,i+1,n,tt);
//   }
//   // else return cnt(s,i+1,n,tt)+cnt(s,i+1,n,tt);
//   return tt;
// }

// ll dp[N][2][2]={0};
// ll n;
// ll a[100000],b[100000];

// ll maxi(int i,int ch,int x)
// {
//   if(i>=n)return 0;
//   if(dp[i][x][ch]!=-1)return dp[i][x][ch];
//   if(x==0) dp[i][x][ch] = max(maxi(i+1,0,1)+b[i],maxi(i+1,1,1)+a[i]);
//   else if(ch==1)  dp[i][x][ch] = max(maxi(i+1,0,1)+b[i],maxi(i+1,0,0));
//   else if(ch==0) dp[i][x][ch] = max(maxi(i+1,1,1)+a[i],maxi(i+1,1,0));
//   return dp[i][x][ch];
// }

// const int N=100005;
// int dp[N][2][2];
// int a[100005];
// int b[100005];
// int n;
// int maxi(int i,int ch,int x)
// {
//   if(i>=n)return 0;
//   if(dp[i][ch][x]!=-1)return dp[i][ch][x];
//   if(x==0) dp[i][ch][x] = max(maxi(i+1,0,1)+b[i],maxi(i+1,1,1)+a[i]);
//   else if(ch==1)dp[i][ch][x] = max(maxi(i+1,0,1)+b[i],maxi(i+1,0,0));
//   else if(ch==0)dp[i][ch][x] = max(maxi(i+1,1,1)+a[i],maxi(i+1,1,0));
//   return dp[i][ch][x];
// }
// int n,k,m;
// int a[N],b[N],c[N];
// int x,y,cnt=0;
// std::vector<pair<int,int>> v;
// std::vector<int> vec,vec1;
// set<int>s;
//********************************---------always check array boundness-----------****************

void solve()
{
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout<<min(a,min(b,min(c,d)));
}
//########################---------code ends here------------------########################################################
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //prime_sieve();
    //w(t)
    solve();
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = min({a, b, c, d});
	cout << ans << endl;
	return 0;
}


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

#define int long long
#define ll long long
//#define ull unsigned ll
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v, x, sizeof v)
#define ff first
#define ss second
#define td(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,a,n) for (int i=(n-1);i>=a;i--)
#define trav(a, x) for(auto& a : x)
#define re(v) {for(auto &_re : v) cin >> _re;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define eb emplace_back
using namespace std;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll M = 1e9 + 7;
//const ll M = 998244353;
//const ll M = 1e9 + 9;
//const ll M = 1e6;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll binpow(ll a, ll b){
  ll res = (a!=0) % M;
  while(b > 0){
    if(b&1) res = res * a % M;
    a = a * a % M;
    b>>=1;
  }
  return res;
}

void solve(){
  ll a, b , c;
  cin >> a >> b >> c;
  cout << (7 - a) + (7 - b) + (7 - c) << endl;

}

int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }

}

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
int n, m, i, j;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	string s, x;
	cin >> s >> x;
	vector<int>dp(10);
	dp[0] = 1;
	for(i=s.size()-1;i>=0;i--){
		vector<int>tmp(10);
		for(j=0;j<7;j++){
			int ps = j*10+s[i]-'0';
			int p = j*10;
			ps %= 7;
			p %= 7;
			if(x[i]=='A'){
				if(dp[ps]&&dp[p])
					tmp[j] = 1;
			}
			else{
				if(dp[ps]||dp[p]){
					tmp[j] = 1;
				}
			}
		}
		dp = tmp;
	}
	if(dp[0])
		cout << "Takahashi\n";
	else
		cout << "Aoki\n";
}


#include<bits/stdc++.h>
#define int long long

using namespace std;

#define MOD 1000000007

void solve()
{
    int n;
    cin>>n;
    int a,b,c;
    int num = n+1;
    int ans = 0;
    vector<vector<pair<int,int>>>gra(num);
    for(int i=0;i<n-1;i++)
    {
        cin>>a>>b>>c;
        gra[a].push_back({b,c});
        gra[b].push_back({a,c});
    }
    queue<int>q;
    q.push(1);
    vector<int>visited(n+1),distance(n+1);
    distance[1] = 0;
    while(!q.empty())
    {
        int r = q.front();
        q.pop();
        if(visited[r]==1)
        {
            continue;
        }
        visited[r] = 1;
        for(int i=0;i<gra[r].size();i++)
        {
            distance[gra[r][i].first] = distance[r]^gra[r][i].second;
            // cout<<gra[r][i].first<<" "<<distance[gra[r][i].first]<<endl;
            q.push(gra[r][i].first);
        }
    }
    for(int i=1;i<=61;i++)
    {
        int numo = 0,numz = 0;
        for(int j=1;j<=n;j++)
        {
            if(distance[j]&1)
                numo++;
            else
                numz++;
            distance[j] = distance[j]>>1;
        }
        int pans = (((int)pow(2,i-1)%MOD*numo)%MOD*numz)%MOD;
        // cout<<pans<<endl;
        ans=(ans+pans)%MOD;
    }
    cout<<ans<<endl;
}

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

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N;
vector<pair<int, ll>> E[201010];
ll xo[201010];
//---------------------------------------------------------------------------------------------------
void dfs(int cu, int pa, ll x) {
    xo[cu] = x;
    fore(p, E[cu]) if (pa != p.first) dfs(p.first, cu, x ^ p.second);
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N - 1) {
        int a, b; ll c; cin >> a >> b >> c;
		a--; b--;
		E[a].push_back({ b, c });
		E[b].push_back({ a, c });
	}

    dfs(0, -1, 0);

    mint ans = 0;
    rep(bit, 0, 60) {
        ll msk = 1LL << bit;
        ll cnt[2] = { 0, 0 };
        rep(i, 0, N) cnt[(xo[i] & msk) != 0]++;
        ans += mint(msk) * mint(cnt[0]) * mint(cnt[1]);
    }
    cout << ans << endl;
}


// Problem : B - Abbreviate Fox
// Contest : AtCoder - AtCoder Regular Contest 108
// URL : https://atcoder.jp/contests/arc108/tasks/arc108_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
    T f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int n;
char s[N], stk[N];
int tp;

int main()
{
    //File("");
    n = gi <int> ();
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i+=1)
    {
    	stk[++tp] = s[i];
    	if (tp >= 3 && stk[tp] == 'x' && stk[tp - 1] == 'o' && stk[tp - 2] == 'f')
    		tp -= 3;
    }
    printf("%d\n", tp);
    return 0;
}

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    string fie[510];
    for(int i=0;i<H;i++)cin>>fie[i];
    int flglis[1010]={0};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(fie[i][j]=='B')flglis[i+j]=flglis[i+j]|1;
            if(fie[i][j]=='R')flglis[i+j]=flglis[i+j]|2;
        }
    }
    long long int ans=1;
    for(int i=0;i<=H+W-2;i++){
        if(flglis[i]==0){
            ans*=2;
            ans%=998244353;
        }
        else if(flglis[i]==3){
            ans*=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

li len(vector<vector<li>>& vec,vector<int>& kero){
  int n=kero.size(),a=0;

  li ret=0;
  rep(i,n){
    ret+=vec[a][kero[i]];
    a=kero[i];
  }
  ret+=vec[a][0];
  if(df)print(ret);
  return ret;
}

int main(){
  int n;
  li k; cin >>n >>k;
  vector<vector<li>> vec(n,vector<li>(n));
  rep(i,n) rep(j,n) cin >>vec[i][j];
  vector<int> kero(n-1);
  rep(i,n-1) kero[i]=i+1;
  int cnt=0;
  do{
    if(k==len(vec,kero)) cnt++;
  }while(next_permutation(kero.begin(),kero.end()));
  print(cnt);
}

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

#define int long long
#define pb push_back
#define all(v) begin(v), end(v)
#define mod (int)(1e9 + 7)
#define inf (int)(4e18)
#define N (int)(2e5 + 10)
#define ff first
#define ss second

/* Clear global containers without fail */
list<pair<int, int>> adjList[10];
int vis[10] = {};
int n, k;

int backtrack(int nd, int time) {
      if (time > k) return 0;
      vis[nd] = true;
      int ans = 0;

      for (auto it : adjList[nd]) {
            if (it.ff == 1 and time + it.ss == k) ans++;
            else if (!vis[it.ff]) ans += backtrack(it.ff, time + it.ss);
      }

      vis[nd] = false;
      return ans;
}

void testCase() {
      cin >> n >> k;
      for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                  int a; cin >> a;
                  adjList[i].pb({j, a});
            }
      }

      cout << backtrack(1, 0) << endl;
}

/* Work hard .. Calm and proceed */
int32_t main() {
      ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
      int t_c = 1;
      // cin >> t_c;
      while (t_c--)
            testCase();
}


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

int main(){
    int n,m;
    cin>>n>>m;

     int A[n];
    map< int,int>P;
    int mx=-1;
    for(int i=0;i<n;++i){
        cin>>A[i];
        P[A[i]]++;
        mx=max(mx,A[i]);
    }

    int c=0;

    int tot=0;int f=0,g=0;
    for(int i=0;i<=(mx+1);++i){
        m=min(m,P[i]);
        tot+=m;
    }
   cout<<tot<<endl;

}

// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 12/19/20 19:28:51
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w; cin>>h>>w;
  int minv = 1000;
  vector<vector<int>> A(h, vector<int>(w));
  for (auto& l:A) for (auto& v:l) {
    cin>>v;
    minv = min(minv, v);
  }
  int ans = 0;
  for (auto& l:A) for (auto& v:l) {
    ans += v-minv;
  }
  cout << ans << endl;

  return 0;
}


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

struct P {
  int id, x, y;
};

int chebyshev(P p1, P p2)
{
  return max(abs(p1.x - p2.x), abs(p1.y - p2.y));
}

int main()
{
  int n;
  cin >> n;
  vector<P> v(n);
  rep(i,0,n-1)
  {
    v[i].id = i;
    cin >> v[i].x >> v[i].y;
  }

  vector<P> unsorted = v;
  vector<int> ids;
  sort(v.begin(), v.end(), [](P p1, P p2) { return p1.x > p2.x; });
  ids.push_back(v[0].id);
  ids.push_back(v[1].id);
  ids.push_back(v[n-2].id);
  ids.push_back(v[n-1].id);
  sort(v.begin(), v.end(), [](P p1, P p2) { return p1.y > p2.y; });
  ids.push_back(v[0].id);
  ids.push_back(v[1].id);
  ids.push_back(v[n-2].id);
  ids.push_back(v[n-1].id);

  sort(ids.begin(), ids.end());
  auto last = unique(ids.begin(), ids.end());
  ids.erase(last, ids.end());

  vector<int> ans;
  for (size_t i = 0; i < ids.size(); ++i)
    for (size_t j = i + 1; j < ids.size(); ++j)
      ans.push_back(chebyshev(unsorted[ids[i]], unsorted[ids[j]]));
  sort(ans.begin(), ans.end(), greater<int>());
  cout << ans[1] << endl;
  return 0;
}

#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<string>
#include<unordered_map>
using namespace std;
using ll = long long;
constexpr int N = 2e5 + 5;

struct Point {
    int x;
    int y;
    int id;
}p[N];

bool cmpx(Point a, Point b) {
    return a.x < b.x;
}

bool cmpy(Point a, Point b) {
    return a.y < b.y;
}

pair<int, int> pa[N];
priority_queue<int> q;
set<pair<int, int> > st;

int main() {
	int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d%d", &p[i].x, &p[i].y);
        pa[i] = {p[i].x, p[i].y};
        p[i].id = i;
    }
    sort(p + 1, p + 1 + n, cmpx);
    for(int i = 1; i <= 2; ++i) {
        for(int t = n - 1; t <= n; ++t) {
            int a = p[i].id;
            int b = p[t].id;
            if(a > b)  swap(a, b);
            st.insert({a, b});
        }
    }
    sort(p + 1, p + 1 + n, cmpy);
    for(int i = 1; i <= 2; ++i) {
        for(int t = n - 1; t <= n; ++t) {
            int a = p[i].id;
            int b = p[t].id;
            if(a > b)  swap(a, b);
            st.insert({a, b});
        }
    }
    for(auto &tt : st) {
        int a = tt.first;
        int b = tt.second;
        q.push(max(abs(pa[a].first - pa[b].first), abs(pa[a].second - pa[b].second)));
    }
    q.pop();
    printf("%d", q.top());
    return 0;
}


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

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
//main関数内に extGCD(a, b, x, y); でx, yに解が格納
ll extGCD(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
//printf("%.10f\n", n);
typedef pair <ll, ll> P;
typedef pair <ld, ll> pp;
ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
struct edge { ll to, cost; };
struct status {
	ll ima;
	ll cost;

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

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

	//input
	ll n; cin >> n;
	vector<ll> v(2 * n); vector<P> card(2 * n);
	rep(i, 2 * n) {
		cin >> v[i]; ll ba = 0;
		if (i < n) { ba = n - i; }
		else { ba = i - n + 1; }
		card[i] = P(v[i], ba);
	}
	sort(all(card)); reverse(all(card));
	set<ll> s;
	rep(i, n + 1) {
		s.insert(i);
	}
	vector<bool> use(2 * n, false);
	ll ans = 0;
	rep(i, 2 * n) {
		ll ba = card[i].second;
		if (!use[ba]) { use[ba] = true; s.erase(ba); ans += card[i].first; }
		else {
			auto itr = s.lower_bound(ba); itr--;
			if (*itr != 0) {
				use[*itr] = true; s.erase(*itr); ans += card[i].first;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

    if(N % 100 == 0) cout << N / 100;
    else cout << N / 100 + 1;
    cout << endl;

}


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

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) for(int j = i + 1; j < N; j++) {
        double slope = (double) (y[j] - y[i]) / (x[j] - x[i]);
        if (slope >= -1 && slope <= 1) {
            ans += 1;
        }
    }

    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define pl pair<lli,lli>
#define vl vector<lli>
#define vvl vector<vl>
#define INF (lli)2e18

lli slope(lli x1,lli y1,lli x2,lli y2){
    auto l = (y2-y1)*(y2-y1);
    auto r = (x2-x1)*(x2-x1);
    if(l<=r)return 1;
    else return 0;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;cin>>n;
    vvl val;val.resize(n);
    for(lli i=0;i<n;i++){
        lli a,b;cin>>a>>b;
        val[i].pb(a);val[i].pb(b);
    }
    lli ans=0;
    for(lli i=0;i<n;i++){
        for(lli j=i+1;j<n;j++){
            if(slope(val[i][0],val[i][1],val[j][0],val[j][1]))ans++;
        }
    }
    cout<<ans;
	return 0;
}


#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(...) begin(__VA_ARGS__) , end(__VA_ARGS__)
#define boost {ios_base::sync_with_stdio(false); cin.tie(); cout.tie();}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll nax = 1699, INF = 2e9+6969;

int n,m,ans,dp[nax][nax],A[nax],B[nax];

int main()
{
	ans = INF;
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;++i) scanf("%d", &A[i]);
	for(int i=1;i<=m;++i) scanf("%d", &B[i]);

	for(int i=1;i<=n;++i) dp[i][0] = i;
	for(int i=1;i<=m;++i) dp[0][i] = i;

	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + 1;
			dp[i][j] = min(dp[i][j], dp[i-1][j-1]+1);
			if(A[i] == B[j]) dp[i][j] = min(dp[i][j], dp[i-1][j-1]);
		}
	}

	//  for(int i=1;i<=n;++i)
	//  {
		//  for(int j=1;j<=m;j++) printf("%d ", dp[i][j]);
		//  puts("");
	//  }

	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) ans = min(ans, dp[i][j] + n-i + m-j);
	printf("%d\n", ans);
	return 0;
}

#include <iostream>
#include <vector>

using namespace std;

class Solution{

private:
    int N, M;

public:
    int solve(int N, int M, vector<int>& A, vector<int>& B){

        this->N = N, this->M = M;
        vector<vector<int>> dp(N, vector<int>(M, -1));
        return dfs(A, B, 0, 0, dp);
    }

private:
    int dfs(const vector<int>& A, const vector<int>& B, int ai, int bi,
            vector<vector<int>>& dp){

        if(ai == A.size()) return B.size() - bi;
        if(bi == B.size()) return A.size() - ai;
        if(dp[ai][bi] != -1) return dp[ai][bi];

        int res = 1 + min(dfs(A, B, ai + 1, bi, dp), dfs(A, B, ai, bi + 1, dp));
        res = min(res, (A[ai] != B[bi]) + dfs(A, B, ai + 1, bi + 1, dp));
        return dp[ai][bi] = res;
    }
};

int main() {

    int N, M;
    cin >> N >> M;

    vector<int> A(N), B(M);
    for(int i = 0; i < N; i ++) cin >> A[i];
    for(int i = 0; i < M; i ++) cin >> B[i];
    cout << Solution().solve(N, M, A, B) << endl;

    return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
#define ll long long
#define ld long double
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

long long powm(long long a, long long b,long long mod) {
long long res = 1;
while (b > 0) {
    if (b & 1)
        res = res * a %mod;
    a = a * a %mod;
    b >>= 1;
}
return res;
}

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

int pre[100005];
int ans[100005];

signed main()
{

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

#ifndef ONLINE_JUDGE
if(fopen("INPUT.txt","r"))
{
freopen("INPUT.txt","r",stdin);
freopen("OUTPUT.txt","w",stdout);
}
#endif

    int n,q;
    cin>>n>>q;
    int a[n+2];
    a[0]=0;

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

    for(int i=1;i<=n;i++)
    {
        pre[i]=pre[i-1]+a[i]-a[i-1]-1;
    }

    pre[n+1]=1e18+pre[n];

    vector<pair<int,int>>qq;
    int x;
    for(int i=0;i<q;i++)
    {
        cin>>x;
        qq.push_back({x,i});
    }
    sort(qq.begin(),qq.end());
    // cout<<pre[2]<<endl;
    for(auto i:qq)
    {
        int l=1,r=n+1;
        int mn=n+1;
        while(l<=r)
        {
            int mid=l+(r-l)/2;
            if(pre[mid]>=i.first)
            {
                r=mid-1;
                mn=min(mn,mid);
            }
            else
            {
                l=mid+1;
            }
        }
        ans[i.second]=a[mn-1]+(i.first-pre[mn-1]);
    }

    for(int i=0;i<q;i++)
        cout<<ans[i]<<'\n';

}

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
using ll = long long;
struct Edge
{
    ll to;
    ll cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), v.end()
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = LLONG_MAX;
const int MAX = 510000;
bool graph[nmax][nmax];
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long K)
{
    ll ans = 0;
    for (int i = 2; i <= 2 * N; i++)
    {
        ll ab = i + K;
        if (ab < 2 || ab > 2 * N)
            continue;

        ll tmp = 0;
        if (ab >= N + 1)
        {
            tmp = N - (ab - N) + 1;
        }
        else
        {
            tmp = ab - 1;
        }

        if (i >= N + 1)
        {
            tmp *= N - (i - N) + 1;
        }
        else
        {
            tmp *= i - 1;
        }
        ans += tmp;
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int> g[200005];
vector<P> p[200005];
int ans[200005];
map<int,int> f(int u=0,int d=0){
  // cout << u << endl;
  map<int,int> s;
  for(int v:g[u]){
    auto t = f(v,d+1);
    if(t.size()>s.size()) swap(s,t);
    for(auto i:t) s[i.first] += i.second;
  }
  s[d]++;
  for(auto i:p[u]) ans[i.first] = s[i.second];
  return s;
}
int main() {
  int n;
  cin >> n;
  rep(i,n-1){
    int p;
    cin >> p;
    g[p-1].push_back(i+1);
  }
  int q;
  cin >> q;
  rep(i,q){
    int u,d;
    cin >> u >> d;
    p[u-1].emplace_back(i,d);
  }
  f();
  rep(i,q) printf("%d\n",ans[i]);
}

#include<iostream>
#include<bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define fo(i,n) for(int i=1;i<=n;i++)
#define foo(i,n) for(int i=0;i<n;i++)
#define sort(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) sort(v); v.resize(unique(v.begin(), v.end())-v.begin());
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define ok ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#define vp vector<pair<int,int>>
#define mod 1000000007
const int huge = 1e17;

int max(int a,int b){ if(a>b) return a; return b; }
int min(int a,int b){ if(a<b) return a; return b; }
int abbs(int a,int b){   if(a-b < 0) return b-a; return a-b; }

int lowerB(vi &v, int val){
int ind=v.size(),l=0,r=v.size(),mid;while(l<=r){mid=(l+r)/2;if(v[mid]>=val){ind=mid;r=mid-1;}else l=mid+1;}return ind;
}

vi adj[200005];
vi in(200005);
vi out(200005);
vi d[200005];
int timer;

void dfs(int node = 1, int dep = 0) {
    in[node] = timer++;
    d[dep].pb(in[node]);
    for(int x: adj[node]) dfs(x, dep+1);
    out[node] = timer++;
}

void solve(){
    int n; cin>>n;
    fo(i,n-1) {
        int x; cin>>x;
        adj[x].pb(i+1);
    }
    dfs();
    int q; cin>>q;
    while(q--) {
        int u, dd;
        cin>>u>>dd;
        int l = in[u], r = out[u];
        int ans = lower_bound(d[dd].begin(), d[dd].end(), l) - lower_bound(d[dd].begin(), d[dd].end(), r+1);
        cout<<ans*-1<<"\n";

    }
    // how many nodes are child of v at depth of d
}

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


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

typedef long long int lld;
#define all(m) m.begin(),m.end()
#define sz(m) lld(m.size())
#define pb push_back
#define mod 1000000007
#define st first
#define nd second
#define endl "\n"

void swagWaalaFunction()
{
	lld a,b,c,ans=0;
	cin>>a>>b>>c;

	ans=21-a-b-c;
	cout<<ans<<endl;
}

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

	lld tc=1;
	//cin>>tc;

	for(int i=0;i<tc;i++)
	{
		// cout<<"Case #"<<i+1<<": ";
		swagWaalaFunction();
	}
	return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll mod = 1000000007;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<21-(a+b+c);
}
int main()
{
    solve();
}


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

const int MN = 200012;

int n, q;
int c[MN];
int id[MN];
set<int> st[MN];
map<int, int> ctr[MN];

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    id[i] = i;
    st[i].insert(i);
    ctr[i][c[i]] = 1;
  }
  while (q--) {
    int op, x, y;
    cin >> op >> x >> y;
    if (op == 1) {
      if (id[x] == id[y]) continue;
      set<int>& sa = st[id[x]];
      set<int>& sb = st[id[y]];
      map<int, int>& ma = ctr[id[x]];
      map<int, int>& mb = ctr[id[y]];
      if (sa.size() < sb.size()) {
        for (int s : sa) {
          id[s] = id[y];
          sb.insert(s);
          mb[c[s]]++;
        }
        sa.clear();
        ma.clear();
      } else {
        for (int s : sb) {
          id[s] = id[x];
          sa.insert(s);
          ma[c[s]]++;
        }
        sb.clear();
        mb.clear();
      }
    } else {
      cout << ctr[id[x]][y] << '\n';
    }
  }
  return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#include <numeric>
#include <memory>
#include <random>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

template<typename Key, typename Cnt=int>
struct hashmultiset{
  float load_factor = 0.8;
  int table_size = 16;
  int mod = 15;
  const Key null_key;
  uint32_t mask;
  Cnt valid_size;
  int valid_type;
  vector<int> idx_table;
  vector<pair<Key, Cnt>> data;
  function<uint32_t(Key)> f = std::hash<uint32_t>();

  void expand_table(){
    table_size *= 2;
    mod = table_size - 1;
    idx_table.resize(table_size);
    fill(idx_table.begin(), idx_table.end(), -1);
    for(int i=0;i<data.size();i++){
      if(data[i].first==null_key) continue;
      inner_insert(i);
    }
  }
  void inner_insert(int idx){
    uint32_t h = f(data[idx].first^mask) & mod;
    while(true){
      if(idx_table[h]==-1){
        idx_table[h] = idx;
        return;
      }
      h = (h + 1) & mod;
    }
  }
public:
  hashmultiset():
    null_key(std::numeric_limits<Key>::max()),mask(random_device()()),
    valid_size(0), valid_type(0), idx_table(table_size, -1){}

  //データの数の総和
  Cnt size(){
    return valid_size;
  }
  //データの種類数
  int type(){
    return valid_type;
  }
  //kをx個数入れる
  void insert(Key k, Cnt x=1){
    assert(k!=null_key);
    uint32_t h = f(k^mask) & mod;
    while(true){
      int idx = idx_table[h];
      if(idx!=-1){
        if(data[idx].first==k){
          data[idx].second += x;
          valid_size += x;
          return;
        }
        h = (h + 1) & mod;
      }else{
        data.push_back({k, x});
        idx_table[h] = int(data.size()) - 1;
        valid_size += x;
        valid_type++;
        if(float(data.size())>load_factor*float(table_size)){
          expand_table();
        }
        return;
      }
    }
  }
  //kを最大x個消す(0未満にはならない。inf個消すこととstd::multisetのeraseは同じ挙動)
  void erase(Key k, Cnt x=std::numeric_limits<Cnt>::max()){
    assert(k!=null_key);
    uint32_t h = f(k^mask) & mod;
    while(true){
      int idx = idx_table[h];
      if(idx==-1) return;
      if(data[idx].first==k){
        if(data[idx].second > x) {
          data[idx].second -= x;
          valid_size -= x;
        }else {
          data[idx].first = null_key;
          valid_size -= data[idx].second;
          valid_type--;
        }
        return;
      }
      h = (h + 1) & mod;
    }
  }
  //kの個数
  int count(Key k){
    assert(k!=null_key);
    uint32_t h = f(k^mask) & mod;
    while(true){
      int idx = idx_table[h];
      if(idx==-1) return 0;
      if(data[idx].first==k) return data[idx].second;
      h = (h + 1) & mod;
    }
  }
};
vector<int> par(200001);

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

int main(){
  int n, q;scanf("%d %d", &n, &q);
  for(int i=0;i<n;i++) par[i] = i;
  vector<hashmultiset<int>> hs(n);

  for(int i=0;i<n;i++){
    int c;scanf("%d", &c);
    hs[i].insert(c, 1);
  }

  for(int i=0;i<q;i++){
    int a, b, c;scanf("%d %d %d", &a, &b, &c);
    if(a==1){
      b = find(b-1);
      c = find(c-1);
      if(b==c) continue;
      if(hs[b].type()>hs[c].type()) swap(b, c);
      //b to c
      for(auto e:hs[b].data){
        if(e.first==hs[b].null_key) continue;
        hs[c].insert(e.first, e.second);
      }
      par[b] = c;
    }else{
      b = find(b-1);
      printf("%d\n", hs[b].count(c));
    }
  }
}


#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d: ",ca)
int ca=1;
using namespace std;
int main(){
fast;
{

	string n;
	cin>>n;
	string x="";
	string y;
	int s = n.size();
	int ans = 1;
	int i = 0, j = s-1, f = 0, l = 0;
	while(n[i]=='0'){
		i++;
		f++;
		if(i>s){
            break;
		}

	}
	while(n[j]=='0' && j>=0){
		j--;
		l++;
		if(j==0){
            break;
		}

	}
	for(int b = i;b<=j;b++){

			x+=n[b];

	}
		y = x;
		reverse(y.begin(),y.end());

		if(x==y && l>=f){
			cout<<"Yes"<<nl;
		}else{
			cout<<"No"<<nl;
		}
}
	}

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

using namespace std;

long long int N;

int main(void) {

	cin >> N;

	if (N == 0) { cout << "Yes" << endl; return 0; }

	while (N % 10 == 0) { N /= 10; }

	vector<int> V;

	long long int K = N;
	while (K > 0) { V.push_back(K % 10); K /= 10; }

	vector<int> W;
	for (int i = (int)V.size() - 1; i >= 0;i--) { W.push_back(V[i]); }

	//for (auto y : V) { cout << " " << y; }cout << endl;
	//for (auto y : W) { cout << " " << y; }cout << endl;

	if (V == W) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}


#line 1 "/workspaces/compro/lib/template.hpp"

#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}

#line 2 "main.cpp"

std::string solve(long long N, string S, std::string X) {
  vector<vector<bool>> dp(N + 1, vector<bool>(7, false));
  dp[N][0] = true;
  for (int i = N - 1; i >= 0; i--) {
    REP(j, 7) {
      int m = 10 * j + (S[i] - '0'); // S[i]を選ぶ
      m %= 7;
      int m0 = 10 * j; // 0を選ぶ
      m0 %= 7;
      if (X[i] == 'T') {
        if (dp[i + 1][m0] || dp[i + 1][m]) {
          dp[i][j] = true;
        } else {
          dp[i][j] = false;
        }
      } else {
        // どっちに転んでも高橋君が勝つ場合
        if (dp[i + 1][m0] && dp[i + 1][m]) {
          dp[i][j] = true;
        } else {
          dp[i][j] = false;
        }
      }
    }
  }

  if (dp[0][0]) {
    return "Takahashi";
  } else {
    return "Aoki";
  }
}

// generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator)
int main() {
  int N;
  string S, X;
  cin >> N;
  cin >> S >> X;
  auto ans = solve(N, S, X);
  cout << ans << endl;
}

#include<bits/stdc++.h>
#define M 200005
typedef long long ll;
using namespace std;
char IO;
int rd(){
	int num=0;
	while(IO=getchar(),IO<48||IO>57);
	do num=(num<<1)+(num<<3)+(IO^48);
	while(IO=getchar(),IO>=48&&IO<=57);
	return num;
}
int n;
int dp[M][7];
char S[M],T[M];
bool dfs(int x,int rst){
	if(x==n+1)return rst==0;
	if(~dp[x][rst])return dp[x][rst];
	if(T[x]=='A')return dp[x][rst]=dfs(x+1,rst*10%7)&dfs(x+1,(rst*10+S[x]-'0')%7);
	else return dp[x][rst]=dfs(x+1,rst*10%7)|dfs(x+1,(rst*10+S[x]-'0')%7);
}
int main(){
	scanf("%d%s%s",&n,S+1,T+1);
	memset(dp,-1,sizeof(dp));
	if(dfs(1,0))cout<<"Takahashi";
	else cout<<"Aoki";
	return 0;
}


#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Erep(i,n) for(int i = 0; i <= (n); ++i)
#define repS(i,s,n) for(int i = s; i < (n); ++i)
#define ErepS(i,s,n) for(int i = s; i <= (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define RSort(a) sort(a.rbegin(), a.rend())
#define Output(a) printf("%lld %s", a, "\n")

typedef long long int ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vst;
typedef vector<double> vd;

const ll INF = 0x1fffffffffffffff;
const ll MOD = 1000000007;
const double PI = acos(-1);

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

ll n;
vd a, b, c, d;

void input(){
    cin >> n;
    a = vd(n);
    b = vd(n);
    c = vd(n);
    d = vd(n);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, n) cin >> c[i] >> d[i];
}

void solve(){
    string ans = "No";
    vd x(n), y(n);
    for(int k = 0; k < 360; k++){
        rep(i, n){
            double tx = a[i], ty = b[i];
            x[i] = tx * cos((k * PI ) / 180) - ty * sin((k * PI ) / 180);
            y[i] = tx * sin((k * PI ) / 180) + ty * cos((k * PI ) / 180);
        }
        double ave_s_x = 0, ave_s_y = 0, ave_t_x = 0, ave_t_y = 0;
        rep(i, n){
            ave_s_x += x[i];
            ave_s_y += y[i];
            ave_t_x += c[i];
            ave_t_y += d[i];
        }
        double diff_x = (ave_t_x - ave_s_x) / n;
        double diff_y = (ave_t_y - ave_s_y) / n;
        ll check = 1;
        rep(i, n){
            ll count = 0;
            rep(j, n){
                double ex = x[i] + diff_x, ey = y[i] + diff_y;
                //if(k == 90)
                //cout << ex << " " << c[j] << " " << ey << " " << d[j] << "\n";
                if(abs(ex - c[j]) <= (double) 0.05 && abs(ey - d[j]) <= (double) 0.05){
                  //cout << k << endl;
                  //cout << x[i] << " " << c[j] << " " << y[i] << " " << d[j] << "\n";
                    count++;
                }
            }
            if(count == 0){
                check = 0;
            }
        }
        if(check){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

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

    input();
    solve();
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 400010, mod = 1e9 + 7;

int e[N], ne[N], h[N], idx, w[N][61], n;
ll tar, d[N][2], res;

void add(int a, int b, long long c) {
	e[idx] = b, ne[idx] = h[a];
	for (int i = 0; i < 60; ++i) {
		if (c & 1) w[idx][i] = 1;
		c /= 2;
		if (!c) break;
	}
	h[a] = idx++;
}

void go(int x, int fa) {
	d[x][0] = d[x][1] = 0;
	for (int i = h[x]; i != -1; i = ne[i]) {
		if (fa == e[i]) continue;
		go(e[i], x);
		if (w[i][tar]) {
			d[x][0] += d[e[i]][1];
			d[x][1] += d[e[i]][0] + 1;
		} else {
			d[x][0] += d[e[i]][0] + 1;
			d[x][1] += d[e[i]][1];
		}
	}
	res += d[x][1];
	ll t = 0;
	for (int i = h[x]; i != -1; i = ne[i]) {
		if (fa == e[i]) continue;
		if (w[i][tar]) {
			res += (d[e[i]][0] + 1) * (d[x][0] - d[e[i]][1]);
		} else {
			res += d[e[i]][1] * (d[x][0] - d[e[i]][0] - 1);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	memset(h, -1, sizeof h);
	for (int i = 1; i < n; ++i) {
		int a, b;
		ll w;
		cin >> a >> b >> w;
		add(a, b, w);
		add(b, a, w);
	}
	ll ans = 0;
	for (int i = 0; i < 60; ++i) {
		tar = i;
		res = 0;
		go(1, -1);
		ans = (ans + res % mod * ((1ll << i) % mod) % mod) % mod;
	}
	cout << ans << '\n';
	return 0;
}


#include <bits/stdc++.h>

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef long int li;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin >> t; while(t--)
#define print_tc(t, c) cout << "Case #" << t << ": " << c << "\n";
const long long int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};
const long long int cons = 100005, ncr_cons = 100005;
const long long int MOD = 1000000007; // const long long int MOD = 998244353;
const long long int const_INT_MAX = 1000000000000000000, const_INT_MIN = -1 * 1000000000000000000;
using namespace std;
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.first > b.first);}
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second < b.second);}
bool sortbysecinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second > b.second);}
ll gcd(ll x, ll y){return (ll)(__gcd(x, y));}
ll lcm(ll x, ll y){return (ll)((x * y) / gcd(x, y));}
ll mod_expo(ll x, ll y, ll p){
    if((x + p) % p == 0) return 0;
    ll res = 1; x = (x + p) % p;
    while (y > 0){
        if(y & 1) res = (res*x + p) % p;
        y = y>>1; x = (x*x + p) % p;
    }
    return res;
}
void usaco(string str = ""){
    fastio;
    if(str.size()){
        freopen((str + ".in").c_str(), "r", stdin);
        freopen((str + ".out").c_str(), "w", stdout);
    }
}
int main(){
    usaco();
    ll n, k; cin >> n >> k;
    ll a[n+1][n+1]; for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++) cin >> a[i][j];
    ll l=0, r=1e9, ans = const_INT_MAX;
    for(ll itr=0;itr<=150;itr++){
        ll mid = l + (r - l) / 2; ll count[n+1][n+1]; memset(count, 0, sizeof(count));
        for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++) if(a[i][j] <= mid) count[i][j] = 1;
        for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++) count[i][j] = count[i][j] + count[i-1][j] + count[i][j-1] - count[i-1][j-1];
        // ll f=0; for(ll i=k;i<=n;i++) for(ll j=k;j<=n;j++) if(count[i][j] + count[i-k][j-k] - count[i-k][j] - count[i][j-k] >= k*k) f=1;
        ll f=0; for(ll i=k;i<=n;i++) for(ll j=k;j<=n;j++) if(2*count[i][j] + 2*count[i-k][j-k] - 2*count[i-k][j] - 2*count[i][j-k] >= k*k) f=1;
        if(f){
            ans = min(ans, mid); r = mid - 1;
        }
        else l = mid + 1;
    }
    cout << ans << "\n";
    // cout << (ans + 1) / 2 << "\n";
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}

#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 800; int n, k;
vector<int> as;
int medianPos;
int a[maxN][maxN];
int b[maxN][maxN];
int acc[maxN + 1][maxN + 1];

int getSum(int loi, int loj, int hii, int hij)
{
  return acc[hii + 1][hij + 1] - acc[loi][hij + 1] - acc[hii + 1][loj] + acc[loi][loj];
}

bool can(lli x)
{
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      b[i][j] = a[i][j] <= x;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      acc[i + 1][j + 1] = acc[i][j + 1] + acc[i + 1][j] - acc[i][j] + b[i][j];

  for (int i = 0; i + k - 1 < n; i++)
    for (int j = 0; j + k - 1 < n; j++)
      if (getSum(i, j, i + k - 1, j + k - 1) >= medianPos)
        return true;
  return false;
}

int main()
{
  while (~scanf("%d %d", &n, &k))
  {
    medianPos = ((k * k + 1) >> 1) + 0;

    as.clear();
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
      {
        scanf("%d", &a[i][j]);
        as.push_back(a[i][j]);
      }
    sort(as.begin(), as.end());
    as.resize(distance(as.begin(), unique(as.begin(), as.end())));

    int lo = 0, hi = as.size() - 1;
    while (lo < hi)
    {
      lli mid = (lo + hi) >> 1;
      if (can(as[mid])) hi = mid;
      else lo = mid + 1;
    }
    printf("%d\n", as[lo]);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for (int i = 1; i < N; i++) {
    int p;
    cin >> p;
    p--;
    G[i].emplace_back(p);
    G[p].emplace_back(i);
  }
  vector<int> in(N), out(N);
  vector<vector<int>> dist(N);
  int timer = 0;
  function<void(int, int, int)> dfs = [&](int u, int p, int d) {
    in[u] = timer++;
    dist[d].emplace_back(in[u]);
    for (int v : G[u]) {
      if (v == p) continue;
      dfs(v, u, d + 1);
    }
    out[u] = timer++;
  };
  dfs(0, 0, 0);
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int u, d;
    cin >> u >> d;
    u--;
    const auto& v = dist[d];
    cout << lower_bound(v.cbegin(), v.cend(), out[u]) - lower_bound(v.cbegin(), v.cend(), in[u])
         << '\n';
  }
  return 0;
}

#include "bits/stdc++.h"
using namespace std;
using ll=int64_t;
using ld=long double;
using ull=unsigned long long;
template <class T>
using grid=vector<vector<T>>;
#define ALL(x) x.begin(),x.end()
#define rep(iter,from,to) for(ll iter=from;iter<to;++iter)

const ll MOD=1e9+7;
const ll INF=1e17;
//#######################################################################
vector<vector<ll>> input(ll N, ll width){
    string str;
    vector<vector<ll>> vec(N,vector<ll>(width));
    for(ll i=0;i<N;++i){
        cin>>str;
        reverse(ALL(str));
        for(ll j=0;j<width;++j){
            vec[i][j]=str.back();
            str.pop_back();
        }
    }
    return vec;
}
void op(vector<ll> vec){
    ll size=(ll)vec.size();
    for(ll i=0;i<size-1;++i) cout<<vec[i]<<" ";
    cout<<vec.back()<<endl;
}

void op(vector<vector<ll>> vec){
    ll height=(ll)vec.size();
    ll width=(ll)vec[0].size();
    for(ll i=0;i<height;++i) {
        for(ll j=0;j<width-1;++j) cout<<vec[i][j]<<" ";
        cout<<vec[i].back()<<endl;
    }
}
//########################################################################

int solve(){
    ll N,K;
    cin>>N>>K;
    ll sum=0;
    rep(i,1,N+1) rep(j,1,K+1) sum+=i*100+j;
    cout<<sum<<endl;
    return 0;
}

int main(void){
    std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


// 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;
}
const int maxn = 1e6 + 10;
int mu[maxn],lpf[maxn];
void lpf1(){
	repa(i,2,maxn){
		if(!lpf[i]){
			for(int j = i;j < maxn;j+=i){
				if(!lpf[j])lpf[j] = i;
			}
		}
	}
}
void sieve(){
	lpf1();
	mu[1] = 1;
	repa(i,2,maxn){
		if(lpf[i / lpf[i]] == lpf[i]){
			mu[i] = 0;
		}
		else{
			mu[i] = -1*(mu[i/lpf[i]]);
		}
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int l,r;
	cin>>l>>r;
	int ans = 0;
	for(int i = max(l,2ll);i <= r;i++){
		for(int j = i+i;j <= r;j += i){
			ans -= 2;
		}
	}
	sieve();
	repa(i,2,r+1){
		// int x1 = l/i;
		// if(l%i != 0)x1++;
		// int x2 = r/i;
		int d = (r/i)-((l-1)/i);
		// cout<<i<<d<<endl;
		// if(d < 2)break;
		ans -= mu[i]*(d*(d-1));
	}
	cout<<ans;
	return 0;
}

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

//左に行きたい各それについて、自分の左でa[i]-iが一致しているやつを見つけて飛び込む
//a[i]-iが一致しているやつの中で最大のものを見つけたらそこまでギュッとする
#define int long long
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
const int INF=1e9+7;
int ans;
typedef pair<int,int> P;

signed main(){
  int n,l;cin>>n>>l;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  set<int> III,JJJ;
  {
    set<P> s;//(a[i]-i,i)
    s.insert(P(1,-1));
    for(int i=0;i<n;i++){
      if(a[i]<b[i])continue;
      s.insert(P(a[i]-i,i));III.insert(i);
    }//nowまでは左に行きたい
    int L=INF;//Lまでは左に押し付けられてる
    for(int i=n-1;i>=0;i--){
      if(!III.count(i))continue;
      int k=b[i]-i;//cout<<i<<" "<<k<<endl;
      s.erase(P(a[i]-i,i));
      if(i>L&&((L==-1&&b[i]==i+1)||(~L&&b[i]==a[L]+i-L)))continue;
      if(a[i]==b[i])continue;
      P p=*--s.lower_bound(P(k,INF));
      int va=p.first,idx=p.second;
      if(va!=k)fin(-1);
      ans+=i-idx;//cout<<i-idx<<endl;
      L=idx;
    }
  }
  //cout<<"A"<<ans<<endl;
  for(int i=0;i<n;i++)a[i]*=-1;
  for(int i=0;i<n;i++)b[i]*=-1;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  {
    set<P> s;//(a[i]-i,i)
    s.insert(P(-l,-1));
    for(int i=0;i<n;i++){
      if(a[i]<b[i])continue;
      s.insert(P(a[i]-i,i));JJJ.insert(i);
    }//nowまでは左に行きたい
    int L=INF;//Lまでは左に押し付けられてる
    for(int i=n-1;i>=0;i--){
      if(!JJJ.count(i))continue;
      int k=b[i]-i;//cout<<i<<" "<<k<<endl;
      s.erase(P(a[i]-i,i));
      if(i>L&&((L==-1&&b[i]==-l-1+i+1)||(~L&&b[i]==a[L]+i-L)))continue;//cout<<b[i]<<" "<<i<<" "<<L<<" "<<a[L]+i-L<<endl;
      if(a[i]==b[i])continue;
      P p=*--s.lower_bound(P(k,INF));
      int va=p.first,idx=p.second;
      if(va!=k)fin(-1);
      ans+=i-idx;
      L=idx;
      //cout<<i-idx<<endl;
    }
  }
  for(int p:JJJ)III.insert(n-1-p);
  if(III.size()<n)fin(-1);
  cout<<ans<<endl;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const ll mod = 1e9+7;
int sum(int a, int b){return (a+b) % mod;}
int sub(int a, int b){return (a + mod - b) % mod;}
int mul(int a, int b){return (1ll * a * b) % mod;}
int power(int a,int b){
	int res = 1;
	while(b){
		if(b&1)res = mul(res,a);
		b >>= 1;
		a = mul(a,a);
	}
	return res;
}

const ll oo = (ll)1e18;

void dijkstra(int src,vector<ll> &dist,vector<vii> &graph){
	priority_queue<ii,vector<ii>,greater<ii>> pq;
	pq.push({0,src});
	dist[src] = 0;
	while(pq.size()){
		ii act = pq.top(); pq.pop();
		ll d = act.fi;
		int u = act.se;
		if(d > dist[u])continue;
		for(auto &sig : graph[u]){
			int v = sig.fi;
			ll c = sig.se;
			if(dist[u]+c < dist[v]){
				dist[v] = dist[u]+c;
				pq.push({dist[v],v});
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,M; cin >> N >> M;
	vector<pair<int,ii>> edges;
	forn(i,0,M){
		int u,v,c; cin >> u >> v >> c; u--; v--;
		edges.pb({c,{u,v}});
	}
	forn(i,0,N){
		vector<vii> graph(N+1);
		for(auto &act : edges){
			int c = act.fi;
			int u = act.se.fi;
			int v = act.se.se;
			graph[u].pb({v,c});
			if(v == i){
				graph[u].pb({N,c});
			}
		}
		vector<ll> dist(N+1,oo);
		dijkstra(i,dist,graph);
		if(dist[N] == oo){
			cout << "-1\n";
			continue;
		}
		cout << dist[N] << '\n';
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/

#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
#define pii pair<int,int>
using namespace std;
const int N=2e5+5,mod=1e9+7,INF=1e15;
int t,n,m,u,v,dist[N];
vector<pii>V[N];
priority_queue<pii,vector<pii>,greater<pii> > q;
string s;
 main(){
 	cin>>n>>m;
 	for(int i=1;i<=m;i++){
 		cin>>u>>v>>t;
 		V[u].push_back({v,t});
	 }
	 for(int i=1;i<=n;i++){
	 	q.push({0,i});
	 	for(int j=1;j<=n;j++)
	 	dist[j]=INF;
	 	while(q.size()){
	 		int d=q.top().f;
	 		int u=q.top().s;
	 		q.pop();
	 		if(d>dist[u]) continue;
	 		for(int j=0;j<V[u].size();j++){
	 			if(dist[V[u][j].f]>d+V[u][j].s){
	 				dist[V[u][j].f]=d+V[u][j].s;
	 				q.push({dist[V[u][j].f],V[u][j].f});
				 }
			 }
		 }
	 	if(dist[i]==INF) cout<<-1<<endl;
	 	else cout<<dist[i]<<endl;
	 }
}