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

int main() {
    string s;
    cin >> s;
    map<ll, ll> mp;
    for(int i=0; i<s.size(); i++) {
        int x = s[i] - '0';
        mp[x]++;
    }
    if(s == "8") {
        cout << "Yes" << endl;
        return 0;
    }
    if(s.size() == 2) {
        int x = (s[0] - '0') * 10 + (s[1] - '0');
        int y = (s[1] - '0') * 10 + (s[0] - '0');
        if(x % 8 == 0 || y % 8 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for(int i=1; i<10; i++) {
        if(mp[i] <= 0) continue;
        mp[i]--;
        for(int j=1; j<10; j++) {
            if(mp[j] <= 0) continue;
            mp[j]--;
            for(int k=1; k<10; k++) {
                if(mp[k] <= 0) continue;
                int a = i, b = j, c = k;
                int m = a * 100 + b * 10 + c;
                if(m % 8 == 0) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
            mp[j]++;
        }
        mp[i]++;
    }
    cout << "No" << 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++)
#define per(i, n) for(int i = n - 1; i >= 0; 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 998244353
using namespace std;
ll modPow(ll a, ll n, ll p){
  if(!n) return 1;
  if(n == 1) return a % p;
  if(n & 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
struct UnionFind {
  vector<int> d;
  int n;
  UnionFind(int n): n(n), d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y){
    return root(x) == root(y);
  }
  int size(int x){
    return -d[root(x)];
  }
  int gorup_num(){
    int res = 0;
    rep(i, n) if(d[i] < 0) res++;
    return res;
  }
};
int main(){
  int n;
  cin >> n;
  UnionFind tree(n);
  rep(i, n){
    int f; cin >> f;
    tree.unite(i, f - 1);
  }
  cout << modPow(2, tree.gorup_num(), mod) - 1 << "\n";
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> X(m),Y(m),Z(m);
    rep(i,m) cin >> X[i] >> Y[i] >> Z[i];
    vector<ll> dp((1<<n)+5);
    dp[0] = 1;

    rep(i,n)
    {
        rep(bit,1<<n)
        {
            //経っているbit数が桁と一致しなければ飛ばす
            int bit_num = 0;
            rep(k,n) if((bit>>k)&1)++bit_num;
            if(bit_num != i) continue;

            //追加する数
            rep(add,n)
            {
                bool ok=true;
                if((bit>>add)&1) continue;
                //遷移先のbit
                int next_bit = bit | (1<<add);
                //next_bitへの遷移が可能かどうかMの条件を見ていく
                rep(mi,m)
                {
                    if(i+1 != X[mi]) continue;
                    //y以下でたってるビット数
                    int bit_num_y = 0;
                    rep(k,Y[mi]) if((next_bit>>k)&1)++bit_num_y;
                    //もしZ以上のbitがたっていたら遷移できない
                    if(bit_num_y>Z[mi]) ok = false;
                }
                if(ok) dp[next_bit] += dp[bit];
            }
        }
    }
    cout << dp[(1<<n)-1] << endl;

    return 0;
}

#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

using namespace std;

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

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
ostream &operator<<(ostream &o, const string &obj) {o << "\""; o << obj.c_str(); o << "\""; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif

template <typename... Ts>
std::istream& IN(Ts&... xs){ return (std::cin >> ... >> xs); }

#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll a,b,c;
    ll ca,cb;
    IN(a,b,c);

    ca=cb=1;
    ll ans = 0;
    ll a1=a%10;
    a1=(a1*(a%10))%10;
    while(a1!=(a%10)){
        ca++;
        a1=(a1*(a%10))%10;
    }
    cb = modpow(b,c,ca);
    cb = (cb+(ca-1))%ca;
    print(ca,cb)

    ll ap=a%10;

    rep(i,cb){
        ap=(ap*(a%10))%10;
    }

    ans = ap;

    cout << ans << endl;

    return 0;
}


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

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

const int mod = 1e9 + 7;
int dp[2][100][100];
int AB[200], *A = AB, *B = AB + 100;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, K;
	cin >> N >> M >> K;
	rep(i, N) {
		cin >> A[i];
	}
	auto mae = dp[0], ato = dp[1];
	int are = modpow(2 * M, mod - 2);

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		if (x < y) swap(x, y);
		mae[x][x]--;
		mae[x][y]++;
		mae[y][y]--;
	}
	rep(x, N) rep(y, x + 1) {
		mae[x][y] = (ll(mae[x][y] + mod) * are + (x == y)) % mod;
		mae[y][x] = mae[x][y];
	}

	const ll ma = (1ll << 32) - 1;

	rep(i, 30) {
		if (K >> i & 1) {
			rep(i, N) {
				ll t1 = 0, t2 = 0;
				rep(j, N) {
					auto tmp = (ll)mae[i][j] * A[j];
					t1 += tmp >> 32;
					t2 += tmp & ma;
				}
				B[i] = ((t1 % mod << 32) + t2) % mod;
			}
			swap(A, B);
		}
		if (!K | i >= 31 - __builtin_clz(K)) break;
		rep(x, N) rep(y, x + 1) {
			auto tmp1 = mae[x];
			auto tmp2 = mae[y];
			ll t1 = 0, t2 = 0;
			rep(z, N) {
				auto tmp = *tmp1++ * (ll)*tmp2++;
				t1 += tmp >> 32;
				t2 += tmp & ma;
			}
			ato[y][x] = (ato[x][y] = ((t1 % mod << 32) + t2) % mod);
		}
		swap(mae, ato);
	}

	rep(i, N) co(A[i]);

	Would you please return 0;
}

/*
 * TheMartian0x48
 */
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = a; i >= (b); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define rll(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<long long>;
// (* read and write *)
template <class T>
void re(vector<T> &v, int n) {v.resize(n); for (auto &e : v) cin >> e;}
template <class T>
void re(vector<T> &v){for (auto &e : v) cin >> e;}
// clang-format on

void solve() {

}

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

  int a, b, c; cin >> a >> b >> c;
  int res = max(a + b, a + c);
  res = max(res, b + c);
  cout << res;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#define f(i,a,b) for(ll  i = a; i < (ll) b ; i++ )
#define af(i,a,b) for(ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll  i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for(ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sz(a) (ll) a.size()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based

using namespace std;

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

const ll MAX = 1e6 + 20;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;

vi adj[MAX];

ll dp[MAX],sz[MAX];

void dfs(ll u){
	vi imp;
	vii par;
	sz[u] = 1;
	dp[u] = 1;
	for(ll v:adj[u]){
		dfs(v);
		sz[u] += sz[v];
		if(sz[v]%2 == 0) imp.push_back(v);
		else par.push_back({2*dp[v]- sz[v],v});
	}
	ll sum = 0,sum1 = 0;
//cout << u << " ::: " << endl;
	for(ll v:imp){
//		cout << v <<" ";
		if(dp[v] <= sz[v] - dp[v])
			dp[u] += dp[v];
		else
			sum += dp[v],sum1 += sz[v] - dp[v];
	}

	ll t = 1;

	sort(all(par));
	for(auto it:par){
		ll v = it.ss;
//		cout << v <<" - ";
		if(t) dp[u] += dp[v];
		else dp[u] += sz[v] - dp[v];
		t = 1-t;
	}
//	cout << endl;
	if(t) dp[u] += sum;
	else dp[u] += sum1;

//	cout << u << " :"  << dp[u] << endl << endl;

}

int main(){
	fastio;
	ll n,p;
 	cin >> n;
 	f(i,2,n+1){
 		cin >> p;
 		adj[p].push_back(i);
 	}
 	dfs(1);
 	cout << dp[1] << endl;
    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 = 2e5+6969, INF = 2e9+6969;

int n,dp[nax],last[nax];
bool vis[nax];
vi v[nax];

void dfs(int a, int dad)
{
	dp[a] = 1;
	int bad = 0;
	vi t;
	for(auto e: v[a])
	{
		if(e == dad) continue;
		dfs(e,a);
		if(last[e])
		{
			if(dp[e] <= 0) dp[a] += dp[e];
			else bad += dp[e];
		}
		else t.pb(dp[e]);
	}
	if(t.size()&1)
	{
		last[a] = 1;
		dp[a] -= bad;
	}
	else
	{
		last[a] = 0;
		dp[a] += bad;
	}
	sort(all(t));
	for(int i=0;i<t.size();i++)
	{
		if(i&1) dp[a] -= t[i];
		else dp[a] += t[i];
	}
}

int main()
{
	scanf("%d", &n);
	for(int i=2;i<=n;i++)
	{
		int x;
		scanf("%d", &x);
		v[x].pb(i);
		v[i].pb(x);
	}
	dfs(1,1);
	//  for(int i=1;i<=n;i++) cout << dp[i] << " " << last[i] << "\n";
	cout << (n+dp[1])/2 << "\n";
	return 0;
}


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

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

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

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

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

void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	vector<ll> ra(n + 1);
	rep(i, n)ra[i + 1] = ra[i] + a[i];
	ld ans = INF;
	rep(i, n) {
		//[0,i]
		//x=a[i]/2
		ld x = a[i] / 2.0;
		ld sum = x * (i + 1);
		sum -= x * (n - 1 - i);
		sum += ra[n] - ra[i + 1];
		ans = min(ans, sum / (ld)n);
	}
	ans = min(ans, ra[n] / (ld)n);
	cout << ans << "\n";
}

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

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

#define ll long long
#define ull unsigned long long
#define lld long double
#define w(x) ll x;cin>>x;while(x--)
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define gcd(a,b)	__gcd(a,b)
#define lcm(a,b)	__detail::__lcm(a,b)
#define goog(tno) cout << "Case #" << tno <<": "
#define PRESS_F_TO_PAY_RESPECT ios_base::sync_with_stdio(false), cin.tie(nullptr)

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

ll dx[]= {-1,-1,-1,0,0,1,1,1};
ll dy[]= {-1,0,1,-1,1,-1,0,1};
const lld pi=3.1415926535897932384626433832795;
const ll INF=1e18;
const ll mod=1000000007;
const ll maxn=1e5+5;

template<typename T>
void printv(const vector<T>& v) { for(auto i:v) cout<<i<<' '; cout<<'\n'; }
template<typename T>
void printv(const vector<pair<T, T>>& v) { for(auto p:v) cout<<"("<<p.first<<","<<p.second<<"),"; cout<<'\n'; }

int main(){
    PRESS_F_TO_PAY_RESPECT;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string x;   cin>>x;
    bool f=0;
    for(auto &i:x){
        if(i=='.'){
            f=1;
            break;
        }
    }
    if(!f){
        cout<<x<<'\n';
    }else{
        ll n=x.size();
        ll i;
        for(i=0;i<n;i++){
            if(x[i]=='.'){
                break;
            }
        }
        cout<<x.substr(0,i)<<'\n';
    }
    return 0;
}


// Daniel Grzegorzewski15
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 2003;

int n, res, t[N], l[N], r[N], in[N];

bool cmp(int i, int j) {
  return l[i] < l[j];
}

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    in[i] = i;
    cin >> t[i] >> l[i] >> r[i];
  }
  sort(in+1, in+n+1, cmp);
  for (int i = 1; i <= n; ++i)
    for (int j = i+1; j <= n; ++j) {
      int p = in[i], q = in[j];
      if (l[q] <= r[p]) {
        if (l[q] == r[p]) {
          if (t[p] == 2 || t[p] == 4 || t[q] == 3 || t[q] == 4)
            continue;
        }
        ++res;
      }
    }
  cout<<res<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  cout<<(2*a+100)-b<<endl;
}

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define MOD 1000000007
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n)     for (int i = 1; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
template <typename T> bool chmax(T& a, const T& b); //aよりもbが大きいならばaをbで更新する //更新されたならばtrueを返す
template <typename T> bool chmin(T& a, const T& b); //aよりもbが小さいならばaをbで更新する //更新されたならばtrueを返す

int main() {

	int a, b;
	cin >> a >> b;

	cout << 2 * a + 100 - b << endl;

	return 0;

}

// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <string>
#include <bitset>
#include <numeric>

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define manytests int TT;cin >> TT; while (TT--)

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORd(i,a,b) for (int i = (a); i >= (b); --i)

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define rev reverse

#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vd vector<double>
#define vs vector<string>
#define vld vector<ld>
#define vb vector<bool>
#define vvi vector<vi>
#define pii pair<int, int>
#define pl pair<ll, ll>
#define pld pair<ld, ld>
#define vpi vector<pii>
#define vpl vector<pl>
#define vpld vector<pld>

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

    int a, b, c;
    cin >> a >> b >> c;
    if (!c) {
        int cnt = 0;
        while (true) {
            if (cnt%2==0) {
                if (!a) return cout << "Aoki\n", 0;
                a--;
            } else {
                if (!b) return cout << "Takahashi\n", 0;
                b--;
            }
            cnt++;
        }
    } else {
        int cnt = 0;
        while (true) {
            if (cnt%2==1) {
                if (!a) return cout << "Aoki\n", 0;
                a--;
            } else {
                if (!b) return cout << "Takahashi\n", 0;
                b--;
            }
            cnt++;
        }
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define print(v,n) for(i=0;i<n;i++) cout<<v[i]<<" ";
#define No cout<<"NO"<<endl;return
#define Yes cout<<"YES"<<endl;return
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
#define PI 3.14159265   ;
ll mod =1e9+7;
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i*i <= n; i = i + 6)
        if (n%i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll powe(ll x, ll y) {
    ll res = 1;
    while (y > 0) {
        if (y & 1) res =( res * x)%mod;
        y = y >> 1;
        x = (x * x)%mod;
    }
    return res;
}
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
unsigned long long power(unsigned long long x, int y, int p)
{
    unsigned long long res = 1; // Initialize result

    x = x % p; // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n,int p)
{
    return power(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n,int r, int p)
{
    if (n < r)
        return 0;
    // Base case
    if (r == 0)
        return 1;
    unsigned long long fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;

    return (fac[n] * modInverse(fac[r], p) % p
            * modInverse(fac[n - r], p) % p)
           % p;
}
bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    if(a.ss<b.ss) return true;
    return false;
}
bool cmp2(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    if(a.ff<b.ff) return true;
    if(a.ff==b.ff) return a.ss<b.ss;
    return false;
}
void solve()
{
    ll i,x,y,m,  j, k, h, n, w, k1, k2,k3,q;
    cin>>x>>y>>k;
    if(k==0)
    {
       if(x>=y+1)
       {
           cout<<"Takahashi"<<ee;
           return;
       }
       cout<<"Aoki"<<ee;
       return;
    }
    if(y>=x+1 ) cout<<"Aoki"<<ee;
    else cout<<"Takahashi"<<ee;
}

int main() {

    fast;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll i, j, l, k, t, n;
    t=1;
    for (i = 1; i <= t; i++)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
    }
}
//


#include <bits/stdc++.h>

const long long INF = 1e9;
const long long MOD = 1e9 + 7;
//const long long MOD = 998244353;
const long long LINF = 1e18;
using namespace std;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define COUT(x) cout<<(x)<<endl
#define SCOUT(x) cout<<(x)<<" "
#define VECCOUT(x) for(auto&youso_: (x) )cout<<right<<setw(2)<<youso_<<" ";cout<<endl
#define ENDL cout<<endl
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) long long __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define mp make_pair
#define PQ priority_queue<long long>
#define PQG priority_queue<long long,V,greater<long long>>

typedef long long ll;
typedef vector<long long> vl;
typedef vector<long long> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef pair<long long, long long> pll;

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
template<class T>
void mod(T &x) {
    x %= MOD;
    x += MOD;
    x %= MOD;
}

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

struct COMB{
    vl fact, fact_inv, inv;
    void init_nCk(long long SIZE) {
        fact.resize(SIZE + 5);
        fact_inv.resize(SIZE + 5);
        inv.resize(SIZE + 5);
        fact.at(0) = fact.at(1) = fact_inv.at(0) = fact_inv.at(1) = inv.at(1) = 1;
        for(long long i = 2; i < SIZE + 5; i++) {
            fact.at(i) = fact.at(i - 1)*i%MOD;
            inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
            fact_inv.at(i) = fact_inv.at(i - 1)*inv.at(i)%MOD;
        }
    }
    long long nCk (long long n, long long k) {
        assert(!(n < k));
        assert(!(n < 0 || k < 0));
        return fact.at(n)*(fact_inv.at(k)*fact_inv.at(n - k)%MOD)%MOD;
    }
};
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;
}

