#include <iostream>
#include <cmath>
#include <string>
#include <array>
#include <queue>

using namespace std;

#define ll long long int

 int max(int a, int b){
    if (a<=b)
    {
        return b;
    }
    else{
        return a;
    }
}

void solve(){
   ll n;
    cin>>n;
    ll a[n];
    ll p[n];
    ll maxval;
    ll add;
    ll prev;
    ll prev1;
    ll x[n];
    prev=0;
    add = 0;
    maxval = 0;
    prev1=0;
    //out<<maxval<<add<<prev;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        maxval = max(maxval, a[i]);
        add+=a[i];
        p[i] = add;
        //prev = p[i];
        x[i] = p[i]+prev1;
        prev1=x[i];
        //cout<<p[i];
        cout<<x[i]+((i+1)*maxval)<<endl;
    }

    for (int i = 0; i < n; ++i)
    {

    }
}

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

    ll t;
    t= 1;
    for(int i = 0; i<t; i++){
        solve();
            }
    return 0;
}

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

#include <bits/stdc++.h>

#include <utility>

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

#define pb push_back

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

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

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

#ifndef ONLINE_JUDGE

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

#ifdef _getchar_nolock
#else
#    define _getchar_nolock getchar_unlocked
#endif

#define integer ll

integer mod = 1e9 + 7;

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

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

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

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

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

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

#define solvsh
//#define multi

#ifdef solvsh

//#define int ll

const int MAXN = 5e3 + 32;

void solve() {

    int n;
    cin >> n;

    vector<int> v;

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

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

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

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

#else

#endif

void multisolve() {

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

    int t;

    cin >> t;

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

#ifndef ONLINE_JUDGE

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

}

#endif

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

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

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


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
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;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

const int mod = 998244353;
struct mint {
    ll x;
    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;
    }
    mint inv() const {return pow(mod - 2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

mint solve(int n, int m, int k) {
    if (n == 1 || m == 1) return mint(k).pow(m + n - 1);
    mint ans = 0;
    for (int x = 1; x <= k; x++) {
        ans += (mint(x).pow(n) - mint(x - 1).pow(n)) * mint(k - x + 1).pow(m);
    }
    return ans;
}

int main() {
    int n, m, k; cin >> n >> m >> k;
    cout << solve(n, m, k) << endl;
}

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

#define ll long long int
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pair<int, int> >
#define REP(i,a,b) for (int i = a; i <= b; i++)

const int mod = 1e9 + 7;
const int INF = INT_MAX;
const int NINF = INT_MIN;

int a, b, c;

void Solve() {
    cin>>a>>b>>c;
    a = 7 - a;
    b = 7 - b;
    c = 7 - c;
    cout<<(a + b+ c)<<"\n";
}

int main()
{
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

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

    Solve();

    return 0;
}


#include <bits/stdc++.h>

#define lowbit(x) ((x) & (-x))
using namespace std;

typedef long long LL;

const int N = 200005;

int n, e;
int a[N], b[N], c[N], d[N * 4];
LL m, f[N * 4];

void init() {
    memset(f, 0, sizeof(f));
}

void add(int p, int val) {
    for (; p < e; p += lowbit(p)) f[p] += val;
}

LL cal(int p) {
    LL ans = 0;
    for (; p > 0; p -= lowbit(p)) ans += f[p];
    return ans;
}

void gao() {
    e = 0;
    d[e++] = 0;
    for (int i = 0; i < n; i++) {
        d[e++] = a[i], d[e++] = a[i] + 1;
        d[e++] = b[i], d[e++] = b[i] + 1;
    }
    sort(d, d + e);
    e = unique(d, d + e) - d;
    for (int i = 0; i < n; i++) {
        a[i] = lower_bound(d, d + e, a[i]) - d;
        b[i] = lower_bound(d, d + e, b[i]) - d;
        // printf("l= %d, r= %d, c= %d\n", a[i], b[i], c[i]);
    }

    init();
    for (int i = 0; i < n; i++) {
        add(a[i], c[i]);
        add(b[i] + 1, -c[i]);
    }

    LL ans = 0;
    for (int i = 1; i < e - 1; i++) {
        LL tmp = cal(i);
        // printf("i= %d %d %lld %lld\n", i, d[i], tmp, tmp * (d[i + 1] - d[i]));
        ans += min(m, tmp) * (d[i + 1] - d[i]);
    }
    cout << ans << '\n';
}

inline bool scan_d(int &num)
{
        char in;bool IsN=false;
        in=getchar();
        if(in==EOF) return false;
        while(in!='-'&&(in<'0'||in>'9')) in=getchar();
        if(in=='-'){ IsN=true;num=0;}
        else num=in-'0';
        while(in=getchar(),in>='0'&&in<='9'){
                num*=10,num+=in-'0';
        }
        if(IsN) num=-num;
        return true;
}

int main() {
    scan_d(n);
    scanf("%lld", &m);
        for (int i = 0; i < n; i++) scan_d(a[i]), scan_d(b[i]), scan_d(c[i]);
        gao();
    return 0;
}

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

#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define MAXN        200001

typedef tree<int, null_type,
     less_equal<int>, rb_tree_tag,
          tree_order_statistics_node_update>
    Ordered_set;
// s.find_by_order(idx) find using index..!
// s.order_of_key(val) Gives iterator to the key..!

/* First solve then try Writing Code.. And be cool ^_^ and calm. */

int n, a[MAXN];

int go(int l, int r)
{
    if(r < l)
        return 0;
    if(r == l)
        return a[r];
    int idx = l;
    for(int i=l;i<=r;i++)
    {
        if(a[i] < a[idx])
            idx = i;
    }

    int fi = go(l, idx-1);
    int se = go(idx+1, r);

    if(a[idx]*(r-l+1) > max(fi, se))
        return a[idx]*(r-l+1);
    else
        return max(fi, se);
}

void solve(){

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

    cout<<go(0, n-1)<<endl;
}

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

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  int n;cin>>n;
  int a[n],b[n],c[n],d[n],e[n];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i]>>e[i];
  }
  int minn=0;int maxx=1e9;int ans=0;
  while(minn<=maxx){
    int midd=minn+(maxx-minn)/2;
    /*int cnt[32];
    for(int i=0;i<32;i++){
      cnt[i]=0;
    }*/
    set<int>cnt;
	for(int i=0;i<n;i++){
      int val=0;
      if(a[i]>=midd)val=(val|(1<<4));
      if(b[i]>=midd)val=(val|(1<<3));
      if(c[i]>=midd)val=(val|(1<<2));
      if(d[i]>=midd)val=(val|(1<<1));
      if(e[i]>=midd)val=(val|(1<<0));
      cnt.insert(val);
    }
    int f=0;
    /*for(int i=0;i<32;i++){
      if(cnt[i]==0)continue;
      if(i==31 && cnt[i]>=3){
        f=1;break;
      }
      for(int j=i+1;j<32;j++){
        if(cnt[j]==0)continue;
        int val=(i|j);
        if(cnt[i]+cnt[j]>=3 && val==31){
          f=1;break;
        }
        for(int k=j+1;k<32;k++){
          if(cnt[k]==0)continue;
          val=(val|k);
          if(val==31){
            f=1;break;
          }
        }
        if(f==1)break;
      }
      if(f==1)break;
    }*/
    for(int x:cnt){
      for(int y:cnt){
        for(int z:cnt){
          if((x|y|z)==31){
            f=1;break;
          }
        }
        if(f==1)break;
      }
      if(f==1)break;
    }
    if(f==1){
      ans=max(ans,midd);
      minn=midd+1;
    }
    else maxx=midd-1;
  }
  cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define mem(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << #x << " = " << x << endl
#define fi(i, l, r) for (int i = l; i < r; i++)
#define cd(a) scanf("%d", &a)
typedef long long ll;
map<ll, bool> mp; //防止重复计算
int main()
{
    ll n, s = 0;
    cin >> n;
    ll k = sqrt(n);
    for (ll a = 2; a <= k; a++) //底数从2枚举到√n
    {
        ll b = 2; //指数从2开始枚举
        while (1)
        {
            ll c = pow(a, b);
            if (c > n) //当a^b大于n时，结束循环
                break;
            if (!mp[c]) //如果还没有出现过
            {
                mp[c] = 1; //记录下这个可展开数
                s++;
            }
            b++;
        }
    }
    printf("%lld\n", n - s);
    return 0;
}


#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<pair<ll, int>> xs, ys;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        xs.push_back({x, i});
        ys.push_back({y, i});
    }
    sort(ALL(xs));
    sort(ALL(ys));
    vector<pair<ll, ll>> ans;
    ans.push_back({xs[xs.size() - 1].first - xs[0].first, xs[xs.size() - 1].second * 100000ll + xs[0].second});
    ans.push_back({xs[xs.size() - 2].first - xs[0].first, xs[xs.size() - 2].second * 100000ll + xs[0].second});
    ans.push_back({xs[xs.size() - 1].first - xs[1].first, xs[xs.size() - 1].second * 100000ll + xs[1].second});

    ans.push_back({ys[ys.size() - 1].first - ys[0].first, ys[ys.size() - 1].second * 100000ll + ys[0].second});
    ans.push_back({ys[ys.size() - 2].first - ys[0].first, ys[ys.size() - 2].second * 100000ll + ys[0].second});
    ans.push_back({ys[ys.size() - 1].first - ys[1].first, ys[ys.size() - 1].second * 100000ll + ys[1].second});

    sort(ALL(ans), greater<pair<ll, ll>>());
    ll id = ans[0].second;
    rep(i, ans.size())
    {
        if (ans[i].second != id)
        {
            cout << ans[i].first << endl;
            return 0;
        }
    }
}

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

