#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#define vi vector<int>
#define lli long long int
#define fo(i,n) for(int i=1;i<=n;i++)
#define foo(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define vii vector<lli>
#define ok ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#define vp vector<pair<lli,lli>>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
lli v[4],t=0;
foo(j,4) cin>>v[j];
	foo(i,4) t+=v[i];
	if(t%2) {
		cout<<"No";
		return 0;
	}
	lli s = 0;
	lli mask = 15;
	fo(i,mask){
		s=0;
		foo(j,4){
			if(i&(1<<j)){
				s+=v[j];
			}
		}
		if(s==t/2){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

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

void d_err() {
    cerr << endl;
}

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

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

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

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

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

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

    ll n; cin >> n;

    set<ll> s;
    FOR(i, 1, sqrt(n) + 1) {
        if (n % i == 0) {
            s.insert(i);
            if (i * i != n) s.insert(n / i);
        }
    }

    for(auto &e: s) print(e);
}


#include <bits/stdc++.h>
using namespace std;
#define SF(A) sort(A.begin(), A.end())
#define LF(A) sort(A.rbegin(), A.rend())
#define COUNT(A,B) count(A.begin(),A.end(),B)
#define REP(i,b,e) for(i=b;i<e;i++)

int main()
{
	int i;
	long long int A, B, C, D, b, r;
	cin >> A >> B >> C >> D;
	if (B >= C * D)
	{
		cout << "-1" << endl;
		return 0;
	}

	b = A;
	r = 0;
	long long int count = 0;
	while (r * D < b)
	{
		b += B;
		r += C;
		count++;
	}
	cout << count << endl;
}

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define rep(i,n) repi(i,0,n)
#define repi(i,a,n) for(ll i=a;i<(ll)n;++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define Show(val) cout<<(val)<<" "
#define Showln(val) cout<<(val)<<endl

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
// using P = pair<int, int>;
void YN(bool a) { cout << (a ? "Yes" : "No"); }
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; }

class UnionFind{
public:
  vector<int> p;		// 親
  vector<int> rank;	// サイズ・各集合の根のみ有効
  UnionFind(int n){
    p.resize(n, -1);
    rank.resize(n, 1);
  }
  int root(int x){
    if(p[x] == -1) return x;
    else return p[x] = root(p[x]); // 深さを 1 にしている
  }
  void unite(int x, int y){
    x = root(x); y = root(y);
    if(x == y)return;
    if(rank[x] > rank[y]) swap(x, y); // rankの小さいものを下につける
    rank[y] += rank[x];
    p[x] = y;
  }
  // グループの数
  ll root_num() {
    ll num = 0;
    for(ll x : p) if (x < 0) num++;
    return num;
  }
  //xが属すグループのサイズ
  int size(int x){ return rank[root(x)]; }
  bool same(int x, int y){ return (root(x) == root(y)); }
};

// 100 は 上 / 101 は 下
ll dist2rsq[102][102];

void solve()
{
  ll n, xi, yi;
  cin >> n;
  // tuple<x, y>
  vector<tuple<ll, ll>> pos(n);
  // tuple<dist, idx, idx>
  vector<tuple<double, ll, ll>> dist;
  rep(i, n)
  {
    cin >> xi >> yi;
    pos[i] = make_tuple(xi, yi);
  }

  rep(i, n-1) repi(j, i+1, n)
  {
    ll x1, y1, x2, y2;
    tie(x1, y1) = pos[i];
    tie(x2, y2) = pos[j];
    double _2r = hypot(x1 - x2, y1 - y2);
    dist.emplace_back(_2r, i, j);
  }

  rep(i, n)
  {
    // n:100 は 上 / n+1:101 は 下
    dist.emplace_back(100 - get<1>(pos[i]), i, n);
    dist.emplace_back(100 + get<1>(pos[i]), i, n+1);
  }

  sort(ALL(dist));

  double ac = 0.0, wa = 300.0;
  while(wa - ac > 0.00005)
  {
    double wj = (ac + wa) / 2.0;
    UnionFind uf(n + 2);
    for(const auto& d : dist)
    {
      double _2r;
      ll i, j;
      tie(_2r, i, j) = d;
      if (_2r < wj) uf.unite(i, j);
      else break;
    }

    if ( uf.same(n, n+1) ) wa = wj;
    else ac = wj;
  }

  printf("%.5lf\n", ac / 2.0);
}

int main()
{
  fastio;
  solve();

  return 0;
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

using ll = long long;
using vll = std::vector<ll>;
using namespace std;
#define REP(i, x, n) for(int i = x; i < (n); i++)
#define rep(i, n) REP(i, 0, n)
template<class T> void gi(T &x){
  int minus=0; x=0; char c=getchar();
  for(;c<'0'||c>'9'; c=getchar()) minus|=(c=='-');
  for(;c>='0'&&c<='9'; c=getchar()) x=(x<<1)+(x<<3)+(c^48);
  if(minus) x=-x;
}
const ll MOD=1000000007;
int main() {
  ll t; gi(t);
  auto square = [](ll n, ll md){
    return n*n%md;
  };
  auto choose2 = [](ll n, ll md){
    return n*(n-1)/2%md;
  };
  rep(i,t){
    ll n,a,b; gi(n),gi(a),gi(b);
    if(a+b > n){
      printf("%lld\n", 0LL);
      continue;
    }
    ll all = (square(n-a+1,MOD)*square(n-b+1,MOD))%MOD;
    ll notoverlaped = choose2(n-a-b+2,MOD)*2%MOD;
    ll overlaped = square((((n-a+1)*(n-b+1)%MOD- notoverlaped+MOD)%MOD),MOD);
    ll ans = (all - overlaped +MOD)%MOD;
    printf("%lld\n", ans);
  }
  return 0;
}

#include <bits/stdc++.h>

// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    int t;
    cin >> t;
    while (t--) {
        ll n, a, b;
        cin >> n >> a >> b;
        if (a + b > n) {
            cout << 0 << endl;
            continue;
        }

        if (a < b) swap(a, b);

        vl kouho;
        kouho.push_back(0);
        kouho.push_back(b);
        kouho.push_back(n - a - b + 1);
        kouho.push_back(n - a + 1);
        sort(all(kouho));
        // UNIQUE(kouho);
        // DEBUG_VEC(kouho);
        ll ans = (n - a + 1) * (n - a + 1) % MOD * (n - b + 1) % MOD * (n - b + 1) % MOD;
        // DEBUG(ans);
        rep (i, 3) {
            rep (j, 3) {
                ll r1 = kouho[i + 1] - kouho[i], r2 = kouho[j + 1] - kouho[j];
                ll add = r1 * r2 % MOD;
                // DEBUG(pll(r1, r2));
                ll s1 = max(0LL, kouho[i] - b + 1), t1 = max(0LL, kouho[j] - b + 1);
                ll s2 = min(kouho[i] + a, n - b + 1), t2 = min(kouho[j] + a, n - b + 1);
                // DEBUG(pll(s1, s2));
                // DEBUG(pll(t1, t2));
                (add *= (s2 - s1) * (t2 - t1) % MOD) %= MOD;
                // DEBUG(add);
                (ans -= add) %= MOD;
            }
        }
        cout << (ans % MOD + MOD) % MOD << endl;
    }
}


#include <bits/stdc++.h>

#define endl "\n"

using namespace std;

void setup() {
    #ifdef LOCAL
    freopen("input", "r", stdin);
    #else
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif
}

int main() {
    setup();
    int N, W;
    cin >> N >> W;
    long long line[200020];
    memset(line, 0, sizeof(long long) * 200020);

    for (int i = 0; i < N; i++) {
        int S, T, P;
        cin >> S >> T >> P;
        line[S] += P;
        line[T] -= P;
    }

    bool no = line[0] > W;
    for (int i = 1; i < 200020; i++) {
        line[i] += line[i-1];
        if (line[i] > W) {
            no = true;
            break;
        }
    }
    if (no) cout << "No" << endl;
    else cout << "Yes" << endl;
}

#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;
double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
signed main() {
  ll N,w;
  cin >> N >> w;
  vector<pair<ll,ll>> a(N);
  vector<pair<ll,ll>> b(N);
  rep(i,N){
      ll tmp0,tmp1,tmp2;
      cin >> tmp0 >> tmp1 >> tmp2;
      a[i] = make_pair(tmp0,tmp2);
      b[i] = make_pair(tmp1,tmp2);
  }
  sort(all(a));
  sort(all(b));
  ll d = 0;
  ll m = 0;
  rep(i,N){
      while(a[i].first >= b[d].first){
          m-=b[d].second;
          d++;
      }
      m+=a[i].second;
      //cout << i << " " << d << endl;
      if(m>w){
          //cout << i <<" " << d << endl;
          cout << "No";
          return 0;
      }
  }
  cout << "Yes";
}


