#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

void solve()
{
    ll n, i;
    ll x;
    cin>>n>>x;
    ll v[n+9], p[n+9];
    for(i=0; i<n; i++)
    {
        cin>>v[i]>>p[i];
    }
    ll in=0;
    ll ans=-1;
    x=x*100;
    for(i=0; i<n; i++)
    {
        in+=v[i]*p[i];
        if(in>x)
        {
            ans=i+1;
            break;
        }
    }
    cout<<ans;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fastio
    ll t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
}

#pragma warning (disable:4996)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

#define ll long long

#define REP(i, n) for(int i = 0; i < n; i++)
#define SET(a) int a = 0; (void)scanf("%d", &a);

#define NMAX 1000

typedef struct { int V; int P; }ALCOHOL;

int main() {
	SET(N); SET(X);
	ALCOHOL alcohol;
	int sum = 0;
	int ans = -1;
	REP(i, N) {
		(void)scanf("%d %d", &alcohol.V, &alcohol.P);
		sum += (alcohol.V * alcohol.P);
		if (sum > 100 * X) {
			ans = (i + 1);
			break;
		}
	}
	printf("%d", ans);
	return 0;
}


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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a,b;
    cin>>a>>b;
    double res=b/a*100;
    res=100-res;
    cout<<fixed<<setprecision(18)<<res;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,y;
unordered_map<ll,ll> k;//h[y]表示将x变成y需要的步数
ll dfs(ll z)
{
    if(z<=x) return x-z;
    if(k.count(z)) return k[z];
    ll re=z-x;
    if(z%2==0) re=min(re,dfs(z/2)+1);  //二倍优先
    else re=min(re,min(dfs(z+1),dfs(z-1))+1);
   return k[z]=re;
}
int main()
{
    cin>>x>>y;
    //倒着逆推
    cout<<dfs(y);
    return 0;
}


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

const int64_t MOD = 1e9 + 7;
const int64_t MOD2 = 998244353;
const int INF = 1e9;

int main() {
  long long h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i=0; i<h; i++) {
    cin >> s.at(i);
  }
  vector<vector<long long>> dp(h, vector<long long>(w));
  dp.at(0).at(0) = 1;
  vector<vector<long long>> row(h, vector<long long>(w));
  vector<vector<long long>> col(h, vector<long long>(w));
  vector<vector<long long>> squ(h, vector<long long>(w));
  row.at(0).at(0) = 1;
  col.at(0).at(0) = 1;
  squ.at(0).at(0) = 1;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (s.at(i).at(j) == '#') {
        continue;
      }
      if (i>0&&j>0) {
        dp.at(i).at(j) = row.at(i).at(j-1) + col.at(i-1).at(j) + squ.at(i-1).at(j-1);
        dp.at(i).at(j) %= MOD;
        row.at(i).at(j) = dp.at(i).at(j) + row.at(i).at(j-1);
        col.at(i).at(j) = dp.at(i).at(j) + col.at(i-1).at(j);
        squ.at(i).at(j) = dp.at(i).at(j) + squ.at(i-1).at(j-1);
      } else if (j>0) {
        dp.at(i).at(j) = row.at(i).at(j-1);
        dp.at(i).at(j) %= MOD;
        row.at(i).at(j) = dp.at(i).at(j) + row.at(i).at(j-1);
        col.at(i).at(j) = dp.at(i).at(j);
        squ.at(i).at(j) = dp.at(i).at(j);
      } else if (i>0) {
        dp.at(i).at(j) = col.at(i-1).at(j);
        dp.at(i).at(j) %= MOD;
        col.at(i).at(j) = dp.at(i).at(j) + col.at(i-1).at(j);
        row.at(i).at(j) = dp.at(i).at(j);
        squ.at(i).at(j) = dp.at(i).at(j);
      }
      col.at(i).at(j) %= MOD;
      row.at(i).at(j) %= MOD;
      squ.at(i).at(j) %= MOD;
    }
  }
  cout << dp.at(h-1).at(w-1)%MOD << endl;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define inf 1e18
#define mod 1000000007

using namespace std;

typedef long long llint;
typedef pair<llint, llint> P;

llint h, w;
llint dp[2005][2005];
llint hsum[2005][2005], wsum[2005][2005], dsum[2005][2005];
char c[2005][2005];

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

	cin >> h >> w;
	rep(y, 1, h) rep(x, 1, w) cin >> c[x][y];

	dp[1][1] = hsum[1][1] = wsum[1][1] = dsum[1][1] = 1;
	rep(x, 1, w){
		rep(y, 1, h){
			if(x == 1 && y == 1) continue;
			if(c[x][y] == '#'){
				dp[x][y] = 0, hsum[x][y] = wsum[x][y] = dsum[x][y] = 0;
				continue;
			}
			dp[x][y] = hsum[x][y-1] + wsum[x-1][y] + dsum[x-1][y-1], dp[x][y] %= mod;;
			hsum[x][y] = hsum[x][y-1] + dp[x][y], hsum[x][y] %= mod;
			wsum[x][y] = wsum[x-1][y] + dp[x][y], wsum[x][y] %= mod;
			dsum[x][y] = dsum[x-1][y-1] + dp[x][y], dsum[x][y] %= mod;
		}
	}
	cout << dp[w][h] << endl;

	return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int c = a+b;
  if(c >= 15 && b >= 8) cout << "1" << endl;
  else if(c >= 10 && b >= 3) cout << "2" << endl;
  else if(c >= 3) cout << "3" << endl;
  else cout << "4" << endl;
}

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#pragma comment(linker, "/stack:200000000")

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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 1e5 + 5;

int a, b;

void solve() {
    cin >> a >> b;
    if (a + b >= 15 && b >= 8) {
        cout << 1 << endl;
    } else if (a + b >= 10 && b >= 3) {
        cout << 2 << endl;
    } else if (a + b >= 3) {
        cout << 3 << endl;
    } else {
        cout << 4 << endl;
    }
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}

ll const N=(ll)2e5+11;
ll const LG=(ll)log2(N)+1;

// bool cmp(pll &a,pll &b){
//         if(a.ff!=b.ff)return a.ff<b.ff;

// }
void solve() {
	ll i,j,k,l,n,m,x,y,z,r;

        cin>>n;

        vllv a(n+11);
        for(i=0;i<n;i++){
                cin>>x>>y;
                a[y].pb(x);
        }
        vll an(n+11);
        a[0].pb(0);
        vll last(n+11);
        for(i=1;i<=n;i++){

                sort(all(a[i]));
                ll tt=0;
                for(j=1;j<a[i].sz;j++){
                        tt+=a[i][j]-a[i][j-1];
                }
                an[i]=tt;
                if(a[i].sz==0){
                        last[i]=last[i-1];
                }else{
                        last[i]=i;
                }
        }
        a[n+1].pb(0);
        vllv dp(n+11,vll(2));
        for(i=1;i<=n+1;i++){
                if(a[i].sz){
                        ll l=last[i-1];
                         m=a[l].sz;
                        k=a[i].sz;
                dp[i][0]=an[i] + min(dp[i-1][0]+abs(a[i][0]-a[l][m-1]),dp[i-1][1]+ abs(a[i][0]-a[l][0]));
                dp[i][1]=an[i] + min(dp[i-1][0]+abs(a[i][k-1]-a[l][m-1]),dp[i-1][1]+ abs(a[i][k-1]-a[l][0]));
                }else{
                        dp[i][0]=dp[i-1][0];
                        dp[i][1]=dp[i-1][1];
                }

        }
        // for(i=1;i<=n;i++){
        //         cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
        // }
        m=a[n].sz;
        cout<<min(dp[n+1][1],dp[n+1][0]);

}
int main(){
        FS;

        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        for(ll tc=1;tc<=q;tc++){
                // cout<<"Case #"<<tc<<": ";
                solve();
        }
        return 0;
}

ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;

        if(m%2==0)return pow1((n*n)%mod,m/2,mod);

        return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

struct Edge {
  int to;
  long long weight;
  Edge() : to(0), weight(0) {}
  Edge(int to, long long weight) : to(to), weight(weight) {}
  Edge(const Edge& e) {
    to = e.to;
    weight = e.weight;
  }
  bool operator>(const Edge &e) const { return weight > e.weight; }
  bool operator<(const Edge &e) const { return weight < e.weight; }
  bool operator==(const Edge &e) const { return weight == e.weight; }
  bool operator<=(const Edge &e) const { return weight <= e.weight; }
  bool operator>=(const Edge &e) const { return weight >= e.weight; }
};

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
using weightedGraph = vector<vector<Edge>>;
using heap = priority_queue<int, vector<int>, greater<int>>;

const ll BIL = 1e9;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 29;
const ld PI = 3.141592653589793238462643383;