#define int long long
#define double long double
#define pii pair<int, int>

const int N = 1e5 + 5;

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

  int n;
  cin >> n;
  vector<pii> vx, vy, v;

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

  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());

  set<int> s;
  s.insert(vx[0].second);
  s.insert(vx[1].second);
  s.insert(vx[n - 1].second);
  s.insert(vx[n - 2].second);

  s.insert(vy[0].second);
  s.insert(vy[1].second);
  s.insert(vy[n - 1].second);
  s.insert(vy[n - 2].second);

  vector<int> q;

  for (auto it: s) {
    q.push_back(it);
  }

  vector<int> dist;
  for (int i = 0; i < q.size(); i++)
    for (int j = i + 1; j < q.size(); j++) {
      dist.push_back(max(
        abs(v[q[i]].first - v[q[j]].first),
        abs(v[q[i]].second - v[q[j]].second)
      ));
    }

  sort(dist.begin(), dist.end());
  dist.pop_back();

  cout << dist.back();
}


#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on
struct in {
    template <class T> operator T() {
        T t;
        std::cin >> t;
        return t;
    }
};
void out() { std::cout << "\n"; }
template <class Head, class... Tail> void out(Head &&h, Tail &&... t) {
    std::cout << h << (sizeof...(Tail) == 0 ? "" : " "), out(std::forward<Tail>(t)...);
}

/**
 *    author:  knshnb
 *    created: Sat Oct 24 21:04:11 JST 2020
 **/

struct UnionFind {
    int cnt;                  // 集合の数
    std::vector<int> number;  // 0以上のとき親のindex, 負のときは集合サイズ
    std::vector<Int> a, b;
    UnionFind(int n) : cnt(n), a(n), b(n), number(n, -1) {}
    int root(int x) { return number[x] < 0 ? x : number[x] = root(number[x]); }
    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (number[y] < number[x]) std::swap(x, y);
        // yをxにマージ
        a[x] += a[y];
        b[x] += b[y];
        number[x] += number[y];
        number[y] = x;
        cnt--;
    }
    bool is_same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -number[root(x)]; }
};

signed main() {
    Int n = in(), m = in();
    UnionFind uf(n);
    REP(i, n) std::cin >> uf.a[i];
    REP(i, n) std::cin >> uf.b[i];
    REP(i, m) {
        Int u = (Int)in() - 1, v = (Int)in() - 1;
        uf.unite(u, v);
    }
    REP(i, n) {
        Int r = uf.root(i);
        if (uf.a[r] != uf.b[r]) {
            out("No");
            return 0;
        }
    }
    out("Yes");
}

#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

using namespace std;

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

constexpr ll MOD = 1000000007;

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

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

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

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

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

    ll a,b,w;
    IN(a,b,w);

    w*=1000;

    ll amin, amax;

    amin = 1000001;
    amax = -1;

    repr(i, 1, 1000001){

        if(i*a <= w && w <= i*b){
            amin = min(amin, i);
            amax = max(amax, i);
        }
    }

    if(amax == -1){
        cout << "UNSATISFIABLE" << endl;
        return 0;
    }

    cout << amin << " " << amax;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
struct Edge {
    int to;
    int cost;
    Edge(int t, int c) : to(t), cost(c) {}
};
using edge = struct {
    long long to;
    long long cost;
};
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int cnt[101010];
bool good[101010];

void dfs(const Graph& g, int c, int parent, const vector<int>& C) {
    if (cnt[C[c]] == 0) good[c] = true;
    cnt[C[c]]++;
    for (auto next_v : g[c]) {
        if (next_v == parent) continue;
        dfs(g, next_v, c, C);
    }
    cnt[C[c]]--;
}
int main() {
    int N;
    cin >> N;
    vector<int> C(N + 1);
    rep(i, N) cin >> C[i + 1];
    Graph g(N + 1);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(g, 1, -1, C);
    rep(i, N) if (good[i + 1]) cout << i + 1 << endl;
    return 0;
}

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

void dfs(int i, int p, vector<int> &colors, vector<vector<int>> &adj_list, set<int> &used_color, vector<bool> &ans) {
  bool add_color;
  if (used_color.count(colors[i])) {
    add_color = false;
    ans[i] = false;
  } else {
    add_color = true;
    used_color.insert(colors[i]);
  }
  if (i == 0) {
    for (int c : adj_list[0]) {
      dfs(c, 0, colors, adj_list, used_color, ans);
    }
  } else {
    if (adj_list[i].size() == 1) {
      if (add_color) {
        used_color.erase(colors[i]);
      }
      return;
    } else {
      for (int c : adj_list[i]) {
        if (c != p) {
          dfs(c, i, colors, adj_list, used_color, ans);
        }
      }
        if (add_color) {
          used_color.erase(colors[i]);
        }
    }
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  vector<vector<int>> adj_list(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    adj_list[a].emplace_back(b);
    adj_list[b].emplace_back(a);
  }

  set<int> used_color;
  vector<bool> ans(n, true);

  dfs(0, -1, c, adj_list, used_color, ans);

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


#pragma region templates
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using PQ = priority_queue<T>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
constexpr ll dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
inline void Yes() { cout << "Yes" << ENDL; }
inline void No() { cout << "No" << ENDL; }
inline void YES() { cout << "YES" << ENDL; }
inline void NO() { cout << "NO" << ENDL; }

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T>
vector<T> finddivisor(T x) {  //整数xの約数(xを含む)
  vector<T> divisor;
  for(T i = 1; (i * i) <= x; i++) {
    if(x % i == 0) {
      divisor.push_back(i);
      if(i * i != x) { divisor.push_back(x / i);}
    }
  }
  sort(divisor.begin(), divisor.end());
  return divisor;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
T rand(T l,T r){
  static random_device rd;
  static mt19937 g(rd());
  return uniform_int_distribution<T>(l,r)(g);
}

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

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}
#pragma endregion templates

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int qq;cin>>qq;
  while(qq--){
    ll n;cin>>n;
    ll tcnt=0;
    while(n%2==0){
      tcnt++;
      n/=2;
    }

    if(tcnt==1){
      cout<<"Same"<<ENDL;
    }else if(tcnt>1)cout<<"Even"<<ENDL;
    else cout<<"Odd"<<ENDL;
  }
}
//(・_・)(・_・)(・_・)(・_・)
//CHECK overflow,what to output?
//any other simpler approach?

#include<bits/stdc++.h>
#define  ll long long
typedef unsigned long long ull;
using namespace std;
const int Max=1e6+20;
const int Maxn=1e7+20;
const int mod=1e9+7;
const int c=231;
inline int read()
{
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1;}
    while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}
    while(ch>='0'&&ch<='9');return x*f;
}

int main()
{
   int t=read();
   ll n;
   while(t--)
   {
       cin>>n;
       if(n%4==0) cout<<"Even"<<endl;
       else if(n%2==0) cout<<"Same"<<endl;
       else cout<<"Odd"<<endl;
   }
   return 0;

}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 2000000000;
const int MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n){
        if(a[i] <= 10) continue;
        a[i] -= 10;
        ans += a[i];
    }
    cout << ans << endl;
}

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

#define fast_IO             ios_base::sync_with_stdio(0);   cin.tie(0);  cout.tie(0);
#define int                 long long
#define rep(i,a,b)          for (int i = a; i < b; i++)
#define rev(i,n)            for(int i=n-1;i>=0;i--)
#define pii                 pair<int,int>
#define ar(n)               array<int,n>
#define sz(n)               (int)n.size()
#define uniq(v)             (v).erase(unique(v.begin(), v.end()),(v).end())

#ifndef ONLINE_JUDGE
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#else
#define dbg(x)
#endif

const int inf=1e18;
const int32_t M=1e9+7;
const int32_t mxn=1e6+1;

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}

auto clk = clock();
mt19937_64 rang(high_resolution_clock::now().time_since_epoch().count());
void run_time()
{
    cerr << endl;
    cerr << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
    return;
}

/*-------------------------------------solve-----------------------------------------*/

void solve()
{
    int n; cin>>n;
    vector<int> v(n); cin>>v;
    int ans=0;
    rep(i,0,n) if(v[i]>10) ans+=abs(10-v[i]);
    cout<<ans<<endl;
}

int32_t main()
{
     fast_IO
     #ifndef ONLINE_JUDGE
        freopen("error.txt","w",stderr);
     #endif
    int t = 1;
    // cin >> t;

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


#include<bits/stdc++.h>
using namespace std;
long double a,b;
int main(){
    cin>>a>>b;
    cout<<fixed<<setprecision(20)<<100*(a-b)/a;
}/*
00100001000010000100
*/

#include<iostream>
using namespace std;
int main()
{
  float A, B, C;
  float D;
  cin >> A >> B;
  C = A-B;
  D = (C/A)*100.0;
  if(A > B)
    cout << D;
  else
    return -1;
  return 0;
}


#include <bits/stdc++.h>

#define index(i, n) for (long long i = 0; i < n; i++)
#define index1(i, n) for (long long i = 1; i <= n; i++)
#define range(i, a, b) for (long long i = a; i < b; i++)
#define indexD(i, n) for (long long i = n - 1; i >= 0; i--)
#define index1D(i, n) for (long long i = n; i >= 1; i--)
#define rangeD(i, a, b) for (long long i = a - 1; i >= b; i--)
#define ceild(a, b) ((a) / (b) + ((a) % (b) != 0))
#define fast_io std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define print(x) cout << (x) << '\n'
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x, y) cout << '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define trace3(x, y, z) cout << '>' << #x << ':' << x << " | " << #y << ':' << y << " | " << #z << ':' << z << endl;
#define trace4(x, y, z, w) cout << '>' << #x << ':' << x << " | " << #y << ':' << y << " | " << #z << ':' << z << " | " << #w << ':' << w << endl;
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define First first
#define Second second
#define MOD 1000000007
#define INF (9223372034707292159ll)