/**
 *    author:  Eccentric_9
 *    created: 12.05.2021 17:34:05
**/
#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     vl              vector<long long>
#define     pll             pair<long long,long long>
#define     mll             map<long long,long long>
#define     sl              set<long long>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)
#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     r(i,n)          FOR(i,0,n-1)
#define     w(x)            int t;cin>>t;while(t--)
#define     en              '\n'
#define     sp              <<" "<<

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

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

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

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

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

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

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1e4+5,K=255;
/*-----</Constants>-----*/

ll n, m, q, k, l, r, x, y, z;
const ll template_array_size = 1e6;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;

void solve()
{
    ll c;
    cin>>n>>c;
    mll m;
    r(i,n){
        ll a,b,cc;
        cin>>a>>b>>cc;
        m[a]+=cc;
        m[b+1]-=cc;
    }auto it=m.begin();
    ll val=it->S,r=it->F;
    it++;
    for(it;it!=m.end();it++){
        val+=it->S;
        it->S=val;
    }it=m.begin();
    val=it->second;
    ans=0;
    for(it;it!=m.end();it++){
        if(it==m.end()) break;
        ans+=(it->F-r)*(min(c,val));
        val=it->S;
        r=it->F;
    }cout<<ans;
}

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

  fast();
  //w(x)
  solve();
}

#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> L_L;
const ll INF=2e18;
const ll MOD=1e9+7;

template <typename T>
class Zip {
public:
  vector<T> d;
  bool flag;
  Zip() {
    flag = false;
  }
  void add(T x) {
    d.push_back(x);
    flag = true;
  }
  ll getNum(T x) { // T need to have operator < !!
    if (flag) {
      sort(d.begin(), d.end());
      d.erase(unique(d.begin(), d.end()), d.end());
      flag = false;
    }
    return lower_bound(d.begin(), d.end(), x) - d.begin();
  }
  ll size() {
    if (flag) {
      sort(d.begin(), d.end());
      d.erase(unique(d.begin(), d.end()), d.end());
      flag = false;
    }
    return (ll)d.size();
  }
};

ll N,C;
map<ll,ll> sum;
ll a[200010],b[200010],c[200010];
int main(){
    cin>>N>>C;
    Zip<ll> zp;
    for(ll i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i];
        zp.add(a[i]);
        zp.add(a[i]-1);
        zp.add(b[i]);
        zp.add(b[i]+1);
    }
    for(ll i=0;i<N;i++){
        sum[a[i]]+=c[i];
        sum[b[i]+1]-=c[i];
    }
    ll ans=0;
    for(ll i=1;i<zp.size();i++){
        sum[zp.d[i]] += sum[zp.d[i-1]];
        ans+=min(C,sum[zp.d[i-1]])*(zp.d[i]-zp.d[i-1]);
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
#define int ll
using namespace std;
const int mod = 1e9+7;
const int MAXN = 100000005;

signed main(){
    std::ios::sync_with_stdio(false);
    int a,b,c;
    cin >>a >> b>>c;
    c *= 1000;
    int maxn,minn;
    minn = c/b;
    maxn = c/a;
    if(c-minn*b <= minn*(b-a) && c - maxn*a <= minn*(b-a)){
        if(c - minn*b != 0)
            minn++;
        cout << minn << ' ' << maxn;
        return 0;
    }
    else
        cout << "UNSATISFIABLE";
    return 0;
}

#include<bits/stdc++.h>
#define int long long
#define rd(x) x=read()
#define seg(x,y) (seg){x,y}
using namespace std;
const int N=1e5+5;
const int M=505;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
inline int read(){int x=0,f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
int ksm(int x,int y){int ret=1;while (y){if (y&1) ret=(ret*x)%mod;x=(x*x)%mod;y>>=1;}return ret;}
int n,m,ans;
void solve(int x,int y)
{
	if (x%y==0) {ans+=x*2-y;return;}
	ans+=(x-x%y)*2;
	solve(y,x%y);
}
signed main()
{
	int a,b,c,d;
	rd(a);rd(b);rd(c);rd(d);
	cout<<min(min(a,b),min(c,d))<<endl;
}


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

const int INF=1e8;
void chmin(int& x, int y){ x=min(x,y);}

int main(){
  int n;
  cin >> n;
  vi x(n),y(n),z(n);
  rep(i,n) cin >> x[i] >> y[i] >> z[i];
  int n2=1<<n;
  vvi dist(n,vi(n));
  rep(i,n) rep(j,n) dist[i][j]=abs(x[j]-x[i])+abs(y[j]-y[i])+max(0,z[j]-z[i]);
  vvi dp(n2,vi(n,INF));
  rep(i,n){
    if(i==0) continue;
    dp[1<<i][i]=dist[0][i];
  }
  rep(i,n2){
    rep(j,n){
      if(!(i>>j&1)) continue;
      rep(k,n){
        if(i>>k&1) continue;
        chmin(dp[i|1<<k][k],dp[i][j]+dist[j][k]);
      }
    }
  }
  cout << dp[n2-1][0];
  return 0;
}

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

//-------------------------------------------------
//--Extended GCD
//-------------------------------------------------

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b==0){
        x = 1; y = 0;
        return a;
    }
    ll d = extgcd(b,a%b,y,x);
    y -= a/b*x;
    return d;
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t; cin>>t;
    while(t--){
        ll N,S,K; cin>>N>>S>>K;
        ll g = __gcd(K,N);
        if (S%g!=0){
            cout<<"-1\n";
            continue;
        }
        N/=g; S/=g; K/=g;
        ll inv,_;
        extgcd(K,N,inv,_);
        inv=(inv+N)%N;
        cout<<inv*(N-S)%N<<"\n";
    }
    return 0;
}


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

const int INF = 1e9;
const long long inf = 1LL<<60;
using ll = long long;

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

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define nl "\n"
#define sp " "
#define rep(i,n) for(i=0;i<n;i++)
#define repe(i,e,n) for(i=e;i<=n;i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vl vector<ll>
#define vvl vector<vl>
#define pll pair<ll,ll >
#define vpll vector<pll>
#define vvpll vector<vpll>
#define mp make_pair
#define mt make_tuple
#define len length()
#define val(n,t) get<n>(t)
#define rev(p) reverse(p.begin(),p.end())
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define sortv(vec) sort(vec.begin(),vec.end())
#define np(str) next_permutation(str.begin(),str.end())
#define mset(a,val) memset(a,val,sizeof(a));
#define popcount(x) __builtin_popcountll(x)
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define PI 3.14159265358979323846264338327950288419716939937510
long long int M = 1e9 + 7 ;
long long int inf = 1e18 + 7;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//CLOCK
ll begtime = clock();
#define time() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//CLOCK ENDED

// modular exponentiation
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1) res *= a;
		a *= a;
		b /= 2;
	}
	return res;
}
//binomial
ll modinv(ll n) {
	return binpow(n, M - 2);
}