ll solve(vector<ll>& r, vector<ll>& g, vector<ll>& b) {
  ll res = INF;
  for(int i=0;i<g.size();i++) {
    auto it = lower_bound(b.begin(), b.end(), g[i]);
    if(it != b.end()) {
      res = min(res, abs(g[i]-*it));
    }
    if(it == b.begin()) continue;
    it--;
    res = min(res, abs(g[i]-*it));
  }
  for(int i=0;i<b.size();i++) {
    auto it = lower_bound(g.begin(), g.end(), b[i]);
    if(it != g.end()) {
      res = min(res, abs(b[i]-*it));
    }
    if(it == g.begin()) continue;
    it--;
    res = min(res, abs(b[i]-*it));
  }
  vector<pll> gr, br;
  for(int i=0;i<r.size();i++) {
    ll t = INF;
    auto it = lower_bound(g.begin(), g.end(), r[i]);
    if(it != g.end()) t = min(t, abs(r[i]-*it));
    if(it != g.begin()) {
      it--;
      t = min(t, abs(r[i]-*it));
    }
    gr.push_back({t, i});
    t = INF;
    auto it2 = lower_bound(b.begin(), b.end(), r[i]);
    if(it2 != b.end()) t = min(t, abs(r[i]-*it2));
    if(it2 != b.begin()) {
      it2--;
      t = min(t, abs(r[i]-*it2));
    }
    br.push_back({t, i});
  }
  sort(gr.begin(), gr.end());
  sort(br.begin(), br.end());
  ll res2 = INF;
  int i = 0;
  int j = 0;
  while(res2 == INF && i < gr.size() && j < br.size()) {
    if(gr[i].second != br[j].second) {
      res2 = gr[i].first + br[j].first;
      break;
    }
    if(i+1 == gr.size() && j+1 == br.size()) break;
    else if(i+1 == gr.size()) j++;
    else if(j+1 == br.size()) i++;
    else if(gr[i].first+br[j+1].first < gr[i+1].first+br[j].first) j++;
    else i++;
  }
  return min(res, res2);
}
int main(int argc,char* argv[]){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  int rn = 0, gn = 0, bn = 0;
  vector<ll> r, g, b;
  for(int i=0;i<2*n;i++) {
    ll a;
    char c;
    cin >> a >> c;
    if(c == 'R') {
      rn++;
      r.push_back(a);
    } else if(c == 'G') {
      gn++;
      g.push_back(a);
    } else {
      bn++;
      b.push_back(a);
    }
  }
  if(rn % 2 == 0 && gn % 2 == 0 && bn % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(r.begin(), r.end());
  sort(g.begin(), g.end());
  sort(b.begin(), b.end());
  ll ans = 0;
  if(rn % 2 == 0) {
    ans = solve(r, g, b);
  } else if(gn % 2 == 0) {
    ans = solve(g, r, b);
  } else {
    ans = solve(b, r, g);
  }
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define vll vector<ll>
using namespace std;
inline void sol() {
  //
  ll n, m;
  cin >> n >> m;
  vector<pll> adj[n + 1];
  for (int i = 0; i < m; i++) {
    ll u, v, c;
    cin >> u >> v >> c;
    adj[u].push_back({c, v});
  }
  for (int i = 1; i <= n; i++)
    sort(adj[i].begin(), adj[i].end());
  for (int start = 1; start <= n; start++) {
    vll costs(n + 1, 1e12);
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    for (auto &p : adj[start]) {
      pq.push(p);
    }
    while (not pq.empty()) {
      auto p = pq.top();
      pq.pop();
      if (costs[p.second] <= p.first)
        continue;
      costs[p.second] = p.first;
      for (auto &q : adj[p.second]) {
        ll next = costs[p.second] + q.first;
        pq.push({next, q.second});
      }
    }
    if(costs[start] == 1e12)
      cout << "-1\n";
    else
      cout << costs[start] << endl;
  }
}

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

  sol();

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
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; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef long double ld;
using P = pair<int,int>;
const int INF=1001001001;
const int mod =1e9+7;

struct edge{
  int to;
  ll w;
  edge(int to,ll w):to(to),w(w){}
};
using Graph=vector<vector<edge>>;

int n,m;

auto dijkstra(int s,Graph G){
  vector<ll>dist(n,INF);
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>q;
  for(auto u:G[s]){
    if(chmin(dist[u.to],u.w)){
      q.push(P(u.w,u.to));
    }
  }
  while(!q.empty()){
    int v=q.top().second;
    ll d=q.top().first;
    if(v==s){return d;}
    q.pop();
    if(d>dist[v]){continue;}
    for(auto e:G[v]){
      if(chmin(dist[e.to],dist[v]+e.w)){
        q.push({dist[e.to],e.to});
      }
    }
  }
  return -1ll;
}

void solve(){
  cin>>n>>m;
  Graph G(n);
  vector<ll>r(n,INF);
  rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G[a].push_back(edge(b,c));
  }
  rep(i,n){
    ll ans=dijkstra(i,G);
    cout<<(ans==INF?-1:ans)<<endl;
  }
}
int main() {
  solve();
  return 0;
}


#include <bits/stdc++.h>

const int N = 200010;
const long long INF = 1ll<<60;
const int inf = 0x3f3f3f3f;
typedef std::pair<int, int> PairInt;
typedef std::pair<long long, int> Pair;
const long long mod = 1e9 + 7;

int n;
std::vector<std::pair<int, long long>> g[N];
int dp[N][60][2];
int mi[100];
int ans;

void Dfs(int u, int f) {
  for (int i = 0; i < 60; ++i) dp[u][i][0] = 1;
  for (size_t i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first;
    long long w = g[u][i].second;
    if (v == f) continue;
    Dfs(v, u);
    for (int j = 0; j < 60; ++j) {
      if ((w >> j) & 1) {
        ans = (ans + 1ll * dp[u][j][0] * dp[v][j][0] % mod * mi[j] % mod) % mod;
        ans = (ans + 1ll * dp[u][j][1] * dp[v][j][1] % mod * mi[j] % mod) % mod;
      } else {
        ans = (ans + 1ll * dp[u][j][0] * dp[v][j][1] % mod * mi[j] % mod) % mod;
        ans = (ans + 1ll * dp[u][j][1] * dp[v][j][0] % mod * mi[j] % mod) % mod;
      }
    }
    for (int j = 0; j < 60; ++j) {
      if ((w >> j) & 1) {
        dp[u][j][0] = (dp[u][j][0] + dp[v][j][1]) % mod;
        dp[u][j][1] = (dp[u][j][1] + dp[v][j][0]) % mod;
      } else {
        dp[u][j][0] = (dp[u][j][0] + dp[v][j][0]) % mod;
        dp[u][j][1] = (dp[u][j][1] + dp[v][j][1]) % mod;
      }
    }
  }
}

int main() {
  scanf("%d", &n);
  mi[0] = 1;
  for (int i = 1; i < 60; ++i) mi[i] = 2ll * mi[i - 1] % mod;
  for (int i = 1; i < n; ++i) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  Dfs(1, 0);
  printf("%d\n", ans);

  return 0;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,s,e) for(int i=s ; i < e ; i++)
#define rrep(i,s,e) for(int i=s ; i > e ; i--)
#define srep(i,s,e,j) for(int i=s ; i < e ; i+=j)
#define tr(i,x) for(auto i : x)
#define inp(a) for(int i=0 ; i<a.size() ; i++)cin>>a[i]
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vb vector<bool>
#define vpi vector<pii>
#define maxpqi priority_queue<int>
#define minpqi priority_queue <int, vector<int>, greater<int> >
#define pii pair<int,int>
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define pf push_front
#define endl '\n'
#define br printf("\n")
#define inf 1000000
#define imap map<int,int>
#define uimap unordered_map<int,int>
#define gcd(a,b) __gcd(a,b)
#define clr(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define lb lower_bound
#define ub upper_bound
#define npos string::npos
#define all(x) x.begin(),x.end()
#define descen greater<int>()

const int mod = 1e9 + 7;

int SumOfXorOfAllPairs(int a[],int n,int numbits){
    int sum = 0;
    int cnt[2];
    rep(i,0,numbits){
        clr(cnt);
        rep(j,0,n)cnt[(a[j]>>i)&1]++;
        sum += (1LL<<i)%mod*cnt[0]%mod*cnt[1];
        sum = sum%mod;
    }
    return sum;
}

void solve(){
    int n;cin>>n;
    vpi adj[n];
    int u,v,w;
    rep(i,0,n-1){
        cin>>u>>v>>w;
        u--;v--;
        adj[u].pb({v,w});
        adj[v].pb({u,w});
    }
    bool vis[n];fill(vis,false);
    int dist[n];clr(dist);
    queue<int>q;
    q.push(0);
    int curr;
    while(!q.empty()){
        curr = q.front();q.pop();
        tr(i,adj[curr]){
            if(!vis[i.F]){
                dist[i.F] = dist[curr]^i.S;
                vis[i.F] = true;
                q.push(i.F);
            }
        }
    }
    cout << SumOfXorOfAllPairs(dist,n,60LL) << endl;
}

int32_t main()
{
    fastio
    // ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    solve();
    return 0;
}

/*
// Sort the array in descending order
    sort(arr, arr + n, greater<int>());
*/


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
#define ios std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
// ios  can not be used with scanf,printf.  IF  ios MUST cin,cout.
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
const ll mod=1000000007;
const int INF=0x3f3f3f3f;
ll ksm(ll a,ll b){ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=2e5+10,M=18;

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        ll n;
        scanf("%lld",&n);
        if(n&1)puts("Odd");
        else if(n%4==2)puts("Same");
        else puts("Even");
    }
    return 0;
}

// Generated by 2.3.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
// #include "atcoder/all"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

void solve(long long n, std::vector<long long> a){
    vector<pair<i64,int>> v;
    for(int i = 0; i < 2 * n; ++i){
        v.emplace_back(a[i], i);
    }
    sort(v.begin(), v.end());
    vector<int> fl(2 * n, 0);
    for(int i = 0; i < n; ++i){
        fl[v[i].second] = true;
    }
    queue<bool> que;
    string s;
    for(int i = 0; i < 2 * n; ++i){
        if(!que.empty() && que.front() != fl[i]){
            s += ')';
            que.pop();
        }
        else{
            que.emplace(fl[i]);
            s += '(';
        }
    }
    assert(que.empty());
    cout << s << endl;
}