typedef unsigned long long ull;
typedef long long int ll;

using namespace std;

int main()
{
        fast_io;

        ll t, n, m, k, x, y, r, ans, c;
        ull pow2[21];
        pow2[0] = 1;
        index1(i, 20) { pow2[i] = 2 * pow2[i - 1]; }
        ans = 0;
        cin >> n >> m;
        string s;
        ll even = 0, odd = 0;
        index(i, n)
        {
                cin >> s;
                x = 0;
                index(j, m) x += (s[j] == '1');
                if (x % 2)
                        odd++;
                else
                        even++;
        }
        print((odd * even));
        return 0;
}

#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
int a[2];
int main() {
	int n, m;
	string s;
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		cin >> s;
		int x = 0;
		for(int j = 0; j < m; ++j) {
			x ^= (s[j] - '0');
		}
		a[x]++;
	}
	print(1ll * a[1] * a[0]);
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N;
	bool A[110][110] = {};
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			char c; cin >> c; A[i][j] = c - '0';
		}
	}
	double ans = 0;
	for(int i = 0; i < N; i++){
		bool ok[110] = {};
		ok[i] = true;
		queue<int> que;
		que.push(i);
		while(que.size()){
			int p = que.front();
			que.pop();
			for(int i = 0; i < N; i++){
				if(A[i][p] && !ok[i]){
					ok[i] = true; que.push(i);
				}
			}
		}
		int cnt = 0;
		for(int i = 0; i < N; i++){
			if(ok[i]) cnt ++;
		}
		ans += (double) 1.0 / cnt;
	}
	cout.precision(15);
	cout << ans << "\n";
}

#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (63 - __builtin_clzll(x))
#define SZ(x) ((int)(x).size())
#define HASK(S, x) (S.find(x) != S.end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

typedef pair <int, int> PII;
template <typename T1, typename T2> inline void remin(T1& a, T2 b) { a = min(a, (T1)b);	}

const int maxN = 123;

int n, vis[maxN], cnt[maxN], visCtr;
char G[maxN][maxN];

void dfs(int v)
{
	vis[v] = visCtr;
	cnt[v]++;
	FOR(u, 1, n+1)
		if (G[v][u] == '1' and vis[u] != visCtr)
			dfs(u);
}

void solve()
{
	scanf ("%d", &n);

	FOR(i, 1, n+1)
		scanf ("%s", &G[i][1]);
	FOR(i, 1, n+1)
	{
		visCtr = i;
		dfs(i);
	}
	long double res = 0;
	FOR(i, 1, n+1)
		res += 1.0 / cnt[i];
	printf("%.13Lf\n", res);
}

int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
int a[200002];

signed main() {
	int i;

	cin >> n >> m;
	rep(i, m) cin >> a[i];
	a[m] = 0; a[m + 1] = n + 1;
	m += 2;
	sort(a, a + m);

	int k = n;
	rep(i, m - 1) {
		if (a[i + 1] - a[i] >= 2) {
			k = min(k, a[i + 1] - a[i] - 1);
		}
	}

	int ans = 0;
	rep(i, m - 1) {
		if (a[i + 1] - a[i] >= 2) {
			ans += ((a[i + 1] - a[i] - 1) + k - 1) / k;
		}
	}

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

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

set<int> getFactors(ll n) {
    set<int> st;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            st.insert(i);
            st.insert(n / i);
        }
    }
    return st;
}

void solve() {
    int N, M; cin >> N >> M;
    vector<int> A (M + 2);
    A[0] = 0;
    A[M + 1] = N + 1;
    for (int i = 1; i < M + 1; ++i) cin >> A[i];
    sort( A.begin(), A.end() );

    set<int> factors;
    for (int i = 1; i < M + 2; ++i) {
        int diff = A[i] - A[i - 1] - 1;
        if (diff > 0)
            factors.emplace(diff);
    }

    int ans = INT_MAX;

    int f = *factors.begin();
    int result = 0;
    for (int i = 1; i < M + 2; ++i) {
        int diff = A[i] - A[i - 1] - 1;
        if (diff <= 0) continue;
        if (diff % f != 0) { result++; }
        result += diff / f;
    }
    ans = min(ans, result);

    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    while(t--) {
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'
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 int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int t;
  cin >> t;
  REP(i, t) {
    ll l, r, ans = 0;
    cin >> l >> r;
    if (r - l * 2 >= 0) {
      ans += (r - l * 2 + 2) * (r - l * 2 + 1) / 2;
    }
    cout << ans << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif

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

inline void solve()
{
	int L,R;
	cin>>L>>R;
	if (2*L>R) cout<<0<<endl;
		else cout<<(R-2ll*L+1ll)*(R-2ll*L+2ll)/2ll<<endl;
}

signed main()
{
	ios::sync_with_stdio(false); cout.tie(NULL);
	int t;
	cin>>t;
	for (int i=1;i<=t;i++) solve();
}


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vi2 = vector<vector<ll>>;
using vl = vector<ll>;
using vl2 = vector<vector<ll>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double LPI = acos(-1.0);
const  double PI = acos(-1.0);
const int mod = 1000000007;

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,x) for(ll i=0;i<(int)(x);i++)
#define REPS(i,x) for(ll i=1;i<=(int)(x);i++)
#define RREP(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(ll i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}
template<typename T> bool isPrime(T a){if(a<=1){return false;}
    for(T i=2;i*i<=a;i++){if (a%i==0) {return false;}}return true;}
template<typename T> T ord(T p,T n){T ans=0;while(true){if(n%p==0){n/=p;ans++;}else{break;}}return ans;}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

int main() {
    ll x,y,a,b;
    cin >> x >> y >> a >> b;
    ll ans = 0;
    while (x<=b/(a-1)&&x*a<y) {
        ans++;
        x *= a;
    }
    ans += (y-x-1)/b;
    COUT(ans);

}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll x, y;
  cin >> x >> y;
  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  for (int t = 0; t <= 60; ++t) {
    bool ng = false;
    ll str = x, exp = 0;
    ll cnt = t;
    while ((double)str * a < (double)y && cnt) {
      str *= a;
      exp++;
      cnt--;
    }
    if (cnt != 0) continue;
    ll u = (y - str) / b;
    str += b * u;
    exp += u;
    if (y <= str) {
      exp--;
    }
    ans = max(ans, exp);
  }
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

struct Ad{ll x, y, r, num;};
struct Recang{
    ll x1, y1, x2, y2;
    ll size(){
        return abs(x2-x1)*abs(y2-y1);
    }
};

const int MAX=9999;
int n;
Ad ads[300];
Recang ans[300];

bool overlap(Recang a, Recang b){
    return max(a.x1,b.x1)<min(a.x2,b.x2)&&max(a.y1,b.y1)<min(a.y2,b.y2);
}

bool check(Recang a, int k){
    REP(i,n){
        if(i==k)
            continue;
        if(overlap(a,ans[i]))
            return 1;
    }
    return 0;
}

void solve(){
    cin >> n;
    int x, y, r;
    REP(i,n){
        cin >> x >> y >> r;
        ads[i]=Ad{x,y,r,i};
    }
    sort(ads,ads+n,[](const Ad& a, const Ad& b){return a.r<b.r;});
    REP(i,n){
        Ad ad=ads[i];
        ans[ad.num]={ad.x,ad.y,ad.x+1,ad.y+1};
    }
    REP(i,n){
        Ad ad=ads[i];
        Recang tmpr={ad.x,ad.y,ad.x+1,ad.y+1};
        while(1){
            bool ok=0;
            tmpr.x1--;
            if(tmpr.x1<0||check(tmpr,ad.num)) tmpr.x1++;
            else ok=1;
            if(tmpr.size()>ad.r) break;
            tmpr.y1--;
            if(tmpr.y1<0||check(tmpr,ad.num)) tmpr.y1++;
            else ok=1;
            if(tmpr.size()>ad.r) break;
            tmpr.x2++;
            if(tmpr.x2>MAX||check(tmpr,ad.num)) tmpr.x2--;
            else ok=1;
            if(tmpr.size()>ad.r) break;
            tmpr.y2++;
            if(tmpr.y2>MAX||check(tmpr,ad.num)) tmpr.y2--;
            else ok=1;
            if(tmpr.size()>ad.r) break;
            if(!ok) break;
        }
        ans[ad.num]=tmpr;
    }
    REP(i,n){
        Recang tmpr=ans[i];
        cout << tmpr.x1 << " ";
        cout << tmpr.y1 << " ";
        cout << tmpr.x2 << " ";
        cout << tmpr.y2 << endl;
    }
}

int main(){
    solve();
    return 0;
}

/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 61;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll conbinationMemo[201][12];

void cmemoInit(){
    rep(i, 201){
        rep(j, 12){
            conbinationMemo[i][j] = -1;
        }
    }
}

ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<ll>> pos(2 * 1e6);
    rep(i, 2 * 1e6) pos[i].push_back(-1);
    rep(i, n){
        pos[a[i]].push_back(i);
    }
    rep(i, 2 * 1e6) pos[i].push_back(n);
    ll ans = n;
    rep(i, n){
        rep(j, pos[i].size() - 1){
            if(abs(pos[i][j] - pos[i][j + 1]) > m){
                ans = min(ans, (ll)i);
            }
        }
    }
    cout << ans << endl;

}


#include<bits/stdc++.h>

#define ll long long
#define min(x,y) x<y?x:y
#define max(x,y) x>y?x:y

using namespace std;

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

    while (k--)
    {
        if(n%200==0)
        {
            n=n/200;
        }
        else
        {
            n = (n*1000)+200;
        }
    }
    cout << n <<endl;

}