int main() {
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// ll n, m, i, j, k, l, x, y, z, t, s, tc = 1;
	double a, b;
	cin >> a >> b;
	double ans = a * (b / 100);
	cout << ans;

	return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf = 1e12;
#define D long double
#define NeedForSpeed ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int MOD = 1000000007;
#define fi first
#define se second
#define endl '\n'
// random_device rd;
// mt19937 rng(rd());
// int getRand(int l,int r){ // get random number in the range [l,r]
//   uniform_int_distribution<int> uid(l,r);
//   return uid(rng);
// }
const int N = 1e5 + 10;
int n , q  ;
string s ;

void go(){
   cin >> n >> s >> q;
   bool f = 1;
   for(int i = 0 ; i < q ; i++){
     int t , a , b ;
     cin >> t >> a >> b;
     if(!f){
       if(a>n)a-=n;else a+=n ;
       if(b>n)b-=n;else b+=n ;
     }
     if(t==1){
          swap(s[a-1],s[b-1]);
     }else{
        f=f^1;
     }
   }
   if(!f){
     for(int i = n ; i < 2*n ; i++)cout << s[i];
     for(int i = 0 ; i < n ; i++)cout << s[i];
   }else{
     cout << s;
   }
}

signed main() {
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        NeedForSpeed
        int t = 1;
        cout << fixed << setprecision(12) ;
        // cin >> t;
        while(t--){
            // cout << "Case #" << cases << ": ";
            go();
        }

}

#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
//const int MOD = (int) 1e9 + 7;
const int MOD = 119 << 23 | 1;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() {return abs((int) mt());}
inline int mrand(int k) {return abs((int) mt()) % k;}
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";

void chemthan() {
    int n, m, k; cin >> n >> m >> k;
    vector<string> s(n);
    FOR(i, 0, n) FOR(j, 0, m) s[i] += "z";
    FOR(i, 0, k) {
        int u, v; cin >> u >> v; u--, v--;
        cin >> s[u][v];
    }
    vector<vi> dp(n, vi(m));
    int iv = inv(3);
    dp[0][0] = fpow(3, n * m - k);
    FOR(i, 0, n) FOR(j, 0, m) {
        if (s[i][j] == 'R') {
            if (j + 1 < m) {
                addmod(dp[i][j + 1], dp[i][j]);
            }
        }
        else if (s[i][j] == 'D') {
            if (i + 1 < n) {
                addmod(dp[i + 1][j], dp[i][j]);
            }
        }
        else if (s[i][j] == 'X') {
            if (j + 1 < m) {
                addmod(dp[i][j + 1], dp[i][j]);
            }
            if (i + 1 < n) {
                addmod(dp[i + 1][j], dp[i][j]);
            }
        }
        else {
            if (j + 1 < m) {
                addmod(dp[i][j + 1], mult(iv, 2 * dp[i][j]));
            }
            if (i + 1 < n) {
                addmod(dp[i + 1][j], mult(iv, 2 * dp[i][j]));
            }
        }
    }
    cout << dp[n - 1][m - 1] << "\n";
}

int32_t main(int32_t argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <unordered_map>
#include <fstream>
#define rep(i,a,n)  for(int i=a;i<=n;i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
#define pb push_back
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const ll N=100005;
const double esp=1e-6;
void debug(ll x)  { cout<<111<<" "<<x<<'\n'; }
ll n,m,k,tt;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
int main() {
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  //ifstream s("photo.in");
  //ofstream c("photo.out");
  //freopen("photo.in", "r", stdin);
  //freopen("photo.out", "w", stdout);
  tt=1;
  //cin>>tt;
  while(tt--) {
    cin>>n;
    string s;
    cin>>s;
    if(s[0]!=s[n-1]) cout<<1<<'\n';
    else {
      int f=0;
      for(int i=1;i<=n-3;i++) if(s[i]!=s[0]&&s[i+1]!=s[n-1]) f=1;
      if(f) cout<<2<<'\n';
      else cout<<-1<<'\n';
    }
  }
  return 0;
}
/*

*/

#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
#define MP make_pair
#define PB push_back
#define I insert

const LL mod=1000000007, N=200005;
using namespace std;

LL n, m, i, j, k, l, r, t, ans[N];
LL fix[N], p[N], fox[N];
vector < LL > v[N];

void go ( LL u, LL par = 0 ){
	fix[u] = fix[par] + 1;
	p[u] = par;
	for ( LL i = 0; i < v[u].size(); ++i ){
		if ( v[u][i] == par ) continue;
		go ( v[u][i], u );
	}
}

void jo ( LL u, LL par = 0 ){
	LL bb = 0;
	ans[u] = ++t;
	for ( LL i = 0; i < v[u].size(); ++i ){
		if ( v[u][i] == par ) continue;
		if ( fox[v[u][i]] ){
			bb = v[u][i];
			continue;
		}
		jo(v[u][i], u);
	}
	if ( bb ){
		jo ( bb, u);
	}
	++t;
}

int main(){
	ios_base::sync_with_stdio(false);

	cin >> n;
	for ( i = 1; i < n; ++i ){
		cin >> l >> r;
		v[l].PB(r);
		v[r].PB(l);
	}

	go ( 1 );
	l = 1;
	for ( i = 1; i <= n; ++i ){
		if ( fix[l] < fix[i] ) l = i;
	}
	go ( l );
	r = 1;
	for ( i = 1; i <= n; ++i ){
		if ( fix[r] < fix[i] ) r = i;
	}

	k = r;
	while ( k != l ){
		fox[k] = 1;
		k = p[k];
	}

	t = 0;
	jo(l);

	for ( i = 1; i <= n; ++i ) cout << ans[i] << " ";

	return 0;
}
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define f first
#define s second
#define ld long double
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int x,y;
    cin>>x>>y;
    if(x>y)
    swap(x,y);
    if(y-x<3)
    cout<<"Yes";
    else
    cout<<"No";
    // int n;
    // cin>>n;
    // vector<int> a(n);
    // for(int i=0;i<n;i++)
    // cin>>a[i];

    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define pi pair
#define K 1000000007
using namespace std;

ll a[2000000];
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll test_case=1;//cin>>test_case;
	while(test_case--)
	{
        ll m,h;cin>>m>>h;
        if(h%m==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
	}
	return 0;
}


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

  if(b==0) cout<<c<<endl;
  else if(b>0){
    if(c==1) cout<<2<<endl;
    else if(c==2) cout<<3<<endl;
    else cout<<c-1+min(2*b,c)<<endl;
  }
  else{
    if(c==1) cout<<2<<endl;
    else if(c==2) cout<<3<<endl;
    else cout<<c+min(2*(-b),c)<<endl;
  }

  return 0;
}

#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
template<class T> bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int main()
{
    ll B,C; scanf("%lld%lld",&B,&C);
    vector<pair<ll,ll>> s;
    s.pb({B-C/2,B});
    s.pb({-B,-B+(C-1)/2});
    s.pb({-B-(C-1)/2,-B});
    if(C>=2) s.pb({B,B+(C-2)/2});
    sort(s.begin(),s.end());
    ll rt=-8e18,ans=0;
    for(auto [l,r]: s)
    {
        if(r>rt)
        {
            if(l>rt) ans+=r-l+1;
            else ans+=r-rt;
            rt=r;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;

struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, M, K; cin >> N >> M >> K;
	if (N == 1) {
		mint ans = mint(K).pow(M);
		cout << ans << endl; return 0;
	}
	if(M == 1){
		mint ans = mint(K).pow(N);
		cout << ans << endl; return 0;
	}
	mint ans = 0;
	for (int i = 1; i <= K; i++) {
		mint now = 0;
		now = mint(i).pow(N) - mint(i - 1).pow(N);
		now *= mint(K - i + 1).pow(M);
		ans += now;
	}
	cout << ans << endl;
	return 0;
}

#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <string.h>

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define all(V) V.begin(), V.end()
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
template <class T>
class prique : public std::priority_queue<T, std::vector<T>, std::greater<T>> {
};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return true;
	}
	return false;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return true;
	}
	return false;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b;
		b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1) return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}
template <typename T>
T mypow(T a, lint b) {
	T res(1);
	while (b) {
		if (b & 1) res *= a;
		a *= a;
		b >>= 1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while (b) {
		if (b & 1) {
			res *= a;
			res %= m;
		}
		a *= a;
		a %= m;
		b >>= 1;
	}
	return res;
}
template <typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()) {
		std::cout << vec[i];
		std::cout << (i == (int)vec.size() - 1 ? "\n" : " ");
	}
}
template <typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != r; i++) {
		std::cout << *i;
		std::cout << (i == rprev ? "\n" : " ");
	}
}
LP extGcd(lint a, lint b) {
	if (b == 0) return {1, 0};
	LP s = extGcd(b, a % b);
	std::swap(s.first, s.second);
	s.second -= a / b * s.first;
	return s;
}
LP ChineseRem(const lint& b1, const lint& m1, const lint& b2, const lint& m2) {
	lint p = extGcd(m1, m2).first;
	lint tmp = (b2 - b1) * p % m2;
	lint r = (b1 + m1 * tmp + m1 * m2) % (m1 * m2);
	return std::make_pair(r, m1 * m2);
}
template <typename F>
inline constexpr decltype(auto) lambda_fix(F&& f) {
	return [f = std::forward<F>(f)](auto&&... args) {
		return f(f, std::forward<decltype(args)>(args)...);
	};
}
template <typename T>
std::vector<T> make_vec(size_t n) {
	return std::vector<T>(n);
}
template <typename T, class... Args>
auto make_vec(size_t n, Args&&... args) {
	return std::vector<decltype(make_vec<T>(args...))>(
		n, make_vec<T>(std::forward<Args>(args)...));
}
#line 2 "main.cpp"
int N;
int main() {
	std::cin >> N;
	lint res = 1;
	REP(i, N) res = lcm(res, i);
	std::cout << res + 1 << std::endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}

