#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define ll long long
#define ss second
#define ff first
#define mod 1000000007
#define w(x) ll x; cin>>x; while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define re(i, j) fo(i, 0, j, 1)
#define pi acos(-1)
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
//18-1326D1 1208B 845C 912B 1009B 1350C 20C 1333C 1234D 1327C 1305B 1304B (or in matrix) 1216-C(26) 21
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
	//cp();
	//w(x)
	{
		de(a);
		de(b);
		de(c);
		ll m=998244353;
		ll ans=1;
		if(a%2==0)
		{
			ans=((ans%m)*(a/2)%m)%m;
			ans=((ans%m)*(a+1)%m)%m;
		}
		else
		{
			ans=((ans%m)*((a+1)/2)%m)%m;
			ans=((ans%m)*(a)%m)%m;
		}
		if(b%2==0)
		{
			ans=((ans%m)*(b/2)%m)%m;
			ans=((ans%m)*(b+1)%m)%m;
		}
		else
		{
			ans=((ans%m)*((b+1)/2)%m)%m;
			ans=((ans%m)*(b)%m)%m;
		}
		if(c%2==0)
		{
			ans=((ans%m)*(c/2)%m)%m;
			ans=((ans%m)*(c+1)%m)%m;
		}
		else
		{
			ans=((ans%m)*((c+1)/2)%m)%m;
			ans=((ans%m)*(c)%m)%m;
		}
		cout<<ans;
	}
}

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

#define endl "\n"
#define pb push_back
#define fo(i, start, end) for (ll i = start; i < end; i++)
#define rep(i, start, end, step) for (ll i = start; i < end; i += step)
#define print(x) cout << #x << " is " << x << endl
#define all(arg) arg.begin(), arg.end()
#define sz(arg) (int)arg.size()

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

void solve() {
    int n, m;
    cin >> n >> m;
    int a;
    vector<vi> mp(n);
    fo(i, 0, n) mp[i].push_back(-1);
    fo(i, 0, n) {
        cin >> a;
        mp[a].push_back(i);
    }
    fo(i, 0, n) mp[i].push_back(n);
    fo(i, 0, n) {
        fo(j, 1, (ll)mp[i].size()) {
            if (mp[i][j] - mp[i][j - 1] > m) {
                cout << i << endl;
                return;
            }
        }
    }
    cout << n << endl;
}

int main() {
#ifndef DEBUG
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin>>s;
  string ss="";
  ll x=s.length();
  for(ll i=(x-1);i>=0;i--){
    ss+=s[i];
    }
  for(ll i=0;i<(ll)ss.length();i++){
    if(ss[i]=='6'){ss[i]='9';
                   continue;}
    if(ss[i]=='9')ss[i]='6';
    }
cout<<ss;
  }