/**
*    author:  Taichicchi
*    created: 13.04.2021 21:52:36
**/

#include <bits/stdc++.h>

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

using namespace std;

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

int main() {
    int M, H;
    cin >> M >> H;
    cout << ((H % M == 0) ? "Yes" : "No") << endl;
    return 0;
}


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

int main(){
    int mod = 200;
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        int ai; cin >> ai;
        ai %= mod;
        a[i] = ai;
    }

    vector<vector<uint>> b(200);
    n = min(8,n);
    for(uint i = 1; i < (1<<n); i++){
        int ai = 0;
        for(int j = 0; j < n; j++){
            if(i>>j&1) ai = (ai+a[j])%200;
        }
        b[ai].push_back(i);
    }

    bool bl = false;
    int ansi;
    for(int i = 0; i < 200; i++){
        if(b[i].size() > 1){
            bl = true;
            ansi = i;
            break;
        }
    }
    if(bl){
        cout << "Yes" << endl;
        vector<vector<int>> ans(2);
        for(int i = 0; i < 2; i++){
            uint j = b[ansi][i];
            for(int k = 0; k < n; k++){
                if(j>>k&1) ans[i].push_back(k+1);
            }
        }
        for(vector<int> an : ans){
            cout << an.size();
            for(int ani : an) cout << " " << ani;
            cout << endl;
        }
    }
    else cout << "No" << endl;

    /*for(auto bi : b){
        for(auto bij : bi){
            cout << bij << ",";
        }
        cout << endl;
    }*/
    /*auto start = chrono::system_clock::now();
    auto end = chrono::system_clock::now();
    auto dur = end-start;
    auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
    cout << msec << "[ms]" << endl;*/
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ff first
#define ss second
#define pi pair<int, int>

const int MX=300000;
const ll mod=1e9+7;

int dp[100];

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

    int n; cin>>n;

    set<int>st;
    set<int>::iterator it;

    for(int i=1; i<=min(n-2, 1666); i++) st.insert(6*i);

    for(int i=1; ; i++)
    {
        if(st.size()==n-1 || 10*i>10000) break;
        st.insert(10*i);
    }

    for(int i=1; ; i++)
    {
        if(st.size()==n) break;
        st.insert(15*i);
    }

    for(it=st.begin(); it!=st.end(); it++) cout<<*(it)<<' ';
    cout<<endl;

    return 0;
}


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

int n;
string s,t;

bool bo(){
  int s1=0,t1=0;
  rep(i,n){
    if(s[i]=='1') s1++;
    if(t[i]=='1') t1++;
  }
  return (s1==t1);
}

int main(){
  cin >> n >> s >> t;
  vector<int> s1(0);
  vector<int> t1(0);
  rep(i,n){
    if(s[i]=='0') s1.push_back(i);
    if(t[i]=='0') t1.push_back(i);
  }
  int sn=s1.size();
  int tn=t1.size();
  if(sn!=tn) cout << -1 << endl;
  else{
    int ans=0;
    rep(i,sn){
      if(s1[i]!=t1[i]) ans++;
    }
    cout << ans << endl;
  }
}

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int K; string S, T; cin >> K >> S >> T;
    vector<ll> cards(10, K), scards(10, 0), tcards(10, 0);
    for (auto c : S) {
        if (c == '#') break;
        cards[c - '0']--;
        scards[c - '0']++;
    }
    for (auto c : T) {
        if (c == '#') break;
        cards[c - '0']--;
        tcards[c - '0']++;
    }

    vector<ll> multiples(10, 1);
    REP(i, 1, 10) multiples[i] = multiples[i - 1] * 10;

    ll s = 0, t = 0;
    REP(i, 1, 10) {
        s += multiples[scards[i]] * i;
        t += multiples[tcards[i]] * i;
    }
    // cout << "### base : " << s << ", " << t << endl;

    ll win = 0, lose = 0;
    REP(i, 1, 10) {
        if (!cards[i]) continue;
        cards[i]--;
        s -= multiples[scards[i]] * i;
        s += multiples[scards[i] + 1] * i;
        // cout << "# i : " << i << ", s : " << s << endl;
        REP(j, 1, 10) {
            if (!cards[j]) continue;
            t -= multiples[tcards[j]] * j;
            t += multiples[tcards[j] + 1] * j;
            // cout << "# j : " << j << ", t : " << t << endl;
            if (s > t) {
                win += (cards[i] + 1) * cards[j];
            } else {
                lose += (cards[i] + 1) * cards[j];
            }
            t -= multiples[tcards[j] + 1] * j;
            t += multiples[tcards[j]] * j;
        }
        s -= multiples[scards[i] + 1] * i;
        s += multiples[scards[i]] * i;
        cards[i]++;
    }
    // cout << win << ", " << lose << endl;
    cout << fixed << setprecision(15);
    cout << (long double)(win) / (win + lose) << endl;
    return 0;
}


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