int main() {
    ll N, M; cin >> N >> M;
    vector<pair<ll,ll>> m(M);
    rep(i,M) {
        ll a, b; cin >> a >> b;
        a--; b--;
        m[i] = {a,b};
    }
    ll K; cin >> K;
    vector<pair<ll,ll>> k(K);
    rep(i,K) {
        ll c, d; cin >> c >> d;
        c--; d--;
        k[i] = {c,d};
    }

    ll ans = 0;
    rep(bit,1<<K) {
        vector<ll> vec(N);
        rep(i,K) {
            ll x = k[i].first, y = k[i].second;
            if ((bit>>i)&1) vec[x]++;
            else vec[y]++;
        }
        ll cnt = 0;
        rep(i,M) {
            ll x = m[i].first, y = m[i].second;
            if (vec[x]>=1 && vec[y]>=1) cnt++;
        }
        ans = max(ans,cnt);
    }

    cout << ans << endl;
}

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

int main () {
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 //~ cin >> T;
	 for (int test_case = 1; test_case <= T; ++test_case) {
		 int n,m;
		 cin >> n >> m;
		 pair<int,int> a[m + 1];
		 for (int i = 1; i <= m; ++i) cin >> a[i].first >> a[i].second;
		 int k;
		 cin >> k;
		 pair<int,int> b[k + 1];
		 int res = 0;
		 for (int i = 1; i <= k; ++i) cin >> b[i].first >> b[i].second;
		 for (int bit = 0; bit < (1 << k); ++bit) {
			 int count[n + 1];
			 for (int i = 1; i <= n; ++i) count[i] = 0;
			 for (int i = 1; i <= k; ++i) {
				 if (bit & (1 << (i - 1))) {
					 ++count[b[i].second];
				 } else {
					 ++count[b[i].first];
				 }
			 }
			 int total = 0;
			 for (int i = 1; i <= m; ++i) {
				 total += (count[a[i].first] and count[a[i].second]);
			 }
			 res = max(res,total);
		 }
		 cout << res << '\n';
	 }
	 //cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;++i)
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=1;i<=n;++i)
#define size sze
typedef long long LL;
const int pri[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int n;
int a[100];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    long long ans=-1;
    for(int i=0;i<(1<<15);i++)
    {
        long long ret=1;
        for(int j=0;j<15;j++)
            if ((1<<j)&i)ret=ret*pri[j];
        int flag=1;
        for(int i=1;i<=n;i++)
            if (__gcd(1ll*a[i],ret)==1)flag=0;
        if (!flag)continue;
        if (ans==-1 || ans>ret)ans=ret;
    }
    cout<<ans<<endl;
    return 0;
}

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

const int MAX = 200010;
bool is[MAX];

int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    is[x] = true;
    while(is[ans]){
      ans++;
    }
    cout << ans << endl;
  }
}


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

int solve(int h, int w, vector<string> s) {
    int res = 0;
    for(int i = 0; i < h - 1; i++) {
        for(int j = 0; j < w - 1; j++) {
            int black = 0;
            if(s[i][j] == '#')
                black++;
            if(s[i][j + 1] == '#')
                black++;
            if(s[i + 1][j] == '#')
                black++;
            if(s[i + 1][j + 1] == '#')
                black++;
            if(black == 1 || black == 3) {
                //cout << "i: " << i << " J " << j << " -> " << black <<endl;
                res++;
            }
        }
    }
    return res;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; i++) {
        cin >> s[i];
    }
    cout << solve(h, w, s) << endl;
}


//yukicoder@cpp14
//coder:luckYrat(twitter:@luckYrat_)
//dijkstraから逃げるな
//おすすめの曲
//https://soundcloud.com/nagiha/alice-in-a-xxxxxxxx
//https://soundcloud.com/synthion/sweetheart

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>