#include<bits/stdc++.h>
#define icantcode ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
bool can = 1;
string s;
int main(){
	icantcode
	cin>>s;
	int l = s.length();
	for(int i=0;i<l;i++){
		if(i%2 == 0){
			if(s[i]>='A' && s[i]<='Z'){
				can = 0;
				break;
			}
		}
		else{
			if(s[i]>='a' && s[i]<='z'){
				can = 0;
				break;
			}
		}
	}
	if(can) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

#include <iostream>
#include <cassert>

template<long long mod>
class modint{
private:
  using T = long long;
  T a;
public:
  constexpr modint(const long long x = 0) noexcept : a((x%mod+mod)%mod) {}
  constexpr T& value() noexcept { return a; }
  constexpr const T& value() const noexcept { return a; }
  constexpr modint operator-() const noexcept {
    return modint(0) -= *this;
  }
  constexpr modint operator+(const modint& rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint& rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint& rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint& rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint& rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint& rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint& rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(const modint& rhs) noexcept {
    return *this *= rhs.inv();
  }
  constexpr bool operator==(const modint& rhs) const noexcept {
    return a == rhs.a;
  }
  constexpr bool operator!=(const modint& rhs) const noexcept {
    return not (*this == rhs);
  }
  constexpr modint pow(long long k) const noexcept {
    modint ret(1);
    modint x = k > 0 ? *this : this->inv();
    k = abs(k);
    while(k > 0){
      if(k&1) ret *= x;
      x *= x;
      k >>= 1;
    }
    return ret;
  }
  constexpr modint inv() const noexcept {
    return pow(mod-2);
  }
  friend std::ostream& operator<<(std::ostream &os, const modint &X) noexcept {
    return os << X.a;
  }
  friend std::istream& operator>>(std::istream &is, modint &X) noexcept {
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

template<typename T>
struct Combination {
private:
  int sz;
  vector<T> F, F_;
public:
  Combination(int sz) : sz(sz), F(sz+1), F_(sz+1) {
    F[0] = 1;
    for(int i = 0; i < sz; ++i) F[i+1] = F[i]*(i+1);
    F_.back() = (T)1/F.back();
    for(int i = sz-1; i >= 0; --i) F_[i] = F_[i+1]*(i+1);
  }
  T C(int n, int k){
    assert(n <= sz);
    if(n < 0 or k > n) return (T)0;
    return F[n]*F_[k]*F_[n-k];
  }
  T P(int n, int k){
    assert(n <= sz);
    if(n < 0 or k > n) return (T)0;
    return F[n]*F_[n-k];
  }
};

int main(){
  using mint = modint<998244353>;
  int n, m;
  cin >> n >> m;
  vector<vector<int>> D(m+1);
  for(int i = 2; i <= m; ++i){
    if(D[i].size()) continue;
    for(int j = 1; j*i <= m; ++j){
      int k = i*j, c = 0;
      while(k%i == 0){
        ++c;
        k /= i;
      }
      D[j*i].emplace_back(c);
    }
  }
  Combination<mint> comb(n+100);
  mint ans = 0;
  for(int i = 1; i <= m; ++i){
    mint t = 1;
    for(auto e : D[i]){
      t *= comb.C(n+e-1,n-1);
    }
    ans += t;
  }
  cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
const long double PI = acos(-1.0);
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){//cout<<fixed<<setprecision(20);
  int a,b;
  cin>>a>>b;
  cout<<(a+b)/2<<" "<<(a-b)/2<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

int n, a[300], f[300], id[300], x[300], y[300], cnt[300];
bool valid(int l, int len) {
    for (int i = 1; i <= n / 2; ++i) {
        if (x[i] != -1 && y[i] != -1) {
            if (x[i] >= l + 2 * len) continue;
            if (y[i] < l) continue;
            if (x[i] >= (l + len)) return false;
            if (x[i] < l) return false;
            if (((y[i] - x[i]) != len)) return false;
        } else if (x[i] == -1) {
            if (y[i] >= (l + 2 * len)) continue;
            if (y[i] < l) continue;
            if (y[i] < l + len) return false;
            if (a[y[i] - len]) return false;
        } else if (y[i] == -1) {
            if (x[i] < l) continue;
            if (x[i] >= l + 2 * len) continue;
            if (x[i] >= l + len) return false;
            if (a[x[i] + len]) return false;
        }
    }
    return true;
}
signed main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d %d", &x[i], &y[i]);
        if(x[i] != -1 && y[i] != -1 && x[i] >= y[i]) return puts("No"), 0;
        ~x[i] ? a[x[i]] = 1, cnt[x[i]]++, id[x[i]] = i : 0;
        ~y[i] ? a[y[i]] = 1, cnt[y[i]]++, id[y[i]] = i : 0;
    }
    n <<= 1, f[0] = 1;
    for(int i = 1; i <= n; i++) if(cnt[i] > 1) return puts("No"), 0;
    for(int i = 0; i <= n; i++) if(f[i])
        for(int j = 1; i + 2 * j <= n; j++)
            f[i + 2 * j] |= valid(i + 1, j);
    puts(f[n] ? "Yes" : "No");
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
}

#include<bits/stdc++.h>
#define int long long
#define all(x) begin(x), end(x)
#define SZ(x) ((int)(x).size())
#define EB emplace_back
#define PB push_back
#define PP pop_back
#define MP make_pair
#define F first
#define S second
#define de(x) if(x && x == MODE)
#define MODE 0

using namespace std;

typedef pair<int, int> pii;
const int INF = 1e18;
const int maxn = 1e5 + 7;

vector<int> G[maxn];

int A[maxn], B[maxn];
int C[maxn];
int target[maxn] = {};
bool v[maxn] = {};
int d[20][20] = {};
int dp[1<<20][20] = {};

int32_t main() {
    int i,j;
    int N, M;

    cin >> N >> M;
    for (int i=1; i<=M; i++)
        scanf("%lld %lld", &A[i], &B[i]);
    for (int i=1; i<=M; i++) {
        G[A[i]].PB(B[i]);
        G[B[i]].PB(A[i]);
    }
    int K;
    cin >> K;
    memset(target, -1, sizeof(target));
    for (int i=0; i<K; i++) {
        scanf("%lld", &C[i]);
        target[C[i]] = i;
    }

    for (int i=0; i<K; i++) {
        memset(v, 0, sizeof(v));
        queue<int> que;
        que.push(C[i]);
        v[C[i]] = 1;
        int step = 1;
        while (!que.empty()) {
            int goal = que.size();
            while (goal--) {
                int x = que.front();
                que.pop();
                for (auto y : G[x]) {
                    if (v[y])
                        continue;
                    v[y] = 1;
                    que.push(y);
                    if (target[y] != -1) {
                        d[i][target[y]] = step;
                    }
                }
            }
            step++;
        }
    }

    de(1) {
        for (int i=0; i<K; i++) {
            for (int j=0; j<K; j++) {
                printf("d(%lld, %lld) = %lld\n", i, j, d[i][j]);
            }
        }
    }

    for (int i=0; i<(1<<K); i++) {
        for (int j=0; j<K; j++)
            dp[i][j] = INF;
    }
    for (int i=0; i<K; i++)
        dp[1<<i][i] = 1;
    for (int i=0; i<(1<<K); i++) {
        for (int j=0; j<K; j++) {
            if (i&(1<<j)) {
                for (int k=0; k<K; k++) {
                    if (j == k || !d[j][k])
                        continue;
                    dp[i][j] = min(dp[i][j], dp[i^(1<<j)][k] + d[k][j]);
                    de(1) printf("dp[%lld][%lld] = %lld\n", i, j, dp[i][j]);
                }
            }
        }
    }

    int ans = INF;
    for (int i=0; i<K; i++)
        ans = min(ans, dp[(1<<K)-1][i]);
    if (ans == INF)
        printf("-1\n");
    else
        printf("%lld\n", ans);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


/*
Another source code by:

  _   _ _ _   _        _____       _
 | \ | (_) | (_)      / ____|     | |
 |  \| |_| |_ _ _ __ | |  __ _ __ | |_
 | . ` | | __| | '_ \| | |_ | '_ \| __|
 | |\  | | |_| | | | | |__| | |_) | |_
 |_| \_|_|\__|_|_| |_|\_____| .__/ \__|
                            | |
                            |_|
*/
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define st string
#define vvll vector<vll>
#define vstr vector <string>
#define vp vector <pair<ll,ll>>
#define fori(n) for(ll i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define s(v) sort(v.begin(),v.end())
#define sr(v) sort(v.rbegin(),v.rend())
#define ll long long
#define MOD 1000000007
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   make_pair
#define ff first
#define ss second

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll md(ll n){if(n>0)return n;else return -n;}
ll mv(vll v){ll m=v[0];fori(v.size()){m=max(v[i],m);}return m;}
vll read(ll n){vll v(n);fori(n)cin>>v[i];return v;}
void out(vll v){fori(v.size()){cout<<v[i]<<" ";}cout<<"\n";}

void solve(){
    ll n,m,k,x;
    cin>>n>>m>>k;
    cout<<21-n-k-m;

}
int main(){

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

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

    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

/*
    code by:-
                                                                          __
                                                                         |  \
  _______  ______  ______ ____  ______ ____  __    __         __  ______  \▓▓_______
 /       \|      \|      \    \|      \    \|  \  |  \       |  \|      \|  \       \
|  ▓▓▓▓▓▓▓ \▓▓▓▓▓▓\ ▓▓▓▓▓▓\▓▓▓▓\ ▓▓▓▓▓▓\▓▓▓▓\ ▓▓  | ▓▓        \▓▓ \▓▓▓▓▓▓\ ▓▓ ▓▓▓▓▓▓▓\
 \▓▓    \ /      ▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓  | ▓▓       |  \/      ▓▓ ▓▓ ▓▓  | ▓▓
 _\▓▓▓▓▓▓\  ▓▓▓▓▓▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓__/ ▓▓       | ▓▓  ▓▓▓▓▓▓▓ ▓▓ ▓▓  | ▓▓
|       ▓▓\▓▓    ▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ | ▓▓\▓▓    ▓▓       | ▓▓\▓▓    ▓▓ ▓▓ ▓▓  | ▓▓
 \▓▓▓▓▓▓▓  \▓▓▓▓▓▓▓\▓▓  \▓▓  \▓▓\▓▓  \▓▓  \▓▓_\▓▓▓▓▓▓▓  __   | ▓▓ \▓▓▓▓▓▓▓\▓▓\▓▓   \▓▓
                                            |  \__| ▓▓ |  \__/ ▓▓
                                             \▓▓    ▓▓ \▓▓    ▓▓
                                              \▓▓▓▓▓▓   \▓▓▓▓▓▓

*/

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, x, y)   for (__typeof(x) i = x; i < y; i++)
#define repr(i, x, y)   for (__typeof(x) i = x; i > y; i --)
#define all(x)                      (x).begin(),(x).end()
// #define Sort(x)                     sort(all((x)))
// #define rSort(x)                    sort((x).rbegin(),(x).rend())
// #define X                           first
// #define Y                           second
#define sep                         ' '
#define SZ(x)                       ll(x.size())
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define first X
#define second Y

const ll N = 1e17 + 10;
const ll M = 1e9 + 7;

void solve()
{
	ll n,x;
	cin>>n>>x;

	ll a[n];
	vector<ll>v;

	rep(i,0,n)
	{
		cin>>a[i];
		if(a[i]!=x)
		{
			v.pb(a[i]);
		}
	}

	rep(i,0,SZ(v))
	{
		cout<<v[i]<<sep;
	}

}

int main()
{
	int t=1;

	while(t--)
	{
		solve();
	}
	// solve();
}


//インクルードなど
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
using namespace std;
typedef long long ll;

//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;
#define coutall(x) {for(int i=0;i<sizeof(x)/sizeof(x[0]);i++){cout<<x[i]<<"|";};};cout<<endl;
//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

signed main(){
    ll n;cin>>n;
    vector<ll> a(n);
    REP(i,n){cin>>a[i];};
    sort(ALL(a));
    bool ok=true;
    REP(i,n){if(a[i]!=i+1){ok=false;};};
    cout<<(ok?"Yes":"No");

}

#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define int long long
#define pb push_back
#define mkp make_pair
#define ms(a) memset(a, 0, sizeof(a));
#define all(a) a.begin(), a.end()
#define endl '\n'
#define boost                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define mod 1000000007
#define inf 1e18
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define deb3(x, y, z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << endl;

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

    cout << 100 - (x % 100);
}

signed main()
{
    //boost
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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


// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define vi vector<int>
#define si set<int>
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int maxm = 300005;
// ll m = 1e9 + 7;
ll m = 998244353;
vector<vi> adj;
vi h;
vi sz;
vi in;

ll add(ll a, ll b, ll mod = m)
{
    return ((a % mod) + (b % mod)) % mod;
}
ll mul(ll a, ll b, ll mod = m)
{
    return ((a % mod) * (b % mod)) % mod;
}
ll sub(ll a, ll b, ll mod = m)
{
    return ((a % mod) - (b % mod) + mod) % mod;
}

ll modmul(ll a, ll b, ll mod = m)
{
    ll ans = 0;
    a = a % mod;
    while (b)
    {
        if (b & 1)
            ans = add(ans, a, mod);
        a = mul(a, 2, mod);
        b >>= 1;
    }
    return ans;
}

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

ll fe(ll base, ll exp, ll mod = m)
{
    ll ans = 1;
    while (exp)
    {
        if (exp & 1)
            ans = mul(ans, base, mod);
        base = mul(base, base, mod);
        exp >>= 1;
    }
    return ans;
}

void dfs_h_sz(int cur, int par)
{
    h[cur] = h[par] + 1;
    sz[cur]++;
    for (const auto &v : adj[cur])
    {
        if (v == par)
            continue;
        dfs_h_sz(v, cur);
        sz[cur] += sz[v];
    }
}

void buildGraph(int n, int m)
{
    adj = vector<vi>(n + 1);
    h = vector<int>(n + 1);
    sz = vector<int>(n + 1);
    in = vector<int>(n + 1);

    loop(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs_h_sz(1, 0);
}
struct cmp
{
    bool operator()(const pi &a, const pi &b)
    {
        return a.ff < b.ff;
    }
};

ll modin(ll a)
{
    return fe(a, m - 2);
}

ll sum(ll a)
{
    return mul(mul(a, a + 1), modin(2));
}
void solve()
{
    int n,k;
    ll sum = 0;
    cin>>n>>k;
    int a = abs(k);
    int arr[maxm]  ={0};
    // int arr[maxm] = {0};

    loop1(i,1,2*n){
        if(i<=n)
        arr[i] = i-1;
        else
        arr[i] = 2*n-i+1;
    }

    loop1(i,2,2*n){
        if(2<=i+k && i+k<=2*n)
        sum += 1LL*arr[i]*arr[i+k];
    }
    cout<<sum<<"\n";
}
int main()
{
    io;

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int test;
    // cin >> test;
    test = 1;
    while (test--)
    {
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
#pragma GCC optimize(3,"Ofast","-funroll-loops","-fdelete-null-pointer-checks")
#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx")
#define int long long
HohleFeuerwerke;
inline int read(){
	int s=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) s=s*10+c-'0';
	return s*f;
}
inline void write(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
int n,k,ans;
inline int calc(int x,int n){
	if(x<=n+1&&x>=2) return x-1;
	else return 2*n-x+1;
}
signed main()
{
	int T=1;
	while(T--){
		n=read(),k=read(),ans=0;
		if(k<0) k=-k;
		for(int s=2;s<=2*n-k;s++)
			ans+=calc(s,n)*calc(s+k,n)/*,cout<<s<<" "<<s+k<<" "<<calc(s,n)<<" "<<calc(s+k,n)<<endl*/;
		write(ans);puts("");
	}
}


#include<iostream>
using namespace std;
template<long long Mod>struct modInt
{
	long long x;
	constexpr modInt()noexcept:x(){}
	template<typename T>
	constexpr modInt(T v=0)noexcept:x(v%Mod){if(x<0)x+=Mod;}
	constexpr long long getval()const noexcept{return x;}
	constexpr modInt operator-()const noexcept{return x?Mod-x:0;}
	constexpr modInt operator+(const modInt&r)const noexcept{return modInt(*this)+=r;}
	constexpr modInt operator-(const modInt&r)const noexcept{return modInt(*this)-=r;}
	constexpr modInt operator*(const modInt&r)const noexcept{return modInt(*this)*=r;}
	constexpr modInt operator/(const modInt&r)const noexcept{return modInt(*this)/=r;}
	constexpr modInt&operator+=(const modInt&r)noexcept{x+=r.x;if(x>=Mod)x-=Mod;return*this;}
	constexpr modInt&operator-=(const modInt&r)noexcept{x-=r.x;if(x<0)x+=Mod;return*this;}
	constexpr modInt&operator*=(const modInt&r)noexcept{x=x*r.x%Mod;return*this;}
	constexpr modInt&operator/=(const modInt&r)noexcept{x=x*r.inv();return*this;}
	constexpr modInt powm(long long n)noexcept
	{
		if(n<0)return powm(-n).inv();
		modInt x=*this,r=1;
		for(;n;x*=x,n>>=1)if(n&1)r*=x;
		return r;
	}
	constexpr modInt inv()const noexcept
	{
		long long a=x,b=Mod,u=1,v=0;
		while(b)
		{
			long long t=a/b;
			a-=t*b;swap(a,b);
			u-=t*v;swap(u,v);
		}
		return modInt(u);
	}
	constexpr bool operator==(const modInt&r){return this->x==r.x;}
	constexpr bool operator!=(const modInt&r){return this->x!=r.x;}
	friend ostream&operator<<(ostream&os,const modInt<Mod>&a){return os<<a.x;}
	friend istream&operator>>(istream&is,modInt<Mod>&a){long long v;is>>v;a=modInt<Mod>(v);return is;}
};

const long long mod=1000000007;
using mint=modInt<mod>;

main()
{
	int n;mint p;cin>>n>>p;
	cout<<(p-1)*(p-2).powm(n-1)<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define double long double
#define DB
#ifdef DB
#define el cerr << "\n";
#define db(...) cerr << " [" << #__VA_ARGS__ << " : " << __VA_ARGS__ << "] ";
#else
#define el
#define db(...)
#endif // DB
#define ll long long

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int L, R;
    cin >> L >> R;
    vector<ll> dp(R + 1);
    ll res = 0;
    int x;
    for (int i = R; i >= 2; --i) {
        // db(i);
        x = (R / i) - ((L - 1) / i);
        dp[i] = 1LL * x * x;
        // db(dp[i]);
        for (int j = i + i; j <= R; j += i) {
            dp[i] -= dp[j];
            // db(j) db(dp[j]) db(dp[i]);
        }
        res += dp[i];
        // db(i) db(dp[i]) db(x) db(res) el;
    }
    for (int i = max(2, L); i <= R; ++i) {
        x = (R / i) - ((L - 1) / i);
        res -= x * 2 - 1;
    }
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  vector<int> fg(N+1, -1);
  rep(i, M) fg[A[i]] = i;

  //現時点での最小
  priority_queue<int, vector<int>, greater<int>> pq;
  rep(i, N+1){
    if( fg[i] == -1 ) pq.push(i);
  }

  int ans = pq.top();
  for( int i = M; i < N; i++ ){
    fg[A[i]] = i;
    if( pq.top() == A[i] ) pq.pop();
    if( fg[A[i-M]] == i-M ) pq.push(A[i-M]);
    ans = min(ans, pq.top());
  }
  cout << ans << endl;

}

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

const int L = 1.5 * 1e6 + 2;
int n, m, a[L], pos[L], dis[L];
bool vis[L];

int main() {
	scanf("%d %d", &n, &m);

	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		a[i]++, vis[a[i]] = true;
		dis[a[i]] = max(dis[a[i]], i-pos[a[i]]);
		pos[a[i]] = i;
	}

	for (int i = 1; i < L; i++) {
		dis[i] = max(dis[i], n-pos[a[i]]+1);

		if (dis[i] > m || !vis[i]) {
			printf("%d", i-1);
			return 0;
		}
	}

	printf("%d", L-1);

	return 0;
}


/*
  Author     : MatsuTaku
  Date         : 06/13/21
  Certificate:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDF9T447OEo8XSQ6O1AznN5tKC8mzvYc4Zs3+oOKfMqgLXfOwQnpfcoxKs4MAP1eICBD13PkcIezJ9IlV6nKQZKs1BQmvjSXJ+zKK8YCKvAueNPuNO0Bim43IBaNHNFWcMvcmUvHgRb6hUSO0V8I7OsjiFo20KDBj3gAznu9tir0Q== CompetitiveProgrammingCertification:tkm.matsumoto@gmail.com
*/

#include <bits/stdc++.h>
using namespace std;
#include <x86intrin.h>
#define REP(i, l, r)      for (int i = (l), i##_less = (r); i < i##_less; i++)
#define rep(i, n)         REP(i, 0, n)
#define RREP(i, l, r)     for (int i = (r)-1, i##_least = (l); i >= i##_least; i--)
#define rrep(i, n)        RREP(i, 0, n)
#define chmax(dst, x)     dst = max(dst, (x))
#define chmin(dst, x)     dst = min(dst, (x))
using lint = long long int;
using ulint = unsigned long long int;
template<typename T>
using vvec = vector<vector<T>>;
template<typename T>
vvec<T> make_vvec(int n, int m, T v) { return vvec<T>(n, vector<T>(m, v)); }

class Solver {
 public:
  Solver();
  void solve();
};

Solver::Solver() {}

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  Solver solver;
  int t = 1;
//  cin>>t;
  while (t--) {
    solver.solve();
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
#define ip(a) lli a; cin >> a
#define ipfl(a) double a; cin >> a
#define ipstr(a) string a; cin >> a
#define op(a) cout << a
#define opspc(a) cout << a << "\n"
#define FOR0(i, n) for(lli i = 0; i < n; i++)
#define FORa(i, a, n) for(lli i = a; i <= n; i++)
#define pb push_back
#define mem(a, b) memset(a, b, sizeof(a))
#define all(arr) arr.begin(), arr.end()
#define vi vector<lli>
#define pwr(a, b) (lli)(pow(a*1.0, b*1.0))

vi primearr(0);

lli fact(lli n);

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}

void genPrime(lli n)
{
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (lli p = 2; p * p <= n; p++)
    {
        if (prime[p] == true)
        {
            for (lli i = p * p; i <= n; i += p)
            {
                prime[i] = false;
            }
        }
    }
    for (lli p = 2; p <= n; p++)
    {
        if (prime[p])
        {
            primearr.pb(p);
        }
    }
}

lli lcm(lli a, lli b)
{
    return a * b / __gcd(a, b);
}

lli nCr(lli n, lli r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

// Returns factorial of n
lli fact(lli n)
{
    lli res = 1;
    for (lli i = 2; i <= n; i++)
        res = res * i;
    return res;
}

void solve()
{
	ip(n);
	string st[n];
	int v[n];
	int maxe = INT_MIN;
	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> st[i];
		cin >> v[i];
	}
	if(n == 2)
	{
	    if(v[0] < v[1])
	    {
	        cout << st[0] << "\n";
	        return;
	    }
	    else
	    {
	        cout << st[1] << "\n";
	        return;
	    }
	}
// 	for (int i = 0; i < n; ++i)
// 	{
// 		cout << st[i] << " " << v[i] << "\n";
// 	}
	for (int i = 0; i < n; ++i)
	{
	    cnt = 0;
	    for(int j = 0; j < n; j++)
	    {
		    if(v[i] >= v[j])
		    {
		    	cnt++;
		    }
	    }
	    if(cnt == n - 1)
	    {
	        cout << st[i] << "\n";
	        return;
	    }
	}
}

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


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define y0 _z_y0
#define y1 _z_y1
#define x0 _z_x0
#define x1 _z_x1
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
void enable_comma(){}
string tostring(char c){
	string s="";
	s+=c;
	return s;
}
string tostring(string s){
	return "\""+s+"\"";
}
string tostring(const char *c){
	return tostring((string)c);
}
string tostring(long long x){
	if (x<0)
		return "-"+tostring(-x);
	if (x>9)
		return tostring(x/10)+tostring(char('0'+x%10));
	else
		return tostring(char('0'+x));
}
string tostring(int x){
	return tostring((long long)x);
}
string tostring(unsigned long long x){
	if (x>9)
		return tostring((long long)(x/10))+tostring(char('0'+x%10));
	else
		return tostring(char('0'+x));
}
string tostring(unsigned x){
	return tostring((long long)x);
}
string tostring(double x){
	static char res[114];
	sprintf(res,"%lf",x);
	string s=tostring(res);
	return s.substr(1,(int)s.size()-2);
}
string tostring(long double x){
	return tostring((double)x);
}
template <class A,class B> string tostring(pair <A,B> p){
	return "("+tostring(p.fi)+","+tostring(p.se)+")";
}
template <class T> string tostring(T v){
	string res="";
	for (auto p : v)
		res+=(res.size()?",":"{")+tostring(p);
	return res.size()?res+"}":"{}";
}
template <class A> string tostring(A* a,int L,int R){
	return tostring(vector <A>(a+L,a+R+1));
};
string tostrings(){
	return "";
}
template <typename Head,typename... Tail>
string tostrings(Head H,Tail... T){
	return tostring(H)+" "+tostrings(T...);
}
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
#ifdef zzd
	#define outval(x) cerr<<#x" = "<<tostring(x)<<endl
	#define outvals(...) cerr<<"["<<#__VA_ARGS__<<"]: "<<\
								tostrings(__VA_ARGS__)<<endl
	#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
	#define outsign(x) cerr<<"<"#x">"<<endl
	#define outarr(a,L,R) cerr<<#a"["<<(L)<<".."<<(R)<<"] = "<<\
								tostring(a,L,R)<<endl
#else
	#define outval(x) enable_comma()
	#define outvals(...) enable_comma()
	#define outtag(x) enable_comma()
	#define outsign(x) enable_comma()
	#define outarr(a,L,R) enable_comma()
#endif
#ifdef ONLINE_JUDGE
	#ifdef assert
		#undef assert
	#endif
	#define assert(x) (!(x)?\
			cout<<"Assertion failed!"<<endl<<\
			"function: "<<__FUNCTION__<<endl<<\
			"line: "<<__LINE__<<endl<<\
			"expression: "<<#x<<endl,exit(3),0:1)
#endif
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
template <class T> void ckmax(T &x,const T y){
	if (x<y)
		x=y;
}
template <class T> void ckmin(T &x,const T y){
	if (x>y)
		x=y;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
//int md(LL x){
//	return (x%mod+mod)%mod;
//}
int main(){
	int n=read();
	string s;
	cin>>s;
	int ans=0;
	For(i,0,n-1){
		int c0=0,c1=0;
		For(j,i,n-1){
			if (s[j]=='A')
				c0--;
			else if (s[j]=='T')
				c0++;
			else if (s[j]=='G')
				c1--;
			else if (s[j]=='C')
				c1++;
			if (!c0&&!c1)
				ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

// Problem: B - DNA Sequence
// Contest: AtCoder - AtCoder Regular Contest 104
// URL: https://atcoder.jp/contests/arc104/tasks/arc104_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#define t(x) (tot[j][(x)]-tot[i-1][(x)])
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	s=" "+s;
	int tot[n+1][200];
	for(int i=0;i<=200;++i)
		tot[0][i]=0;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=200;++j)
			tot[i][j]=tot[i-1][j];
		++tot[i][s[i]];
	}
	int tt=0;
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if(t('A')==t('T')&&t('C')==t('G'))
				++tt;
	cout<<tt;
}


using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;

char win(char a, char b) {
    if (a == b) return a;
    if ((a ^ b) == ('R' ^ 'S')) return 'R';
    if ((a ^ b) == ('R' ^ 'P')) return 'P';
    return 'S';
}

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<char> v;
    for (int i = 0; i < n; i++) {
        v.push_back(s[i]);
    }

    for (int i = 0; i < k; i++) {
        vector<char> u;
        if (v.size() % 2 == 0) {
            for (int j = 0; j < v.size(); j += 2) {
                u.push_back(win(v[j], v[j + 1]));
            }
        }
        else {
            for (int j = 0; j < 2*v.size(); j += 2) {
                u.push_back(win(v[j%v.size()], v[(j + 1)%v.size()]));
            }
        }

        v = u;
    }
    cout << v[0] << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll maxn=2e5+10;
const ll m1=1e18+7;
const ll mod=1e18+7;
const ll INF64 = ll(1e18);

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
ll t[4*maxn];
void build(ll a[], ll v, ll tl, ll tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        ll tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = t[v*2] + t[v*2+1];
    }
}
ll sum(ll v, ll tl, ll tr, ll l, ll r) {
    if (l > r)
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    ll tm = (tl + tr) / 2;
    return sum(v*2, tl, tm, l, min(r, tm))
           + sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}
void update(ll v, ll tl, ll tr, ll pos, ll new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        ll tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = t[v*2] + t[v*2+1];
    }
}
bool compare(pair<ll,ll> p1,pair<ll,ll> p2)
{
	if(p1.second==p2.second)
	{
		return(p1.first<p2.first);
	}
	else
		return(p1.second<p2.second);
}

int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
//long long tt = clock();
#endif
ios_base::sync_with_stdio(NULL);  cin.tie(0); cout.tie(0);
//Line Sweep

ll n,m,n2,i;
cin>>n>>m>>n2;
vector<pair<ll,ll>> v;

ll x_l=INT_MAX,y_l=INT_MAX;
for(i=0;i<n2;++i)
{
	ll x,y;
	cin>>x>>y;
	if(x==1)
	{
		x_l=min(x_l,y);
	}
	if(y==1)
	{
		y_l=min(y_l,x);
	}
	v.push_back(make_pair(x,y));

}
for(i=1;i<=m;++i)
{
	v.push_back(make_pair(0,i));
	v.push_back(make_pair(n+1,i));
}
if(x_l!=INT_MAX)
{
	for(i=x_l+1;i<=m;++i)
	{
		v.push_back(make_pair(1,i));
	}
}
if(y_l!=INT_MAX)
{
	for(i=y_l+1;i<=n;++i)
	{
		v.push_back(make_pair(i,1));
	}
}
sort(v.begin(),v.end(),compare);
ll active[maxn];

memset(active,0,sizeof(active));
build(active,1,0,maxn-1);
ll ans=0;
/*for(i=0;i<v.size();++i)
{
	cout<<v[i].first<<" "<<v[i].second<<"\n";
}*/

for(i=0;i<v.size()-1;++i)
{	active[v[i].first]=1;

	update(1,0,maxn-1,v[i].first,1);
	if(v[i].second!=v[i+1].second)
	{

		continue;
	}
	if(v[i].first==v[i+1].first)
		continue;

	ll diff=v[i+1].first-v[i].first-1;
	if(v[i].first==0)
	{
		ans+=diff;
	}
	else
	{
		ans+=diff-(v[i].first+1<=v[i+1].first-1?sum(1,0,maxn-1,v[i].first+1,v[i+1].first-1):0);
	}

}
cout<<ans;

return(0);
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using prique = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

int main() {
	ll n, t;
	cin >> n >> t;
	vector<ll> a(n);
	cin >> a;
	int m = n / 2;
	vector<ll> x(1 << m);
	vector<ll> y(1 << (n - m));
	rep(i, 1 << m) {
		rep(j, m) {
			if (i >> j & 1) {
				x[i] += a[j];
			}
		}
	}
	rep(i, 1 << (n - m)) {
		rep(j, n - m) {
			if (i >> j & 1) {
				y[i] += a[j + m];
			}
		}
	}
	y.pb(-INF);
	sort(all(x));
	sort(all(y));
	ll ans = 0;
	for (ll v : x) {
		ll rem = t - v;
		auto itr = upper_bound(all(y), rem);
		itr--;
		ll s = v + (*itr);
		chmax(ans, s);
	}
	cout << ans << '\n';
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n, t;

int a[100];

set<int> zen, kou;

void dfs(int i, int ma, int now, int b){
	if(i >= ma){
		if(b == 0){
			zen.insert(now);
		}else{
			kou.insert(now);
		}
		return;
	}

	dfs(i+1, ma, now, b);
	dfs(i+1, ma, now+a[i], b);
}

signed main(){
	cin >> n >> t;

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

	dfs(0, n/2, 0, 0);
	dfs(n/2, n, 0, 1);

	int ans = 0;
	for(auto e = zen.begin(); e != zen.end();e++){
		int x = *e;
		if(x > t) continue;
		auto hoge = kou.upper_bound(t-x);
		hoge--;
		ans = max(ans, x+*hoge);
	}

	cout << ans << endl;

	return 0;
}


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

typedef long long ll;

const ll lim = 1000000000000000000ll;

vector <ll> seq;

const int Maxn = 90;

bool op[Maxn];
vector <int> res;

int main()
{
	seq.push_back(1);
	seq.push_back(1);
	while (seq.back() <= lim) {
		ll nw = seq.back() + seq[int(seq.size()) - 2];
		seq.push_back(nw);
	}
	ll n; scanf("%lld", &n);
	while (n > 0) {
		int ind = upper_bound(seq.begin(), seq.end(), n) - seq.begin() - 1;
		n -= seq[ind];
		op[Maxn - 1 - ind] = true;
	}
	int p = 0;
	while (!op[p]) p++;
	while (p < Maxn) {
		if (p % 2 == 0) {
			res.push_back(4);
			if (op[p])
				res.push_back(2);
		} else {
			res.push_back(3);
			if (op[p])
				res.push_back(1);
		}
		p++;
	}
	printf("%d\n", int(res.size()));
	for (int i = 0; i < res.size(); i++)
		printf("%d\n", res[i]);
    return 0;
}

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

int main(){
  long long n;
  cin >> n;
  long long x = 0, y = 0;
  vector<int> Q;
  auto q = [&](int i){
    if(i == 0){
      x += 1;
    }
    if(i == 1){
      y += 1;
    }
    if(i == 2){
      x += y;
    }
    if(i == 3){
      y += x;
    }
    Q.emplace_back(i);
  };
  vector<long long> F(2,0);
  F[1] = 1;
  for(int i = 2; i < 130; ++i){
    long long t = F[i-1] + F[i-2];
    if(t > n) break;
    F.emplace_back(t);
  }
  vector<int> A;
  long long n_ = n;
  for(int i = F.size()-1; i >= 0; --i){
    if(F[i] <= n_){
      A.emplace_back(i);
      n_ -= F[i];
    }
  }
  q(0);
  int p = 3, j = A[0]-1;
  for(auto a : A){
    if(a == A[0]) continue;
    while(j > a){
      q(p);
      p ^= 1;
      --j;
    }
    q(p&1);
  }
  if(y == n){
    swap(x,y);
    for(auto& q : Q)
      q ^= 1;
  }
  cout << Q.size() << endl;
  for(auto e : Q){
    cout << e+1 << '\n';
  }
  cerr << x << " " << y << endl;
  assert(x == n);
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }

void solve() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << N - A + B << endl;
}

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

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

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector <ll> vi;

#define MAX 100003
bool comp(pii a,pii b)
{
   return a.second < b.second;
}
int main()
{
 //  freopen("inputfile.txt","r",stdin);;
   int x,a,b;cin>>x>>a>>b;
   cout<<(x-a)+b<<endl;
   return 0;
}


/*Lucky_Glass*/
#include <set>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long llong;
#define con(typ) const typ &

const int N = 1e5 + 10;
const llong INF = 0x3f3f3f3f3f3f3f3fll;

int n;
std::set<llong> exi[3];
std::vector<llong> ele[3];

llong aAbs(con(llong) k) { return k < 0 ? -k : k; }
llong nextTo(std::set<llong> &se, con(llong) val) {
  auto s = se.lower_bound(val);
  llong ret = INF;
  if ( s != se.end() ) ret = std::min(ret, aAbs(val - *s));;
  if ( s != se.begin() ) ret = std::min(ret, aAbs(val - *(--s)));
  return ret;
}
int main() {
  scanf("%d", &n), n *= 2;
  for ( int i = 1, k; i <= n; ++i ) {
    char typ[10] = ""; llong val;
    scanf("%lld%s", &val, typ);
    if ( typ[0] == 'R' ) k = 0;
    else if ( typ[0] == 'G' ) k = 1;
    else k = 2;
    exi[k].insert(val), ele[k].push_back(val);
  }
  int sp[3] = {-1, -1, -1};
  for ( int i = 0; i < 3; ++i )
    if ( ele[i].size() & 1 ) {
      if ( ~sp[0] ) sp[1] = i;
      else sp[0] = i;
    } else {
      sp[2] = i;
    }
  if ( sp[0] == -1 ) { printf("0\n"); return 0; }
  llong ans = INF;
  for ( llong i : ele[sp[0]] )
    ans = std::min(ans, nextTo(exi[sp[1]], i));
  std::pair<llong, int> mna[2], mnb[2];
  mna[0].first = mnb[0].first = mna[1].first = mnb[1].first = INF;
  for ( int i = 0; i < (int)ele[sp[2]].size(); ++i ) {
    llong val = nextTo(exi[sp[0]], ele[sp[2]][i]);
    if ( val < mna[0].first ) mna[1] = mna[0], mna[0] = std::make_pair(val, i);
    else if ( val < mna[1].first ) mna[1] = std::make_pair(val, i);
    val = nextTo(exi[sp[1]], ele[sp[2]][i]);
    if ( val < mnb[0].first ) mnb[1] = mnb[0], mnb[0] = std::make_pair(val, i);
    else if ( val < mnb[1].first ) mnb[1] = std::make_pair(val, i);
  }
  if ( mna[0].second != mnb[0].second ) {
    ans = std::min(ans, mna[0].first + mnb[0].first);
  } else {
    ans = std::min(ans, mna[0].first + mnb[1].first);
    ans = std::min(ans, mna[1].first + mnb[0].first);
  }
  printf("%lld\n", ans);
  return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x <<"\n"
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int util(vi A, vi B)
{

    int a = 0, b = 0;
    int result = INF;
    while (a < A.size() && b < B.size())
    {
        if (abs(A[a] - B[b]) < result)
            result = abs(A[a] - B[b]);
        if (A[a] < B[b])
            a++;

        else
            b++;
    }
    return result;
}

void solve()
{
	int n, a;
	char c;
	cin>>n;
	vi r, g, b;
	REP(i, 2*n)
	{
		cin>>a>>c;
		if(c=='R')
		{
			r.pb(a);
		}
		else if(c=='G')
		{
			g.pb(a);
		}
		else
		{
			b.pb(a);
		}
	}
	sort(all(r));
	sort(all(g));
	sort(all(b));
	if(r.size()%2==0&&g.size()%2==0&&b.size()%2==0)
	{
		cout<<"0";
	}
	else if(r.size()%2==0)
	{
		int x=util(r, g);
		int y=util(r, b);
		int z=util(g, b);
		cout<<min(z, x+y);
	}
	else if(g.size()%2==0)
	{
		int x=util(g, r);
		int y=util(g, b);
		int z=util(r, b);
		cout<<min(z, x+y);
	}
	else
	{
		int x=util(b, r);
		int y=util(b, g);
		int z=util(r, g);
		cout<<min(z, x+y);
	}
}
signed main()
{
	FastIO
	int t=1;
	//cin>>t;
	WL(t){
solve();
if(t!=0)
cout<<"\n";
}
return 0;
}


//https://atcoder.jp/contests/abc182/tasks/abc182_c
//C - To 3
#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n;
    cin>>n;

    //特判
    if (0==n%3) {
        cout<<"0\n";
        return 0;
    } else if (n<=2) {
        cout<<"-1\n";
        return 0;
    }

    //转换为数字
    int cnt[3]={};//每个数字个数
    int tot=0;//每个位数总和
    vector<int> v;
    while (n) {
        int p=n%10;//取个位
        n/=10;
        tot+=p;
        v.push_back(p);
        cnt[p%3]++;
    }

    n = v.size();
    if (1==tot%3) {
        if (n>1 && cnt[1]>=1) {
            cout<<"1\n";
        } else if (n>2 && cnt[2]>=2) {
            cout<<"2\n";
        } else {
            cout<<"-1\n";
        }
    } else if (2==tot%3) {
        if (n>1 && cnt[2]>=1) {
            cout<<"1\n";
        } else if (n>2 && cnt[1]>=2) {
            cout<<"2\n";
        } else {
            cout<<"-1\n";
        }
    }

    return 0;
}

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

int main () {
    string s;
    cin >> s;
    int right = s.length()-1;
    while (s[right] == '0') {
        right--;
    }

    for (int left = 0; right >= 0; ++left) {
        if (s[left] != s[right]) {
            cout << "No";
            return 0;
        }
        --right;
    }

    cout << "Yes";
    return 0;
}

//je kotinnnnnnnnnnnnnnnn


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

int main() {
	int t; scanf("%d", &t);
	while (t--) {
		int l, r; scanf("%d%d", &l, &r);
		printf("%lld\n", r < l << 1 ? 0 : 1ll * (r - (l << 1) + 1) * (r - (l << 1) + 2) >> 1);
	}
	return 0;
}

#include <bits/stdc++.h>
#define repp(i, l, r) for (long long i = (l); i < (r); i++)
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define per(i, n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PLI = pair<long long, int>;
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//ミョ(-ω- ?)
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<pair<long double, long double>> a(n);
    rep(i, n) { cin >> a[i].first >> a[i].second; }

    for (ll i = 0; i < n; i++) {
        for (ll j = i + 1; j < n; j++) {
            for (ll k = j + 1; k < n; k++) {
                ll x1 = (a[i].first - a[j].first);
                ll x2 = (a[j].first - a[k].first);
                ll y1 = (a[i].second - a[j].second);
                ll y2 = (a[j].second - a[k].second);
                if(x2 * y1 == x1 * y2){
                    cout << "Yes\n";
                    cerr << i << j << k << "\n";
                    return 0;
                }
            }
        }
    }
    cout << "No\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

int TLE_TERROR()
{
 	ll n,ans=0;
 	cin>>n;
 	ll a[n],b[n];
 	for(ll i=0;i<n;i++)
 		cin>>a[i];
 	for(ll i=0;i<n;i++)
 		cin>>b[i];
 	for(ll i=0;i<n;i++)
 	{
 		ans+=(a[i]*b[i]);
 	}
 	if(ans==0)
 		cout<<"Yes"<<endl;
 	else
 		cout<<"No"<<endl;

 	return 0;
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

bool isCollinear(int x1, int y1, int x2,int y2, int x3, int y3) {
        int result = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
        return result==0;
    }

int main() {

  int t; cin>>t;
  vector<pair<int, int>> points;
  while(t--)
  {
      int a , b; cin>>a>>b;

      points.push_back({a,b});
  }

  int n  = points.size();
  bool ok = false;
  for(int i = 0 ; i  <  n ; i++)
  {
      pair<int, int> p1 = points[i];
      for(int j = i+1 ; j < n ; j++)
      {
          pair<int, int> p2 = points[j];
          for(int k = j+1; k < n ; k++)
          {

              pair<int, int> p3 = points[k];
              if(isCollinear(p1.first, p1.second, p2.first, p2.second, p3.first, p3.second) == true)
              {
                  ok =true;
                  break;
              }
          }
          if(ok)
            break;
      }
    if(ok )
    break;
  }
    if(ok)
      cout<<"Yes\n";
      else
      cout<<"No\n";
}


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

long long int MOD = 1000000007;

void mult(vector<vector<long long int>> &a, vector<vector<long long int>> &b, int n) {
    vector<vector<long long int>> c(n, vector<long long int>(n, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                c[i][j] += a[i][k] * b[k][j];
                c[i][j] %= MOD;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            a[i][j] = c[i][j];
        }
    }
}

void bin_mat(vector<vector<long long int>> &m, long long int e, int n, vector<vector<long long int>> &temp) {
    if (e == 0)
        return;
    if (e == 1)
        return;

    bin_mat(m, e / 2, n, temp);
    mult(m, m, n);
    if (e % 2)
        mult(m, temp, n);
}

long long int bin_pow(long long int b, long long int e) {
    if (e == 0) return 1;

    long long int temp = bin_pow(b, e / 2);
    temp = temp * temp % MOD;
    if (e % 2)
        return temp * b % MOD;
    return temp;
}

void solve() {
    int n,m,k; cin >> n >> m >> k;
    vector<long long int> num(n);
    for (int i = 0; i < n; i++) {
        cin >> num[i];
    }
    vector<vector<int>> graph(n);
    for (int i = 0; i < m; i++) {
        int a,b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<vector<long long int>> mat(n, vector<long long int>(n, 0));

    for (int i = 0; i < n; i++) {
        int cnt = m - graph[i].size();
        mat[i][i] += 2 * cnt % MOD;
        for (auto j: graph[i]) {
            mat[i][i]++;
            mat[i][j]++;
        }
    }
    vector<vector<long long int>> temp = mat;
    bin_mat(mat, k, n, temp);

    if (k > 0) {
        vector<long long int> ans(n, 0);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ans[i] += mat[i][j] * num[j] % MOD;
                ans[i] %= MOD;
            }
        }

        long long int val = bin_pow(2 * m, k);
        val = bin_pow(val, MOD - 2);
        for (int i = 0; i < n; i++) {
            cout << ans[i] * val % MOD << '\n';
        }
    } else {
        for (int i = 0; i < n; i++)
            cout << num[i] % MOD << '\n';
    }

}

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

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

    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
typedef pair<pi,ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#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)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 101
#define MOD 1000000007
#define int ll

int N,M,K,A[maxn];
//~ int dp[maxn][maxn * 10];
//~ vi adj[maxn];

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

int modinv(int A,int B){
	A %= MOD;
	B = qexp(B,MOD-2);
	A *= B;
	A %= MOD;
	return A;
}

//~ int dpf(int i,int j){
	//~ if (j == 0) return A[i];
	//~ if (dp[i][j] != -1) return dp[i][j];
	//~ dp[i][j] = 0;
	//~ aFOR(k,adj[i]){
		//~ dp[i][j] += modinv((dpf(i,j-1) + dpf(k,j-1)) % MOD, 2);
	//~ }
	//~ dp[i][j] += (dpf(i,j-1) * (M - adj[i].size())) % MOD;
	//~ dp[i][j] = modinv(dp[i][j], M);
	//~ return dp[i][j];
//~ }

struct Matrix{
	ll a[101][101];
	Matrix(){
		FOR(i,1,N) FOR(j,1,N) a[i][j] = 0;
	}

	Matrix operator *(Matrix other){
		Matrix product = Matrix();
		FOR(i,1,N) FOR(j,1,N) FOR(k,1,N){
			product.a[i][k] += (a[i][j] * other.a[j][k]) % MOD;
			product.a[i][k] %= MOD;
		}
		return product;
	}
};

Matrix mat_exp(Matrix mat, int k){
	Matrix ans = Matrix();
	FOR(i,1,N) ans.a[i][i] = 1;
	while (k > 0){
		if (k % 2 == 1){
			ans = ans * mat;
		}
		mat = mat * mat;
		k /= 2;
	}
	return ans;
}

int32_t main(){
	fast;

	cin >> N >> M >> K;
	FOR(i,1,N) cin >> A[i];

	Matrix mat = Matrix();
	FOR(i,1,M){
		int x,y;
		cin >> x >> y;
		//~ adj[x].pb(y); adj[y].pb(x);
		mat.a[x][y] = mat.a[y][x] = 1;
		mat.a[x][x]++; mat.a[y][y]++;
	}
	FOR(i,1,N){
		mat.a[i][i] = (2 * M - mat.a[i][i]) % MOD;
		mat.a[i][i] = (mat.a[i][i] + MOD) % MOD;
	}
	Matrix res = mat_exp(mat, K);
	//~ cout << K << '\n';
	//~ FOR(i,1,N){
		//~ FOR(j,1,N) cout << res.a[i][j] << ' ';
		//~ cout << '\n';
	//~ }

	//~ return 0;
	int k = qexp((2 * M) % MOD, K);

	FOR(i,1,N){
		int ans = 0;
		FOR(j,1,N){
			ans += (res.a[i][j] * A[j]) % MOD; ans %= MOD;
		}
		cout << modinv(ans, k) << '\n';
	}
	//~ mem(dp,-1);
	//~ FOR(i,1,N){
		//~ cout << dpf(i,K) << '\n';
	//~ }

}


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

using namespace std;

int X, Y, Z;

int main(void) {

	cin >> X >> Y >> Z;
	int ans = 0;
	for (int i = 0; i <= 1000000; i++) {
		if (Y*Z > i*X) { ans = i; }
	}

	cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
/* ループ処理 0からnまで*/
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
  double X, Y, Z;
  cin >> X >> Y >> Z;
  double a = Y / X;
  double b = a * Z;
  cout << int(ceil(b - 1)) << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define BE(x) x.begin(), x.end()

int main() {
    ll s, p;
    cin >> s >> p;

    for (ll i = 1; i*i <= p; i++) {
        if (p % i > 0) continue;
        ll n = i, m = p / i;
        if (n + m == s) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

using namespace std;

const int N = 2e5 + 5;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    string str;
    cin >> str;
    string s = "";
    char ch[3] = {'1','1','0'};
    if(str.size() ==1)
    {
        ll ans = 1e10;
        if(str[0] == '0')
        {
            cout << ans << "\n";
        }
        else
            cout << 2*ans << "\n";
        return 0;
    }
    for(int i=0;i<2*n;i++)
    {
        s += ch[i%3];
    }
    ll cnt = 0;
    int j =0;
    ll add = 0;
    ll fst = 0;
    for(int i=0;i<2*n;i++)
    {
        //cout << i << " " << j << '\n';
        if(str[j] == s[i])
        {
            j++;
            if(j == n)
            {
                fst = i-n+1;
                cnt =  1;
                break;
            }
        }
        else
        {
            j = 0;
            if(str[j] == s[i])
                j++;
        }
    }
    if(cnt == 0)
    {
        cout << 0 << '\n';
    }
    else
    {
        ll curr = 0;
        ll low = 1;
        ll high = 3e10;
        ll best = 1;
        ll lim = 3e10;
        fst++;
        //ll v = fst + 3*(1e10 - 1);
        //v += str.size() - 1;
        //cout << v << "\n";
        while(low <= high)
        {
            ll mid = (low + high)/2;
            ll val = fst + 3*mid;
            ll r = val + str.size() - 1;
            if(r > lim)
            {
                high = mid-1;
            }
            else
            {
                best = mid;
                low = mid+1;
            }
        }
        cout << best+1;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+5;
struct edge{
    int u,to,nxt;
}e[2*maxn];
int head[maxn],cnt;
int x,y;
void add(int x,int y){
    e[++cnt].to=y;
    e[cnt].u=x;
    e[cnt].nxt=head[x];
    head[x]=cnt;
}
int c[maxn],n,m,p,dep[maxn];
void dfs(int u,int fa){
    dep[u]=dep[fa]+1;
    for(int i=head[u];i;i=e[i].nxt){
        int v=e[i].to;
        if(v==fa)continue;
        dfs(v,u);
    }
}
void dfs2(int u,int fa,int res){
    res+=c[u];
    c[u]=res;
    for(int i=head[u];i;i=e[i].nxt){
        int v=e[i].to;
        if(v==fa)continue;
        dfs2(v,u,res);
    }
}
signed main(){
	cin>>n;
	for(int i=1;i<n;i++){
	    cin>>x>>y;
	    add(x,y);
	    add(y,x);
	}
	dfs(1,0);
	int q;
	cin>>q;
	for(int i=1;i<=q;i++){
	    int t;
	    cin>>t>>x>>y;
	    int u=e[2*x-1].u,v=e[2*x-1].to;
	    if(t==2){
	        swap(u,v);
	    }
	//    cerr<<u<<' '<<v<<endl;
	    if(dep[u]>dep[v]){
	        c[u]+=y;
	    }
	    else{
	        p+=y;
	        c[v]-=y;
	    }
	}
	dfs2(1,0,p);
	for(int i=1;i<=n;i++){
	    cout<<c[i]<<endl;
	}
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
// --------------------------------------------------------
template<class T> bool chmax(T& a, const T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T b) { if (b < a) { a = b; return 1; } return 0; }
#define FOR(i,l,r) for (ll i = (l); i < (r); ++i)
#define RFOR(i,l,r) for (ll i = (r)-1; (l) <= i; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define COUNT(c,v) count(ALL(c),(v))
#define SZ(c) ((ll)(c).size())
#define BIT(b,i) (((b)>>(i)) & 1)
#define PCNT(b) __builtin_popcountll(b)
#define CLZ(b) __builtin_clzll(b)
#define BITLEN(b) (64LL - CLZ(b))
#define CIN(c) cin >> (c)
#define COUT(c) cout << (c) << '\n'
#define debug(x) cerr << "l." << __LINE__ << " : " << #x << " = " << (x) << '\n'
ll llceil(ll a, ll b) { return (a + b - 1) / b; }
string toupper(const string& S) { string T(S); REP(i,SZ(T)) T[i] = toupper(T[i]); return T; }
string tolower(const string& S) { string T(S); REP(i,SZ(T)) T[i] = tolower(T[i]); return T; }
using P = pair<ll,ll>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VVS = vector<VS>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VVVLL = vector<VVLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VVVB = vector<VVB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VVVD = vector<VVD>;
using VLD = vector<ld>;
using VVLD = vector<VLD>;
using VVVLD = vector<VVLD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const ll INF = (1LL << 62) - 1;  // 4611686018427387904 - 1
// --------------------------------------------------------
// #include <atcoder/all>
// using namespace atcoder;

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

    ll N; cin >> N;
    VLL C(N); REP(i,N) cin >> C[i];
    VVLL G(N);
    REP(_,N-1) {
        ll A, B; cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    ll L = 1e5;
    VLL cnt(L+1,0);
    VLL ans = {1};
    auto rec = [&](auto self, ll u, ll p) -> void {
        if (cnt[C[u]] == 0) ans.push_back(u+1);
        cnt[C[u]]++;
        for (ll v : G[u]) if (v != p) {
            self(self, v, u);
        }
        cnt[C[u]]--;
    };
    cnt[C[0]]++;
    for (ll v : G[0]) {
        rec(rec, v, 0);
    }
    SORT(ans);
    for (ll a : ans) COUT(a);

    return 0;
}


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

using namespace std;

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());

    if (a[2] - a[1] == a[1] - a[0]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#define int             long long
#define pb              push_back
#define endl            '\n';
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mi              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 all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define ps(x,y)         fixed<<setprecision(y)<<x
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define fo(i, n)        for(int i=0; i<n; i++)

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

void test_case(int test_num) {
    vi a(3);
    fo(i,3) {
        cin >> a[i];
    }
    sortall(a);
    if(a[0] - a[1] == a[1] - a[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int _;
    _ = 1;
   //cin >> _;

    for(int t = 1; t <= _; t++) {
        test_case(t);
    }
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

/*** mod int ***/

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

/*** mod int ここまで ***/

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(1000005);

void Solve(){
    int n, a, b; cin >> n >> a >> b;
    if(a+b>n) {
        cout << 0 << endl;
        return;
    }
    mint x = (mint)(n-(a+b)+2) * (mint)(n-(a+b)+1)/2;
    mint y = (mint)(n-a+1) * (mint)(n-b+1) - (mint)x * 2;
    mint ans = (mint)(n-a+1) * (mint)(n-a+1) * (mint)(n-b+1) * (mint)(n-b+1) - y * y;
    cout << ans << endl;
}

void Main(){
    int t; cin >> t;
    while(t--) Solve();
    return;
}

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

#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 2147483607
#define common cout << "Case #" << w+1 << ": "

int main()
{
    int te;
    cin >> te;
    for(int w=0;w<te;w++)
    {
        int n,a,b;
        cin >> n >> a >> b;
        if(n-a-b+1<=0)
            cout << "0" << endl;
        else
        {
            int ans=(n+1-a);
            ans=(ans*1LL*(n+1-b))%mod;
            ans=(ans*1LL*(n+1-a-b))%mod;
            ans=(ans*1LL*(n+2-a-b))%mod;
            ans=(ans*1LL*2)%mod;
            int ans1=(n+1-a-b)*1LL*(n+1-a-b)%mod;
            int ans2=(n+2-a-b)*1LL*(n+2-a-b)%mod;
            ans1=(ans1*1LL*ans2)%mod;
            ans=(ans*1LL-ans1)%mod;
            ans=(ans*1LL+mod)%mod;
            cout << ans << endl;
        }
    }
}


#include <bits/stdc++.h>

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; for(int tt = 0; tt < t; ++tt)
#define sz(x) (int)(x).size()
#define sort_unique(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()));
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

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

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

const int N = 5e2+5;
const int INF = 0x3f3f3f3f;
/**
Read problem statement carefully
**/
int dp[N][N];
LL A[N][N], B[N][N];

int r, c;
void solve(int x){
    memset(dp, 0x3f, sizeof dp);

    cin >> r >> c;
    for(int i = 1; i <= r; ++i)
        for(int j= 1; j < c; ++j)
            cin >> A[i][j];

    for(int i = 1; i < r; ++i)
        for(int j = 1; j <= c; ++j)
            cin >> B[i][j];

    dp[1][1] = 0;
    priority_queue<ii, vector<ii>, greater<ii>> pq;
    pq.push({0, 0});

    while(sz(pq)){
        auto [cost, idx] = pq.top(); pq.pop();
        int x = idx/c, y = idx%c;
        x++, y++;
        if(cost > dp[x][y]) continue;
        dp[x][y] = cost;
        if(y < c){
            if(dp[x][y+1] > dp[x][y] + A[x][y]){
                dp[x][y+1] = dp[x][y] + A[x][y];
                pq.push({dp[x][y+1], (x-1) * c + y});
            }
        }
        if(y > 1){
            if(dp[x][y-1] > dp[x][y] + A[x][y-1]){
                dp[x][y-1] = dp[x][y] + A[x][y-1];
                pq.push({dp[x][y-1], (x-1) * c + y - 2});
            }
        }
        if(x < r){
            if(dp[x+1][y] > dp[x][y] + B[x][y]){
                dp[x+1][y] = dp[x][y] + B[x][y];
                pq.push({dp[x+1][y], x * c + y - 1});
            }
        }
        for(int i = 1; i < r && x - i > 0; ++i){
            int ga = 1 + i;
            if(dp[x][y] + ga < dp[x-i][y]){
                dp[x-i][y] = dp[x][y] + ga;
                pq.push({dp[x-i][y], (x - i - 1) * c + y-1});
            }
        }
    }

    cout << dp[r][c] << "\n";
}

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

/**
Enjoy the problem.
**/

//...Bismillahir Rahmanir Rahim. . .

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

// typedefs...
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

// constants...
const double PI = acos(-1);
const ll mod = 998244353; // 1000000007;
const int MXS = 2e5+5;
const ll MXI = 1e9+5;
const ll MXL = 1e18+5;
const ll INF = 1e9+5;
const ll INFLL = 1e18+5;
const ll EPS = 1e-9;

// defines...
#define MP        make_pair
#define PB        push_back
#define fi         first
#define se         second
#define sz(x)      (int)x.size()
#define all(x)      begin(x), end(x)
#define si(a)       scanf("%d", &a)
#define sii(a, b)    scanf("%d%d", &a, &b)
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define boost_      ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define iter_(i,n)    for (int i = 0; i < int(n); i++)
#define for_n(i, n)  for (int i = 1; i <= int(n); i++)
#define print_array(a) for(int i=0;i<n;i++)  cout<<a[i]<<" ";
#define rev(i,n)     for(int i=n;i>=0;i--)
#define itr          ::iterator
#define s_sort(s)    sort(s.begin(),s.end())
#define n_sort(a, n)    sort(a,a+n)
#define precise_impact cout<<setprecision(10)<<fixed;
#define endl         "\n"
// functions...
ll gcd(ll a, ll b){ while (b){ a %= b; swap(a, b);} return a;}
ll lcm(ll a, ll b){ return (a/gcd(a, b)*b);}
ll ncr(ll a, ll b){ ll x = max(a-b, b), ans=1; for(ll K=a, L=1; K>=x+1; K--, L++){ ans = ans * K; ans /= L;} return ans;}
ll bigmod(ll a,ll b){ if(b==0){ return 1;} ll tm=bigmod(a,b/2); tm=(tm*tm)%mod; if(b%2==1) tm=(tm*a)%mod; return tm;}
ll egcd(ll a,ll b,ll &x,ll &y){ if(a==0){ x=0; y=1; return b;} ll x1,y1; ll d=egcd(b%a,a,x1,y1); x=y1-(b/a)*x1; y=x1; return d;}
ll modpow(ll a,ll p) {ll ans=1;while(p){if(p%2)ans=(ans*a)%mod;a=(a*a)%mod;p/=2;} return ans;}
ll inverse_mod(ll n) {return modpow(n,mod-2);}
//ll ncr_mod(ll n,ll r) {return (((fact[n]*inverse_mod(fact[r]))%mod)*inverse_mod(fact[n-r]))%mod;}
int main()
{
    boost_;
    ll n,k;
    vector<pair<ll,ll> > v;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        ll num,x;
        cin>>num>>x;
        v.PB({num,x});
    }
    sort(all(v));
    ll pos=0;
    for(int i=0;i<n;i++)
    {
        if(pos+k<v[i].fi) {cout<<pos+k<<endl;return 0;}

        k=k-(v[i].fi-pos)+v[i].se;
        pos=v[i].fi;
    }
    cout<<pos+k<<endl;
}


//Created By:Hardik Kapoor
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
//template begins
#define int long long int
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itt vector<int>:: iterator
#define pb push_back
#define mp make_pair
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define min3(a,b,c) min(min((a),(b)),(c))
#define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define db long double
#define itp vector<pair<int,int> >:: iterator
#define ff first
#define ss second
#define endl "\n"
typedef pair<int,int> pii;
template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
	find_by_order() - Returns an iterator to the k-th largest element (counting from zero)
	order_of_key()  - The number of items in a set that are strictly smaller than our item
	Rest same as set
*/
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;
const long long mod = 1000000007;
// const long long mod = 998244353;
int pow(int x, unsigned int y, int p){
	int res=1;
	x=x%p;
	if (x==0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
	}
	return res;
}
int _pow(int a, int b){
	if(!b)
		return 1;
	int temp = _pow(a, b / 2);
	temp = (temp * temp);
	if(b % 2)
		return (a * temp);
	return temp;
}
int invmod(int a,int m){
	return pow(a,m-2,m);
}
int cl(int a,int x){
	if(a%x==0)
		return a/x;
	else
		return a/x+1;
}
//template ends

signed main(){
	ios
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int Tests=1;
	while(Tests--)
	{
		int a,b,c;
		cin>>a>>b>>c;
		if(a==b)
			cout<<c<<endl;
		else if(b==c)
			cout<<a<<endl;
		else if(a==c)
			cout<<b<<endl;
		else
			cout<<0<<endl;
	}
}

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

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

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


#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;
#define N 200005
ll p=1e9+7;
ll n,m,f[N][17][17]={0},v[22]={0},sm;
char a[N];
int main()
{
	ll i,j,k,a1,a2,an=0;
	scanf("%s",a+1);
	n=strlen(a+1);
	for(ll i=1;i<=n;i++)
		if(a[i]>='0'&&a[i]<='9')
			a[i]-='0';
		else
			a[i]-='A'-10;
	scanf("%lld",&m);
	for(ll i=0;i<=m;i++)
		f[0][i][i]=1;
	for(ll i=1;i<=n;i++)
		for(ll j=1;j<=m;j++)
			for(ll k=j;k<=m;k++)
				f[i][j][k]=((ll)f[i-1][j][k-1]*(17ll-k)+(ll)f[i-1][j][k]*k)%p;
	for(ll i=1;i<=n;i++)
		an=(an+15ll*f[i-1][1][m])%p;
	// for(ll i=1;i<=n;i++)
	// {
	// 	for(ll j=1;j<=m;j++)
	// 		for(ll k=j;k<=m;k++)printf("%lld\n",f[i][j][1]);
	// }
	for(ll i=1;i<=n;i++)
	{
		for(ll j=a[i]+1;j<=15;j++)
			an=(an-f[n-i][sm+(!v[j])][m]+p)%p;
		//printf("%lld\n",an);
		sm+=!v[a[i]];
		v[a[i]]=1;
	}
	printf("%lld",an);
}

//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].l+tr[u].r>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;

//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

const int N=200010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;

int n,k;
int a[N];
char s[N];
int f[N][20][2];

int dfs(int pos,int state,int flag,int lead)
{
    int cnt=__builtin_popcount(state);
    if(cnt>k) return 0;
    if(pos==n+1) return cnt==k&&lead;
    if(flag&&lead&&f[pos][cnt][lead]!=-1) return f[pos][cnt][lead];
    int x=flag? 15:a[pos];
    int ans=0;
    for(int i=0;i<=x;i++)
        (ans+=dfs(pos+1,(!lead&&i==0)? state:state|(1<<i),flag||i<x,lead||i!=0))%=mod;
    f[pos][cnt][lead]=ans;
    return ans;
}

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

    scanf("%s%d",s+1,&k);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
        if(s[i]>='A'&&s[i]<='Z') a[i]=s[i]-'A'+10;
        else a[i]=s[i]-'0';
    memset(f,-1,sizeof(f));
    printf("%d",dfs(1,0,0,0));

	return 0;
}
/*

*/


#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

template<class T>
using nega_queue = priority_queue<T,vector<T>,greater<T>>;

ll waittime(ll D){
  ll l=0, r=40000;
  while(r-l > 1){
    ll m = (l+r)/2;
    if(m*m+m <= D) l=m; else r=m;
  }
  return l;
}

struct Edge{ int to; ll c,d,w; };

const ll INF = 1001001001001001001;

int N,M;
vector<vector<Edge>> E;

int main(){
  cin >> N >> M;
  E.resize(N);
  rep(i,M){
    int a,b,c,d; cin >> a >> b >> c >> d;
    a--; b--;
    E[a].push_back({ b,c,d,waittime(d) });
    E[b].push_back({ a,c,d,waittime(d) });
  }
  vector<ll> D(N,INF);
  nega_queue<pair<ll,int>> Q;
  D[0] = 0;
  Q.push({0ll,0});
  while(Q.size()){
    int p = Q.top().second;
    ll d = Q.top().first;
    Q.pop();
    if(D[p] != d) continue;
    for(auto e : E[p]){
      ll t = max(d,e.w);
      ll nxd = t + e.c + e.d / (t+1);
      if(D[e.to] <= nxd) continue;
      D[e.to] = nxd;
      Q.push({nxd,e.to});
    }
  }

  if(D[N-1] == INF) cout << "-1\n";
  else cout << D[N-1] << "\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;

#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<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>

#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 printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define all(v) (v).begin(),(v).end()
#define all_rev(v) (v).rbegin(),(v).rend()
#define debug(x) cout << #x << ": " << x << '\n';
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using PL = pair<ll, ll>;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

  int n;
  cin >> n;
  vector<P> a;
  vector<P> b;

  rep (i, n) {
    int t, tt;
    cin >> t >> tt;
    a.push_back({t,i});
    b.push_back({tt,i});
  }
  sort(all(a));
  sort(all(b));

  if (a[0].second != b[0].second) {
    cout << max(a[0].first, b[0].first) << endl;
  } else {
    int t = a[0].first + b[0].first;
    int tt = max(a[1].first, b[0].first);
    int ttt = max(a[0].first, b[1].first);

    t = min(t, tt);
    t = min(t, ttt);
    cout << t << endl;
  }

  return 0;
}


//
//#ifdef ONLINE_JUDGE
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#endif

#include <bits/stdc++.h>

#include <utility>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back

using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
typedef long double ld;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
//using pii = pair<ll, ll>;
//using ld = long double;

template <typename T>
void do_uniq(vector<T> &vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#ifndef ONLINE_JUDGE

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << endl;
}
#endif

#ifdef _getchar_nolock
#else
#    define _getchar_nolock getchar_unlocked
#endif

#define integer ll

integer mod = 1e9 + 7;

integer ml(integer a, integer b) {
    return (a * 1ll * b) % mod;
}

integer add(integer a, integer b) {
    return (a + b) % mod;
}

integer sub(integer a, integer b) {
    return add(a, mod - b);
}

integer sq(integer a) {
    return ml(a, a);
}

integer b_p(integer b, integer p) {
    if (p == 0) return 1;
    if (p & 1) return ml(b, b_p(b, p - 1));
    return sq(b_p(b, p >> 1));
}

int gcd(int x, int y){
    return y == 0 ? x : gcd(y, x % y);
}

#define solvsh
//#define multi

#ifdef solvsh

//#define int ll

const int MAXN = 5e3 + 32;

void solve() {

    int n;
    cin >> n;

    vector<int> v;

    for (int i = 0; i < n; ++i) {
        int curr;
        cin >> curr;
        v.push_back(curr);
    }

    ll mmx = 0;
    ll pref = 0;
    ll add = 0;

    for (int i = 0; i < n; ++i) {
        mmx = max(mmx, 0ll + v[i]);
        ll answr = (i + 1) * mmx;
        pref += v[i];
        add += pref;
        answr += add;

        cout << answr << "\n";
    }
}

#else

#endif

void multisolve() {

#ifndef ONLINE_JUDGE
    freopen("../input.in", "r", stdin);
#endif

    int t;

    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << i << ": ";
        solve();
//        i++;
    }
}

#ifndef ONLINE_JUDGE

void gen() {
#ifndef ONLINE_JUDGE
    freopen("../input.in", "w", stdout);
#endif

}

#endif

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(20);

#ifdef multi
//    gen();
    multisolve();
//    checkk();
#else

    solve();
#endif
//     time_calc();
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define all(x)                      (x).begin(),(x).end()
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << ": " <<  x << endl;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	set<int> st;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		st.insert(x);
	}

	ll ans = 1, prv = 0;
	while (!st.empty()) {
		int x = *st.begin();
		ans = ans * (x - prv + 1) % MOD;
		st.erase(st.begin());
		prv = x;
	}

	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int mod=1000000007,inv2=(mod+1)/2;
int n,a[100010];
LL ans=1;
inline int read()
{
	int x=0;bool w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
LL ksm(LL B,LL K,LL A=1)
{
	for(;K;K>>=1,B=B*B%mod)
	if(K&1)A=A*B%mod;
	return A;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	sort(a+1,a+1+n);
	n=unique(a+1,a+1+n)-a-1;
	for(int i=1;i<=n;i++)
		ans=ans*(1+a[i]-a[i-1])%mod;
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;

const int maxn = 105;
int x[maxn], y[maxn];
int main() {
    int n;
    cin >> n;
    ii cin >> x[i] >> y[i];
    int ok = 0;
    for(int i=1;i<=n;++i) {
        for(int j=i+1;j<=n;++j) {
            for(int k=j+1;k<=n;++k) {
                // (y[i] - y[k]) / (x[i] - x[k]) = (y[j] - y[k]) / (x[j] - x[k])
                if((y[i] - y[k]) * (x[j] - x[k]) == (y[j] - y[k]) * (x[i] - x[k])) {
                    ok = 1;
                    break;
                }
            }
        }
    }
    if(ok) cout << "Yes";
    else cout << "No";
}

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cassert>
#include <climits>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define abs(x) ((x) > 0 ? (x) : -(x))
#define FOREACH(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
typedef long long LL;
double my_sqrt(double d) {return sqrt(max(d, 0.0));}
double my_acos(double d) {return acos(d<-1?-1:d>1?1:d);}
#define sqr(v) ((v)*(v))
const int MAXN = 105;
const double eps = 1E-6;
int n;
int sig(double d) {
	return (d>eps) - (d<-eps);
}
struct Point {
	double x, y;
	Point(double x, double y) : x(x), y(y) {}
	Point() {}
	Point operator - (const Point & p) const {
		return Point(x-p.x, y-p.y);
	}
	Point operator + (const Point & p) const {
		return Point(x+p.x, y+p.y);
	}
	Point operator * (double d) const {
		return Point(x*d, y*d);
	}
	/*double operator * (const Point &b) const {
		return x * b.y - y * b.x;
	}*/
	bool operator == (const Point & p) const {
		return sig(x-p.x)==0 && sig(y-p.y)==0;
	}
	bool operator < (const Point & p) const {
		return sig(x-p.x)!=0 ? x<p.x : sig(y-p.y)<0;
	}
	Point resize(double d) {
		d /= my_sqrt(sqr(x)+sqr(y));
		return Point(x*d, y*d);
	}
	Point left90() {
		return Point(-y, x);
	}
	Point rotate(double radian) {	//逆时针转
		double c = cos(radian), s = sin(radian);
		return Point(x*c-y*s, y*c+x*s);
	}
	double mod() {
		return my_sqrt(sqr(x)+sqr(y));
	}
	void output() {
		printf("x = %.2f, y = %.2f\n", x, y);
	}
};
double cross(const Point & o, const Point & a, const Point & b) {
	return (a.x-o.x)*(b.y-o.y) - (b.x-o.x)*(a.y-o.y);
}
double dot(Point o, Point a, Point b) {
	return (a.x-o.x)*(b.x-o.x) + (a.y-o.y)*(b.y-o.y);
}

int main() {
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        p[i] = Point(x, y);
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                // cout << i << j << k << " " << cross(p[i], p[j], p[k]) << endl;
                if (sig(cross(p[i], p[j], p[k])) == 0) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


//
//  main.cpp
//  test
//
//  Created by wyzwyz on 2021/5/13.
//

#include<cstdio>
#include<cctype>
#include<map>

#define maxn 505505

template<class T>

inline T read(){
    T r=0,f=0;
    char c;
    while(!isdigit(c=getchar()))f|=(c=='-');
    while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar();
    return f?-r:r;
}

template<class T>

inline T min(T a,T b){
    return a<b?a:b;
}

int n,a[maxn];

long long sum[2][maxn];

std::map<long long,int> cnt;

int main(){
    n=read<int>();
    for(int i=1;i<=n;i++)
        a[i]=read<int>();
    sum[1][1]=a[1];
    cnt[-a[1]]=1;
    for(int i=2;i<=n;i++){
        if(i&1){
            sum[0][i]=sum[0][i-1];
            sum[1][i]=sum[1][i-2]+a[i];
        }
        else {
            sum[1][i]=sum[1][i-1];
            sum[0][i]=sum[0][i-2]+a[i];
        }
        cnt[sum[0][i]-sum[1][i]]++;
    }
    long long ans=cnt[0];
    for(int i=1;i<n;i++){
        cnt[sum[0][i]-sum[1][i]]--;
        ans+=cnt[sum[0][i]-sum[1][i]];
    }
    printf("%lld\n",ans);
    return 0;
}

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

#define ll  long long
#define ull unsigned  long long
#define pll  pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn =7e5+100;
const ll mod=1e9+7 ;
const ll base=2e18;
ll n;
vector<pll> adj[maxn];
ll dp[(1ll<<18)];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("t.inp","r"))
    {
        freopen("test.inp","r",stdin);
        freopen("test.ans","w",stdout);
    }
    ll  m;
     cin>> n>> m ;
     dp[0]=1;
     while (m--)
     {
         ll x, y, z;
          cin>>x>> y>> z;
          adj[x].pb(make_pair(y-1,z));
     }
     for (int i=1;i<(1ll<<n);i++)
     {
         vector<ll> vt;
         for (int j=0;j<n;j++)
         {
             if (i&(1ll<<j))
             {
                 dp[i]+=dp[i^(1ll<<j)];
                 vt.pb(j);
             }
         }
         ll x=__builtin_popcount(i);
         for (auto p:adj[x])
         {
             ll y=p.ff;
             ll z=p.ss;
             auto h=upper_bound(vt.begin(),vt.end(),y)-vt.begin();
             if (h>z) dp[i]=0;
         }
     }
     cout <<dp[(1ll<<n)-1];

}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(b%a==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

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

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b); i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

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

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 150001; //check the limits, dummy

void solve(int t) {

}

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

  int M,H;
  cin>>M>>H;
  cout << (H%M?"No\n":"Yes\n");
}

// read the question correctly (ll vs int)
// template by bqi343