int main() {
    int n, m; cin >> n >> m;
    vector<int> h(n), w(m);
    rep(i, n) cin >> h[i];
    rep(i, m) cin >> w[i];
    sort(h.begin(), h.end());
    sort(w.begin(), w.end());
    //左詰での身長差の累積和と右詰での累積和
    vector<int> left, right;
    int lsum = 0, rsum = 0;
    int ans = 1001001001;
    if(h.size() == 1) {
        auto it = lower_bound(w.begin(), w.end(), h[0]);
        int idx = it - w.begin();
        if(it == w.end()) {
            idx = w.size()-1;
        }
        if(idx == 0) {
            ans = abs(h[0] - w[idx]);
        } else {
            ans = min(abs(h[0] - w[idx]), abs(h[0] - w[idx-1]));
        }
        cout << ans << endl;
        return 0;
    }
    for(int i = 0; i < n-1; i += 2) {
        lsum += h[i+1] - h[i];
        rsum += h[i+2] - h[i+1];
        left.push_back(lsum);
        right.push_back(rsum);
    }
    for(int i = 0; i < n; i += 2) {
        int tmp;
        if(i == 0) {
            tmp = right.back();
        }
        else tmp = left[i/2-1] + right.back() - right[i/2-1];
        //先生の分を足す
        auto it = lower_bound(w.begin(), w.end(), h[i]);
        int idx = it - w.begin();
        if(it == w.end()) {
            idx = w.size()-1;
        }
        if(idx == 0) {
            tmp += abs(h[i] - w[idx]);
        } else {
            tmp += min(abs(h[i] - w[idx]), abs(h[i] - w[idx-1]));
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
typedef long long LL;
#define lowbit(x) (x & (-x))

const LL inf  = 1e17+9;
const LL mod  = 1e9+7;
const LL maxn = 2e5+8;

LL n, m, h[maxn], w[maxn], sa[maxn], sb[maxn];

void solve() {
    LL i, j, ans = inf;
    scanf("%lld%lld", &n, &m);
    for (i = 1; i <= n; i++) scanf("%lld", &h[i]);
    for (i = 1; i <= m; i++) scanf("%lld", &w[i]);
    std::sort(h + 1, h + 1 + n);
    for (i = 2; i <= n; i += 2) sa[i] = sa[i - 2] + h[i] - h[i - 1];
    for (i = n - 1; i >= 1; i -= 2) sb[i] = sb [i + 2] + h[i + 1] - h[i];
    for (i = 1; i <= m; i++) {
        LL pos = std::lower_bound(h + 1, h + 1 + n, w[i]) - h;
        if (pos == 0) ans = std::min(ans, sb[2] + abs(h[1] - w[i]));
        else if (pos & 1) ans = std::min(ans, sa[pos - 1] + sb[pos + 1] + abs(h[pos] - w[i]));
        else ans = std::min(ans, sa[pos - 2] + sb[pos] + abs(h[pos - 1] - w[i]));
    }
    printf("%lld\n", ans);
}

signed main() {
    LL t = 1; //scanf("%lld", &t);
    while (t--) solve();
    return 0;
}


#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a; i >-1; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a; i > b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

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

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<128>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll mypow(ll x, ll n, const ll &p = -1)
{ //x^nをmodで割った余り

	if (p != -1)
	{
		x =(x%p+p)%p;
	}
	ll ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;

template<typename T>
struct BIT{
  //0オリジンで与える
  vector<T>bit;
  int N;

  BIT(int n):N(n){
    bit.assign(++n,0);
  }

  T sum(int i){
    T s=0;
    ++i;//0オリジンに対応させる
    while(i>0){
      s+=bit[i];
      i-=i&-i;//iから最後の1のビットを減算
    }
    return s;
  }

  void add(int i,T x){
    ++i;//0オリジンに対応させる
    while(i<(int)bit.size()){
      bit[i]+=x;
      i+=i&-i;
    }
  }

  T Lower_bound(T k){
    if(k<=0)
      return 0;
    T x = 0;
    T mul = 1;
    while (mul<N){
      mul *= 2;
    }
    for (T i = mul; i > 0;i/=2){
      if(x+i<=N&&bit[x+i]<k){
        k -= bit[x + i];
        x += i;
      }
    }
    return x;
  }
};

using P=pair<ll,int>;
void solve()
{
	int n,m,q;
	cin>>n>>m>>q;
	vector<int>t(q),x(q);
	vector<ll>y(q);
	rep(i,q)cin>>t[i]>>x[i]>>y[i],x[i]--;
	vector<ll>prea(n),preb(m);
	vector<int>id(q);
	rep(i,q)id[i]=y[i];
	id.eb(0);
	sort(all(id));

	BIT<ll>a(q+1),b(q+1);
	BIT<int>aid(q+1),bid(q+1);
	aid.add(0,n);
	bid.add(0,m);

	ll ans=0;
	rep(i,q){
		if(t[i]==1){
			int pos=lower_bound(all(id),prea[x[i]])-id.begin();
			ll val=bid.sum(pos)*prea[x[i]];
			val+=b.sum(q+1)-b.sum(pos);
			ans-=val;
			aid.add(pos,-1);
			a.add(pos,-prea[x[i]]);

			prea[x[i]]=y[i];
			pos=lower_bound(all(id),prea[x[i]])-id.begin();
			val=bid.sum(pos)*prea[x[i]];
			val+=b.sum(q+1)-b.sum(pos);
			ans+=val;
			aid.add(pos,1);
			a.add(pos,prea[x[i]]);
		}else{
			int pos=lower_bound(all(id),preb[x[i]])-id.begin();
			ll val=aid.sum(pos)*preb[x[i]];
			val+=a.sum(q+1)-a.sum(pos);
			ans-=val;
			bid.add(pos,-1);
			b.add(pos,-preb[x[i]]);

			preb[x[i]]=y[i];
			pos=lower_bound(all(id),preb[x[i]])-id.begin();
			val=aid.sum(pos)*preb[x[i]];
			val+=a.sum(q+1)-a.sum(pos);
			ans+=val;
			bid.add(pos,1);
			b.add(pos,preb[x[i]]);
		}
		cout<<ans<<"\n";
	}
}

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

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

#define fo(i, x, y) for (int i = (x); i <= (y); ++i)
#define fd(i, x, y) for (int i = (x); i >= (y); --i)

const int maxn = 2e5 + 5, inf = 1e9;

struct edge{int to; edge *nxt;} *arc[maxn], pool[maxn << 1], *pt = pool;
int n, k, len, cnt;
int mi[maxn], mx[maxn];

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

void dfs(int x, int fa)
{
	mi[x] = inf; mx[x] = 0;
	for (edge *e = arc[x]; e; e = e->nxt)
		if (e->to != fa)
		{
			dfs(e->to, x);
			mi[x] = min(mi[x], mi[e->to] + 1);
			mx[x] = max(mx[x], mx[e->to] + 1);
		}
	if (mi[x] + mx[x] <= len)
		mx[x] = -inf;
	else if (mi[x] + mx[x] > len && mx[x] == len)
		mi[x] = 0, mx[x] = -inf, cnt++;
}

bool check(int x)
{
	len = x; cnt = 0;
	dfs(1, 0);
	cnt += (mi[1] + mx[1] > len);
	return cnt <= k;
}

void addedge(int u, int v)
{
	*pt = (edge){v, arc[u]};
	arc[u] = pt++;
}

int main()
{
	n = getint(); k = getint();
	fo(i, 1, n - 1)
	{
		int u, v;
		u = getint(); v = getint();
		addedge(u, v);
		addedge(v, u);
	}
	int l = 0, r = n + 1;
	while (l + 1 < r)
	{
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid;
	}
	printf("%d\n", r);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i=0; i<(ll)(n); i++)
#define rev_rep(i, n) for (ll i=(n); i > 0; i--)
#define REP(i, n) for (ll i=1; i<=(ll)(n); i++)
#define FOR(i, n, m) for (ll i=(n); i<=(ll)(m); i++)
#define rev_FOR(i, n, m) for (ll i=(n); i<=(ll)(m); i--)
#define ll long long
#define vc vector<ll>
#define vc2 vector<vector<ll>>
#define vc3 vector<vector<vector<ll>>>
#define vcd vector<double>
#define vc2d vector<vector<double>>
#define vc3d vector<vector<vector<double>>>
#define vcs vector<string>
#define vc2s vector<vector<string>>
#define vc3s vector<vector<vector<string>>>
#define ALL(vec) vec.begin(),vec.end()
const ll INF=1LL<<60;
const ll mod = 1000000007;
const double pi=3.1415926535;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ox[4] = {1, -1, 1, -1};
const int oy[4] = {1, 1, -1, -1};
template<class T>bool ch_max(T &a, const T &b) {if (a<b) {a = b; return 1; } return 0;}
template<class T>bool ch_min(T &a, const T &b) {if (b<a) {a = b; return 1; } return 0;}

int CrossProduct(vc &a, vc &b, vc &c) {
    return (a[0]-c[0])*(b[1]-c[1])-(a[1]-c[1])*(b[0]-c[0]);
}

int dist(vc &a, vc &b) {
    return (a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]);
}

int main() {
    int N;
    cin >> N;
    vc2 S(N, vc(2)),T(N, vc(2));
    rep(i, N) cin >> S.at(i).at(0) >> S.at(i).at(1);
    rep(i, N) cin >> T.at(i).at(0) >> T.at(i).at(1);
    if(N == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    else if(N == 2) {
        if(dist(S.at(0), S.at(1)) == dist(T.at(0),T.at(1))) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    vc2 dS(N, vc(3));
    rep(i, N) {
        dS.at(i).at(0) = dist(S.at(0),S.at(i));
        dS.at(i).at(1) = dist(S.at(1),S.at(i));
        dS.at(i).at(2) = CrossProduct(S.at(0),S.at(1),S.at(i));
    }
    sort(ALL(dS));
    rep(i, N) {
        rep(j, N) {
            if(i == j) continue;
            vc2 dT(N, vc(3));
            rep(k, N) {
                dT.at(k).at(0) = dist(T.at(i), T.at(k));
                dT.at(k).at(1) = dist(T.at(j), T.at(k));
                dT.at(k).at(2) = CrossProduct(T.at(i), T.at(j), T.at(k));
            }
            sort(ALL(dT));
            /*rep(k, N) {
                cout << dT.at(k).at(0) << " ";
                cout << dT.at(k).at(1) << " ";
                cout << dT.at(k).at(2) << " ";
            }
            cout << endl;
            rep(k, N) {
                cout << dS.at(k).at(0) << " ";
                cout << dS.at(k).at(1) << " ";
                cout << dS.at(k).at(2) << " ";
            }
            cout << endl;
            cout << endl;*/
            if(dT == dS) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <iomanip>

#include <fstream>

using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){fastio
    string s;cin>>s;
    if(s[0]==s[1] && s[1]==s[2]){
        cout<<"Won"<<endl;
    }else{
        cout<<"Lost"<<endl;
    }

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--)

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

	long long int a, b, ans=0;
	cin>>a>>b;
	string s="";
	forr(i, 0, a)
		s+=(i+'0');
	long long int c[a][a];
	forr(i, 0, a)
	{
		forr(j, 0, a)
			cin>>c[i][j];
	}
	do{
		if(s[0]=='0')
		{
			int l=0, kk=0;
			forr(i, 0, s.size())
			{
				kk+=c[l][s[i]-'0'];
				l=s[i]-'0';
			}
			kk+=c[l][0];
			//cout<<kk<<'\n';
			if(kk==b)
				ans++;
		}
		else
			break;

	}while(next_permutation(s.begin(), s.end()));
	cout<<ans;

	return 0;
}

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<vector<int>> T(n, vector<int>(n));
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin >> T[i][j];
		}
	}

	vector<int> index;
	for(int i=0; i<n; i++)index.push_back(i);

	int ans = 0;
	do{
		int time = 0;
		for(int i=0; i<n; i++) time += T[index[i]][index[(i+1)%n]];
		if(time == k) ans++;
	}while(next_permutation(index.begin()+1, index.end()));

	cout << ans << endl;
}


#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define _roverload(_a1,_a2,_a3,name,...) name
    #define _rep(i,n) repi(i,0,n)
    #define repi(i,a,b) for(int i=int(a);i<int(b);++i)
    #define rep(...) _roverload(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
    #define _rrep(i,n) rrepi(i,0,n)
    #define rrepi(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);--i)
    #define rrep(...) _roverload(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    void print() {cout << '\n';}
    template<class T> void print(const vector<T> &v)
    {bool f=false; for(const auto &e: v){if(f)cout << ' '; cout << e; f=true;} cout << '\n';}
    template<class... T> void print(const T&... args)
    {bool f=false; for(const auto &e: {args...}){if(f)cout << ' '; cout << e; f=true;} cout << '\n';}
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    string s; cin >> s;
    int n = s.length();
    vi cnt(26);
    ll ans = 0;
    rrep(i,n){
        cnt[s[i]-'a']++;
        if(i>0 && s[i-1]==s[i]){
            rep(j,26){
                if(s[i]-'a' == j) continue;
                ans += cnt[j];
                cnt[j] = 0;
            }
            cnt[s[i]-'a'] = n-i;
        }
    }
    print(ans);

}

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include<map>
#define ll                   long long
#define skip                 cin>>ws;
#define vll                  vector<ll>
#define vi                   vector<int>
#define vb                   vector<bool>
#define vpll                 vector<pair<ll,ll>>
#define vpi                  vector<pair<int, int>>
#define vvll                 vector<vector<ll>>
#define vvi                  vector<vector<int>>
#define vvvll                vector<vector<vector<ll>>>
#define pll                  pair<ll,ll>
#define vs                   vector<string>
#define vvpll                vector<vector<pair<ll, ll>>>
#define vvpi                 vector<vector<pair<int, int>>>
#define pb                   push_back
#define pob                  pop_back()
#define MOD                  (ll)(1e9 + 7)
#define MOD2                 (ll)(998244353)
#define INF                  (ll)(1e18 + 5)
#define count1(n)            __builtin_popcountll(n)
#define test                 ll t; cin>>t; while(t--)
#define enter(a)             for(ll i=0;i<a.size();i++) cin>>a[i];
#define show(a)              for(ll e: a) cout<<e<<" "; cout<<"\n";

using namespace std;

ll mo(ll a){ return a%MOD;}

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

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

    string s;
    skip
    cin>>s;
    skip

    ll n = s.size(), pre_in = -1, pre = -1, ans = 0;
    vvll cnt(n + 1, vll(26));
    cnt[n-1][s[n-1] - 'a']++;

    for(ll i=n-2;i>=0;i--)
    {
        for(ll j=0;j<26;j++)
        {
            cnt[i][j] = cnt[i + 1][j];
        }
        cnt[i][s[i] - 'a']++;

        if(s[i] == s[i + 1])
        {
            if(s[i] - 'a' == pre)
            {
                ans += max((pre_in - (i + 1) - 1), 0LL);
                ans -= max((cnt[i + 1][s[i] - 'a'] - cnt[pre_in][s[i] - 'a'] -1), 0LL);
            }
            else
            {
                ans += (max((n-1) - (i + 1), 0LL) - (cnt[i + 2][s[i] - 'a']
                 - ((pre_in!=-1)?cnt[pre_in][s[i] - 'a'] :0LL)));
            }
            // cout<<ans<<"\n";

            pre = s[i] - 'a';
            pre_in = i;
        }

    }

    cout<<ans<<"\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int k;
    cin >> k;
    long long ans = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k / i; j++) {
            for (int l = 1; l <= k / (i * j); l++) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
class Osa_k{
public:
  int max_number;
  vi min_factor;

  Osa_k(int N) : max_number(N) {
    Build();
  }

  void Build() {
    min_factor.resize(max_number+1);
    iota(min_factor.begin(),min_factor.end(), 0);
    for(int i = 2; i <= max_number; ++i) {
      if(min_factor[i] < i) continue;
      for(int j = 1; i*j <= max_number; ++j) {
        min_factor[i*j] = i;
      }
    }
  }

  vvi PrimeFactor() {
    vvi res(max_number+1);
    for(int i = 2; i <= max_number; ++i) {
      int num = i;
      while(num >= 2) {
        int factor = min_factor[num];
        res[i].push_back(factor);
        while(num % factor == 0) num /= factor;
      }
    }
    return res;
  }

  void Test() {
    vvi res = PrimeFactor();
    for(int i = 2; i <= max_number; ++i) {
      cout << i << "\n";
      for(auto tmp: res[i]) cout << tmp << " ";
      cout << "\n";
    }
  }

};
int main()
{
  ll l,r; cin >> l >> r;
  Osa_k os(r+1);
  vvi primeFactor = os.PrimeFactor();
  ll res = 0;
  for(int i = l; i <= r; ++i) {
    int n = sz(primeFactor[i]);
    rep1(S,(1<<n)-1){
      int prod = 1;
      rep(j,n) {
        if((S>>j)&1) prod *= primeFactor[i][j];
      }
      ll count = r/prod - (i-1)/prod;
      count -= r/i;
      if(__builtin_popcount(S) % 2 == 1) res += count;
      else res -= count;
    }
  }
  cout << res*2 << "\n";
  return 0;
}

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define pb push_back
#define ll long long int
#define pll pair<ll,ll>
#define mp make_pair
# define fio ios_base::sync_with_stdio(false); cin.tie(NULL)

const int MAX_N = 2e6+1;

ll mod = 1e9+7;

int main()
{
    fio;

    int l,r;
    cin>>l>>r;

    ll store[r+1];
    ll ans = 0;

    for(int i=r;i>=2;i--){
        store[i]  =0;
        for(int j=i;j<=r;j+=i){
            store[i] -= store[j];
        }
        ll low = (l-1)/i;
        ll high = r/i;
        store[i] += (high-low) * (high-low);
        ans += store[i];
    }

    for(int i=max(2,l);i<=r;i++){
        ll high = r/i;
        ans -= (2*high - 1);
    }
    cout<<ans;
    return 0;
}


#include<iostream>
#define ll long long
using namespace std;
ll T,X,Y,P,Q,a,b,c,k1,k2,tans;
ll exgcd(ll a,ll b,ll &x,ll &y) {
	if(!b) {
		x=1,y=0;
		return a;
	}
	int t=exgcd(b,a%b,y,x);
	y-=a/b*x;
	return t;
}
int main() {
	cin>>T;
	while(T--) {
		cin>>X>>Y>>P>>Q;
		a=2*X+2*Y,b=P+Q;
		tans=5e18;
		for(int q=0; q<Q; q++) {
			for(int y=0; y<Y; y++) {
				c=P+q-X-y;
				int t=exgcd(a,b,k1,k2);
				if(c%t)continue;

				k1=k1*c/t;
				k1=(k1%(b/t)+(b/t))%(b/t);
				tans=min(tans,a*k1+y+X);
			}
		}
		if(tans==5e18)cout<<"infinity\n";
		else cout<<tans<<endl;
	}
}

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

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
#define mul(a, b) ((a*b)%MOD)
#define add(a, b) ((a+b)%MOD)
#define dec(a, b) ((a-b+MOD)%MOD)
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int INF = 1e9;
const long LINF = 1e18;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
// inv[1] = 1;
// fac[0] = ifac[0] = 1;
// for(int i = 2; i <= 500000; i++) inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
// for(int i = 1; i <= 500000; i++) fac[i] = mul(i, fac[i-1]), ifac[i] = mul(inv[i], ifac[i-1]);
// /mnt/c/Users/vince/Desktop/POST-IOI/

map<int,int> cnt;
int A[100003];

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int t; scanf("%d", &t);
	while(t--)
	{
		int n; scanf("%d", &n);
		for(int i = 1; i <= n; i++)
		{
			scanf("%d", &A[i]);
		}
		if(n&1)
		{
			printf("Second\n");
		}
		else
		{
			cnt.clear();
			for(int i = 1; i <= n; i++)
				cnt[A[i]]++;

			bool bol = 1;
			for(auto it : cnt)
				if(it.se&1)
					bol = 0;
			if(bol) printf("Second\n");
			else printf("First\n");
		}
	}
}


#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define popcount(v) __builtin_popcount(v)
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    INT(n);
    int ans=n*108/100;
    if(ans==206)out("so-so");
    else if(ans>206)out(":(");
    else out("Yay!");
}