//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define mkp make_pair
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {mkp(0,1),mkp(0,-1),mkp(1,0),mkp(-1,0)};
P ar8[8] = {mkp(-1,-1),mkp(-1,0),mkp(-1,1),mkp(0,-1),mkp(0,1),mkp(1,-1),mkp(1,0),mkp(1,1)};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  for(int i = 1; n >= i; i++){
    if(A[i-1] != i){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n, x[50];
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> x[i];
	long long ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = 0; i < (1<<15); i++) {
		long long val = 1;
		for (int j = 0; j < 15; j++)
			if (i & (1<<j)) val *= prime[j];
		bool flag = 1;
		for (int j = 1; j <= n; j++)
			if (gcd(val, x[j]) == 1) flag = 0;
		if (flag) ans = min(ans, val);
	}
	cout << ans << endl;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define ll long long
#define MAXN 300005
#define uns unsigned
#define INF 0x3f3f3f3f
using namespace std;
inline ll read(){
	ll x=0;bool f=1;char s=getchar();
	while((s<'0'||s>'9')&&s>0){if(s=='-')f^=1;s=getchar();}
	while(s>='0'&&s<='9')x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return f?x:-x;
}
ll n,s;
int main()
{
	n=read(),s=n;
	for(int b=0;(1ll<<b)<=n;b++){
		ll B=(1ll<<b),a=n/B,c=n-a*B;
		s=min(s,a+b+c);
	}
	printf("%lld\n",s);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long diff;
map<long long, long long> dp;

long long fun(long long n, long long m)
{
    if(n>=m)
        return dp[m] = (n-m);
    long long res=m-n;
    if(m%2)
    {
        long long r1, r2;
        if(!dp[m-1])
            r1 = fun(n, m-1);
        else
            r1 = dp[m-1];
        if(!dp[m+1])
            r2 = fun(n, m+1);
        else
            r2 = dp[m+1];
        res = min(res, 1+min(r1, r2));
    }
    else
    {
        long long r3;
        if(!dp[m/2])
            r3 = fun(n, m/2);
        else
            r3 = dp[m/2];
        res = min(res, 1+r3);
    }
    return dp[m] = res;
}

int main()
{
    long long n, m;
    cin >> n >> m;
    long long res = fun(n, m);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
//const int mod = 1000000007;
const int mod = 998244353;
template<long long MOD>
struct ModInt{

    using ll = long long;
    ll val;

    void setval(ll v) { val = v % MOD; };
    ModInt(): val(0) {}
    ModInt(ll v) { setval(v); };

    ModInt operator+(const ModInt &x) const { return ModInt(val + x.val); }
    ModInt operator-(const ModInt &x) const { return ModInt(val - x.val + MOD); }
    ModInt operator*(const ModInt &x) const { return ModInt(val * x.val); }
    ModInt operator/(const ModInt &x) const { return *this * x.inv(); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator+=(const ModInt &x) { return *this = *this + x; }
    ModInt operator-=(const ModInt &x) { return *this = *this - x; }
    ModInt operator*=(const ModInt &x) { return *this = *this * x; }
    ModInt operator/=(const ModInt &x) { return *this = *this / x; }
    bool operator==(const ModInt &x) const { return (*this).val == x.val; }

    friend ostream& operator<<(ostream &os, const ModInt &x) { os << x.val; return os; }
    friend istream& operator>>(istream &is, ModInt &x) { is >> x.val; x.val = (x.val % MOD + MOD) % MOD; return is; }

    ModInt pow(ll n) const {
        ModInt a = 1;
        if(n == 0) return a;
        int i0 = 64 - __builtin_clzll(n);
        for(int i = i0 - 1; i >= 0; i--){
            a = a * a;
            if((n >> i) & 1) a *= (*this);
        }
        return a;
    }
    ModInt inv() const { return this->pow(MOD - 2); }
};

using mint = ModInt<mod>; mint pow(mint x, long long n) { return x.pow(n); }

int main() {
    int T;cin>>T;while(T--) {
        ll n;cin>>n;
        int cnt=0;
        while(n%2==0) n/=2,cnt++;
        if(cnt==0) cout<<"Odd";
        else  if(cnt==1) cout<<"Same";
        else cout<<"Even";
        cout<<endl;
    }
    return 0;
}

#include<iostream>
using namespace std;

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

    for(int i = 0; i < T; i++){
        if(c[i] % 2 != 0){
            cout << "Odd\n";
        } else if(c[i] % 4 == 0){
            cout << "Even\n";
        } else {
            cout << "Same\n";
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
//#define mn LLONG_MAX
//#define mx LLONG_MIN
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define pb(a) push_back(a)
ll prime[][2]={{0,0},{2,3},{11,13},{101,103},{1009,1013},
   {10007,10009},{100003,100013},{1000003,1000033},{10000019,10000079},{100000007,100000037}};
ll arr[]={0,1,10,100,1000,10000,100000,1000000,10000000,100000000,100000000,1000000000};
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b){
         return (a.second<b.second);
          }

bool ff(const pair<int ,int>&a,const pair<int,int>&b)//sorting a parir of first element increasing wise and if they are equal second element in decreasing wise
{if(a.first==b.first)
return (a.second>b.second);
else return (a.first<b.first);}

ll fact(ll n){
           ll ans=1;
           while(n>0){
            ans*=n;
            n--;
           }
           return ans;
           }
 void primme(ll n){

 vector<ll>v(n,0);
 for(ll i=2;i<=n;i++){
              if(v[i]==0){
       for(ll j=i*i;j<=n;j+=i){
         v[j]=1;
       }
 }}

 for(ll i=2;i<=n;i++)
       if(v[i]==0)
       cout<<i<<" ";
cout<<"\n";

 }

void solve(){

ll n;
cin>>n;
ll a[n],i;
map<ll,ll>m;
for(i=0;i<n;i++){
       cin>>a[i];
       m[a[i]]++;
}
while(n){
       if(m[n]!=1)
       {
              cout<<"No\n";
              return;
       }
  --n;
}
cout<<"Yes\n";

}

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

    }

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

int main(){
  int n; cin >> n;
  vector<bool> t(n,false);
  bool ans = true;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    if(t[a-1]) ans = false;
    t[a-1] = true;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i, begin, end) for(int i = int(begin); i < int(end); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}
// UF木
struct UnionFind {
  vector< int > data;

  UnionFind() = default;

  explicit UnionFind(size_t sz) : data(sz, -1) {}

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int find(int k) {
    if(data[k] < 0) return (k);
    return data[k] = find(data[k]);
  }
  int size(int k) {
    return -data[find(k)];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<ll> a(n);
    cin >> a;
    vector<ll> b(n);
    cin >> b;
    UnionFind uf(n);
    rep(i,m){
        int c,d;
        cin >> c >> d;
        c--;d--;
        uf.unite(c, d);
    }
    vector<ll> ans(n), res(n);
    rep(i,n){
        ll num = uf.find(i);
        ans[num] += a[i];
        res[num] += b[i];
    }
    rep(i,n){
        if(ans[i] != res[i]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

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

#define vec vector
#define PB push_back

#define MP make_pair
#define MT make_tuple
#define F first
#define S second

using ll = long long int; // watch out for overflows in your code
using pii = pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void debug() { cout << "\n"; };
template <typename T, typename... Targs>
void debug(T t, Targs... args) {
    cout << t << " ";
    debug(args...);
}

template <typename T1, typename T2>
inline ostream& operator << (ostream& os, const pair<T1,T2>& p) {
    return os << "(" << p.F << ", " << p.S << ")";
}

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

template <typename T>
inline ostream& operator << (ostream& os, const vec<vec<T>>& m) {
    for(auto& v : m) {
        for(auto& t : v) {
            os << t << " ";
        }
        os << "\n";
    }
    return os;
}

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

template <typename K, typename V>
inline ostream& operator << (ostream& os, const map<K,V>& m) {
    for(auto& p : m) {
        os << p.F << " -> " << p.S << "\n";
    }
    return os;
}

const ll INF = 9 * 1e18;

int N;
vec<ll> lo, hi;

ll dist(ll st, ll fn, ll x) {
    return abs(x-st) + abs(st-fn);
}

vec<vec<ll>> dp;

void compute_dp() {
    dp.assign(N+1, vec<ll>(2,0));
    ffor(c, 1, N) {
        if(lo[c] == lo[c-1] && hi[c] == hi[c-1]) {
            dp[c][0] = dp[c-1][0];
            dp[c][1] = dp[c-1][1];
        }
        else {
            dp[c][0] = min(dp[c-1][0] + dist(hi[c], lo[c], lo[c-1]), dp[c-1][1] + dist(hi[c], lo[c], hi[c-1]));
            dp[c][1] = min(dp[c-1][0] + dist(lo[c], hi[c], lo[c-1]), dp[c-1][1] + dist(lo[c], hi[c], hi[c-1]));
        }
    }
}

////////////////////////////////////////////////////////////////////////

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

    cin >> N;
    lo.assign(N+1, INF);
    hi.assign(N+1, -INF);
    lo[0] = hi[0] = 0;
    ffor(i, 1, N) {
        ll x; int c;
        cin >> x >> c;
        lo[c] = min(lo[c], x);
        hi[c] = max(hi[c], x);
    }

    ffor(c, 1, N) {
        if(lo[c] == INF) lo[c] = lo[c-1];
        if(hi[c] == -INF) hi[c] = hi[c-1];
    }

    compute_dp();
    cout << min(dp[N][0] + abs(lo[N]), dp[N][1] + abs(hi[N])) << "\n";
}


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

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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 gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
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;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

// ２項係数
/*
ll ncrmod(ll n, ll r)
{
  ll ans;

  return ans;
}
*/

// 繰り返し二乗法
ll powmod(int a, int n){//aのn乗を計算します(MOD)。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = (x*a) % MOD;
    }
    a = (a*a) % MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

ll f(ll a, ll b)
{
  ll ret;
  if(a > b) ret = a * 1000000 + b;
  else ret = b * 1000000 + a;
  return ret;
}

void solve()
{
  ll N; cin >> N;
  vector<ll> x(N), y(N); rep(i, N) cin >> x[i] >> y[i];
  vector<pair<ll,ll>> x1;
  vector<pair<ll,ll>> y1;
  rep(i, N) {
	x1.push_back({x[i], i});
	y1.push_back({y[i], i});
  }
  sort(x1.begin(), x1.end());
  sort(y1.begin(), y1.end());
  vector<pair<ll,ll>> m;
  m.push_back({x1[N-1].first-x1[0].first, f(x1[N-1].second, x1[0].second)});
  m.push_back({x1[N-2].first-x1[0].first, f(x1[N-2].second, x1[0].second)});
  m.push_back({x1[N-1].first-x1[1].first, f(x1[N-1].second, x1[1].second)});

  m.push_back({y1[N-1].first-y1[0].first, f(y1[N-1].second, y1[0].second)});
  m.push_back({y1[N-2].first-y1[0].first, f(y1[N-2].second, y1[0].second)});
  m.push_back({y1[N-1].first-y1[1].first, f(y1[N-1].second, y1[1].second)});

  sort(m.rbegin(), m.rend());

  if(m[0].second != m[1].second) {
  cout << m[1].first << endl;
  } else {
	cout << m[2].first << endl;
  }

}

int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}

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

#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define ps(x) fixed << setprecision(10) << x
#define mod 1000000007
#define inf 1e18
#define w(tc)  int tc; cin >> tc; for (int i = 1; i <= tc; ++i)
#define PI 3.14159265358979323846264338327950L
#define span(a) begin(a), end(a)
#define ll long long

const int N = 109;
double dp[N][N][N];

double calc(int a, int b, int c) {
	if (a >= 100 or b >= 100 or c >= 100)
		return 0;

	if (dp[a][b][c] >= 0) return dp[a][b][c];

	double tot = a + b + c;
	dp[a][b][c] = 1 + a / tot * calc(a + 1, b, c) + b / tot * calc(a, b + 1, c) + c / tot * calc(a, b, c + 1);

	return dp[a][b][c];
}

inline void solve() {
	memset(dp, -1, sizeof(dp));
	int a, b, c; cin >> a >> b >> c;
	double ans = calc(a, b, c);
	cout << ps(ans);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//w(tc)
	solve();
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <functional>
#include <cassert>
#include <stack>
#include <numeric>
#include <iomanip>
#include <limits>
#include <random>
#include <unordered_set>
#include <chrono>

typedef int64_t ll;
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
typedef std::pair<double, double> Pdd;

#define rip(_i, _n, _s) for (int _i = (_s); _i < (int)(_n); _i++)
#define all(_l) _l.begin(), _l.end()
#define rall(_l) _l.rbegin(), _l.rend()
#define MM << " " <<

template<typename _T>
using MaxHeap = std::priority_queue<_T>;
template<typename _T>
using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>;

template<typename _T>
inline bool chmax(_T &_l, const _T _b) {
    if (_l < _b) {
        _l = _b;
        return true;
    }
    return false;
}
template<typename _T>
inline bool chmin(_T &_l, const _T _b) {
    if (_l > _b) {
        _l = _b;
        return true;
    }
    return false;
}

template<typename _T>
void vdeb(const std::vector<_T> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename _T>
void vdeb(const std::vector<std::vector<_T>> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        // std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using namespace std;

void solve() {
    int n; cin >> n;
    vector<int> da(n);
    rip(i,n,0) cin >> da[i];
    vector<int> ans;
    int c = 0;
    while(1) {
        int flg = 0;
        for(int i = n-2; i >= 0; i--) {
            if((i^c^1)&1) {
                if(da[i] > da[i+1]) {
                    ans.push_back(i+1);
                    swap(da[i], da[i+1]);
                    flg = 1;
                    break;
                }
            }
            else {
                if(da[i] > da[i+1]) {
                    flg = 2;
                }
            }
        }
        if(flg == 2) {
            if((c&1) == 1) {
                swap(da[1], da[2]);
                ans.push_back(2);
            }
            else {
                swap(da[1], da[0]);
                ans.push_back(1);
            }
        }
        else if(flg == 0){
            break;
        }
        c++;
    }
    cout << ans.size() << endl;
    vdeb(ans);
}

int main() {
    int t; cin >> t;
    rip(i,t,0) solve();
}

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T popFirst(multiset<T> &a){
  T res = *(a.begin());
  a.erase(a.begin());
  return res;
}
template<class T> inline T getFirst(multiset<T> &a){
  return *(a.begin());
}
template<class T> inline T popFirst(set<T> &a){
  T res = *(a.begin());
  a.erase(a.begin());
  return res;
}
template<class T> inline T getFirst(set<T> &a){
  return *(a.begin());
}
int N;
char S[500000+2];
char T[500000+2];
int main(){
  int i;
  int x;
  int y;
  long long res = 0;
  set<int> ss;
  set<int> tt;
  rd(N);
  rd(S);
  rd(T);
  for(i=(0);i<(N);i++){
    if(S[i]=='1'){
      ss.insert(i);
    }
  }
  for(i=(0);i<(N);i++){
    if(T[i]=='1'){
      tt.insert(i);
    }
  }
  while(ss.size() || tt.size()){
    if(ss.size()==0){
      wt_L(-1);
      wt_L('\n');
      return 0;
    }
    if(tt.size()==0 || getFirst(ss) < getFirst(tt)){
      if(ss.size()==1){
        wt_L(-1);
        wt_L('\n');
        return 0;
      }
      x = popFirst(ss);
      y = popFirst(ss);
      res += y - x;
      continue;
    }
    else{
      x = popFirst(ss);
      y = popFirst(tt);
      res += x - y;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20201115-1

// --- original code ---
// int N;
// char S[5d5+2], T[5d5+2];
// {
//   int x, y;
//   ll res = 0;
//   set<int> ss, tt;
//   rd(N,S,T);
//   rep(i,N) if(S[i]=='1') ss.insert(i);
//   rep(i,N) if(T[i]=='1') tt.insert(i);
//   while(ss.size() || tt.size()){
//     if(ss.size()==0) wt(-1), return 0;
//     if(tt.size()==0 || getFirst(ss) < getFirst(tt)){
//       if(ss.size()==1) wt(-1), return 0;
//       x = popFirst(ss);
//       y = popFirst(ss);
//       res += y - x;
//       continue;
//     } else {
//       x = popFirst(ss);
//       y = popFirst(tt);
//       res += x - y;
//     }
//   }
//   wt(res);
// }


#include <bits/stdc++.h>

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)

using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}

//TODO: SOLUTION

char playGame(str & s, int l, int r) {
    if (l == r)
        return s[l];
    char w1 = playGame(s, l, (l + r) / 2);
    char w2 = playGame(s, (l + r) / 2 + 1, r);

    if (w1 == 'R') {
        if (w2 == 'P')
            return w2;
        else
            return w1;
    }
    if (w1 == 'P') {
        if (w2 == 'S')
            return w2;
        else
            return w1;
    }
    if (w1 == 'S') {
        if (w2 == 'R')
            return w2;
        else
            return w1;
    }
    return w1;
}

void solve() {
    int n, k; cin >> n >> k;
    str s; cin >> s;

    if (k <= 15) {
        str w;
        while (w.size() < pow(2, k))
            w += s;
        cout << playGame(w, 0, pow(2, k) - 1);
        return;
    }

    int played = 0;
    while (played < k) {
        str a;
        s += s;
        for (int i = 0; i < n; i++)
            a.push_back(playGame(s, 2*i, 2*i + 1));
        s = a;
        played++;
    }

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

int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

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

char win[256][256];

int main()
{
    // editorial
    // 区間長2nの隣同士の対戦結果から
    // 区間長nの列を生成

    win['R']['R'] = win['R']['S'] = win['S']['R'] = 'R';
    win['P']['P'] = win['P']['R'] = win['R']['P'] = 'P';
    win['S']['S'] = win['S']['P'] = win['P']['S'] = 'S';

    int n, k;
    string s;

    cin >> n >> k >> s;

    rep(x, k) {
        string t = s + s;
        rep(i, n) {
            int a = t[i * 2], b = t[i * 2 + 1];
            s[i] = win[a][b];
        }
    }

    cout << s[0] << "\n"s;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

struct Edge {
    int to;
    pair<ll,ll>w;
    Edge(int to, pair<ll,ll> w) : to(to), w(w) {}
};

using Graph = vector<vector<Edge>>;

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

int main() {
    int N, M, s;
    cin >> N >> M;
	s=0;

    Graph G(N);
    for (int i = 0; i < M; ++i) {
      int a, b;cin>>a>>b;a--;b--;
      ll w,d;
      cin>>w>>d;
      G[a].push_back(Edge(b, {w,d}));
      G[b].push_back(Edge(a,{w,d}));
    }

    // ダイクストラ法
    vector<long long> dist(N, INF);
    dist[s] = 0;

    // (d[v], v) のペアを要素としたヒープを作る
    priority_queue<pair<long long, int>,
                   vector<pair<long long, int>>,
                   greater<pair<long long, int>>> que;
    que.push(make_pair(dist[s], s));

    // ダイクストラ法の反復を開始
        while (!que.empty()) {
        // v: 使用済みでない頂点のうち d[v] が最小の頂点
        // d: v に対するキー値
        int v = que.top().second;
        long long d = que.top().first;
        que.pop();

        // d > dist[v] は，(d, v) がゴミであることを意味する
        if (d > dist[v]) continue;
        // 頂点 v を始点とした各辺を緩和
        for (auto e : G[v]) {
          for(int t=(int)sqrt(e.w.second)-2;t<=(int)sqrt(e.w.second)+2;t++){
            if(t<0)continue;
          if(dist[v]<=t){
            if (chmin(dist[e.to], t + e.w.first+e.w.second/(t+1))) {
                // 更新があるならヒープに新たに挿入
                que.push(make_pair(dist[e.to], e.to));
              }
          }
          else{
            if (chmin(dist[e.to], dist[v] + e.w.first+e.w.second/(dist[v]+1))) {
                // 更新があるならヒープに新たに挿入
                que.push(make_pair(dist[e.to], e.to));
            }
          }
          }
        }
    }

    // 結果出力
    if (dist[N-1] < INF) cout << dist[N-1] << endl;
    else cout << -1 << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define nline "\n"
const ll M1=1e9+7;
const ll M=998244353;
const ll N=100005;
const ll INF_ADD=1e18;
const ll INF_MUL=1e13;
#define f first
#define s second
#define pll pair<ll,ll>
#ifndef ONLINE_JUDGE
#define debug(x) cerr<<#x<<" "; _print(x); cerr<<nline;
#else
#define debug(x);
#endif
void _print(ll x){cerr<<x;}
template<class T,class V> void _print(pair<T,V> p) {cerr<<"{"; _print(p.first);cerr<<","; _print(p.second);cerr<<"}";}
template<class T>void _print(vector<T> v) {cerr<<" [ "; for (T i:v){_print(i);cerr<<" ";}cerr<<"]";}
template<class T>void _print(set<T> v) {cerr<<" [ "; for (T i:v){_print(i); cerr<<" ";}cerr<<"]";}
template<class T>void _print(multiset<T> v) {cerr<< " [ "; for (T i:v){_print(i);cerr<<" ";}cerr<<"]";}
template<class T,class V>void _print(map<T, V> v) {cerr<<" [ "; for(auto i:v) {_print(i);cerr<<" ";} cerr<<"]";}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ll optimal(ll x,ll t){
    ll sq=sqrt(x);
    set<ll> comp;
    comp.insert(t+x/(t+1));
    if(sq>t)
        comp.insert(sq+x/(sq+1));
    sq++;
    if(sq>t)
        comp.insert(sq+x/(sq+1));
    sq++;
    if(sq>t)
        comp.insert(sq+x/(sq+1));
    sq=sqrt(x);
    sq--;
    if(sq>t)
        comp.insert(sq+x/(sq+1));
    sq--;
    if(sq>t)
        comp.insert(sq+x/(sq+1));
    ll best=*(comp.begin());
    return best;
}
void solve(){
    ll n,m; cin>>n>>m;
    vector<vector<pll>> adj(n+2);
    vector<ll> ans(n+5,INF_ADD);
    priority_queue<pll> prefer;
    prefer.push({0,1});
    vector<vector<ll>> a(m+4,vector<ll>(5,0));
    ans[1]=0;
    for(ll i=1;i<=m;i++){
        for(ll j=1;j<=4;j++)
            cin>>a[i][j];
        adj[a[i][1]].pb({a[i][2],i});
        adj[a[i][2]].pb({a[i][1],i});
    }
    while(prefer.size()){
        auto it=prefer.top();
        prefer.pop();
        if(ans[it.s]!=-it.f)
            continue;
        ll node=it.s,instant=-it.f;
        for(auto chld:adj[node]){
            ll compare=(a[chld.s][3]+optimal(a[chld.s][4],instant));
            if(compare<ans[chld.f]){
                prefer.push({-compare,chld.f});
                ans[chld.f]=compare;
            }
        }
    }
    if(ans[n]!=INF_ADD)
        cout<<ans[n];
    else
        cout<<"-1";

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    /*
    Correct data type?
    Infinity?
    Base case?
    */
    cerr<<"Time:"<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";
}


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

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

/* ALIASES */
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;

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

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<lli> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

/* DEFINITIONS */
#define mp make_pair
#define pb push_back
#define F  first
#define S  second
#define lb lower_bound
#define ub upper_bound

#define all(x) x.begin(), x.end()
#define allr(x) rbegin(x), rend(x)
#define fo(i, a, b) for(auto i=a; i<(b); i++)
#define forev(i, b, a) for(auto i = (b)-1; i >= a; i--)
#define sortall(x) sort(all(x))
#define sz(x) (int)x.size()
#define nl "\n"
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cout << vars << " = ";
    string delim = "";
    (..., (cout << delim << values, delim = ", "));
}

/* UTILITIES */

// ====================> Python-like print
void print() {
    cout << "\n";
}
template <typename T>
void print(T &&t) {
    cout << t << "\n";
}
template <typename T, typename... Args>
void print(T &&t, Args &&... args) {
    cout << t << " ";
    print(forward<Args>(args)...);
}
// ====================> cin >> vector<T>
template<typename T>
istream& operator>>(istream &istream, vector<T> &v)
{
    for (auto &it : v) cin >> it;
    return istream;
}
// ====================> cout << vector<T>
template<typename T>
ostream& operator<<(ostream &ostream, const vector<T> &c)
{
    for (auto &it : c) cout << it << " ";
    return ostream;
}

/* CONSTANTS */
const ld PI = 4 * atan((ld)1);
const lli MOD = 1000000007;
const lli INF = 2e18;

/*===========================================================================*/

void solve() {
    lli a, b, c; cin >> a >> b >> c;
    if (a >= 0 && b >= 0) {
        if (a > b) print(">");
        else if (a < b) print("<");
        else print('=');
    } else {
        if (c % 2 == 0) {
            if (abs(a) > abs(b)) {
                print(">");
            }
            else if (abs(b) > abs(a)) {
                print("<");
            }
            else if (abs(a) == abs(b)) print("=");
        } else {
            if (a < b) {
                print("<");
            } else if (b < a) {
                print(">");
            } else print("=");
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    // cin >> t;
    fo(i, 0, t) {
        solve();
    }
    return 0;
}

#include<cstdio>
#include<cmath>
using namespace std;
int a,b,c;
int main() {
	scanf("%d%d%d",&a,&b,&c);
	if(c%2==0) {
		a=abs(a);
		b=abs(b);
	}
	if(a>b)
		printf(">");
	else if(a==b)
		printf("=");
	else
		printf("<");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
#define ll long long int
#define pb push_back
#define fo(i, n) for (int i = 0; i < n; i++)
#define vct vector<long long int>
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans =0;
    if(n>=1000) ans = ans + n-999;
    if(n>=1000000) ans = ans + n-999999;

    if(n>=1000000000) ans = ans + n-999999999;

    if(n>=1000000000000) ans = ans + n-999999999999;

    if(n>=1000000000000000) ans = ans + n-999999999999999;
    cout<<ans<<endl;

    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;
}
//-----------------------ここから-----------
template<class T> T fastpow(T a, T b){
    T res = 1;
    while(b > 0){
        if(b & 1){
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}
int main(void){
    ll n;
    cin >> n;

    string s = to_string(n);
    ll ans = 0;
    rep(i, s.size() - 1){
        ans += fastpow(10LL, (ll)i) * 9 * (i / 3);
    }

    ans += fastpow(10LL, (ll)s.size() - 1) * (ll)(s[0] - '0' - 1) * (ll)((s.size() - 1) / 3);
    ll now = s[0] - '0';
    ll cnt = s.size() - 1;
    while(cnt--) now *= 10;
    now--;
    ans += (n - now) * (ll)((s.size() - 1) / 3);

    cout << ans << endl;

    // ll ans2 = 0;
    // for(ll i = 1; i <= n; i++){
    //     string ss = to_string(i);
    //     ans2 += (ss.size() - 1) / 3;
    // }
    // cout << ans2 << endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
ll powermd(long long x,  int y,	ll p)
{
    ll res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    // if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
//ll mpow(ll x,ll y){
//	if(y==0)
//		return 1;
//	ll res=mpow(x,y/2);
//	res=res*res%mod;
//	if(y&1)
//		res=res*x%MOD;
//	return res;
//}
// ll mpow(ll n,ll t){
// 	if(t==0) return 1;
// 	ll ret=mpow(n,t/2);
// 	ret=ret*ret%MOD;
// 	if(t%2==1) ret=ret*n%MOD;
// 	return ret;
// }
void solve(){
	ll n,p;
	cin>>n>>p;
	cout<<(powermd(p-2,n-1,1000000007)*(p-1))%1000000007;
}
int main(){
// 	ios::sync_with_stdio(false);
// 	cout.tie(0);
// 	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
    while(t--) {
    	// int n;
    	// cin>>n;
    	solve();
	}
}

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

#include<bits/stdc++.h>

using namespace std;

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

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

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

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

class AAtCoderJumper {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      for(int i=0; i<n; i++) {
        int a = i*2;
        int b = i*2+1;
        cout << a%n+1 << ' ' << b%n+1 << endl;
      }
    }
};

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


/*
ID:ACwisher
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
//const int N=;
typedef long long ll;
ll n;
int m;
int power(int a,ll b,int mo){
	int ret=1;
	while(b){
		if(b&1) ret=1ll*ret*a%mo;
		a=1ll*a*a%mo; b>>=1;
	}
	return ret;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdiout);
	scanf("%lld%d",&n,&m);
	int mm=m*m;
	int k=power(10,n,mm);
	printf("%d\n",k/m);
	return 0;
}

/*########################################################################
# File Name: A.cpp
# Author: SoMnus_L
# Mail: lr599909928@gmail.com
# Created Time:日  1/10 14:45:58 2021
########################################################################*/
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
#define rep(a,b,c) for(int a=b;a<=c;++a)
#define per(a,b,c) for(int a=b;a>=c;--a)
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}

ll n,m;

ll fpow(ll a,ll k,ll mod){
	ll res=1;
	while(k){
		if(k&1) res=res*a%mod;
		k>>=1;
		a=a*a%mod;
	}
	return res;
}

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

	cin>>n>>m;

	cout<<fpow(10,n,m*m)/m%m<<'\n';

    return 0;
}


#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
ll INF = 1000000000000000;
struct segment_tree{
    int n; vector<ll> seg;
    segment_tree(vector<ll> v){
        n = v.size(); seg.resize(2*n);
        for(int i=0;i<n;i++) seg[i + n] = v[i];
        for(int i=n - 1;i>0;i--) seg[i] = seg[i<<1] + seg[i<<1|1];
    }
    void update(int p,ll val){
        for(seg[p += n] += val;p>1;p>>=1) seg[p>>1] = seg[p] + seg[p^1];
    }
    ll query(int l,int r){
        ll res = 0;
        for(l += n,r += n; l<r;l>>=1,r>>=1){
            if(l&1) res += seg[l++];
            if(r&1) res += seg[--r];
        }
        return res;
    }
    void clear(){for(int i=0;i<2*n;i++) seg[i] = 0;}
};

int t[200010],x[200010],y[200010];
int main(){
    int i,n,m,q; cin >> n >> m >> q;
    vector<int> a(n),b(m);
    map<int,int> mp;
    mp[0]++;
    for(i=0;i<q;i++){
        cin >> t[i] >> x[i] >> y[i];
        t[i]--; x[i]--; mp[y[i]]++;
    }
    vector<ll> v,u;
    for(auto x:mp) v.push_back(x.first);
    for(i=0;i<v.size();i++) mp[v[i]] = i;
    int k = v.size(); u.resize(k);
    vector<segment_tree> seg(2,segment_tree(u)),seg_num(2,segment_tree(u));
    for(i=0;i<n;i++) seg[0].update(mp[a[i]],a[i]),seg_num[0].update(mp[a[i]],1);
    for(i=0;i<m;i++) seg[1].update(mp[b[i]],b[i]),seg_num[1].update(mp[b[i]],1);
    ll ans = 0;
    for(i=0;i<q;i++){
        ll now;
        int j = x[i];
        if(t[i]==0) now = a[j];
        else now = b[j];
        ans -= seg_num[1 - t[i]].query(0,mp[now])*now + seg[1 - t[i]].query(mp[now],k);
        if(t[i]==0){
            seg[0].update(mp[a[j]],-a[j]); seg_num[0].update(mp[a[j]],-1); a[j] = y[i];
        }else{
            seg[1].update(mp[b[j]],-b[j]); seg_num[1].update(mp[b[j]],-1); b[j] = y[i];
        }
        seg[t[i]].update(mp[y[i]],y[i]); seg_num[t[i]].update(mp[y[i]],1);
        ans += seg_num[1 - t[i]].query(0,mp[y[i]])*y[i] + seg[1 - t[i]].query(mp[y[i]],k);
        cout << ans << "\n";
    }
}

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<int,P>;
using PP = pair<P, P>;
constexpr int INF32 = 1 << 29;
constexpr ll INF64 = 1LL << 62;
constexpr ll MOD = 1000000007;
// constexpr ll MOD = 998244353;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-10;
const double PI = acos(-1);

#define ALL(v) (v).begin(),(v).end()
#define REP(i,n) for(int i=0,i_len=n; i<i_len; ++i)

template<typename T1,typename T2> bool chmax(T1 &a, T2 b) { if (a<b) { a=b; return 1; } return 0; }
template<typename T1,typename T2> bool chmin(T1 &a, T2 b) { if (b<a) { a=b; return 1; } return 0; }

void compress(vector<int> &x, map<int, int> &zip) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    for (int i = 0; i < x.size(); i++) {
        zip[x[i]] = i+1;
    }
}

template <typename T>
struct BIT {
    int N;
    std::vector<T> bit;

    BIT() = default;
    BIT(int n) {init(n);}
    void init(int n){
        N = n;
        bit.assign(n+1, 0);
    }
    T getSum(int i) {  // i番目までの要素の和を求める(1-index)
        T sum = 0;
        while (i > 0) {
            sum += bit[i];
            i -= i & -i;
        }
        return sum;
    }
    void add(int i, T x) {  // i番目の要素にxを加算
        while (i <= N) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

int solve(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<P3> query;
    vector<int> num;
    REP(i,q){
        int t, x, y;
        cin >> t >> x >> y;
        x--;
        query.emplace_back(t,P(x,y));
        num.emplace_back(y);
    }
    num.emplace_back(0);
    map<int,int> zip;
    compress(num, zip);
    vector<ll> a(n), b(m);
    ll res = 0;
    BIT<ll> bitA(num.size()), bitB(num.size()), bitA2(num.size()), bitB2(num.size());
    bitA.add(zip[0], n);
    bitB.add(zip[0], m);
    REP(i,q){
        int t, x, y;
        t = query[i].first;
        x = query[i].second.first;
        y = query[i].second.second;
        if(t == 1){
            res -= bitB.getSum(zip[a[x]]) * a[x];
            res += bitB.getSum(zip[y]) * y;
            if(a[x] < y){
                res -= bitB2.getSum(zip[y]) - bitB2.getSum(zip[a[x]]);
            }else{
                res += bitB2.getSum(zip[a[x]]) - bitB2.getSum(zip[y]);
            }
            bitA.add(zip[a[x]],-1);
            bitA.add(zip[y],1);
            bitA2.add(zip[a[x]],-a[x]);
            bitA2.add(zip[y],y);
            a[x] = y;
        }else{
            res -= bitA.getSum(zip[b[x]]-1) * b[x];
            res += bitA.getSum(zip[y]-1) * y;
            if(b[x] < y){
                res -= bitA2.getSum(zip[y]-1) - bitA2.getSum(zip[b[x]]-1);
            }else{
                res += bitA2.getSum(zip[b[x]]-1) - bitA2.getSum(zip[y]-1);
            }
            bitB.add(zip[b[x]],-1);
            bitB.add(zip[y],1);
            bitB2.add(zip[b[x]], -b[x]);
            bitB2.add(zip[y], y);
            b[x] = y;
        }
        cout << res << endl;
    }
    return 0;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    // int t; cin >> t; for(int i=0;i<t;i++) solve();
    // while(!solve());
    solve();
    return 0;
}


// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(ll i=(ll)s; i<(ll)(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define pss pair<string, string>
#define ull unsigned long long int
#define lld long double
#define F first
#define S second
#define PI 3.141592653589793238
#define prec(n) fixed<<setprecision(n)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    itval(++it, args...);
}
const ll MOD = 1e9 + 7;
template <typename T>
inline void print(T x) {cout << x << "\n";}
template <typename T>
inline void printvec(T x) {for (auto a : x)cout << a << ' '; cout << '\n';}
// -----------------------------------------------------------------------

struct custom {
    bool operator()(const pair<ll, pll> &p1, const pair<ll, pll> &p2)const {
        return p1.F < p2.F;
    }
};

// Calculate a^b % MOD -------------------------------------------------
ll get_pow(ll a, ll b, ll M = MOD) {
    ll res = 1;
    while (b) {
        if (b & 1) res = (res * a) % M;
        a = (a * a) % M;
        b >>= 1;
    }
    return res;
}
// ---------------------------------------------------------------------
const ll N = 2e5 + 5, inf = 2e18;

void solve()
{
    ll a[2][2];
    forn(i, 0, 2)
    forn(j, 0, 2)
    cin >> a[i][j];
    ll ans = -inf;
    forn(i, 0, 2)
    {
        forn(j, 0, 2)
        ans = max(ans, a[0][i] - a[1][j]);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int test = 1;
    clock_t z = clock();
//   cin >> test;

    forn(tes, 0, test)
    {
        solve();
    }
    debug("Total Time:%.4f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define INF ((int64_t)1e16)

int main()
{
    int N;
    int64_t X;
    cin >> N >> X;
    vector<int64_t> A(N);
    for (auto &a : A)
    {
        cin >> a;
    }

    vector<int64_t> cnt(N);
    for (int i = 0; i < N; i++)
    {
        int j = N - 1 - i;
        cnt.at(j) = X / A.at(j);
        X %= A.at(j);
    }
    vector<int64_t> limit(N);
    for (int i = 0; i < N - 1; i++)
    {
        limit.at(i) = A.at(i + 1) / A.at(i);
    }
    limit.at(N - 1) = INF / A.at(N - 1);

    vector<int64_t> ans1(N, 0);
    vector<int64_t> ans2(N, 0);
    if (cnt.at(0) > 0)
    {
        ans1.at(0) = 1;
    }
    ans2.at(0) = 1;
    for (int i = 1; i < N; i++)
    {
        ans1.at(i) = ans1.at(i - 1);
        ans2.at(i) = ans2.at(i - 1);
        if (cnt.at(i) + 1 < limit.at(i))
        {
            ans2.at(i) += ans1.at(i - 1);
        }
        if (cnt.at(i) > 0)
        {
            ans1.at(i) += ans2.at(i - 1);
        }
    }

    cout << ans2.at(N - 1) << endl;

    return 0;
}


#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
//const bool debug = false;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	int ans = 0;
	rep(i, n) {
		int a; cin >> a;
		if (a >= 10)ans += a - 10;
	}
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>

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

	int a, b, ans = 0;
	cin >> a;
	for (int i = 0; i < a; ++i)
	{
		cin >> b;
		ans += max(0LL, b - 10);
	}
	cout << ans << endl;
	return 0;
}


//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
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); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const ll  LINF = (ll)1 << 60;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> cnt(500,0);
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    cnt[a[i]+200]++;
  }
  ll ans=0;
  rep(i,n){
    cnt[a[i]+200]--;
    REP(j,-200,201){
      ans+=pow(abs((j)-a[i]),2)*cnt[j+200];
    }
  }
  cout<<ans<<'\n';
  return(0);
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);
#define mem(a,v) memset(a,v,sizeof(a))
const ll INF=1e18;
const int mod=1e9+7;
const int iinf=1e9+10;
const int xd[4]={1,0,-1,0},yd[4]={0,1,0,-1},mxN=2e5+2;
map<string,int> mp,mp1;
string s[mxN];
int main(){
    faster
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        string g="";
        if(s[i][0]=='!'){
            for(int j=1;j<sz(s[i]);j++)
                g+=s[i][j];
            mp1[g]++;
        }
        else {
            g=s[i];
            mp[g]++;
        }
    }
    for(auto a:mp){
        //cout<<"a.fi="<<a.fi<<"\n";
        if(mp1.find(a.fi)!=mp1.end()){
            cout<<a.fi;exit(0);
        }
    }
    cout<<"satisfiable";
}