signed main(){
    long long N;
    std::scanf("%lld", &N);
    std::vector<long long> A(2*N);
    for(int i = 0 ; i < 2*N ; i++){
        std::scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define int long long
#define ll long long
#define ld long double
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define sz(x) (int)(x.size())

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

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

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

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

string to_string(const char& s) {
    return to_string(string(1, s));
}

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

string to_string(const bool& b) {
    return (b ? "1" : "0");
}

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

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

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

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

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

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

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef XOX // use -DXOX flag while compiling
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int inf = 1e15;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // code here
    int n, m;
    cin >> n >> m;
    vector<array<int, 3>> edges;
    vector<int> dis(n * n, -1);
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        if(u > v) swap(u, v);
        dis[u * n + v] = 1;
        dis[v * n + u] = 1;
        char ch;
        cin >> ch;
        edges.push_back({u, v, (int)(ch - 'a')});
    }
    for(int i = 0; i < n; i++) {
        dis[i * n + i] = 0;
    }
    auto getp = [&](int u, int v) {
        if(u > v) swap(u, v);
        return u * n + v;
    };
    vector<vector<int>> adj(n * n);
    for(int i = 0; i < sz(edges); i++) {
        for(int j = i + 1; j < sz(edges); j++) {
            auto p1 = edges[i], p2 = edges[j];
            if(p1[2] != p2[2]) continue;
            int u = getp(p1[0], p2[0]);
            int v = getp(p1[1], p2[1]);
            adj[u].push_back(v);
            adj[v].push_back(u);

            u = getp(p1[0], p2[1]);
            v = getp(p1[1], p2[0]);
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
    }
    debug(adj);
    debug(dis);
    vector<int> D(n * n, -1);
    queue<int> qu;
    qu.push(n - 1);
    D[n - 1] = 0;
    int ans = inf;
    while(!qu.empty()) {
        auto u = qu.front();
        qu.pop();
        if(dis[u] != -1) {
            ans = min(ans, D[u] + dis[u]);
            continue;
        }
        for(int v : adj[u]) {
            if(D[v] != -1) continue;
            D[v] = D[u] + 2;
            qu.push(v);
        }
    }
    cout << (ans == inf ? -1 : ans) << '\n';
    return 0;
}

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

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
#define int ll
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;

vvi g;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin >> n >> m;
    g.assign(n*n, vi());
    vvii edges(26);
    for (int i = 0; i < m; ++i) {
        int u, v;
        char c;
        cin >> u >> v >> c;
        edges[c-'a'].pb({u-1, v-1});
    }
    for (int ch = 0; ch < 26; ++ch) {
        for (int i = 0; i < (int)edges[ch].size(); ++i) {
            for (int j = i+1; j < (int)edges[ch].size(); ++j) {
                int a,b,c,d;
                a = edges[ch][i].ff;
                b = edges[ch][i].ss;
                c = edges[ch][j].ff;
                d = edges[ch][j].ss;
                g[a*n+c].pb(b*n+d); g[b*n+d].pb(a*n+c);
                g[c*n+a].pb(d*n+b); g[d*n+b].pb(c*n+a);
                g[a*n+d].pb(b*n+c); g[b*n+c].pb(a*n+d);
                g[d*n+a].pb(c*n+b); g[c*n+b].pb(d*n+a);
            }
        }
    }
    vi dis(n*n, -1);
    queue<int> q;
    q.push(n-1);
    dis[n-1] = 0;
    while (q.size()){
        int u = q.front(); q.pop();
        for (int v: g[u]){
            if (dis[v] == -1){
                dis[v] = dis[u]+1;
                q.push(v);
            }
        }
    }
    int ans = 1e9;
    for (int i = 0; i < n; ++i) {
        if (dis[n*i+i] + 1) ans = min(ans, dis[n*i+i]*2);
    }
    for (int c = 0; c < 26; ++c) {
        for (ii p: edges[c]){
            if (dis[n*p.ff+p.ss] + 1) ans = min(ans, dis[n*p.ff+p.ss]*2+1);
            swap(p.ff, p.ss);
            if (dis[n*p.ff+p.ss] + 1) ans = min(ans, dis[n*p.ff+p.ss]*2+1);
        }
    }
    if (ans == (int)1e9) ans = -1;
    cout << ans << "\n";
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  char a,b,c;
  cin>>a>>b>>c;
  cout<<b<<c<<a;
  return 0;
}

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

using namespace std;
using ll = long long;

#define for(i, a, b) for (int i=(a); i < (b); i++)
#define rep(i, n) for(i, 0, n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

int main () {
    string s;
    cin  >> s;

    cout  << s[1] << s[2] << s[0] << endl;
}


#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define bit(n,k) ((n>>k)&1) //nのk　bit目
#define vec(T) vector<T>
#define vvec(T) vector<vector<T>>
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

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; }
const ll llINF = 1LL << 60;
const int iINF = 1e9;

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

struct Solver{

    void solve(){
        ll A,B;
        cin >> A>>B;

        ll ans=1;

        rep1(g,B) if( ceil(A/double(g)) < floor(B/double(g)) ) ans=g;

        cout  << ans << endl;
    }
};

int main(){
    int testcasenum=1;
    //cin >> testcasenum;
    rep1(ti,testcasenum){
        Solver solver;
        solver.solve();
    }
    return 0;
}

#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 2000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int lg[maxn+5];
int a[maxn+5],b[maxn+5];
int n;

int d[maxn+5][maxn+5];

void adj(int &x)
{
    if(x & (1<<lg[n-1])) x^=1<<lg[n-1];
    if(x>=n) x^=1<<(lg[n-1]-1);
}
int main()
{
    scanf("%d",&n);
    rep(i,1,n) lg[i]=lg[i>>1]+1;
    rep(i,0,n-1)
    {
        a[i]=i*2;
        b[i]=i*2+1;
        adj(a[i]);
        adj(b[i]);
    }
    /*
    rep(i,1,n) rep(j,1,n) d[i][j]=inf;
    rep(i,0,n-1) d[i+1][a[i]+1]=d[i+1][b[i]+1]=1;
    rep(i,1,n) d[i][i]=0;
    rep(k,1,n) rep(i,1,n) rep(j,1,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    rep(i,1,n) rep(j,1,n) assert(d[i][j]<=10);
    */

    rep(i,0,n-1) printf("%d %d\n",a[i]+1,b[i]+1);
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a*a+b*b<c*c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(int i=cc;i>=n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

const vector<int> dx = {1, 0, -1,  0};
const vector<int> dy = {0, 1,  0, -1};

const vector<int> dx2 = {1, 1,  1, 0,  0, 0, -1, -1, -1};
const vector<int> dy2 = {1, 0, -1, 1, -1, 0,  1,  0, -1};

const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
const ll mod2 = 998244353;

const ll MAX = 1000000;
const ll MOD = 1000000007;
const ll big = (1ll<<60);

const ll moda = 1000000007;
const ll modb = 100000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

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

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  cout << (a*a+b*b<c*c ? "Yes":"No") << endl;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)

int n;
int x[105],y[105];
vector<int> G[105];
bool vis[105];
inline void dfs(int u){
	vis[u]=1;
	for (int i=0;i<G[u].size();++i) if (!vis[G[u][i]]) dfs(G[u][i]);
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	// lower bound line: 0    upper bound line: n+1
	REP(i,n) cin>>x[i]>>y[i];
	int l=0,r=1e8;// l:ok  r:bad
	// multiplied by 1e6.
	while(r-l>1){
		int m=l+r>>1;
		rep(i,n+2) G[i].clear();
		REP(i,n) if ((y[i]+100)*1e6<m*2) G[0].pb(i);
		REP(i,n) if ((100-y[i])*1e6<m*2) G[i].pb(n+1);
		for (int i=1;i<n;++i) for (int j=i+1;j<=n;++j)
			if ((ll)((x[i]-x[j])*(x[i]-x[j])+((y[i]-y[j])*(y[i]-y[j])))*1e6*1e6 < (ll)m*m*4) G[i].pb(j),G[j].pb(i);
		memset(vis,0,sizeof(vis));
		dfs(0);
		if (vis[n+1]) r=m;
		else l=m;
	}
	double x=(double)l/1e6;
	printf("%0.5lf",x);
	return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << '\n'; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

class UnionFind {
public:
    vector<int> par;
    int N;
    UnionFind(int n) {
        par.resize(n, -1);
        N = n;
    }
    int Find(int n) {
        return par[n] < 0 ? n : par[n] = Find(par[n]);
    }
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        if (x == y) return false;
        if (-par[x] > -par[y]) swap(x, y);
        par[y] += par[x];
        par[x] = y;
        N--;
        return true;
    }
    bool Same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -par[Find(x)];
    }
    int size() {
        return N;
    }
};

#include <iomanip>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<int> x(n), y(n);
    REP(i, 0, n) {
        cin, x[i], y[i];
    }
    double l = 0, r = 100;
    double ans = 0;
    while (abs(r - l) >= 1e-9) {
        UnionFind uf(n + 2);
        double mid = (l + r) / 2;
        REP(i, 0, n) {
            REP(j, 0, n) {
                if ((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) < 4 * mid * mid) {
                    uf.Union(i, j);
                }
            }
            if (y[i] + mid > 100 - mid) {
                uf.Union(i, n);
            }
            if (y[i] - mid < -100 + mid) {
                uf.Union(i, n + 1);
            }
        }
        dump(mid, uf.Same(n, n + 1));
        if (uf.Same(n, n + 1)) {
            r = mid;
        } else {
            l = mid;
            ans = mid;
        }
    }
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define DB double
#define LL long long

#define MST(a,b) memset((a),(b),sizeof(a))

#ifdef _DEBUG_
#define MRK() cout<<"Mark"<<endl;
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;
#else
#define MRK() ;
#define WRT(x) ;
#endif

#define MAXN 1010000
#define MAXM 2010000
#define MOD 998244353  //1000000007
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;

int n;
int w[MAXN];
LL pool[101][21000];
LL* dp[101];
LL fac[MAXN];
void init()
{
	for (int i=0;i<=100;i++)
		dp[i]=pool[i]+10050;
}

void work()
{
	dp[0][0]=1;
	int sum=0;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>w[i];
		sum+=w[i];
	}
	if (sum%2==1)
	{
		cout<<0<<endl;
		return ;
	}
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=i-1;j>=0;j--)
			for (int k=10000;k>=0;k--)
			{
				//dp[j+1][k]=(dp[j+1][k]+dp[j][k])%MOD;
				dp[j+1][k+w[i]]=(dp[j+1][k+w[i]]+dp[j][k])%MOD;
			}
	}
	fac[0]=1;
	for (int i=1;i<MAXN;i++)
		fac[i]=fac[i-1]*i%MOD;
	LL ans=0;
	for (int i=0;i<=n;i++)
	{
		WRT(dp[i][sum/2])
		ans+=dp[i][sum/2]*fac[i]%MOD*fac[n-i]%MOD;
	}
	cout<<ans%MOD<<endl;
}