#include<iostream>
using namespace std;

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

/*ABIDSTIC*/
#include <bits/stdc++.h>
/*---------------------------------PB_DS---------------------------------*/
// #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 ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k) = returns an iterator to the k-th largest element (counting from zero)
// order_of_key(k) = the number of items in a set that are strictly smaller than k.
/*-----------------------------------------------------------------------*/
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define fill(a,b)           memset(a, (b), sizeof(a))
#define debug(x)            cout<<#x<<" "<<x<<'\n';
#define sfc(a)              scanf("%c",&a)
#define pb(a)               push_back(a)
#define X                   first
#define Y                   second
#define sz(x)               x.size()
#define pii                 pair<int,int>
#define pli                 pair<long long int,int>
#define mp(a,b)             make_pair(a,b)
#define fr(i,x,n)           for(int i=x;i<n;i++)
#define rfr(i,x,n)          for(int i=x;i>n;i--)
#define Lcm(a, b)           ((a)*((b)/Gcd(a,b)))
#define endl                '\n'
template<typename T>T Abs(T a){return a<0?-a:a;}
template<typename T>T Max(T a, T b){return a>b?a:b;}
template<typename T>T Min(T a, T b){return a<b?a:b;}
template<typename T>T Gcd(T a, T b){return (!b)?a:Gcd(b,a%b);}
template<typename T>T Pow(T a, T b){if(!b)return 1;T t=Pow(a,b/2);return b%2?a*t*t:t*t;}
template<typename T>inline void read(T &x){
    T f=1;char c;x=0;
    for(c=getchar();c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
    x*=f;
}
using fl = float;
using db = double;
using ll = long long;
using ull = unsigned long long;
const int mx = 1000005;
const int inf = 99999999;
const int intlim = 2147483648;
const db PI = acos(-1); //3.14159265358979323846264338328
/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};           // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};          // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
//#ifndef ONLINE_JUDGE
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//#endif
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int a,b;
cin>>a>>b;
int x=(a+b)/2;
int y=a-x;
cout<<x<<" "<<y<<endl;

    return 0;
}