void dfs(vector<queue<int> > &m, vector<int> &used, int n, vector<int> &C, vector<int> &S, vector<int> &l, ll from) {
//    dump(n);
//    dump(C.at(n));
    if(S.at(C.at(n))) {
        used.at(n) = -1;
    } else {
        used.at(n) = 1;
        l.at(n) = 1;
    }
    S.at(C.at(n))++;
    while(m.at(n).size()) {
        if(used.at(m.at(n).front()) == 0) {
            dfs(m, used, m.at(n).front(), C, S, l, n);
        }
        m.at(n).pop();
    }
    if(from != -1) {
        S.at(C.at(n))--;
    }
}

void Main() {
    CIN(N);
    vector<int> C(N);
    VECCIN(C);
    vector<queue<int> > m(N);
    for(int i = 0; i < N - 1; i++) {
        CIN(a, b);
        --a;
        --b;
        m.at(a).push(b);
        m.at(b).push(a);
    }
    vector<int> used(N, 0);
    vector<int> ansl(N, 0);
    ll ans = 0;
    vector<int> s(1e5 + 10, 0);
//    s.insert(C.at(0));
    dfs(m, used, 0, C, s, ansl, -1);
    for(int i = 0; i < N; i++) {
        if(ansl.at(i) == 1) cout << i + 1 << endl;
    }
//    VECCOUT(used);
//    cout << ans << endl;
}