int main()
{
	#ifdef _DEBUG_
	freopen("C:/Users/DELL/Documents/Dev-C++/sample.in","r",stdin);
	#endif
	init();
	int casenum=1;
	//scanf("%d",&casenum);
	for (int testcase=1;testcase<=casenum;testcase++)
	{
		#ifdef _DEBUG_
		printf("Case #%d:\n",testcase);
		#endif
		work();
	}
	return ~~(0^_^0);
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

const int mod = 1000000007; // 998244353;
struct mint {
  long long x;
  mint(long long 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(long long 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, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

typedef pair<int,ll>P;

vector<P> to[200009];
mint odd[200009], even[200009];

mint dfs(int p, int last, int n){
  mint odds=0, res=0;
  rep(i,to[p].size()){
    int next=to[p][i].fi;
    int w=(to[p][i].se>>n)&1;
    if(next==last)continue;
    res+=dfs(next,p,n);
    if(w==0){
      odd[p]+=odd[next];
      even[p]+=even[next];
    }
    else{
      odd[p]+=even[next];
      even[p]+=odd[next];
    }
  }
  rep(i,to[p].size()){
    int next=to[p][i].fi;
    int w=(to[p][i].se>>n)&1;
    if(next==last)continue;
    if(w==0){
      res += (odd[p] - odd[next]) * even[next];
    }
    else{
      res += (odd[p] - even[next]) * odd[next];
    }
  }
  res+=odd[p];
  //cout<<p<<' '<<res<<' '<<odd[p]<<endl;
  return res;
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int u,v;
    ll w;
    cin>>u>>v>>w;
    u--;v--;
    to[u].push_back(P(v, w));
    to[v].push_back(P(u, w));
  }
  mint ans=0;
  rep(i,60){
    rep(j,n){
      odd[j]=0;
      even[j]=1;
    }
    ans += dfs(0,0,i)*((ll)1<<i);
  }
  cout<<ans<<endl;
  return 0;
}


#include <stdio.h>
#include <stack>
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld", &n);
  char s[n + 10], t[n + 10];
  scanf("%s%s", s, t);
  std::stack<ll> a, b;
  for(i = 0; i < n; ++i) {
    if(t[i] == '1') a.push(i);
    if(s[i] == '1') {
      if(b.size()) ans += i - b.top(), b.pop();
      else if(a.size()) ans += i - a.top(), a.pop();
      else b.push(i);
    }
  }
  printf("%lld", a.size() || b.size() ? -1 : ans);
  return 0;
}

#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

template<class T> bool chmin(T &a, T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b){a=b;return 1;}return 0;}
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;

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

    ll n;
    string s,t;
    cin >> n >> s >> t;

    ll ssum = 0,tsum = 0;
    for (ll i = 0; i < n; i++){
        if (s[i] == '1'){
            ssum++;
        }

        if (t[i] == '1'){
            tsum++;
        }
    }

    if (ssum %2 != tsum %2){
        cout << -1 << endl;
        return 0;
    }

    ll erase = 0;
    ll ans = 0;
    ll count = 0;

    ll j = 0;

    for (ll i = 0; i < n; i++){
        if (t[i] == '0') continue;

        ll k = -1;

        while (j < i){
            if (s[j] == '1'){
                count++;
                if (count %2 == 1){
                    k = j;
                }
                else{
                    ans += (j - k);
                    k = -1;
                }
            }

            j++;
        }

        //cout << i << " " << j << " " << k << endl;

        if (k != -1){
            while (j < n){
                if (s[j] == '1'){
                    ans += (j - k);
                    //cout << ans << endl;
                    j++; count++;
                    k = -1;
                    break;
                }
                else j++;
            }
        }

        if (k != -1){
            cout << -1 << endl;
            return 0;
        }

        while (j < n){
            if (s[j] == '1'){
                ans += (j - i);
                //cout << ans << endl;
                break;
            }
            else j++;
        }

        if (j >= n){
            cout << -1 << endl;
            return 0;
        }
        else if (j == n-1){
            if (count != ssum - tsum){
                cout << -1 << endl;
                return 0;
            }
            else break;
        }
        else{
            j++;
        }

        //cout << ans << endl;
    }
    //cout << count << endl;

    if (count != ssum - tsum){
        //cout << "Yes" << endl;
        ll k = -1;
        for (ll i = n-1; i >= 0; i--){
            if (s[i] == '1'){
                count++;
                if (count %2 == 1){
                    k = i;
                }
                else{
                    ans += (k - i);
                    k = -1;
                }

                if (count == ssum - tsum) break;
            }
        }
    }

    cout << ans << endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5;
int main(){
	vector<pair<int,int>>ans;
	int n,m;cin>>n>>m;
	int x=m;
	if((m>0&&x+2>n)||m<0){
		cout<<"-1\n";
		return 0;
	}
	ans.emplace_back(1,4*x+3);
	for(int i=0;i<n-1;i++){
		ans.emplace_back(4*i+2,4*i+4);
	}
	for(auto& i:ans){
		cout<<i.first<<' '<<i.second<<'\n';
	}
}

#include <bits/stdc++.h>

using namespace std;

int main() {

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

	int n, m;
	cin >> n >> m;

	if(n == 1) {
		if(m != 0)
			cout << -1 << endl;
		else
			cout << "1 2" << endl;
		return 0;
	}

	if(m < 0 || m > n - 2) {
		cout << -1 << endl;
		return 0;
	}

	if(m == 0) {
		for(int i=0, s = 5; i<n; ++i, s+= 2) {
			cout << s << " " << s + 1 << endl;
		}
		return 0;
	}

	assert(m <= n - 2);

	cout << 1 << " " << 2*(m + 1) + 5 << endl;

	for(int s=2, cnt=0; cnt<m+1; s+=2, ++cnt) {
		cout << s << " " << s + 1 << endl;
	}

	int start = 2*(m + 1) + 10;
	for(int k=0; k < n-m-2; ++k) {
		cout << start << " " << start + 1 << endl;
		start += 2;
	}

	return 0;
}


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

#define int long long

const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MX = 1e5 + 5;

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

int32_t main()
{
    int l;
    cin >> l;

    int den = 39916800;
    int num = 1;
    for(int i=1;i<=11;i++) {
        num = num * (l - i);
        int g = gcd(num, den);
        num = num/g;
        den = den/g;
    }
    cout << num/den << endl;

    return 0;
}

#include <stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n<0)
	printf("0");
	else
	printf("%d",n);
}


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

long long N;
long long X[1 << 18], C[1 << 18];
long long dp[1 << 18][3];
vector<long long> G[1 << 18];
vector<long long> J;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> C[i];
		J.push_back(C[i]);
	}
	J.push_back(0);
	J.push_back(N + 1);
	sort(J.begin(), J.end());
	J.erase(unique(J.begin(), J.end()), J.end());
	for (int i = 1; i <= N; i++) {
		C[i] = lower_bound(J.begin(), J.end(), C[i]) - J.begin();
		G[C[i]].push_back(X[i]);
	}
	G[0].push_back(0);
	G[J.size() - 1].push_back(0);
	for (int i = 0; i < J.size(); i++) {
		sort(G[i].begin(), G[i].end());
		if (G[i].size() >= 2) {
			vector<long long> H = { G[i][0], G[i][G[i].size() - 1] };
			G[i] = H;
		}
	}

	for (int i = 0; i < J.size(); i++) {
		dp[i][0] = (1LL << 60);
		dp[i][1] = (1LL << 60);
	}

	dp[0][0] = 0;
	for (int i = 1; i < J.size(); i++) {
		for (int j = 0; j < G[i - 1].size(); j++) {
			for (int k = 0; k < G[i].size(); k++) {
				if (G[i].size() == 1) {
					dp[i][k] = min(dp[i][k], dp[i - 1][j] + abs(G[i - 1][j] - G[i][k]));
				}
				if (G[i].size() == 2) {
					dp[i][k] = min(dp[i][k], dp[i - 1][j] + abs(G[i - 1][j] - G[i][k ^ 1]) + abs(G[i][k ^ 1] - G[i][k]));
				}
			}
		}
	}
	cout << dp[J.size() - 1][0] << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