/**

   * Made by:    Diego Briaares
   * At:   06.03.2021 16:16:56
**/

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

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

	int main () {
		optimize();
		int n;
		cin >> n;
		vector<pair<int, int>> emp(n);
		int ans = 1e9;
		for (int i = 0; i < n; i++)	{
			cin >> emp[i].first >> emp[i].second;
			ans = min(ans, emp[i].first + emp[i].second);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				ans = min(ans, max(emp[i].first, emp[j].second));
				ans = min(ans, max(emp[j].first, emp[i].second));
			}
		}
		cout << ans << "\n";
	}

#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stdio.h>
//end of libraries
#define lnf 3999999999999999999
#define inf 999999999
#define PI 3.14159265359
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define rsz(a,n) a.resize(n)
#define pii pair <int,int>
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(int i = x ; i < n ; i++)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

const int max_n = 300000;

using namespace std;
int n,m;
ll mod = 998244353 , fact[max_n];
ll binpow(ll a, ll b) {
  a %= mod; ll res = 1;
  while (b) { if (b%2) res = res * a % mod; a = a * a % mod; b /= 2; }
  return res % mod;
}
void dofact() {
  fact[0]=fact[1]=1;
  rep(i,max_n-3){
    if(i>1)fact[i] = fact[i-1]*i; fact[i] %= mod;
  }
}

ll cnk(ll k , ll n){
  if(k>n) return 0;
  return (fact[n] * binpow(fact[k]*fact[n-k]%mod,mod-2)) % mod;
}
ll sub(ll a , ll b){
  a%=mod; b%=mod;
  return (((a-b)%mod)+mod)%mod;
}
ll prod(ll a , ll b){
  a%=mod; b%=mod;
  return ((a*b)%mod);
}

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

int main(){
fcin;
dofact();

	cin >> n >> m;
	vector <pii> b;

	ll ans = 0;

	for(int i = 1 ; i <= m ; i++) {
		int y = i;
		b.clear();
		for(int x = 2 ; x <= sqrt(i) ; x++) {
			if(y%x == 0) {
				int cnt = 0;
				while(y%x == 0) {y/=x; cnt++;}
				b.pb({x,cnt});
			}
		}

		b.pb({y,1});

		ll c = 1;
		for(auto p : b) {
			if(p.fi == 1) continue;
			// cout << cnk(p.se,n+p.se-1) << " , ";
			// c *= cnk(p.se,n+p.se-1);
			c = prod(c,cnk(p.se,n+p.se-1));
		}
		// ans += c;
		ans = add(ans,c);
		// cout << c << "\n";
	}

	cout << ans << "\n";

/*
*/

    return 0;
}


//selem
#include <bits/stdc++.h>
//void IO() {freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
using namespace std;typedef long long ll;
#define all(x) begin(x), end(x)
#define pb push_back
typedef pair<ll,ll> pll;;typedef map<ll, ll> mll;
typedef vector<pll> vpll;
typedef vector<ll> vll;
int Arr[10000];vll adj[1000];
//finding root of an element.
int root(int Arr[ ],int i)
{
    while(Arr[ i ] != i)           //chase parent of current element until it reaches root.
    {
     i = Arr[ i ];
    }
    return i;
}

/*modified union function where we connect the elements by changing the root of one of the element */

int un(int Arr[ ] ,int A ,int B)
{
    int root_A = root(Arr, A);
    int root_B = root(Arr, B);
    Arr[ root_A ] = root_B ;       //setting parent of root(A) as root(B).
}
bool fnd(int A,int B)
{

    if( root(Arr, A)==root(Arr, B) )       //if A and B have same root,means they are connected.
    return true;
    else
    return false;
}
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);

        double f;cin>>f;
        double ff;cin>>ff;
        cout<<(f/100.0)*ff;
        return 0;
}

#line 1 "main.cpp"
#include <bits/stdc++.h>
#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 repr(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;

long long bf[1 << 19];
long long bg[1 << 19];
void init() {
	for (int i = 1; i <= 400000; i++) {
		int pos = i;
		while (pos % 3 == 0) { pos /= 3; bf[i] += 1; }
		bg[i] = pos % 3;
	}
	bg[0] = 1;
	for (int i = 1; i <= 400000; i++) bf[i] += bf[i - 1];
	for (int i = 1; i <= 400000; i++) bg[i] = (bg[i] * bg[i - 1]) % 3;
}
int ncr_mod_3(int n, int r) {
	if (bf[n] != bf[r] + bf[n - r]) return 0;
	if (bg[n] == 1 && bg[r] * bg[n - r] == 1) return 1;
	if (bg[n] == 1 && bg[r] * bg[n - r] == 2) return 2;
	if (bg[n] == 1 && bg[r] * bg[n - r] == 4) return 1;
	if (bg[n] == 2 && bg[r] * bg[n - r] == 1) return 2;
	if (bg[n] == 2 && bg[r] * bg[n - r] == 2) return 1;
	if (bg[n] == 2 && bg[r] * bg[n - r] == 4) return 2;
	return -1;
}

map<char, int> c2d;
map<char, int> d2c;

int main() {
    c2d['B'] = 0;
    c2d['W'] = 1;
    c2d['R'] = 2;
    d2c[0] = 'B';
    d2c[1] = 'W';
    d2c[2] = 'R';
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    init();
    rep(i, n) {
        int v = c2d[s[i]];
        // cerr << i << " " << ncr_mod_3(n-1,i)  << " " << v << endl;
        ans += ncr_mod_3(n-1,i)*v;
        ans %= 3;
    }
    if (n % 2 == 0) ans *= 2;
    ans %= 3;
    // cerr << ans << endl;
    cout << (char)d2c[ans] << endl;

    return 0;
}


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

#define int long long int
#define double long double

#define all(x) (x).begin(), (x).end()
#define RemoveDuplicates(a) a.resize(unique(all(a))-a.begin())
#define Debug(x) cerr<<"["<<#x<<": "<<x<<"]"
#define endl '\n'

void solve(){
	int n,x;
	cin>>n>>x;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	map<int,int>cnt;
	cnt[x]=1;
	for(int i=0;i<n-1;i++){
		map<int,int>newcnt;
		int d=a[i+1]/a[i];
		for(pair<int,int>p:cnt){
			int val=p.first;
			int count=p.second;
			if(val%d!=0){
				newcnt[val/d+1]+=count;
			}
			newcnt[val/d]+=count;
		}
		cnt=newcnt;
	}
	int ans=0;
	for(pair<int,int>p:cnt){
		ans+=p.second;
	}
	cout<<ans<<endl;
}