int main() {
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

int main(){
  int x, y;
  int a, b;
  cin >> a >> b;
  x = (a + b)/2;
  y = (a-b)/2;

  cout << x  << " " << y << endl;
  return 0;
}


#include <algorithm>
#include <iostream>

using namespace std;

const int MD = 1000000007;

long long inv(int n) {
	return n == 1 ? 1 : inv(n - MD % n) * (MD / n + 1) % MD;
}

long long choose(int n, int k) {
	return n < k ? 0 : k == 0 ? 1 : choose(n - 1, k - 1) * n % MD * inv(k) % MD;
}

int main() {
	int n, m, k; cin >> n >> m >> k;
	if (n - m >= k + 1) {
		cout << "0\n";
		return 0;
	}
	int ans = choose(n + m, n) - choose(n + m, n + (k + 1 - (n - m)));
	if (ans < 0)
		ans += MD;
	cout << ans << '\n';
	return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=long long;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
// LMAX = 18446744073709551615 (1.8*10^19)
// IMAX = 2147483647 (2.1*10^9)
/*

*/
//nCk
const ll MAX = 2000010;
const ll MOD = 1000000007;

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==0 || k==0) return 1;
  if (n<k)
    return 0;
  if (n<0 || k<0)
    return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

//modpow
ll modpow(ll a, ll n){//a^n
  if (n == 0) return 1;
  if (n == 1) return a % MOD;
  if (n%2 == 1) return (a * modpow(a, n - 1)) % MOD;
  else {
    ll t = modpow(a, n / 2) % MOD;
    return (t * t) % MOD;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  COMinit();
  ll N, M, K;
  cin >> N >> M >> K;
  if (M+K<N){
    cout << 0 << endl;
    return 0;
  }
  ll total = COM(N+M, N);
//  cout << total << endl;
  ll cnt = 0;
  for(ll i=K; i<N+M; i+=2){ // 左側の総数
    ++cnt;
    if (N < K+cnt) break;
    total -= (((COM(i, K+cnt-1) * (K+1))%MOD * modpow(K+cnt, MOD-2))%MOD  * COM(N+M - (i+1), M-(cnt-1)))%MOD;
//    cout << "total:" << total <<" i:" << i << " K+cnt-1:" << K+cnt-1 << " N+M-(i+1):" << N+M - (i+1) << " M-(cnt-1):" << M-(cnt-1) << endl;
    total += MOD;
    total %= MOD;
  }
  cout << total << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5 + 5;

char s[MAXN];

int main(void)
{
	int n;
	scanf("%d%s",&n,s+1);

	if(s[1] != s[n]) return printf("1"), 0;
	for(int i=1; i<n; ++i)
		if(s[i] != s[1] && s[i+1] != s[1])
			return printf("2"), 0;
	printf("-1");
	return 0;
}

                                                     /*CP is fun!*/
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
using namespace std;
const int MAXN=2e5+5;
const int MOD=1e9+7;
const int MAX=205;

ll powerm(ll a,ll b,ll m) { //m-> mod
    if(b==0) {
        return 1;
    }
    ll res=powerm(a,b/2,m);
    if(b%2) {
        return ((res*res)%m*(a%m))%m;
    }
    return (res*res)%m;
}

//INVERSE -> a^(m-2) ...m -> prime

int power(ll a,ll b) {
    if(b==0) {
        return 1;
    }
    ll res=power(a,b/2);
    if(b%2==0) {
        return res*res;
    }
    return res*res*a;
}

/*vector<int>fac(1e5);

void facm(ll m) { //factorial mod precompute
    fac[0]=1;
    for(int i=1;i<fac.size();i++) { //name an array fac
        fac[i]=((i)%m*fac[i-1])%m;
    }
    return;
}

ll choose(ll a,ll b,ll m) { //a choose b mod m
    if(a<b) {
        return 1;
    }
    ll ans=((fac[a]*(powerm(fac[a-b],m-2,m)))%m*powerm(fac[b],m-2,m))%m;
    return ans;
}*/

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout<<setprecision(9)<<fixed;
    //freopen("diamond.in","r",stdin);
    //freopen("diamond.out","w",stdout);
    int n;
    cin>>n;
    string s;
    cin>>s;
    s.pb('z');
    int dp[n+1][26][2];
    for(int j=0;j<26;j++) {
        dp[n][j][0]=0;
        dp[n][j][1]=1e15;
    }
    for(int i=n-1;i>=0;i--) {
        for(int j=0;j<26;j++) {
            dp[i][j][0]=dp[i+1][j][1];
            if(s[i]!=j+'a') {
                dp[i][j][1]=min(1+dp[i+1][s[i+1]-'a'][0],dp[i+1][j][1]);
            } else {
                dp[i][j][1]=dp[i+1][j][1];
            }
        }
    }
    if(dp[0][s[0]-'a'][0]>=1e10) {
        cout<<-1;
    } else {
        cout<<dp[0][s[0]-'a'][0];
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<vector<int> > v;
    for(int i = 0 ; i < n ; i++) {
        vector<int> temp(5);
        for(int i = 0 ; i < 5 ; i++) {
            cin >> temp[i];
        }
        v.push_back(temp);
    }
    vector<vector<int> > A(n);
    A[n-1]=v[n-1];
    for(int i=n-2; i>=0; i--) {
        if(A[i+1][0]>v[i][0]) {
            A[i]=A[i+1];
        } else {
            A[i]=v[i];
        }
    }

    vector<vector<int> > B(n);
    B[n-1]=v[n-1];
    for(int i=n-2; i>=0; i--) {
        if(B[i+1][1]>v[i][1]) {
            B[i]=B[i+1];
        } else {
            B[i]=v[i];
        }
    }

    vector<vector<int> > C(n);
    C[n-1]=v[n-1];
    for(int i=n-2; i>=0; i--) {
        if(C[i+1][2]>v[i][2]) {
            C[i]=C[i+1];
        } else {
            C[i]=v[i];
        }
    }

    vector<vector<int> > D(n);
    D[n-1]=v[n-1];
    for(int i=n-2; i>=0; i--) {
        if(D[i+1][3]>v[i][3]) {
            D[i]=D[i+1];
        } else {
            D[i]=v[i];
        }
    }
    vector<vector<int> > E(n);
    E[n-1]=v[n-1];
    for(int i=n-2; i>=0; i--) {
        if(E[i+1][4]>v[i][4]) {
            E[i]=E[i+1];
        } else {
            E[i]=v[i];
        }
    }

    int res=0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n-1; j++) {
            for(int k=0; k<5; k++) {
                vector<int> *side;
                if(k==0) {
                    side=&A[j+1];
                } else if(k==1) {
                    side=&B[j+1];
                } else if(k==2) {
                    side=&C[j+1];
                } else if(k==3) {
                    side=&D[j+1];
                } else if(k==4) {
                    side=&E[j+1];
                }
                int foo=INT_MAX;
                for(int k=0; k<5; k++) {
                    foo = min(foo,max(v[i][k],max((*side)[k],v[j][k])));
                }
                res = max(res,foo);
            }
        }
    }

    cout << res << '\n';

    return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}
int search(vec_int& DP, vector<vec_int>& G, vec_int& A, int town){
    if(G.at(town).size()==0){
        DP.at(town) = A.at(town-1);
        return A.at(town-1);
    }
    if(DP.at(town)>=0){
        return DP.at(town);
    }
    int result = -1;
    for(auto next_town: G.at(town)){
        int temp  = search(DP, G, A, next_town);
        result = max(temp, result);
    }
    result = max(A.at(town-1), result);
    DP.at(town) = result;

    return result;
}

signed main(){
    int N; cin>>N;
    int M; cin>>M;
    vec_int A(N); rep(i,N)cin>>A.at(i);
    vec_int X(M);
    vec_int Y(M);
    rep(i,M)cin>>X.at(i)>>Y.at(i);

    vector<vec_int> G(N+1);
    vector<vec_int> G2(N+1);
    rep(i,M){
        G.at(X.at(i)).push_back(Y.at(i));
    }

    vec_int DP(N+1, -1);
    int ans = -1*pow(10,12);
    for(int i=1;i<=N;i++){
        if(G.at(i).size()==0)continue;
        int temp = search(DP, G, A, i);
        int max_val = -1;
        for(auto next_city:G.at(i)){
            max_val = max(max_val, DP.at(next_city));
        }
        ans = max(ans, max_val- A.at(i-1));
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
//#define mod 998244353
#define inf 1e18
#define PI 3.14159265
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,n) x.clear();x.resize(n,0)
#define precise(x) fixed<<setprecision(x)
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> pbds;

/**
 *  author: nayakashutosh9
 *	created: [2021-04-11 19:52]
 *	"Compete against yourself"
**/

const int N = 1e5 + 5;
int n;
vi a, g[N];
bool vis[N];
set<int> ans;
void dfs(int node, int par) {
	if (vis[a[node]] == 0) {
		ans.insert(node);
	}
	bool prev = vis[a[node]];
	vis[a[node]] = 1;
	for (int j : g[node]) {
		if (j != par) dfs(j, node);
	}
	vis[a[node]] = prev;
}
void solve() {
	cin >> n;
	clr(a, n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 0; i <= n; i++) g[i].clear();
	for (int i = 1; i < n; i++) {
		int x, y; cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	memset(vis, 0, sizeof(vis));
	ans.clear();
	dfs(1, 0);
	for (int i : ans) cout << i << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T = 1;
	//cin >> T; cin.ignore();
	for (int i = 1; i <= T; i++) {
		//cout << "Case #" << i << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
	}

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    A[i] = a;
    B[i] = b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<int> C(N, -1);
  C[0] = -2;
  {
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
      auto u = que.front();
      que.pop();
      for (int v : G[u]) {
        if (C[v] != -1) continue;
        C[v] = u;
        que.push(v);
      }
    }
  }
  int Q;
  cin >> Q;
  vector<int64_t> res(N, 0);
  for (int q = 0; q < Q; q++) {
    int t, e;
    int64_t x;
    cin >> t >> e >> x;
    e--;
    if (t == 1) {
      if (A[e] == C[B[e]]) {
        res[0] += x;
        res[B[e]] -= x;
      } else {
        res[A[e]] += x;
      }
    } else {
      if (A[e] == C[B[e]]) {
        res[B[e]] += x;
      } else {
        res[0] += x;
        res[A[e]] -= x;
      }
    }
  }
  {
    queue<int> que;
    que.push(0);
    vector<bool> used(N, false);
    used[0] = true;
    while (!que.empty()) {
      auto u = que.front();
      que.pop();
      for (int v : G[u]) {
        if (used[v]) continue;
        que.push(v);
        used[v] = true;
        res[v] += res[u];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << res[i] << '\n';
  }
  return 0;
}


#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int A=0,B=0,C=0;
    cin>>A>>B>>C;
    cout<<(B*C-1)/A<<endl;
    return 0;
}

// RAKSHIT KADAM

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// find_by_order returns iterator to  element present at that index...
// order_of_key returns no. of elements having value stricktly less than that given in the order_of_key();
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :

#define inf 1000000003
#define MOD  1000000007
#define newMOD  998244353
#define MAX 200006
#define pi 3.1415926535897932384626433832795
#define ld long double
#define ll long long
#define int long long
#define INF 1000000000000000008
#define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define satisfy cerr<<"\n\n---------------Running on multiple test cases--------------"<<endl;ll t; cin>> t; while(t--)
#define mp make_pair
#define pb push_back
#define endl "\n"
#define x first
#define y second
#define Endl endl
#define pii pair<ll,ll>
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500004;
//ll fact[300007] = {0};
//void facto() {fact[0] = 1; fact[1] = 1; for(int i = 2; i < 300005; i++){fact[i] = (fact[i-1]*i)%MOD;}}
//ll ncr(ll n, ll r)
//{
//    if(r>n)return 0;
//    ll res = 1;
//    res = fact[n];
//    res*=modInverse(fact[r],MOD);
//    res%=MOD;
//    res*=modInverse(fact[n-r],MOD);
//    res%=MOD;
//    return res;
//}

//vector<ll>primes;

void solve()
{
    double x,y,z;
    cin>>x>>y>>z;
    ll i=0;
    while(y/x>(double(i))/z)i++;
    cout<<--i<<endl;
}

signed main()
{

    Need_for_speed(activated);

//    satisfy
//    { solve();
//    }

    solve();
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define ppb 			pop_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define M               1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define ld				long double
#define nline 			"\n"
#define all(x) 			(x).begin(), (x).end()
// memset(matrix, 0, sizeof(matrix));

// for 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.ff); cerr << ","; _print(p.ss); 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 << "]";}

inline int mod(int x) {return (x % M + M) % M;}
inline int add(int a, int b) {return mod(mod(a) + mod(b));}
inline int sub(int a, int b) {return mod(mod(a) - mod(b) + M);}
inline int mul(int a, int b) {return mod(mod(a) * mod(b));}
inline int power(int a, int p) {int r = 1; while (p) { if (p & 1) r = mul(r, a); a = mul(a, a); p >>= 1; } return r;}
inline int modInv(int a) {return power(a, M - 2);}
inline int divi(int a, int b) {return mul(a, modInv(b));}
inline int fact(int a) {int r = 1; while (a) { r = mul(r, a); a--; } return r;}
inline int ncr(int n, int r) {return mul(mul(fact(n), modInv(fact(n - r))), modInv(fact(r)));}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b);}
inline int ceil(int x, int y) {if (x % y == 0) {return x / y;} return x / y + 1;}
void solve()
{
	int n;
	cin >> n;

	vector<int> arr(n);

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

	map<int, vector<int> > h;
	for (int i = 0; i < n; i++)
	{
		h[arr[i]].push_back(i);
	}
	int ans = 0;
	for (auto x : h)
	{
		if (x.second.size() >= 2)
		{
			ans += (x.second.size() * (x.second.size() - 1)) / 2;
		}
	}

	int v = (n - 1) * n / 2;

	cout << v - ans << nline;
}

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

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

	// w(t)
	// {
	// 	solve();

	// }
	solve();
	return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define m_p make_pair
#define pb push_back
#define ld long double
#define fi first
#define se second
#define ull unsigned long long
#define mod 1000000007
#define md 998244353
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define int ll
using namespace std;
inline void read(int &x){
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0'||c>'9'){
		if(c=='-')negative=-1;
		c=getchar();
	}
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll qpow(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
const int N=200010;
int n;
int a[N];
int b[N];
int c[N];
int bit[N];
vector<int>v;
queue<int>q[N];
map<int,int>mp;
int lowbit(int x){
	return x&(-x);
}
void add(int pos,int val){
	while(pos<=n){
		bit[pos]+=val;
		pos+=lowbit(pos);
	}
}
int getsum(int pos){
	int res=0;
	while(pos>=1){
		res+=bit[pos];
		pos-=lowbit(pos);
	}
	return res;
}
signed main(){
	ios::sync_with_stdio(0);
	cin>>n;
	forn(i,1,n)cin>>a[i],a[i]+=i;
	forn(i,1,n)cin>>b[i],b[i]+=i;
	forn(i,1,n){
		v.pb(b[i]);
	}
	forn(i,1,n){
		mp[b[i]]=i;
	}
	forn(i,1,n){
		q[mp[b[i]]].push(i);
	}
	forn(i,1,n){
		if(mp[a[i]]<1||q[mp[a[i]]].empty()){
			cout<<-1<<"\n";
			return 0;
		}
		c[i]=q[mp[a[i]]].front();
		q[mp[a[i]]].pop();
	}
	int ans=0;
	forn(i,1,n){
		add(c[i],1);
		ans+=i-getsum(c[i]);
	}
	cout<<ans<<"\n";
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
const int M=2e5+5;
const int N=1e3+5;
#define int long long
int Max(int x,int y){return x>y?x:y;}
int Min(int x,int y){return x>y?y:x;}
int Abs(int x){return x>0?x:-x;}
void write (int x) {
	if (x < 0) {
		putchar ('-');
		x = (~x) + 1;
	}
	if (x > 9) {
		write (x / 10);
	}
	putchar (x % 10 + '0');
}
int read () {
	int f = 1, num = 0;
	char s = getchar ();
	while (s > '9' || s < '0') {
		if (s == '-') f = -1;
		s = getchar ();
	}
	while (s >= '0' && s <= '9') {
		num = (num << 3) + (num << 1) + (s - '0');
		s = getchar ();
	}
	return num *= f;
}
int Bit[M];
int H[M],W[M];
int n,m,K;
int ans;
vector<int> G[M];
int lowbit(int x){
	return x&(-x);
}
int Sum(int x){
	int res=0;
	for(int i=x;i>=1;i-=lowbit(i)){
		res+=Bit[i];
	}
	return res;
}
void update(int x,int y){
	for(int i=x;i<=n;i+=lowbit(i)){
		Bit[i]+=y;
	}
}
signed main(){
	n=read(),m=read(),K=read();
	for(int i=0;i<=n+1;i++) H[i]=m+1;
	for(int i=0;i<=m+1;i++) W[i]=n+1;
	for(int i=1;i<=K;i++){
		int x=read(),y=read();
		H[x]=Min(H[x],y);
		W[y]=Min(W[y],x);
	}
//	for(int i=1;i<=n;i++){
//		printf("%d\n",H[i]);
//	}
//	for(int i=1;i<=m;i++){
//		printf("%d\n",W[i]);
//	}
	for(int i=1;i<=n;i++){
		if(H[i]==1){
			for(int j=i+1;j<=n;j++) H[j]=1;
			break;
		}
		ans+=H[i]-1;
	}
	for(int i=1;i<=n;i++){
		G[H[i]].push_back(i);
	}
	for(int i=1;i<=m;i++){
		if(W[i]==1) break;
		ans+=Sum(W[i]-1);
		for(int j=0;j<G[i].size();j++){
			update(G[i][j],1);
		}
	}
	printf("%lld",ans);
	return 0;
}

// atcoder/abc186/F/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

template<typename T>
struct SegTree {
  int n;
  int origin_size;
  vector<T> v;
  using F = function<T(T, T)>;
  F fn;
  T e;
  SegTree(int n_, T e_, F fn_) {
    origin_size = n_;
    e = e_;
    fn = fn_;
    n = 1;
    while (n < n_) n *= 2;
    v.resize(2 * n - 1, e);
  }

  void update(size_t k, T a) {
    k += n - 1;
    v[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      v[k] = fn(v[k * 2 + 1], v[k * 2 + 2]);
    }
    return ;
  }

  T operator [] (size_t idx) const {
    return v.at(idx + n - 1);
  }

  inline T operator () () const {
    return query(0, origin_size, 0, 0, n);
  }

  inline T operator () (size_t a) const {
    return query(a, a+1, 0, 0, n);
  }

  inline T operator () (size_t a, size_t b) const {
    return query(a, b, 0, 0, n);
  }

  inline T query(size_t a, size_t b) const {
    assert(a < b);
    assert(b <= origin_size);
    return query(a, b, 0, 0, n);
  }

  T query(size_t a, size_t b, size_t k, size_t l, size_t r) const {
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return v.at(k);

    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

    return fn(vl, vr);
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  lli h, w;
  int m;
  while (cin >> h >> w >> m) {
    vec<pair<lli, lli>> v(m);
    cin >> v;
    each (i, v) --i.first, --i.second;

    const int N = 2 * 1e5 + 5;
    const lli inf = 1LL << 60;
    static lli mn[N];
    fill(mn, mn + N, h);
    each (i, v) {
      setmin(mn[i.second], i.first);
    }

    lli sum = 0;
    for (int j = 0; j < w; ++j) {
      if (mn[j] == 0) break;
      sum += mn[j];
    }

    static vec<int> u[N];
    fill(u, u + N, vec<int>());
    each (i, v) {
      u[i.first].push_back(i.second);
    }
    for (int i = 0; i < N; ++i) {
      sort(u[i].begin(), u[i].end());
    }
    if (u[0].size()) {
      for (int j = u[0].front(); j < w; ++j) {
        u[0].push_back(j);
      }
    }

    SegTree<int> segtree(N, 0, [] (int a , int b) { return a + b; });
    for (int i = 1; i < h; ++i) {
      if (u[i].size() && u[i].front() == 0) break;
      each (j, u[i - 1]) {
        segtree.update(j, 1);
      }
      sum += segtree.query(0, (u[i].empty() ? w : u[i].front()));
    }
    cout << sum << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pld> vpld;
typedef unordered_map<int, int> mpii;

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

	cout << fixed;
	cout.precision(17);

	ll k; cin >> k;
	cin.ignore();
	string s; getline(cin, s);
	string t; getline(cin, t);

	vl vec(10, k);
	unordered_map<int, int> S, T;
	for (const auto &a : s) S[a - '0']++, vec[a - '0']--;
	for (const auto &a : t) T[a - '0']++, vec[a - '0']--;

	auto calc = [](auto &cnt) {
		ll ret = 0;
		for (int i = 1; i <= 9; i++) ret += i * powl(10, cnt[i]);
		return ret;
	};

	ll ans = 0;
	for (int i = 1; i <= 10; i++) {
		if (!vec[i]) continue;
		--vec[i];
		for (int j = 1; j <= 10; j++) {
			if (!vec[j]) continue;
			S[i]++;
			T[j]++;
			if (calc(S) > calc(T)) { //ok win
				if (i == j) ans += vec[i] * (vec[i] + 1);
				else ans += (vec[i] + 1) * vec[j];
				//cout << i << " " << j << "\n";
			}
			S[i]--;
			T[j]--;
		}
		++vec[i];
	}

	ld cnt = 9 * k - 8;
	cout << ans / (cnt * (cnt - 1));
}

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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 SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DPoker {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int k; cin >> k;
      string s; cin >> s;
      string t; cin >> t;
      vector<ll> cnts(10);
      vector<ll> cntt(10);
      vector<ll> cnt(10, k);
      rep(i, 4) {
        cnts[s[i]-'0']++;
        cntt[t[i]-'0']++;
        cnt[s[i]-'0']--;
        cnt[t[i]-'0']--;
      }
      ll all = 9*k-8;
      ll allc = all*(all-1);
      double ret = 0;

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

        cnts[i]++;
        ll takahashi = 0;
        for(int a=1; a<=9; a++) {
          ll now = a;
          int tmp = cnts[a];
          while(tmp--) {
            now *= 10;
          }
          takahashi += now;
        }
        cnts[i]--;

        for(int j=1; j<=9; j++) {
          double p = 0;
          if (i==j) {
            ll c = cnt[i]*(cnt[i]-1);
            p = (double)c/(double)allc;
          } else {
            ll c = cnt[i] * cnt[j];
            p = (double)c/(double)allc;
          }

          cntt[j]++;
          ll aoki = 0;
          for(int a=1; a<=9; a++) {
            ll now = a;
            int tmp = cntt[a];
            while(tmp--) {
              now *= 10;
            }
            aoki += now;
          }
          cntt[j]--;

          debug(i, j, takahashi, aoki, p);
          if (takahashi > aoki) {
            ret += p;
          }
        }
      }

      cout << setprecision(10) << fixed;
      cout << ret << endl;
    }
};

signed main() {
  DPoker solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define     REP(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {

        ll n, i, x, y, s = 0, j;
        cin >> n;
        ll a[n + 3];
        unordered_map<ll,ll>m;
        for (i = 1; i <= n; i++)
        {
            cin >> x;
            m[x]++;
        }

        for (auto i = m.begin(); i != m.end(); i++)
        {
            for (auto j = next(i); j != m.end(); j++)
            {
                // x =(i->first - j->first);
                // x=x*x;
                // x = x * (i->second * j->second);
                // s += x;
                 s+=i->second * j->second * ceil(pow(i->first - j->first, 2));
            }
        }
        cout<<s<<endl;
    }
}

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

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

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

    bool was_output = false;
    template<class t>
    void output(t a){
        if(was_output)cout << " ";
        cout << a;
        was_output = true;
    }
    void outendl(){
        was_output = false;
        cout << endl;
    }

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

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

    template<class t>
    ostream& operator<<(ostream&os, vector<t> &v){
        os << "{";
        for(t &i:v){
            os << i << ", ";
        }
        os << "}";
        return os;
    }

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

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

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

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

    long long gcd(long long a,long long b){
        while(b){
            a %= b;
            swap(a,b);
        }
        return a;
    }

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

using namespace templates;

string func(){
    int n = in();
    vector<string> strs(3);
    foreach(i,strs)i=in<string>();
    string res = "";
    rep(_,n)res += "1";
    rep(_,n)res += "0";
    res += "1";
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n = in();
    rep(i,n){
        cout << func() << endl;
    }
    return 0;
}


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

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

  int mi = INT_MAX, ma = INT_MIN;
  for (int i = 1; i <= 1000000; i++) {
    if (A * i <= 1000 * W && 1000 * W <= B * i) {
      mi = min(mi, i);
      ma = max(ma, i);
    }
  }
  if (ma == INT_MIN)
    cout << "UNSATISFIABLE";
  else
    cout << mi << ' ' << ma;
  return 0;
}

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

int main() {
    long double a, b, r;
    cin >> a >> b >> r;

    r = nextafter(r, INFINITY);
    int lx = ceil(a - r), rx = floor(a + r);
    long long ans = 0;
    for (int x = lx; x <= rx; ++x) {
        long double dy = sqrt(r * r - (x - a) * (x - a));
        int upper = floor(b + dy), lower = ceil(b - dy);
        ans += upper - lower + 1;
    }
    cout << ans << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define m 2147483647
#define mn -2147483647
int main()
{
    lli i,j,n,k,add=0,add1;
    cin>>n>>k;
for(i=1;i<=n;i++)
{
    for(j=1;j<=k;j++)
    {
        add+=100*i+j;
    }
}
 cout<<add<<endl;

}

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

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

  cout << 50*N*(N+1)*K+N*K*(K+1)/2 << endl;
}


/*Jai Shree Ram*/
// Never Give Up
/*自分を信じない人にとっては、一生懸命働くことは無意味です*/

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define F(i,s,e,j)        for(int i=s;i<=e;i+=j)
#define mt19937                 rng(chrono::steady_clock::now().tjhe_since_epoch().count());
//shuffle(arr,arr+n,rng)
/*---------------------------------------------------------------------------------------------------------------------------*/
int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
int expo(int a, int b,int m) {int res = 1; while (b > 0) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b = b >> 1;} return res;}
void extendgcd(int a, int b, int*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); int x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size1 3
int mminv(int a, int b) {int arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
int mminvprime(int a, int b) {return expo(a, b - 2, b);}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
int combination(int n, int r, int m, int*fact, int *ifact) {int val1 = fact[n]; int val2 = ifact[n - r]; int val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
vi sieve(int n) {int*arr = new int[n + 1](); vi vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
int mod_add(int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_mul(int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_sub(int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
int mod_div(int a, int b, int m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}  //only for prime m
int phin(int n) {int number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0) n /= 2;} for (int i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))
/*--------------------------------------------------------------------------------------------------------------------------*/
 void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
const int MAXN = 2000000;
int fact[MAXN+1];
int inv_fact[MAXN+1];
void pre_compute()
{
    fact[0] = 1;
    for(int i=1;i<=MAXN;i++)
        fact[i] = mod_mul(i,fact[i-1],mod);
    inv_fact[0] = 1;
    for(int i=1;i<=MAXN;i++)
        inv_fact[i] = mod_mul(mminv(i,mod),inv_fact[i-1],mod);
}
int combination(int i,int j)
{
    int ans = fact[i];
    ans = mod_mul(ans,inv_fact[j],mod);
    ans = mod_mul(ans,inv_fact[i-j],mod);
    return ans;
}
int32_t main()
{
   c_p_c();
   pre_compute();
   int n,m,k;
   cin>>n>>m>>k;
   if(n>m+k)
    cout<<0<<endl;
   else
   {
      int ans = (combination(m+n,m)-combination(n+m,n-k-1)+mod)%mod;
      cout<<ans<<"\n";
   }
}

#include <bits/stdc++.h>
using namespace std;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define int long long
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define endl "\n"
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MAX = 2e6 + 5;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
inline ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline ll power(ll x, ll n) {
    if (!n) {
        return 1;
    }
    return (n & 1 ? mul(x, power(mul(x, x), n / 2)) : power(mul(x, x), n / 2));
}
int ways = 0;
void rec(int i, int j, int n, int m, int k, vector<char> a) {
    if (i + j == n + m) {
        int wi = 0, bi = 0;
        bool ok = true;
        for (int i = 0; i < n + m; i++) {
            wi += a[i] == 'w';
            bi += a[i] == 'b';
            ok &= (wi <= bi + k);
        }
        ways += ok;
        return;
    }
    if (i < n) {
        a.push_back('w');
        rec(i + 1, j, n, m, k, a);
        a.pop_back();
    }
    if (j < m) {
        a.push_back('b');
        rec(i, j + 1, n, m, k, a);
        a.pop_back();
    }
}
vector<int> fact(MAX, 1);
void pre() {
    for (int i = 1; i < MAX; i++) fact[i] = mul(i, fact[i - 1]);
}
int ncr(int n, int r) {
    if (r > n) return 0LL;
    return mul(fact[n], mul(power(fact[r], mod - 2), power(fact[n - r], mod - 2)));
}
// 7 4 0
// 0 0
// 0 1
// 0 2
// 165 3
// 275 4
// 319 5
// 329 6
// 330 7
// 330 8
// 330 9
// 330 10
// 330 11

// 4 7 0
// 165 0
// 275 1
// 319 2
// 329 3
// 330 4
// 330 5
// 330 6
// 330 7
// 330 8
// 330 9
// 330 10
// 330 11
void solve() {
    pre();
    int n, m, k;
    cin >> n >> m >> k;
    if (n > m) {
        if (k >= n) {
            cout << ncr(n + m, n) << endl;
        } else {
            int diff = n - k;
            if (diff > m) {
                cout << 0 << endl;
            } else {
                cout << sub(ncr(n + m, n), ncr(n + m, diff - 1)) << endl;
            }
        }
    } else {
        if (k >= n) {
            cout << ncr(n + m, n) << endl;
        } else {
            cout << sub(ncr(n + m, n), ncr(n + m, n - k - 1)) << endl;
        }
    }
    // for (int k = 0; k <= n + m; k++) {
    //     vector<char> a;
    //     ways = 0;
    //     rec(0, 0, n, m, k, a);
    //     cout << ways << " " << k << endl;
    // }
}

signed main() {
    fastio;

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

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


#include<bits/stdc++.h>
using namespace std;
#define N 2
#define NN 205
#define For(i,x,y)for(i=x;i<=(y);i++)
int f[NN][NN][N][N][N],val[NN][NN][N][N][N],a[NN],used[NN];
pair<pair<int,int>,pair<bool,pair<bool,bool> > >pre[NN][NN][N][N][N];
int main()
{
	int n,i,j,k,p,tot=0,l,u,v;
	pair<pair<int,int>,pair<bool,pair<bool,bool> > >pa;
	cin>>n;
	For(i,1,n)cin>>a[i],a[i]%=200;
	f[0][0][0][0][0]=1;
	For(i,1,n)
	For(l,0,i-1)
	For(j,0,199)
	For(u,0,1)
	For(v,0,1)
	For(k,0,1)
	if(f[l][j][k][u][v])
	{
		p=(j+a[i])%200;
		f[i][p][1][1][v]=val[i][p][1][1][v]=1;
		pre[i][p][1][1][v]=make_pair(make_pair(l,j),make_pair(k,make_pair(u,v)));
		p=(j-a[i]+200)%200;
		f[i][p][1][u][1]=1;
		val[i][p][1][u][1]=2;
		pre[i][p][1][u][1]=make_pair(make_pair(l,j),make_pair(k,make_pair(u,v)));
		f[i][j][k][1][1]=1;
		val[i][j][k][1][1]=3;
		pre[i][j][k][1][1]=make_pair(make_pair(l,j),make_pair(k,make_pair(u,v)));
	}
	if(f[n][0][1][1][1])
	{
		puts("yEs");
		i=n;
		j=0;
		k=u=v=1;
		while(i)
		{
			/*cout<<i<<' '<<j<<' '<<k<<' '<<u<<' '<<v<<endl;*/
			used[i]=val[i][j][k][u][v];
			pa=pre[i][j][k][u][v];
			i=pa.first.first;
			j=pa.first.second;
			k=pa.second.first;
			u=pa.second.second.first;
			v=pa.second.second.second;
		}
	}
	else puts("nO"),exit(0);
	For(i,1,n)tot+=used[i]==1||used[i]==3;
	cout<<tot;
	For(i,1,n)
	if(used[i]==1||used[i]==3)cout<<' '<<i;
	cout<<endl;
	tot=0;
	For(i,1,n)tot+=used[i]==2||used[i]==3;
	cout<<tot;
	For(i,1,n)
	if(used[i]==2||used[i]==3)cout<<' '<<i;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    int a[210];
    for (int i = 0;i < n;++i) cin >> a[i];
    vector<vector<int>> dp(n+1,vector<int>(200,0));
    dp[0][0] = 1;
    for (int i = 0;i < n;++i) {
        dp[i+1] = dp[i];
        for (int j = 0;j < 200;++j) dp[i+1][(j+a[i])%200] += dp[i][j];
        for (int j = 0;j < 200;++j) dp[i+1][j] = min(dp[i+1][j],3);
    }
    dp[n][0]--;
    bool ok = false;
    int m;
    for (int i = 0;i < 200;++i) if (dp[n][i] > 1) {
        ok = true;
        m = i;
        break;
    }
    if (!ok) {
        cout << "No" << newl;
        return 0;
    }
    cout << "Yes" << newl;
    int z = m;
    for (int i = 0;i < n;++i) {
        for (int j = 0;j < n+1;++j) for (int k = 0;k < 200;++k) dp[j][k] = 0;
        dp[0][0] = 1;
        for (int j = 0;j < n;++j) {
            dp[j+1] = dp[j];
            if (i == j) continue;
            for (int k = 0;k < 200;++k) dp[j+1][(k+a[j])%200] += dp[j][k];
            for (int k = 0;k < 200;++k) dp[j+1][k] = min(dp[j+1][k],2);
        }
        int mm = (m-a[i]%200+200)%200;
        if (!(dp[n][m] && dp[n][mm])) continue;
        vector<int> b,c;
        for (int j = n-1;j >= 0;--j) {
            int u = (m-a[j]%200+200)%200;
            if (dp[j][u] == 0) continue;
            if (j == i) continue;
            b.push_back(j);
            m = u;
        }
        for (int j = n-1;j >= 0;--j) {
            int u = (mm-a[j]%200+200)%200;
            if (dp[j][u] == 0) continue;
            if (j == i) continue;
            c.push_back(j);
            mm = u;
        }
        c.push_back(i);
        reverse(b.begin(),b.end());
        sort(c.begin(),c.end());
        int x = b.size(),y = c.size();
        if (x == 0 || y == 0) continue;
        cout << x << " ";
        for (int j = 0;j < x;++j) cout << b[j]+1 << " \n"[j == x-1];
        cout << y << " ";
        for (int j = 0;j < y;++j) cout << c[j]+1 << " \n"[j == y-1];
        return 0;
    }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	while(n--)
	{
		int x;
		cin>>x;
		if(x>10)
			ans+=x-10;
	}
	cout<<ans;
	return 0;
}

/*Created By:---- Dibas Behera*/
#include<bits/stdc++.h>
using namespace std;

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

#define goo(x)	cout<<"Case #"<<(x)<<": ";
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
ll binpowM(ll a,ll b,ll m=MD){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a;ans%=m; a=a*a;a%=m; b=b>>1;}	return ans;}
template <typename T>
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

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

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;

	ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
    ll ans=0;
    repi(i,n){
        if(a[i]>10) ans+=a[i]-10;
    }
    db(ans);
	/*
	int test1;cin>>test1;while(test1--){

	 }
	 //*/
return 0;
}


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

const int maxn=200010;

int n,m;
string s;
char t[maxn];

int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		t[++m]=s[i];

		if(m>=3&&t[m-2]=='f'&&t[m-1]=='o'&&t[m]=='x') m-=3;
	}

	cout<<m;

	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long;
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (200006)
ll n, K, mod=998244353, grid[52][52], sz[52], f[52];
struct u_ {
	int p[52];
	u_() { FOR(i,0,51) p[i]=i; }
	void merge(int x,int y) { p[find(x)]=find(y); }
	ll find(ll x){return p[x]==x?x:p[x]=find(p[x]);}
} ufds;
ll ans=1;
void funny() {
	mmst(sz,0);
	FOR(i,0,n-1) ++ sz[ufds.find(i)];
	FOR(i,0,n-1) if(ufds.find(i) == i) {
		ans *= f[sz[i]], ans %= mod;
	}
}
int main(){
	FAST
	cin>>n>>K;
	f[0]=1; FOR(i,1,51) f[i]=f[i-1]*i%mod;
	FOR(i,0,n-1) FOR(j,0,n-1) {
		cin>>grid[i][j];
	}
	ufds = u_();
	FOR(i,0,n-1) {
		FOR(k,0,n-1) if(i^k) {
			bool can = 1;
			FOR(j,0,n-1) {
				if(grid[i][j] + grid[k][j] > K) can = 0;
			}
			if(can) ufds.merge(i, k);
		}
	}
	funny();
	ufds = u_();
	FOR(j,0,n-1) {
		FOR(k,0,n-1) if(j^k) {
			bool can = 1;
			FOR(i,0,n-1) {
				if(grid[i][j] + grid[i][k] > K) can = 0;
			}
			if(can) ufds.merge(j, k);
		}
	}
	funny();
	cout<<ans<<'\n';
}


#include <bits/stdc++.h>
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define long long long
#define endl "\n"
using namespace std;
// const double PI = acos(-1.0);
// const double E = exp(1.0);
// const double EPS = 1e-9;
const int MOD = (int)1e9 + 7;
const int N = (int)1e5;

int main()
{
#ifdef MY_PREPROCESSOR
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, a, b;
    cin >> n >> a >> b;
    cout << n - a + b;

    return 0;
}

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

// #include <atcoder/all>
// using namespace atcoder;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

void solve(long long N, long long K){
    ll ans = 0;
    rep(i, N) rep(j, K) {
        ans += (i + 1) * 100 + (j + 1);
    }
    cout << ans << endl;
}

// Generated by 2.3.1 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    std::scanf("%lld", &N);
    long long K;
    std::scanf("%lld", &K);
    solve(N, K);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

//begin of def

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define endl '\n'

using lli = long long int;
using ulli = unsigned long long int;
using Ld = long double;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
using pld = pair<Ld, Ld>;
#define X first
#define Y second

#define rep(I, S, E) for(int I = (S); I < (E); I++)
#define repq(I, S, E) for(int I = (S); I <= (E); I++)

#define pb push_back
#define epb emplace_back

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

//end of def

int main(){
    fastio;
    lli n;
    int m;
    cin >> n >> m;
    vector<pii> v(m);
    rep(i, 0, m)
        cin >> v[i].X >> v[i].Y;
    sort(ALL(v));
    set<lli> st;
    st.insert(n);
    lli nw = -2, er = -2;
    rep(i, 0, m){
        if(i && v[i].X != v[i - 1].X)
            nw = er = -2;
        int t = er;
        if(st.count(v[i].Y))
            er = v[i].Y;
        st.erase(v[i].Y);
        if((st.count(v[i].Y - 1) && nw != v[i].Y - 1) || st.count(v[i].Y + 1) || t == v[i].Y - 1){
            if(st.count(v[i].Y) == 0)
                nw = v[i].Y;
            st.insert(v[i].Y);
        }
    }
    cout << st.size();
    return 0;
}

// Problem: C - Max GCD 2
// Contest: AtCoder - Japanese Student Championship 2021
// URL: https://atcoder.jp/contests/jsc2021/tasks/jsc2021_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define pb push_back
#define mp make_pair
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9+7;
const int MAX_N = 2e6+10;

int a, b;

void solve()
{
	int ans = 1;
	for(int i=1;i<=b;++i){
		int mi = (a + i-1)/ i;
		int mx = b / i;
		if(mx > mi) ans = i;
	}
	cout << ans << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cin >> a >> b;
	solve();
	return 0;
}


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

const int N = 5005, mod = 998244353;

int n, m, ans, f[N][N];

int fpow_(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = 1ll*a*a%mod)
		if (b&1)
			res = 1ll*res*a%mod;
	return res;
}

int main() {
	scanf("%d%d", &n, &m);
	ans = 1ll*fpow_(m, n)*n%mod;
	f[0][0] = 1;
	for (int k = 1; k <= m; k++) {
		f[k][0] = 1;
		for (int i = 1; i <= n; i++)
			f[k][i] = 1ll*f[k][i - 1]*k%mod;
	}
	for (int i = 2; i <= n; i++)
		for (int j = 1; j <= m; j++)
			ans = (ans - 1ll*f[m][n - i]*(n - i + 1)%mod*f[m - j][i - 2])%mod;
	printf("%d\n", (ans%mod + mod)%mod);
}

#include<bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A>
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
#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 pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;
typedef pair<ll,ll> plint;
const int mod = 998244353;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

const int N = 2e5 + 10;
template<int mod>
struct ModInt{
	int x;
	ModInt () : x(0) {}
	ModInt (int64_t x) : x(x >= 0 ? x % mod : (mod - -x % mod) % mod) {}
	ModInt &operator += (const ModInt &p){
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator -= (const ModInt &p) {
		if ((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator *= (const ModInt &p) {
		x = (int64_t) x * p.x % mod;
		return *this;
	}
	ModInt &operator /= (const ModInt &p) {
		*this *= p.inverse();
		return *this;
	}
	ModInt &operator ^= (int64_t p) {
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator - () const { return ModInt(-x); }
	ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
	ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
	ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
	ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
	ModInt operator ^ (int64_t p) const { return ModInt(*this) ^= p; }
	bool operator == (const ModInt &p) const { return x == p.x; }
	bool operator != (const ModInt &p) const { return x != p.x; }
	explicit operator int() const { return x; }
	ModInt &operator = (const int p) { x = p; return *this;}
	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			a -= t * b;
			std::swap(a, b);
			u -= t * v;
			std::swap(u, v);
		}
		return ModInt(u);
	}
	friend std::ostream & operator << (std::ostream &stream, const ModInt<mod> &p) {
		return stream << p.x;
	}
	friend std::istream & operator >> (std::istream &stream, ModInt<mod> &a) {
		int64_t x;
		stream >> x;
		a = ModInt<mod>(x);
		return stream;
	}
};
typedef ModInt<998244353> mint;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<mint> pw(n + 1, 1);
	for (int i = 1; i <= n; ++i) pw[i] = pw[i - 1] * mint(m);
	//vector<mint> sum(m + 1, 1);
	vector< vector<mint> > pws(m + 1, vector<mint> (n + 1, 1));
	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= n; ++j) {
			pws[i][j] = pws[i][j - 1] * mint(m - i);
		}
	}
	// pws[i][j] = (m - i) ^ j;
	vector< vector<mint> > sum(n + 1, vector<mint> (m + 1 , 0));
	// (m - x) ^ (k)  x : 1 -> m
	// sum[i][j] =
	for (int i = 0; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			sum[i][j] = sum[i][j - 1] + pws[j][i];
		}
	}
	mint ans = 0;

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j < i; ++j) {
			ans += sum[i - j - 1][m] * pw[n - 1 - (i - j)];
		}
	}

	cout << mint(n) * pw[n] - ans << endl;
    return 0;
}


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

#define endl '\n'
#define nitro std::ios_base::sync_with_stdio(false), std::cin.tie(NULL)
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define debug(x) cerr<<GREEN<<#x": "<<(x)<<endl<<RESET
#define case_g(x) cout<<"Case #"<<x<<": "
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, bool> pib;
typedef std::pair<ll, bool> plb;
typedef std::vector<pii> vii;
typedef std::vector<pll> vll;
typedef std::vector<pib> vib;
typedef std::vector<plb> vlb;
typedef std::vector<vi> vvi;
typedef std::vector<vl> vvl;
typedef std::vector<vb> vvb;
typedef std::unordered_map<int, int> umapii;
typedef std::unordered_map<ll, ll> umapll;
typedef std::unordered_map<int , bool> umapib;
typedef std::unordered_map<ll, bool> umaplb;
typedef std::map<int, int> mapii;
typedef std::map<ll, ll> mapll;
typedef std::map<int, bool> mapib;
typedef std::map<ll, bool> maplb;

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"

void precompute() {
}

void solve() {
	vi a(3);

	cin >> a[0] >> a[1] >> a[2];

	sort(all(a));

	if( a[1] == a[0] ) cout << a[2] << endl;
	else if( a[1] == a[2] ) cout << a[0] << endl;
	else cout << 0 << endl;
}

int main() {
	nitro;

	int tc = 1;
	//cin >> tc;

	precompute();
	for(int i = 1; i <= tc; ++i) {
		//case_g(i);
		solve();
	}
	return 0;
}

#include<iostream>

using namespace std;

int a[4];

int main(){
    for(int i=0;i<4;++i) cin>>a[i];
    for(int i=0;i<1<<4;++i){
        int remain=0,tot=0;
        for(int j=0;j<4;++j){
            if(i>>j&1) tot+=a[j];
            else remain+=a[j];
        }
        if(remain==tot){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


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

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

int to[400001], ne[400001], he[200001];
int Q[200001], pl[200001], dl[200001];

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

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

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

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

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

		int num = 0;

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

		int are = num + (dl[1] > pd0);
		if (are > K) L = wj;
		else R = wj;

		pd0 += are;
	}

	printf("%d", R);

	Would you please return 0;
}

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

const int maxl=3e5+10;
const int inf=1e9+10;

int n,m,k,cnt,tot,cas,ans;
int a[maxl],f[maxl],g[maxl];
bool vis[maxl];
char s[maxl];
vector<int> e[maxl];

inline void prework()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n-1;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
}

inline void dfs(int u,int fa,int mid)
{
	f[u]=inf;g[u]=0;
	for(int v:e[u])
	if(v!=fa)
	{
		dfs(v,u,mid);
		f[u]=min(f[u],f[v]+1);
		g[u]=max(g[u],g[v]+1);
	}
	if(f[u]+g[u]<=mid)
		g[u]=-inf;
	else if(g[u]==mid)
		g[u]=-inf,f[u]=0,++cnt;
}

inline bool jug(int mid)
{
	cnt=0;
	dfs(1,0,mid);
	if(g[1]>=0) cnt++;
	return cnt<=k;
}

inline void mainwork()
{
	int l=0,r=n;
	while(l+1<r)
	{
		int mid=(l+r)>>1;
		if(jug(mid))
			r=mid;
		else
			l=mid;
	}
	if(jug(l)) ans=l;
	else ans=r;
}

inline void print()
{
	printf("%d\n",ans);
}

int main()
{
	int t=1;
	//scanf("%d",&t);
	for(cas=1;cas<=t;cas++)
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

// 点(x2,y2)の角度
double nasukaku(double x1, double y1, double x2, double y2, double x3, double y3){
    double a1 = (x1-x2), a2 = (y1-y2);
    double b1 = (x3-x2), b2 = (y3-y2);
    double costheta = (a1*b1+a2*b2)/(sqrt(a1*a1+a2*a2)*sqrt(b1*b1+b2*b2));

    double rad = acos(costheta);
    // return rad; // ラジアン
    return rad * 180.0 / M_PI; // 度数法
}

int main() {
    int n;
    cin >> n;
    double x[n], y[n];
    rep(i,n) cin >> x[i] >> y[i];
    double eps = 1e-12;
    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(i == j || j == k || k == i) continue;
                double a = nasukaku(x[i],y[i],x[j],y[j],x[k],y[k]);
                if(180.0-eps<a&&a<180.0+eps){
                    cout << "Yes" << endl;
                    return 0;
                }
                if(-eps<a&&a<eps){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

#include <iostream>
#include <algorithm>
#define MAX 100
using namespace std;

template <typename T>
bool next_combination(const T first, const T last, int k)
{
    const T subset = first + k;
    // empty container | k = 0 | k == n
    if (first == last || first == subset || last == subset)
    {
        return false;
    }
    T src = subset;
    while (first != src)
    {
        src--;
        if (*src < *(last - 1))
        {
            T dest = subset;
            while (*src >= *dest)
            {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int main()
{
    int n;
    double x[MAX], y[MAX];
    int r[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];

    for (int i = 0; i < 100; i++)
    {
        r[i] = i;
    }

    do
    {
        if (x[r[0]] - x[r[1]] == 0 || x[r[2]] - x[r[0]] == 0)
        {
            if (x[r[0]] - x[r[1]] == 0 && x[r[2]] - x[r[0]] == 0)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }

        else if (((y[r[0]] - y[r[1]]) / (x[r[0]] - x[r[1]])) == ((y[r[2]] - y[r[0]]) / (x[r[2]] - x[r[0]])))
        {
            cout << "Yes" << endl;
            return 0;
        }
    } while (next_combination(r, r + n, 3));

    cout << "No" << endl;
}


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm],st[mm],num[mm];
ll sum[3000][3000];
string s[3000];
ll mod=1e9+7;
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk;
    scanf("%lld%lld",&n,&m);
	for(i=0;i<n;i++) cin>>s[i];
	d[0]=1; num[0]=1; st[m]=1;
	sum[0][0]=0;
	for(i=0;i<n;i++)
	for(j=0;j<m;j++)
	{
	  	if(i==0&&j==0) continue;
	  	if(s[i][j]=='.')
	  	{
	  	sum[i][j]=(sum[i][j]+d[i]+num[j]+st[i-j+m])%mod;
	  	d[i]=(d[i]+sum[i][j])%mod;
	  	num[j]=(num[j]+sum[i][j])%mod;
	  	st[i-j+m]=(st[i-j+m]+sum[i][j])%mod;
	    }
	    else
	    {
	    	d[i]=0; num[j]=0; st[i-j+m]=0;
	    	sum[i][j]=0;
		}
	//	cout<<i<<' '<<j<<' '<<sum[i][j]<<' '<<d[i]<<endl;
	}
	printf("%lld\n",sum[n-1][m-1]);

}

#include <bits/stdc++.h>

using namespace std;

// using mint = long double;
// using mint = modint998244353;
// using mint = modint1000000007;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<ll, vector<ll>> Pd;

const ll INF = 1e18;
const ll fact_table = 3200008;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)
#define rep2(i, a, b) for (ll i = a; i <= (b); i++)
#define rep3(i, a, b) for (ll i = a; i >= (b); i--)

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll m = mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= m; b >>= 1;}(x *= a) %= m; b--;} return x;}
vec readvec(ll read) { vec res(read); for (int i = 0; i < read; i++) { cin >> res[i]; } return res;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/

bool icpc = false;
bool multicase = false;

ll n, m, k;
ll dp[3000][3000];
ll tatesum[3000][3000], yokosum[3005][3005], nanamesum[3005][3005];
string s[3005];

bool solve() {
    cin >> n >> m;
    rep(i, n) {
        cin >> s[i];
    }
    dp[1][1] = 1;
    tatesum[1][1] = yokosum[1][1] = nanamesum[1][1] = 1;
    rep2(i, 1, n) {
        rep2(j, 1, m) {
            if (s[i - 1][j - 1] == '#') continue;
            if (i + j == 2) continue;
            ll sum1 = tatesum[i - 1][j] + mod - tatesum[0][j];
            ll sum2 = yokosum[i][j - 1] + mod - yokosum[i][0];
            ll sum3;
            if (i >= j) {
                sum3 = nanamesum[i - 1][j - 1] + mod - nanamesum[i - j][0];
            } else {
                sum3 = nanamesum[i - 1][j - 1] + mod - nanamesum[0][j - i];
            }
            dp[i][j] = (sum1 + sum2 + sum3) % mod;
            tatesum[i][j] = (tatesum[i - 1][j] + dp[i][j]) % mod;
            yokosum[i][j] = (yokosum[i][j - 1] + dp[i][j]) % mod;
            nanamesum[i][j] = (nanamesum[i - 1][j - 1] + dp[i][j]) % mod;
        }
    }
    ll ans = dp[n][m];
    p(ans);
    return true;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    if (icpc) {
        while (solve());
        return 0;
    }
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }

// solve();
    return 0;
}