std::mt19937 rnd(time(0));
inline int sj(int n)
{
	unsigned int x=rnd();
	return x%n+1;
}
#define rand fst
template<typename typC> void read(register typC &x)
{
	register int c=getchar(),fh=1;
	while ((c<48)||(c>57))
	{
		if (c=='-') {c=getchar();fh=-1;break;}
		c=getchar();
	}
	x=c^48;c=getchar();
	while ((c>=48)&&(c<=57))
	{
		x=x*10+(c^48);
		c=getchar();
	}
	x*=fh;
}
template<typename typC, typename... Args> void read(typC &first, Args& ... args) {
	read(first);
	read(args...);
}
template<typename typC> void read(register typC *a,int num)
{
	for (register int i=1;i<=num;i++) read(a[i]);
}
template<typename typC> void write(register typC x)
{
	if (x<0) putchar('-'),x=-x;
	static int st[100];
	register int tp=1;
	register typC y;st[1]=x%10;x/=10;
	while (x) y=x/10,st[++tp]=x-y*10,x=y;++tp;
	while (--tp) putchar(st[tp]|48);
}
template<typename typC> void write(register typC *a,register int num)
{
	for (register int i=1;i<=num;i++) write(a[i]),putchar(i==num?10:32);
}
template<typename typC> typC ab(register typC x)
{
	if (x<0) return -x;
	return x;
}
#define space(x) write(x),putchar(32)
#define enter(x) write(x),putchar(10)
const int p=1e9+7;
const db eps=1e-9;
inline void inc(register int &x,const int y)
{
	if ((x+=y)>=p) x-=p;
}
inline void dec(register int &x,const int y)
{
	if ((x-=y)<0) x+=p;
}
inline int ksm(register int x,register int y)
{
	register int r=1;
	while (y)
	{
		if (y&1) r=(ll)r*x%p;
		x=(ll)x*x%p;
		y>>=1;
	}
	return r;
}
priority_queue<int> ONLYYFORRCOPYY;
priority_queue<int,vector<int>,greater<int> > ONLYYFORRCOPYY__;
struct Q
{
	int u,v;
	Q(int a=0,int b=0):u(a),v(b){}
	bool operator<(const Q &o) const {return v<o.v;}
};
const int N=1e6+2,M=1e6+2,inf=1e9;
vector<Q> lj[N];
ll lb[N][3];
int a[N],b[N],ds[N],dep[N],cnt[2];
int T,n,m,c,i,j,k,x,y,z,ans,la,ksiz,ks;
bool ed[N];
void dfs(int x)
{
	ed[x]=1;cnt[dep[x]]++;
	for (auto v:lj[x]) if (!ed[v.u])
	{
		dep[v.u]=dep[x]^v.v;
		dfs(v.u);
	}
	ed[x]=0;
}
int main()
{
	//ios::sync_with_stdio(false);
	cout<<setiosflags(ios::fixed)<<setprecision(15);
	T=1;
	read(n);
	for (i=1;i<n;i++) read(lb[i]-1,3),++ds[lb[i][0]],++ds[lb[i][1]];
	for (j=0;j<60;j++)
	{
		cnt[0]=cnt[1]=0;
		for (i=1;i<=n;i++) lj[i].clear(),lj[i].reserve(ds[i]);
		for (i=1;i<n;i++)
		{
			x=lb[i][0];y=lb[i][1];z=lb[i][2]>>j&1;
			lj[x].push_back(Q(y,z));
			lj[y].push_back(Q(x,z));
		}dfs(1);
		ans=(ans+(1ll<<j)%p*cnt[0]%p*cnt[1])%p;
	}
	write(ans);
}


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

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

  ll T; cin >> T;
  for (ll i = 0; i < T; i++) {
    string S; cin >> S;
    if (S > "atcoder") {
      cout << 0 << '\n';
      continue;
    }
    ll ans = -1;
    for (ll j = 0; j < S.size(); j++) {
      if (S[j] != 'a') {
        ans = j;
        break;
      }
    }
    if (ans != -1) {
      if (S[ans] > 't') {
        ans--;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vp> vvp;

// input
int N;
vi p;

void input() {
    cin >> N;
    p = vi(N);
    rep(i, N) cin >> p[i];
}

int main() {
    input();
    vi ans;
    set<int> s;
    rep(i, N - 1) s.insert(i + 1);
    set<int> mx{p[0]};
    int i = 1;
    while (i < N) {
        if (i == 0) {
            mx.insert(p[0]);
            i++;
            continue;
        }
        if (p[i - 1] < p[i]) {
            mx.insert(p[i]);
            i++;
            continue;
        }
        mx.erase(p[i - 1]);
        mx.insert(p[i]);
        if (*mx.end() == i) {
            if (s.count(i)) {
                s.erase(i);
                ans.push_back(i);
                mx.erase(p[i - 1]);
                swap(p[i - 1], p[i]);
                i--;
                continue;
            } else {
                cout << -1 << endl;
                return 0;
            }
        }
        i++;
    }
    rep(i, N - 1) {
        if (p[i] > p[i + 1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    if (ans.size() != N - 1) {
        cout << -1 << endl;
        return 0;
    }
    for (int x : ans) cout << x << endl;
}


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

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

  int total = 0;

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= k; j++){
      int room = i * 100 + j;
      total += room;
    }
  }

  cout << total << endl;

  return 0;
}

#include <iostream>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <algorithm>
#include <vector>
#define rep(i, a,b) for (int i = a; (int)i < b; i++)
#define repe(i,a,b) for(int i=a;(int)i<=b;i++)
#define per(i,a,b) for(int i=a;(int)i>b;i--)
#define fi(i,a) for(int i=0;(int)i<a;i++)
#define FS(i,a) for(int i=0;a[i];++i)
#define deb(x) cout<<'\n'<<#x<<" :- "<<x<<'\n'
typedef long long ll;
#define sz(a) (int)a.length()
#define nl '\n'
#define ga ' '
/*array stuff*/
#define SET(a)                memset( a, -1,    sizeof a )
#define CLR(a)                memset( a,  0,    sizeof a )
#define MEM(a,val)            memset( a,  val,  sizeof(a) )
/*array stuff ends*/
#define F first
#define S second
#define pb push_back
#define RUN_LOCAL(testfilename,testfilename1) {freopen(testfilename, "r",stdin);freopen(testfilename1,"w",stdout);}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
using namespace std;

bool com(int a, int b) {
	return a > b;
}

vector<bool> sieve(int N) {
	vector<bool> isPrime(N + 1);
	for (int i = 0; i <= N; ++i) {
		isPrime[i] = true;
	}
	isPrime[0] = false;
	isPrime[1] = false;
	for (int i = 2; i * i <= N; ++i) {
		if (isPrime[i] == true) {                   //Mark all the multiples of i as composite numbers
			for (int j = i * i; j <= N ; j += i)
				isPrime[j] = false;
		}
	}
	return isPrime;
}
int finde(vector<int> v, int n) {
	fi(i, v.size()) {
		if (v[i] == n)return 1;
	}
	return 0;
}

bool isPalinrome(string s) {
	for (int i = 0; i < (int)s.size() / 2; i++) {
		if (s[i] != s[(int)s.size() - 1 - i]) return false;
	}
	return true;
}

int gcd(int n1, int n2) {
	if (n2 != 0)
		return gcd(n2, n1 % n2);
	else
		return n1;
}

string ToStr( char c ) {
	return string( 1, c );
}
int main() {
#ifndef ONLINE_JUDGE
	RUN_LOCAL("input.txt", "output.txt");
	//freopen("error.txt", "w", stderr);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int ct = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			ct += (i * 100) + j;
		}
	}
	cout << ct;
#ifndef ONLINE_JUDGE
	cout << "\n[Time Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s]";
	cout << "\n |ヽ__／|   (`ヽ\n |_ _  |.--.) )\n ( T   )     ヽ\n(((^_(((/(((_／\n";
#endif
//ctrl+u cancel build
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

const string YES = "Yes";
const string NO = "No";
bool solve(int N, int64_t W, const vector<int64_t> & S, const vector<int64_t> & T, const vector<int64_t> & P) {
    map<int, int64_t> m;
    REP(i, N)
    {
        m[S[i]] += P[i];
        m[T[i]] -= P[i];
    }
    int64_t x = 0;
    for(auto &a: m){
        x += a.second;
        // cerr << a.first << " " << x << endl;
        if(W < x) return 0;
    }
    return 1;
}

// generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t N;
    int64_t W;
    cin >> N;
    vector<int64_t> S(N), T(N), P(N);
    cin >> W;
    REP (i, N) {
        cin >> S[i] >> T[i] >> P[i];
    }
    auto ans = solve(N, W, S, T, P);
    cout << (ans ? YES : NO) << endl;
    return 0;
}

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

using namespace std;
vector<int> A;

const int MAX = 200010;
int main()
{
	ll N,W;
	cin >> N >> W;
	vector<ll> num(MAX + 1, 0);
	for(int i = 0; i < N; i++)
	{
		ll s,t,w;
		cin >> s >> t >> w;
		num[s] += w;
		num[t] -= w;
	}
	for(int i = 0; i < MAX; i++)
	{
		num[i + 1] += num[i];
		if (num[i] > W)
		{
			cout << "No" << endl;
			return (0);
		}
	}
	cout << "Yes" << endl;
}


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++) cout<<*i<<" ";cout<<*--x.end()<<endl;
#define coutVEC2(x) rep(j, x.size()) {auto y=x.at(j); coutALL(y);}
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 main(){
	ll k,n,m,bsum=0;
	cin>>k>>n>>m;
	vector<ll> a(k), b(k);
	vector<pair<ll,ll>> rest;
	rep(i, k) cin>>a[i];

	rep(i, k) {
		a[i] *= m;
		b[i] = a[i]/n;
		bsum += b[i];
		rest.push_back({a[i]-b[i]*n, i});
	}
	// coutALL(b);
	sort(rest.begin(), rest.end(), greater<pair<ll,ll>>());
	// rep(i, k) cout<<rest[i].first<<" "<<rest[i].second<<endl;
	rep(i, m-bsum) b[rest[i].second]++;
	coutALL(b);

	return 0;
}

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

int main() {
    ll k,n,m;cin>>k>>n>>m;
    vector<ll> a(maxn),b(maxn);
    vector<pii> lg,sm;
    for(int i=1;i<=k;i++) cin>>a[i];
    int left=m;
    for(int i=1;i<=k;i++) {
        b[i]=a[i]*m/n;
        if(abs((b[i]+1)*n-a[i]*m)>abs(b[i]*n-a[i]*m)) lg.push_back({abs((b[i]+1)*n-a[i]*m),i});
        else sm.push_back({b[i]*n-a[i]*m,i});
        left-=b[i];
    }
    sort(lg.begin(),lg.end());
    sort(sm.begin(),sm.end());
    for(int i=0;left&&i<sm.size();i++) {
        b[sm[i].second]++;left--;
    }
    for(int i=0;left&&i<lg.size();i++) {
        b[lg[i].second]++;left--;
    }
    for(int i=1;i<=k;i++) cout<<b[i]<<' ';cout<<endl;
    return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef map<ll, ll> mll;

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define ff first
#define ss second
#define fi(n) for (int i = 0; i < n; i++)
#define fj(n) for (int j = 0; j < n; j++)
#define fi(s, e) for (int i = s; i < e; i++)
#define fk(n) for (int k = 1; k <= n; k++)
#define pb push_back
#define mp make_pair
const int mod = 1e9 + 7;
// **** CODE STARTS HERE ******//
bool cmpd(ll a, ll b)
{
    return a > b;
}
bool cmp(pair<ll, ll> a, pair<ll, ll> b)
{
    if (a.ss == b.ss)
    {
        return a.ff<b.ff;
    }

        return a.ss > b.ss;
}
ll inter(ll a, ll b)
{
    cout << "? " << a << " " << b << endl;
    ll k;
    cin >> k;
    return k;
}
ll fact(ll a)
{
    ll val = 1;
    for (ll i = 1; i <= a; i++)
    {
        val = (val % mod * i % mod) % mod;
    }
    return val;
}
int ans[500][500];
void dfs(int ans[][500],int i,int j,int n,int &val,int k)
{
    if (val == 0)
    {
        return;
    }
    if(i<0||j<0||i>=n||j>=n)
    {
        return;
    }
    if(ans[i][j]!=0)
    return;

        ans[i][j]=k;
        val=val-1;
        dfs(ans,i,j-1,n,val,k);
        dfs(ans,i+1,j,n,val,k);
        dfs(ans,i,j+1,n,val,k);
        dfs(ans,i-1,j,n,val,k);

}
void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
        if((a*a+b*b)<c*c)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
}

int main()
{
    fastio;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    /*ll t;
    cin >> t;
    while (t--)*/
        solve();

    // checktime;
    return 0;
}

#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;

//typedef long long int i64; // 9e18
typedef long long int i64; // 9e18

typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const long double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;
//i64 mod = 998244353;