int32_t main(){

	// Remove for Interactive Problems
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

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

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
// #define LOCAL // 提出時はコメントアウト
#define DEBUG_

typedef long long ll;
const double EPS = 1e-9;
const ll INF = ((1LL<<62)-(1LL<<31));
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;
template<typename T> using uset = unordered_set<T>;
template<typename T, typename U> using mapv = map<T,vector<U>>;
template<typename T, typename U> using umap = unordered_map<T,U>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define contains(S,x) find(ALL(S),x) != S.end()
ll llceil(ll a,ll b) { return (a+b-1)/b; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> vector<vector<T>> genarr(ll n, ll m, T init) { return vector<vector<T>>(n,vector<T>(m,init)); }

///// DEBUG
#define DUMPOUT cerr
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
template<typename T>istream&operator>>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T,typename U>ostream&operator<<(ostream&os,pair<T,U>&pair_var){os<<"("<<pair_var.first<<", "<<pair_var.second<<")";return os;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&vec){os<<"{";for(int i=0;i<vec.size();i++){os<<vec[i]<<(i+1==vec.size()?"":", ");}
os<<"}";return os;}
template<typename T,typename U>ostream&operator<<(ostream&os,map<T,U>&map_var){os<<"{";repi(itr,map_var){os<<*itr;itr++;if(itr!=map_var.end())os<<", ";itr--;}
os<<"}";return os;}
template<typename T>ostream&operator<<(ostream&os,set<T>&set_var){os<<"{";repi(itr,set_var){os<<*itr;itr++;if(itr!=set_var.end())os<<", ";itr--;}
os<<"}";return os;}
void dump_func(){DUMPOUT<<endl;}
template<class Head,class...Tail>void dump_func(Head&&head,Tail&&...tail){DUMPOUT<<head;if(sizeof...(Tail)>0){DUMPOUT<<", ";}
dump_func(std::move(tail)...);}
#ifndef LOCAL
#undef DEBUG_
#endif
#ifdef DEBUG_
#define DEB
#define dump(...)                                                          \
DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
        << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
        << endl                                                            \
        << "    ",                                                         \
    dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

//////////

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

vecl A;
vector<umap<ll,ll>> memo(60);
ll solve(ll x, int i) {
    if (i >= A.size() - 1) return 1;
    if (memo[i].count(x) > 0) return memo[i][x];
    if (x % A[i+1] == 0) return memo[i][x] = solve(x, i+1);

    return memo[i][x] = solve(x - x % A[i+1], i+1) + solve(x - x % A[i+1] + A[i+1], i+1);
}

int main() {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    ll N,X;
    cin>>N>>X;

    A.resize(N);
    rep(i,N) cin>>A[i];

    ll ans = solve(X,0);
    cout << ans << endl;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define mod 1000000007
#define ll long long
using namespace std;
const int maxx=600010;
ll t,n,m;
ll ans=0,total=0,sum=0,cnt=0,l=1,r=1;
ll a[maxx],x[maxx],y[maxx];
ll bjl[3111][3111],bjr[3111][3111];
char c[3111][3111];
ll ksm(ll x,ll p)
{
	ll res=1;
	while(p)
	{
		if(p&1)res=res*x%mod;
		x=x*x%mod;
		p>>=1;
	}
	return res;
}
int main()
{
	cin>>n>>m;
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
		{
			cin>>c[i][j];
			if(c[i][j]=='.')total++;
		}
	for(register int i=1;i<=n;i++)c[i][m+1]='#';
	for(register int i=1;i<=m;i++)c[n+1][i]='#';
	for(register int i=1;i<=n+1;i++)
	{
		l=1;
		for(register int j=1;j<=m+1;j++)
		{
			if(c[i][j]=='#')
			{
				for(register int k=l;k<j;k++)bjl[i][k]=x[i];
				x[i]=0,l=j+1;
			}
			else x[i]++;
		}
	}
	for(register int j=1;j<=m+1;j++)
	{
		r=1;
		for(register int i=1;i<=n+1;i++)
		{
			if(c[i][j]=='#')
			{
				for(register int k=r;k<i;k++)bjr[k][j]=y[j];
				r=i+1;
				y[j]=0;
			}
			else y[j]++;
		}
	}
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
		{
			if(c[i][j]=='.')
			{
				sum=bjl[i][j]+bjr[i][j]-1;
				ans=(ans+(ksm(2,sum)%mod-1+mod)%mod*ksm(2,total-sum)%mod)%mod;
			}
		}
	printf("%lld",ans);
	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;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define all(v) v.begin(),v.end()
#define  mat vector<vector<ll>>
#define el cout<<'\n';
const ll N=2e3+5;
ll lf[N][N];
ll rt[N][N],up[N][N],down[N][N];

ll pw(ll k){
    ll a=2;
    ll ans=1;
    while(k){
        if(k&1){
        ans*=a;
        ans%=mod;
        }

        a*=a;
        a%=mod;
        k>>=1;
    }
    return ans;
    }
void solve(){
  ll n,m,k;
  cin>>n>>m;
  int ar[n][m];
  k=0;
  fr(i,0,n){
      fr(j,0,m){
     char ch;
     cin>>ch;
     ar[i][j]=(ch=='.'?1:0);
     k+=ar[i][j];
      }
  }

  for(int i=0;i<n;i++){
      fr(j,0,m){
          if(j==0) lf[i][j]=ar[i][j];
           else if(ar[i][j]==1)
           lf[i][j]+=lf[i][j-1]+1;

           if(i==0)
           up[i][j]=ar[i][j];
           else if(ar[i][j])
           up[i][j]=up[i-1][j]+1;

      }
  }

  for(int i=n-1;i>=0;i--){
      for(int j=m-1;j>=0;j--){
    if(j==m-1)
        rt[i][j]=ar[i][j];
    else if(ar[i][j]==1)
        rt[i][j]=rt[i][j+1]+1;

      if(i==n-1)
        down[i][j]=ar[i][j];
      else if(ar[i][j]==1)
        down[i][j]=down[i+1][j]+1;
  }
  }
//   d1(k)

  ll ans=k*pw(k)%mod;
  ll ng=0;
  fr(i,0,n){
      fr(j,0,m){
          if(ar[i][j]==1){
         ll l=0,r=0,u=0,d=0;
         if(j!=0)
         l=lf[i][j-1];
         if(j!=m-1)
         r=rt[i][j+1];
         if(i!=0)
         u=up[i-1][j];
         if(i!=n-1)
         d=down[i+1][j];
         ll tot=l+r+u+d+1;
        //  d1(tot);
         ng+=pw(k-tot);

         ng%=mod;

          }

      }
  }
  cout<<(ans-ng+mod)%mod;

}
int main(){
 boost
 ll t=1;

// cin>>t;

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


/*ver 7*/
#include <bits/stdc++.h>
using namespace std;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll,ll>;
using mll = map<ll,ll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
#define each(x,v) for(auto& x : v)
#define reps(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
const ll INF = 1LL << 60;
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<=b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){}
template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
template <typename T> void in1(T &s) {rep(i,s.size()){in(s[i]);}}
template <typename T> void in2(T &s,T &t) {rep(i,s.size()){in(s[i],t[i]);}}
template <typename T> void in3(T &s,T &t,T &u) {rep(i,s.size()){in(s[i],t[i],u[i]);}}
template <typename T> void in4(T &s,T &t,T &u,T &v) {rep(i,s.size()){in(s[i],t[i],u[i],v[i]);}}
template <typename T> void in5(T &s,T &t,T &u,T &v,T &w) {rep(i,s.size()){in(s[i],t[i],u[i],v[i],w[i]);}}
void out(){cout << endl;}
template <typename T,class... U> void out(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; out(u...);}
void die(){cout << endl;exit(0);}
template <typename T,class... U> void die(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; die(u...);}
template <typename T> void outv(T s) {rep(i,s.size()){if(i!=0)cout<<" ";cout<<s[i];}cout<<endl;}
template <typename T> void out1(T s) {rep(i,s.size()){out(s[i]);}}
template <typename T> void out2(T s,T t) {rep(i,s.size()){out(s[i],t[i]);}}
template <typename T> void out3(T s,T t,T u) {rep(i,s.size()){out(s[i],t[i],u[i]);}}
template <typename T> void out4(T s,T t,T u,T v) {rep(i,s.size()){out(s[i],t[i],u[i],v[i]);}}
template <typename T> void out5(T s,T t,T u,T v,T w) {rep(i,s.size()){out(s[i],t[i],u[i],v[i],w[i]);}}
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
template <typename T> T allSum(vector<T> a){T ans=T();each(it,a)ans+=it;return ans;}
ll ceilDiv(ll a,ll b) {return (a+b-1)/b;}
ld dist(pair<ld,ld> a, pair<ld,ld> b){return sqrt(abs(a.fi-b.fi)*abs(a.fi-b.fi)+abs(a.se-b.se)*abs(a.se-b.se));} // ２点間の距離
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
#define YES(n) ((n) ? "YES" : "NO"  )
#define Yes(n) ((n) ? "Yes" : "No"  )
#define yes(n) ((n) ? "yes" : "no"  )

int main(){
	init();
	inl(n);
	V<ll> a(n);
	in1(a);
	V<ll> ans;
	rep(i,n)a[i]--;
	ll now=0;
	ll old=0;
	while(now<n){
		if(now==n-1 || a[now]==old){
			for(int i=now-1;i>=old;i--){
				swap(a[i],a[i+1]);
				//outv(a);
				ans.push_back(i);
			}
			old=now;
		}
		now++;
	}
	rep(i,n){
		if(a[i]!=i)die(-1);
	}
	rep(i,ans.size())out(ans[i]+1);
	return 0;
}

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

class Solution
{
#define int int64
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)

    int x, y, r, res = 0;

    void SHURU()
    {
        double a, b, c;
        cin >> a >> b >> c;
        x = round(a * 10000);
        y = round(b * 10000);
        r = round(c * 10000);
    }

    void SHUCHU()
    {
        cout << res << endl;
    }

    bool inCircle(int dx, int dy)
    {
        return dx * dx + dy * dy <= r * r;
    }

    void CHULI()
    {
        x %= 10000;
        y %= 10000;
        int l = 0, r = 1;
        for (int i = 1000100000; i >= 0; i -= 10000)
        {
            while (inCircle(x - l * 10000, y + i))
                --l;
            while (inCircle(x - r * 10000, y + i))
                ++r;
            res += r - l - 1;
        }
        l = 0;
        r = 1;
        for (int i = 1000100000; i >= 10000; i -= 10000)
        {
            while (inCircle(x - l * 10000, y - i))
                --l;
            while (inCircle(x - r * 10000, y - i))
                ++r;
            res += r - l - 1;
        }
    }

public:
    Solution()
    {
        SHURU();
        CHULI();
        SHUCHU();
    }
#undef int
#undef tfor
#undef sfor
};

int32 main()
{
#ifdef LILY
    while (1)
    {
#endif
        Solution();
#ifdef LILY
    }
#endif
    return 0;
}


#include<iostream>
using namespace std;
int main(){
  int a,b,x,y,ans;
  cin>>a>>b>>x>>y;

  if(a>b)
    if(2*x<y)
      ans=2*x*(a-b)-x;
  	else
      ans=x+y*(a-b-1);
  else
    if(2*x<y)
      ans=2*x*(b-a)+x;
  	else
      ans=x+y*(b-a);

  cout<<ans;
}

#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll a, b, x, y;
    cin >> a >> b >> x >> y;
    ll t = 0;
    if(a == b){
        PRINT(x);
    }else if(a > b){
        t += (a - b - 1) * min(2 * x, y);
        t += x;
        PRINT(t);
    }else{
        t += (b - a) * min(2 * x, y);
        t += x;
        PRINT(t);
    }
    return 0;
}