i64 T, n, m, k;

//string s1;
//getline(cin, s1);

//bool comp(pair<i64,i64> a, pair<i64,i64> b)
//{
//    if (a.first == b.first)
//        return (a.second < b.second);
//    return (a.first < b.first);
//
//}

//map <i64, set<i64>> g;
//vector<bool> used;
//
//void dfs(i64 v) {
//    used[v] = true;
//    for (auto v0 : g[v]) {
//        if (used[v0]) {
//            continue;
//        }
//
//        //do sth
//        dfs(v0);
//    }
//}

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

    T = 1;
    //cin >> T;

    for (i64 tt = 1; tt <= T; ++tt) {

        i64 a, b, c;
        cin >> a >> b >> c;
        i64 res = 0;

        //cout << res << endl;

        //cout << "Case #" << tt << ": " << res << endl;
        //cout.flush();

        bool yes_no = true;
        if (yes_no) {
            bool fl = true;

            if (a * a + b * b >= c * c) {
                fl = false;
            }

            fl ? cout << "Yes" << endl : cout << "No" << endl;

        }

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pq(T) priority_queue<T, vector<T>, greater<T>>
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return 0;}
template<class T> void print(const T &t) { cout << t << "\n"; }
const ll INF = 1LL << 60;

ll k;
string t, s;

ll f(map<int,ll> ma){
    ll cnt = 0;
    rep1(i,9) cnt += i * pow(10,ma[i]);
    return cnt;
}

int main() {
    fio(); cin>>k>>t>>s;
    map<int, ll> cards, tak, aok;
    rep1(i,9) cards[i] = k;
    rep(i,4) {int tmp = t[i] - '0'; cards[tmp]--; tak[tmp]++;}
    rep(i,4) {int tmp = s[i] - '0'; cards[tmp]--; aok[tmp]++;}
    ll ans = 0;
    rep1(i,9) {
        if(cards[i]>0) tak[i]++;
        else continue;
        rep1(j,9) {
            if(i==j) {
                if(cards[j]>1) aok[j]++;
                else continue;
                if(f(tak) > f(aok)) {
                    ans += cards[i] * (cards[i] - 1);
                }
                aok[j]--;
            } else {
                if(cards[j]>0) aok[j]++;
                else continue;
                if(f(tak) > f(aok)) {
                    ans += cards[i] * cards[j];
                }
                aok[j]--;
            }
        }
        tak[i]--;
    }
    ll denom = (k * 9 - 8) * (k * 9 - 9);
    long double res = ans / (double)denom;
    cerr<< ans << " " << denom<< endl;
    cout << fixed << setprecision(16) << res << "\n";
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
# define rep(i,a,b) for(int i=(a); i<=(b); ++i)
# define drep(i,a,b) for(int i=(a); i>=(b); --i)
typedef long long int_;
inline int readint(){
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0'||c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c&&c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}

const int MaxN = 100005;
int cnt[2][10];
char str[10];

int main(){
	int n = readint();
	scanf("%s",str);
	for(int i=0; i<4; ++i)
		++ cnt[0][str[i]-'0'];
	scanf("%s",str);
	for(int i=0; i<4; ++i)
		++ cnt[1][str[i]-'0'];

	int_ ans = 0;
	for(int i=1; i<=9; ++i){
		int_ now = (n-cnt[0][i]-cnt[1][i]);
		++ cnt[0][i]; int sum0 = 0;
		for(int j=1; j<=9; ++j){
			int t = j;
			rep(x,1,cnt[0][j]) t *= 10;
			sum0 += t;
		}
		for(int j=1; j<=9; ++j){
			if(cnt[0][j]+cnt[1][j] >= n)
				continue; // cannot choose
			now *= (n-cnt[0][j]-cnt[1][j]);
			++ cnt[1][j]; int sum1 = 0;
			rep(x,1,9){
				int t = x;
				rep(y,1,cnt[1][x]) t *= 10;
				sum1 += t;
			}
			if(sum0 > sum1)
				ans += now;
			-- cnt[1][j]; // restore
			now /= (n-cnt[0][j]-cnt[1][j]);
		}
		-- cnt[0][i];
	}
	printf("%.15f\n",double(ans)/(9*n-8)/(9*n-9));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define frfr  freopen("input.text","r",stdin); //freopen("output.txt","w",stdout)
#define LL long long int
#define ull unsigned long long int
#define wh int T;cin >> T;while(T--)
#define foro(i,n) for(int i=0;i<n;i++)
#define forn(i,k,n) for(int i=k;i<n;i++)
#define PB push_back
#define mod 1000000007
#define UMP unordered_map<int,int>
#define MP map<int,int>
#define stack stack<int>
#define stackL 	stack<LL>

void solve(){
	double n;
	cin >> n;
	double e = 0;
	double m = 0;
	double c=0;
	for(int i=0;i<n;i++){
		double x;
		cin >> x;
		x = abs(x);
		m +=x;
		e += x*x;
		c = max(c,x);
	}

	printf("%0.15f\n",m);
	printf("%0.15f\n",sqrt(e));
	printf("%0.15f",c);

}
int main()
{
   //IOS;
   //frfr;
   // wh{
	   solve();
	//}

 return 0;
}

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

#define ll long long
#define test int tt; cin>>tt; while(tt--)
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair

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

    int n;
    cin>>n;

    string s[n];

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

    ll int ans=0;

    for(int i=0;i<n;i++)
    {
        if(s[i][0]=='O')
            ans+=(1ll<<(i+1));
    }

    cout<<ans+1<<endl;
}


#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
//#define MOD 998244353LL
#define doublecout(a) cout<<setprecision(16)<<a<<endl;
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL;
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}

ll m;
string x;

bool solve(ll c){
  double dc=0.0;
  dc=c;
  double dgk=0.0;
  double dw=1.0;
  ll xs=x.size();
  bool flag=true;
  for(ll i=0;i<x.size();i++){
    if (dw>5223372036854775808.0){
      flag=false;
      break;
    }
    dgk+=dw*(x[xs-1-i]-48);
    if (dgk>5223372036854775808.0){
      flag=false;
      break;
    }
    dw*=dc;
  }

  if (flag==true){
    ll w=1;
    ll gk=0;
    for(ll i=0;i<x.size();i++){
      gk+=(x[xs-1-i]-48)*w;
      if (gk>m){
        flag=false;
        break;
      }
      w*=c;
    }
  }

  return flag;
}

int main(){
  ll ans=0;
  cin>>x;
  cin >> m;
  ll mm=m;

  if (x.size()==1){
    if (x[0]-48<=m){
      cout<<1<<endl;
    }else{
      cout<<0<<endl;
    }
    return 0;
  }

  ll mx=0;
  for(ll i=0;i<x.size();i++){
    mx=max(x[i]-48LL,mx);
  }

  if (x.size()==2){
    m-=(x[1]-48);
    ll s=(x[0]-48);
    ans=m/s;
    ans-=mx;
    cout<<ans<<endl;
    return 0;
  }

  if (x.size()>=3){
    ans=-9910000;
    int fflag=0;
    for(__int128_t i=2;i<1000002;i++){
      __int128_t gk=0;
      int flag=0;
      for(ll j=0;j<x.size();j++){
        gk*=i;
        gk+=(x[j]-48);
        if (gk>m)flag=1;
      }
      if (flag==1){
        ans=i-1-mx;
        fflag=1;
        break;
      }
    }
    if (fflag==1){
      if (ans<0)ans=0;
      cout<<ans<<endl;
      return 0;
    }
  }

  if (x.size()==3){
    x[0]-=48;
    x[1]-=48;
    x[2]-=48;

    double s4ac=(double)x[1]*(double)x[1]-4.0*(double)x[0]*(double)((double)x[2]-(double)m);
    if (s4ac<0){
      cout<<0<<endl;
      return 0;
    }
    s4ac=sqrt(s4ac);
    double niji=(double)(-(double)x[1]+s4ac)/(2.0*(double)x[0]);
    //cout<<niji<<endl;
    ll erm=1.0*niji;

    ll pm=1;
    ans=mx;
    if (x[0]*erm*erm+x[1]*erm+x[2]>m)pm=-1;

    for(ll i=0;i<2000000;i++){
      if (x[0]*erm*erm+x[1]*erm+x[2]<=m){
        ans=erm;
        if (pm==-1)break;
      }else{
        if (pm!=-1)break;
      }
      erm+=pm;
    }
    ans=ans-mx;
    if (ans<0)ans=0;

    x[0]+=48;
    x[1]+=48;
    x[2]+=48;

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

  /*
455
1234567890123456
  */

/*

  m=mm;
  //2分岐探索
  ll ok=mx;//解が存在する値
  ll ng=10000000000;//解が存在しない値
  while(abs(ok-ng)>1)
  {
    ll mid=(ok+ng)/2;
    //cout<<mid<<endl;
    if (solve(mid))//これを満たす最小のmidがokになる
    {
      ok=mid;
    }
    else
    {
      ng=mid;
    }
  }
  //okの値を使う
  ll ans2=ok-mx;

  if (ans!=ans2){
    print2(ans,ans2);
  }
*/

  cout<<ans<<endl;
  return 0;
}
/*
100000000000000000000000000000000000000000000000000000000000
10

*/

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<time.h>
#include<deque>
#include<cstring>
#define ll  long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define pf push_front
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define M 5000005
#define endl "\n"
#define AC ios::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll dp[105][105][105]={0};
int n,a[105];
ll modd(ll x,ll y){
    if(y==1) return 0;
    ll r=x%y;
    if(r<0) return r+y;
    return r;
}
signed main(){
    AC;
    ll ans=(1e18);
    ll x;
    cin>>n>>x;

    FOR(i,0,n){
        cin>>a[i];
    }

    FOR(i,0,105)FOR(j,0,105)FOR(k,0,105) dp[i][j][k]=-INF;
    FOR(i,0,105) dp[i][0][0]=0;

    FOR(c,1,n+1){
        FOR(i,0,n){
            for(int j=c;j>0;j--){
                FOR(k,0,c){
                    dp[c][j][k]=max(dp[c][j][k],a[i]+dp[c][j-1][modd(k-a[i],c)]);
                }
            }
        }
    }

    FOR(c,1,n+1){
        ll m=x%c;
        ll now=(x-dp[c][c][m])/c;
        if(dp[c][c][m]>0) ans=min(ans,now);
    }
    cout<<ans<<endl;
}


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

int main(){
    int a ,b;
    double ans = 0.0;

    cin >> a >> b;

    ans = (double) (a - b) /(double) a * 100;

    cout << ans << endl;
}

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

constexpr long long mod=998244353;

long long fpow(long long a,long long b){
    long long z=1;
    while(b){
        if(b&1)z=z*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return z;
}

long long inv(long long x){
    return fpow(x,mod-2);
}

main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N,M;
    cin>>N>>M;
    vector<vector<long long> > ans(M+1,vector<long long > (20,0));
    for(int i=1;i<=M;i++){
        ans[i][0]=1;
        for(int j=2*i;j<=M;j+=i){
            for(int k=1;k<N&&k<20;k++){
                ans[j][k]=(ans[j][k]+ans[i][k-1])%mod;
            }
        }
    }
    vector<long long > jc(N+1);
    jc[0]=1LL;
    for(int i=1;i<=N;i++){
        jc[i]=(jc[i-1]*i)%mod;
    }
    function<long long(int,int) > C=[&](int b,int t ){
        return (jc[b]*inv(jc[t])%mod)*inv(jc[b-t])%mod;
    };
    long long cans=0;
    for(int i=1;i<=M;i++){
        for(int j=0;j<N&&j<20;j++){
            cans=(cans+C(N-1,j)*ans[i][j]%mod)%mod;
        }
    }
    cout<<cans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<long long > printDivisors(ll int n)
{ vector<long long > v;
for (ll int i = 1; i <= sqrt(n); i++)
 { if (n % i == 0) {
if (n / i == i)
v.push_back(i);
else {
v.push_back(i);
v.push_back(n / i);
}
}
}
      return v;
}
int  main()
{

	ll int n;
	cin>>n;
	//input ppart has been done
	vector<long long > divisors = printDivisors(2*n);
	// ao(divisors);
	int count=0;
	for(int t=0;t<=divisors.size();t++){
		ll int i=divisors[t];
		if(i==0){
			continue;
		}
		if(i>2*n){
			break;
		}
		if(((2*n/i)-i+1)%2==0){
			// cout<<i<<" ";
			// cout<<(2*n/i)-i+1<<endl;
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repe(i,a,b) for(ll i=a;i<=b;++i)
#define revlp(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#define sz(x) (ll)(x).size()
#define endl '\n'
typedef long long ll;        typedef long double ld;
typedef pair<ll,ll> pi;     typedef vector<ll> vi;
typedef vector<pi> vpi;       typedef vector<vi> graph;
long long mod=1000000007;     long double EPS=1e-9;
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif

void solve(){
    ll n;
    cin>>n;
    vector<ll> factors;
    for(ll i=1;i*i<=n;i++){
      if(n%i==0){
        ll d1=i;
        ll d2=n/i;
        if(d1!=d2){
          factors.EB(d1);
          factors.EB(d2);
        }
        else factors.EB(d1);
      }
    }
    ll ans=0;
    for(auto x:factors){
      ll nn=2*x;
      ll d2=n/x;
      ll a=d2-(nn-1);
      if(abs(a)%2==0) ans++;
    }
    cout<<2*ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout<<fixed<<setprecision(15);
    //clock_t begin = clock();
    ll tc=1;//cin>>tc;
    for(ll i=1;i<=tc;i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    // clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define vec(a, y, x) vector<vector<char>> a(y, vector<char>(x))
using P = pair<int, int>;
using T = tuple<int, int, int>;
const double PI = 3.14159265358979323846;
const in MOD = 1000000007;
const in INF = 1e18 + 7;
const int inf = 1e9 + 7;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
//cout << fixed << setprecision(10);

int main(void)
{
    in n;
    cin>>n;
    int rank=0;
    in ans =0;
    in nani = n/pow(10,3);//1
    if(nani>0)
        rank++;

    nani = nani / pow(10, 3);//2
    if (nani > 0)
        rank++;

    nani = nani / pow(10, 3);//3
    if (nani > 0)
        rank++;

    nani = nani / pow(10, 3);//4
    if (nani > 0)
        rank++;
    nani = nani / pow(10, 3);//5
    if (nani > 0)
        rank++;

    if(rank == 1){
        ans+=n-999;
    }
    if(rank >=2){
        ans+=pow(10,6) - pow(10,3);
    }
    if(rank == 2){
        ans+=(n+1-pow(10,6))*2;
    }

    if (rank >= 3)
    {
        ans += (pow(10, 9) - pow(10, 6))*2;
    }
    if (rank == 3)
    {
        ans += (n + 1 - pow(10, 9))*3;
    }

    if (rank >= 4)
    {
        ans += (pow(10, 12) - pow(10, 9))*3;
    }
    if (rank == 4)
    {
        ans += (n + 1 - pow(10, 12))*4;
    }

    if(rank == 5){
        ans += 5;
        ans += (pow(10, 15) - pow(10, 12)) * 4;
    }
    cout<<ans<<endl;
    //cout<<rank<<endl;
}


#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

///////// combination
const ll N = 200007;
ll fac[N],finv[N],inv[N];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

ll COM(ll n, ll k){
    if(n < k or n < 0 or k < 0) return 0;
    k = min(n - k, k);
    ll ret = finv[k]; // for() modpow(a, mod - 2);
    for(ll r=n-k+1;r<=n;r++){
        ret *= r;
        ret %= mod;
    }
    return ret;
}

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

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

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

    cominit();
    ll n, m;
    cin >> n >> m;
    vector<vector<mint> > dp(15, vector<mint> (m + 1, mint(0)));
    rep(i, 15){
        if(i == 0){
            for(ll j=0;j<=m;j+=2) dp[i][j] = mint(com(n, j));
            continue;
        }
        ll p = modpow(2LL, ll(i));
        for(ll j=0;j<=m;j+=2){
            for(ll k=0;k<=n;k+=2){
                if(k*p > j) break;
                dp[i][j] += dp[i - 1][j - k*p] * mint(com(n, k));
            }
        }
    }
    cout << dp[14][m].x << endl;
    return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

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

void d_err() {
    cerr << endl;
}

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

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

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

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

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

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

    string s; cin >> s;
    ll m; cin >> m;

    ll d = 0;
    for (auto &e: s) d = max(d, ll(e - '0'));
    d++;

    if (s.size() == 1) {
        if (s[0] - '0' <= m) print(1);
        else print(0);
        return 0;
    } else {
        auto check = [&](ll b) -> bool {
            ll cur = 0;
            for(auto &e: s) {
                if (cur > 0) {
                    ld val = log10(cur) + log10(b);
                    if (val >= 18.1) return false;
                }
                cur *= b;
                cur += e - '0';
            }

            return cur <= m;
        };

        if (not check(d)) {
            print(0);
            return 0;
        }

        ll ok = d, ng = m + 5;
        while(ng - ok > 1) {
            ll mid = (ok + ng) / 2;
            if (check(mid)) ok = mid;
            else ng = mid;
        }

        print(ok - d + 1);
    }

}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define int long long
#define ull unsigned long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<int, int>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define SZ(x) ((int)(x.size()))
#define LC (id<<1)
#define RC (id<<1|1)

constexpr int N = 1e6+9;
constexpr int M = 1e9+7;
#ifdef int
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;
#else
constexpr int INF = 0x3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcf;
#endif

signed main() {
    fastio;
    int n;
    cin >> n;
    vector<int> a(n), b(n), p(n);
    for (auto& x: a) cin >> x;
    for (auto& x: b) cin >> x;
    for (auto& x: p) cin >> x, x--;
    for (int i = 0; i < n; i++) {
        if (b[p[i]] >= a[i] && p[i] != i) {
            cout << -1 << "\n";
            return 0;
        }
    }
    vector<int> vis(n, 0);
    vector<pii> ans;
    for (int i = 0; i < n; i++) {
        if (vis[i]) continue;
        if (p[i] == i) continue;
        vector<int> v;
        int u = i;
        int start = i;
        while (p[u] != i) {
            vis[u] = 1;
            v.emplace_back(u);
            u = p[u];
            if (a[u] > a[start])
                start = u;
        }
        vis[u] = 1;
        while (p[start] != start) {
            if (b[p[start]] >= a[start]) {
                cout << -1 << "\n";
                return 0;
            }
            ans.emplace_back(start, p[start]);
            swap(p[start], p[p[start]]);
        }
    }
    cout << SZ(ans) << "\n";
    for (auto& [x, y]: ans)
        cout << x+1 << " " << y+1 << "\n";
    return 0;
}

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

const int maxn = 200010;
int n, a[maxn], b[maxn], c[maxn], p[maxn];
bool vis[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &b[i]);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i]), c[i] = b[p[i]];
    }
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; i++) if (!vis[i]) {
        vector<int> V;
        for (int j = i; !vis[j]; j = p[j]) V.push_back(j), vis[j] = 1;
        if (V.size() == 1) continue;
        int mx = 0;
        for (int x : V) if (a[x] > a[mx]) mx = x;
        for (int j = 0; j < V.size(); j++) if (a[V[j]] == a[mx]) {
            for (int k = (j + 1) % V.size(); k ^ j; ++k %= V.size()) {
                if (a[V[j]] <= c[V[j]]) printf("-1\n"), exit(0);
                if (a[V[k]] <= c[V[k]]) printf("-1\n"), exit(0);
                ans.emplace_back(V[j], V[k]);
                swap(c[V[j]], c[V[k]]);
            }
            break;
        }
    }
    printf("%d\n", ans.size());
    for (auto p : ans) printf("%d %d\n", p.first, p.second);
    return 0;
}


// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

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

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
    return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
    return n = n | (1LL << pos);
}

vector < ll > g[200005];

struct BIT
{
    vector < ll > tree;
    ll n;

    BIT(ll n) : n(n), tree(n + 3, 0) {}

    void init()
    {
        tree.assign(n + 3, 0);
    }

    ll query(ll idx)
    {
        ll sum=0;
        while(idx>0)
        {
            sum+=tree[idx];
            idx -= idx & (-idx);
        }
        return sum;
    }

    void update(ll idx, ll x) //n is the size of the array, x is the number to add
    {
        while(idx<=n)
        {
            tree[idx]+=x;
            idx += idx & (-idx);
        }
    }
} bit(200002);

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> m >> k)
    {
        ans = 0;

        for(ll i = 1; i <= m; i++) g[i].clear();

        bool on = 0;

        for(ll i = 1; i <= k; i++)
        {
            ll u, v;

            cin >> u >> v;

            g[v].pb(u);
        }

        bit.init();

        for(ll i = 1; i <= m; i++)
        {
            sort(g[i].rbegin(), g[i].rend());

            if(i == 1 && !g[i].empty())
            {
                for(ll j = g[i].back(); j <= n; j++)
                {
                    bit.update(j,1);
                    ans++;
                }

                continue;
            }

            if(!g[i].empty() && g[i].back() == 1) on = 1;
			ll lim = 2e5 + 1;

            if(on)
            {
				for(auto it: g[i])
				{
					ll x = bit.query(it);
					if(it > 1)  x -= bit.query(it - 1);
					if(x == 0) bit.update(it,1);
				}

				ans += bit.query(lim);
            }
            else
            {
                for(auto it: g[i])
                {
                    ans++;

                    ll obs = bit.query(lim) - bit.query(it);

                    ans += obs;

                    ll x = bit.query(it);
					if(it > 1)  x -= bit.query(it - 1);
					if(x == 0) bit.update(it,1);

                    lim = it - 1;
                }

            }

//            cout << ans << "\n";

        }

        ans = (n * m) - ans;

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

}

#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class K, class V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int r, c, n; cin >> r >> c >> n;
    vector<ar<int,2>> a(n);
    vector<int> rb(r + 1, c), cb(c + 1, r);
    for (auto &[x, y] : a) {
        cin >> x >> y;
        rb[x] = min(rb[x], y - 1);
        cb[y] = min(cb[y], x - 1);
    }
    ll ans = 0;
    for (int i = 1; i <= rb[1]; i++) ans += cb[i]; // all squares that can be reached by right-down
    vector<ar<int,2>> v;
    for (int i = 2; i <= cb[1]; i++) v.push_back({rb[i], i});
    sort(v.begin(), v.end());
    ordered_set<int> os;
    for (int i = 0, j = 0; i < v.size(); i++) {
        while (j < min(v[i][0], rb[1])) os.insert(cb[++j]);
        int dup = os.size() - os.order_of_key(v[i][1]);
        ans += rb[v[i][1]] - dup;
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tc = 1;
    // cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


// Problem : A - A*B*C
// Contest : AtCoder - AtCoder Regular Contest 113
// URL : https://atcoder.jp/contests/arc113/tasks/arc113_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#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,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define bug(x) cout<<#x<<"="<<x<<endl;
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_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

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const ld pii=3.14159265359;
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy

//TWO POINTERS APPLICABLE??????
//CHECK EDGE CASES, ALWAYS
void solve()
{
	ll N;cin>>N;
	ll ans=0;
	FOR(x,1,N+1){
		FOR(y,1,N+1){
			if(x*(ll)y>N)break;
			ans+=N/(x*(ll)y);
		}
	}
	cout<<ans;
}

int main()
{
	// think two times, so you won't have to code three times
	ios_base::sync_with_stdio(0); cin.tie(0);
	int Test_case=1;
	// cin>>Test_case;
	while(Test_case--!=0)
	{
		solve();
	}
	return 0;
}
// template by bqi343

#include <stdio.h>
#include <string.h>
#include <vector>
#include <set>
#include <queue>
#include <string>
#include <map>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <iostream>
#include <memory>
//防掉rating提示：想好正确的算法，错误的算法是不能通过的。任何题目都有可能难倒你，所以如果你短时间内想不到算法，放弃这题。
#include <cstdio>
const int MAXN = 200010;
int numbers[MAXN];
char word[MAXN];
std::string word_tag = "110";
int main()
{
	int t;
	int n;
	//freopen("in.txt", "r", stdin);
	//scanf("%d", &t);
	//while (t--)
	{
		scanf("%d", &n);
		scanf(" %s", word);
		long long res = 10000000000ll;
		if (n == 1) {
			if (word[0] == '0') {

			}
			else {
				res *= 2;
			}
			printf("%lld\n", res);
			return 0;
		}
		long long num_110_cnt = 1;
		int begin_pos = -1;
		for (int i = 0; i <= 2; i++) {
			int next = (i + 1) % 3;
			if (word_tag[i] == word[0] && word_tag[next] == word[1]) {
				begin_pos = i;
				break;
			}
		}
		if (begin_pos == -1) {
			printf("0\n");
			return 0;
		}
		bool tag = true;
		for (int i = begin_pos; i < begin_pos + n; i++) {
			if (i % 3 == 0 && i > 0) {
				num_110_cnt++;
			}
			if (word[i - begin_pos] != word_tag[i % 3]) {
				tag = false;
				break;
			}
		}
		if (!tag) {
			printf("0\n");
		}
		else {
			printf("%lld\n", res - num_110_cnt + 1);
		}
		/*printf("debug\n", res);
		for (long long i = 2; i <= n; i++) {
			printf("%lld\n", res % i);
		}*/
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define endl "\n"

using namespace std;

const int max_n = 105;
const int max_k = 22;
const int off_set = 1e5+5;
const int max_A = 55;
const int Mod = 1e9+7;
const long long inf = 1e18;

vector<vector<int> > mul(vector<vector<int> >& a,vector<vector<int> >& b){
    vector<vector<int> > c(a.size(),vector<int>(b[0].size(),0));

    for(int i=0;i<a.size();i++){
        for(int j=0;j<b[0].size();j++){
            for(int k=0;k<a[0].size();k++){
                c[i][j]+=(a[i][k]*b[k][j])%Mod;
                c[i][j]%=Mod;
            }
        }
    }

    return c;
}

vector<vector<int> > power(vector<vector<int>>& a,int b){
    if(b==0){
        vector<vector<int> > ans(a.size(),vector<int>(a[0].size(),0));
        for(int i=0;i<a.size();i++){
            ans[i][i]=1;
        }
        return ans;
    }
    vector<vector<int> > temp = power(a,b/2);
    temp = mul(temp,temp);

    if(b%2==0){
        return temp;
    }else{
        return mul(a,temp);
    }
}

int power_int(int a,int b){
    if(b==0) return 1;
    int temp = power_int(a,b/2)%Mod;
    if(b%2==0){
        return (temp*temp)%Mod;
    }else{
        return (a*((temp*temp)%Mod))%Mod;
    }
}

int n,m,k;
int a[max_n];
vector<int> adj[max_n];

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++) cin>>a[i];

    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;x--;y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    vector<vector<int> > T(n,vector<int>(n,0));

    int inverse_2 = power_int(2,Mod-2);
    int inverse_m = power_int(m,Mod-2);

    for(int i=0;i<n;i++){
        int deg = adj[i].size();

        T[i][i]=((m-deg)*power_int(m,Mod-2))%Mod;
        int other = (deg*power_int(2*m,Mod-2))%Mod;

        T[i][i] = (T[i][i]+other)%Mod;

        for(int y:adj[i]){
            T[i][y]=(inverse_2*inverse_m)%Mod;
        }
    }

    T = power(T,k);

    vector<vector<int>> V(n,vector<int>(1,0));
    for(int i=0;i<n;i++){
        V[i][0]=a[i];
    }

    T = mul(T,V);

    for(int i=0;i<n;i++){
        cout<<T[i][0]<<endl;
    }

}

#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>
#include <list>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 1000000007;
const ll inf = 100000000;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % mod;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % mod;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

ll inverse(ll n){
    return pow(n,mod-2);
}

void pline(vector<ll> lis){
    rep(i,0,lis.size()){
        printf ("%lld",lis[i]);
        if (i != lis.size()-1) printf(" ");
        else printf("\n");
    }
}

vector<vector<ll>> matrix_mul(vector<vector<ll>> A,vector<vector<ll>> B){
    vector<vector<ll>> ans(A.size(),vector<ll> (B[0].size(),0));

    rep(ai,0,A.size()){
        rep(bj,0,B[0].size()){

            ll now = 0;
            rep(same,0,A[0].size()){
                now += A[ai][same] * B[same][bj];
                now %= mod;
            }

            if (mod > 0){
                ans[ai][bj] = now % mod;
            }else{
                ans[ai][bj] = now;
            }
        }
    }

    return ans;
}

vector<vector<ll>> matrix_pow(vector<vector<ll>> A,ll x){
    vector<vector<ll>> B(A.size(),vector<ll> (A[0].size(),0));
    rep(i,0,A.size()){
        rep(j,0,A[0].size()){
            B[i][j] = A[i][j];
        }
    }

    vector<vector<ll>> ans(A.size(),vector<ll> (A[0].size(),0));
    rep(i,0,A.size()) ans[i][i] = 1;

    while (x > 0){
        if (x % 2 == 1){
            ans = matrix_mul(ans,B);
        }
        B = matrix_mul(B,B);
        x /= 2;
    }
    return ans;
}

int main(){

    ll N,M,K;
    cin >> N >> M >> K;

    vector<vector<ll>> A(1,vector<ll> (N));
    rep(i,0,N) cin >> A[0][i];

    vector<ll> enu(N,0);
    vector<vector<ll>> XY(0);

    rep(i,0,M){
        ll X,Y;
        cin >> X >> Y;
        X--;Y--;

        XY.push_back({X,Y});
        enu[X] += 1;
        enu[Y] += 1;
    }

    ll invM = inverse(M);
    ll half = inverse(2);

    vector<vector<ll>> H(N,vector<ll> (N,0));

    rep(i,0,N){
        H[i][i] += (M-enu[i]) * invM;
        H[i][i] %= mod;
        H[i][i] += ((enu[i] * invM) % mod) * half;
        H[i][i] %= mod;
    }

    rep(i,0,XY.size()){
        ll X,Y;
        X = XY[i][0]; Y = XY[i][1];

        H[X][Y] += (invM * half) % mod;
        H[Y][X] += (invM * half) % mod;
        H[X][Y] %= mod;
        H[Y][X] %= mod;

    }

    vector<vector<ll>> ans = matrix_mul(A,matrix_pow(H,K));
    rep(i,0,N){
        cout << ans[0][i] << '\n';
    }
}