// #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<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 << '\n'; cout << '\n';}
// -----------------------------------------------------------------------

struct custom {
    bool operator()(const pll &p1, const 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 = 3000 + 5, inf = 2e18;
ll dp[N][N];
ll tot[N][N];
void solve()
{
    int n;
    cin >> n;
    vll v(n + 1);
    forn(i, 1, n + 1) cin >> v[i];
    ll sum = 0;
    dp[0][0] = 1;
    forn(i, 0, n + 1)
    {
        sum += v[i];
        forn(j, 1, n + 1)
        {
            ll x = sum % j;
            dp[i][j] += tot[j][x];
            dp[i][j] %= MOD;
        }
        forn(j, 1, n + 1)
        {
            ll x = sum % j;
            tot[j][x] += dp[i][j - 1];
            tot[j][x] %= MOD;
        }
    }

    ll ans = 0;
    forn(i, 0, n + 1)
    {
        ans += dp[n][i];
        ans %= MOD;
    }

    cout << ans;

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

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

const ll MOD = 1000000007;

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

ll mul(ll a, ll b){
    return (a*b)%MOD;
}

const ll MAXN = 3000;

ll dpp[MAXN+5];
ll dp[MAXN+5];
ll ima[MAXN+5];

ll a[MAXN+5];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n;
    cin >> n;
    for(ll i=1; i<=n; i++){
        cin >> a[i];
        dpp[i] = 1;
    }
    ll res = 1;
    for(ll turns=2; turns<=n; turns++){
        ll tr = 0;
        for(ll i=0; i<turns; i++) ima[i] = 0;
        for(ll i=1; i<=n; i++){
            tr = (tr+a[i])%turns;
            dp[i] = ima[tr];
            ima[tr] = add(ima[tr], dpp[i]);
        }
        res = add(res, dp[n]);
        for(ll i=1; i<=n; i++) dpp[i] = dp[i];
    }
    cout << res;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#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 length size()
#define int long long
#define ll long long
#include <cstdint>
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    if(n==0) return 0;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
const int MOD = 1000000007;
const int mod = 998244353;
const int MAX = 510000;
const int inf = 400000000000000;
template<typename T> string join(vector<T> &vec ,const string &sp){
    int si = vec.length;
    if(si==0){
        return "";
    }else{
        stringstream ss;
        rep(i,si-1){
            ss << vec[i] << sp;
        }
        ss << vec[si - 1];
        return ss.str();
    }
}
vector<vector<int>> ruiseki2d(vector<vector<int>> vec){
    rep(i,vec.size()-1){
        rep(j,vec[0].size()-1){
            vec[i+1][j+1] = vec[i][j+1]+vec[i+1][j]-vec[i][j]+vec[i+1][j+1];
        }
    }
    return vec;
}
class CompareDist
{
public:
    bool operator()(pair<int,int> p,pair<int,int>q){
    return p.second > q.second;
}
};
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}
vector<int> dijkstra(vector<vector<pair<int,int>>> vec,int s){
    priority_queue<pair<int,int>,vector<pair<int,int>>,CompareDist> que;
    pair<int,int> f = make_pair(s,0);//point,cost;
    que.push(f);
    bool y = false;
    vector<int> cost(vec.size(),inf);
    while(!que.empty()){
        pair<int,int> tmp = que.top();
        que.pop();
        int p = tmp.first;
        int c = tmp.second;
        if(cost[p]>c){
        cost[p] = c;
        rep(i,vec[p].size()){
            if(cost[vec[p][i].first]<=inf){
            tmp = make_pair(vec[p][i].first,vec[p][i].second+c);
            que.push(tmp);
            }
        }
        }
        if(!y) cost[p] = inf;
        y = true;
    }
    return cost;
}
signed main(void){
    int n;
    cin >> n;
    double ans = 0;
    rep(i,n){
        ans += (double)((double)1/((double)i+1));
    }
    cout << std::setprecision(20) <<ans*n-1 << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

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

    ll n; cin >> n;
    ll ans = INF, b = 0;
    while((1LL << b) <= n){
        ll a = n / (1LL << b);
        ll c = n % (1LL << b);
        ans = min(ans, a + b + c);
        b++;
    }
    print(ans)

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>data(3);
  for(int i=0;i<3;i++){
    cin>>data[i];
  }
  sort(data.begin(),data.end());
  if(data[0]-data[1]==data[1]-data[2]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

#include<stdio.h>
#define Swap(a,b) do{typeof(a) T=(a);a=b;b=T;}while(0)
static inline int Min(int a,int b){return a<b?a:b;}
static inline int IN(void)
{
  int x=0,f=1,c=getchar();while(c<48||c>57){if(c==45){f=-f;}c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f*x;
}
int main(void)
{
  int A=IN(),B=IN(),C=IN(),x=A+B+C;if(x!=x/3*3){return !puts("No");}
  if(A>B){Swap(A,B);}if(B>C){Swap(B,C);}if(A>B){Swap(A,B);}
  return !puts(C+A==2*B?"Yes":"No");
}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}
int solve(vector<vec_int> &DP, vector<vec_int> &mat, int state, int pos, int K){
    if(DP.at(state).at(pos)>=0){
        return DP.at(state).at(pos);
    }
    int temp=1;
    vec_int city_vec;
    rep(i,K){
        if((state/temp)%2==1 && i!=pos){
            city_vec.push_back(i);
        }
        temp*=2;
    }
    if(city_vec.size()==0){
        DP.at(state).at(pos) = 1;
        return 1;
    }

    int next_state = state - (1<<pos);

    int result = INT_MAX;
    for(auto next_city: city_vec){
        int temp = solve(DP, mat, next_state, next_city, K) + mat.at(next_city).at(pos);
        result = min(temp, result);
    }
    DP.at(state).at(pos) = result;
    return result;
}
signed main(){
    int N, M; cin>>N>>M;
    vec_int A(M), B(M); rep(i,M)cin>>A.at(i)>>B.at(i);
    vector<vec_int> G(N+1);
    rep(i,M){
        G.at(A.at(i)).push_back(B.at(i));
        G.at(B.at(i)).push_back(A.at(i));
    }

    int K; cin>>K;
    vec_int C(K); rep(i,K)cin>>C.at(i);
    vector<vec_int> mat(K, vec_int(K,-1));

    rep(k,K){
        int start = C.at(k);
        priority_queue<P, vector<P>, greater<P>> pq;
        pq.emplace(0, start);
        vec_int visited(N+1, -1);
        while(!pq.empty()){
            int cost, pos; tie(cost, pos) = pq.top(); pq.pop();
            if(visited.at(pos)>=0)continue;
            visited.at(pos) = cost;
            for(auto next_pos: G.at(pos)){
                if(visited.at(next_pos)>=0)continue;
                pq.emplace(cost+1, next_pos);
            }
        }
        rep(i,K){
            mat.at(k).at(i) = visited.at(C.at(i)); //都市kからiまでの最短コスト, -1の時には到達不能
            if(visited.at(C.at(i))==-1){
                cout<<-1<<endl;
                return 0;
            }
        }
    }

    // TSPをbitDPで解く
    // DP.at(i).at(j): 今までの回った年: i, 最後の都市i
    vector<vec_int> DP(1<<K, vec_int(K, -1));
    int ans = INT_MAX;
    rep(i,K){
        ans = min(ans, solve(DP, mat, (1<<K)-1, i, K));
    }
    cout<<ans<<endl;

    return 0;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int n,ans,cnt=0;
    cin>>n;
    string s;
    cin>>s;
    if(s[0]!=s[n-1])ans=1;
    else{
        char x=s[0];
        rep(i,n-1){
            if(s[i]!=x&&s[i+1]!=x)cnt++;
        }
        if(cnt)ans=2;
        else ans = -1;
    }
    cout<<ans;

	return 0;
}


#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}
template < typename T, typename U >
ostream &operator<<(ostream &os, const pair< T, U > &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template < typename T, typename U >
istream &operator>>(istream &is, pair< T, U > &p) {
	is >> p.first >> p.second;
	return is;
}
template < typename T >
istream &operator>>(istream &is, vector< T > &A) {
	rep(i, A.size()) is >> A[i];
	return is;
}

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

struct edge {
	int from, to, d, c, i;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0, int _i = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
		i = _i;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
		ios::sync_with_stdio(false);
		std::cin.tie(nullptr);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > X(N);
	rep(i, N) cin >> X[i];
	int M = 0;
	rep(i, N) M += abs(X[i]);
	cout << M << endl;
	double U = 0.0;
	rep(i, N) U += X[i] * X[i];
	U = sqrt(U);
	cout << U << endl;
	int C = -LINF;
	rep(i, N) chmax(C, abs(X[i]));
	cout << C << endl;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main(){

    int n;
    cin>>n;
    long long int manhd = 0;
    long long eud = 0;
    long long  int chebd = 0;

    while(n--){
        long long x;
        cin>>x;
        x = abs(x);
        manhd += x;
        eud += (x*x);
        chebd = max(chebd, x);
    }

    double eudd = sqrt(eud);
    cout<<manhd<<endl;
    cout<<setprecision(10)<<eudd<<endl;
    cout<<chebd<<endl;

}


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

using namespace std;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    int ans = 1e18;
    for (int i = 0; i < 60; ++ i){
        int c = n % (1ll << i);
        int b = i;
        int a = (n - c) / (1ll << i);
        int x = a + b + c;
        ans = min(ans, x);
    }
    cout << ans;
}

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

using namespace std;
using namespace __gnu_pbds;
template <class T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define pb push_back
#define FOR(i,f,n) for(int i=f;i<n;i++)
#define FORI(i,f,n) for(int i=f;i>=n;i--)
#define sz(a) ((int)(a).size())
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define alli(a) (a).rbegin(),(a).rend()
#define approx(a) fixed<<setprecision(a)
#define trav(a,x) for(auto& a : x)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,bool> pib;
typedef pair<ll,bool> plb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T> void ckmin(T &a, const T &b) { a = min(a, b); }
template <class T> void ckmax(T &a, const T &b) { a = max(a, b); }

template <class T> void read(vector<T> &v);
template <class F, class S> void read(pair<F, S> &p);
template <class T> void read(T &x) {cin>>x;}
template <class R, class... T> void read(R& r, T&... t){read(r); read(t...);};
template <class T> void read(vector<T> &v) {trav(x, v) read(x);}
template <class F, class S> void read(pair<F, S> &p) {read(p.ff, p.ss);}

template <class F, class S> void pr(const pair<F, S> &x);
template <class T> void pr(const T &x) {cout<<x;}
template <class R, class... T> void pr(const R& r, const T&... t) {pr(r); pr(t...);}
template <class F, class S> void pr(const pair<F, S> &x) {pr("{", x.ff, ", ", x.ss, "}");}
void ps() {pr("\n");}
template <class T> void ps(const T &x) {pr(x); ps();}
template <class T> void ps(vector<T> &v) {trav(x, v) pr(x, ' '); ps();}
template <class F, class S> void ps(const pair<F, S> &x) {pr(x.ff, ' ', x.ss); ps();}
template <class R, class... T> void ps(const R& r,  const T &...t) {pr(r, ' '); ps(t...);}

void solve(){
	double n; read(n);
	n = (1.08 * n);
	int ans = n;
	if(ans < 206) ps("Yay!");
	else if(ans > 206) ps(":(");
	else ps("so-so");
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef pair<int,int> pii;
const int N = 1e5+10;
int n, A, B, sum, a[N], b[N], tot;
pii tmp[N];

signed main() {
	cin >> n >> A >> B; sum = B;
	for(int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
		b[i] = 1ll * a[i] * B / A;
		sum -= b[i];
		if(1ll * a[i] * B % A)
			tmp[++tot] = pii(1ll * a[i] * B % A, i);
	}
	sort(tmp + 1, tmp + 1 + tot);
	while(sum) {
		int p = tmp[tot].second;
		b[p] ++; sum --, tot --;
	}
	for(int i = 1; i <= n; i ++) printf("%d ", b[i]), sum += b[i];
	assert(sum == B);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#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 rep2(i, n, m) for(int i=(int)n; i<=(int)m; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
typedef vector<vl> wl;
const ll inf=1LL<<60;
const ll mod=1000000007;

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

  int n, m, t;
  cin >> n >> m >> t;
  vi a(m), b(m);
  rep(i, m)cin >> a[i] >> b[i];

  int bt=n, f=0, e=0;
  rep(i, m){
  	bt-=a[i]-e;
  	if(bt<=0){
  		f=1;
  		break;
  	}
  	bt+=b[i]-a[i];
  	bt=min(n, bt);
  	e=b[i];
  }

  if(f==0&&bt-(t-e)>0)cout << "Yes\n";
  else cout << "No\n";

  return 0;
}


#include <bits/stdc++.h>
#include <string>
#define rep(i, n) for (long long i = 0; i < n; i++)
#define ll long long
using namespace std;
// cout << fixed << setprecision(8) << result << endl;

int main() {
    int n, k, ans=0;
    cin >> n >> k;
    ans = n*(n+1)*k*100/2;
    ans += n*k*(k+1)/2;
    cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main()
{
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			ans += 100 * i + j;
		}
	}
	cout << ans;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<set>
#include<bitset>
#include<cassert>
#include<numeric>
#define ll long long
#define MOD 1000000007
using namespace std;
//aのb乗
ll mypow(ll a,ll b){
    ll ans=1;
    for(ll i=0;i<b;i++){
        ans*=a;
    }
    return ans;
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    //ll ans=1;
    /*
    for(int i=0;i<a.size();i++){
        if(a[i]==1){
            ans*=(a[i]+1);
        }else{
            ans*=a[i];
        }
        ans%=MOD;
    }
    cout<<ans<<endl;
    */
    ll ans=a[0]+1;
    for(ll i=1;i<a.size();i++){
        if(a[i]-a[i-1]==1){
            ans*=2;
        }else{
            ans*=(a[i]-a[i-1]+1);
        }
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;

}
//157,753,845,000

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
int main()
{
	int N = 0;
	cin >> N;
	vector<int>A;
	int a = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());
	int b = A[N - 1];
	vector<int>B;
	int c = 0;
	for (int i = 2; i <= b; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (A[j] % i == 0)
			{
				c++;
			}
		}
		B.push_back(c);
		c = 0;
	}
	int max = 0;
	int ans = 0;
	for (int i = 0; i < B.size(); i++)
	{
		if (max < B[i])
		{
			max = B[i];
			ans = i + 2;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define int long long
#define MOD 1000000007
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back

int n;
int a[1000005];
priority_queue <int, vector<int>, greater<int> > pq;
int res;

void solve(){
	cin >> n;
	for(int i = 1; i <= 2 * n; i++){
	    cin >> a[i];
	    res += a[i];
	}
	for(int i = 1; i <= n; i++){
	    pq.push(a[n - i + 1]);
	    pq.push(a[n + i]);
	    res -= pq.top();
	    pq.pop();
	}
	cout << res;
}

signed main(){
	//freopen(".inp", "r", stdin);
	//freopen(".out", "w", stdout);

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

		solve();
	return 0;
}

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

// Segment tree for range minimum and addition.
class SegTree {
	private:
		const ll NEUT = 4 * (ll)1e18;
		vector<ll> seg, tag;
		int h = 1;

		void apply(int i, ll v) {
			seg[i] += v;
			if (i < h) tag[i] += v;
		}
		void push(int i) {
			if (tag[i] == 0) return;
			apply(2*i, tag[i]);
			apply(2*i+1, tag[i]);
			tag[i] = 0;
		}
		ll combine(ll a, ll b) { return min(a, b); }

		ll recGet(int a, int b, int i, int ia, int ib) {
			if (ib <= a || b <= ia) return NEUT;
			if (a <= ia && ib <= b) return seg[i];
			push(i);
			int im = (ia + ib) >> 1;
			return combine(
				recGet(a, b, 2*i, ia, im),
				recGet(a, b, 2*i+1, im, ib));
		}
		void recApply(int a, int b, ll v, int i, int ia, int ib) {
			if (ib <= a || b <= ia) return;
			if (a <= ia && ib <= b) apply(i, v);
			else {
				push(i);
				int im = (ia + ib) >> 1;
				recApply(a, b, v, 2*i, ia, im);
				recApply(a, b, v, 2*i+1, im, ib);
				seg[i] = combine(seg[2*i], seg[2*i+1]);
			}
		}
		int recFind(int a, int b, ll v, int i, int ia, int ib) {
			if (seg[i] > v) return b;
			if (b <= ia || ib <= a) return b;
			if (ib == ia + 1) return ia;

			push(i);
			int im = (ia + ib) >> 1;
			int off = recFind(a, b, v, 2*i, ia, im);
			if (off < b) return off;
			else return recFind(a, b, v, 2*i+1, im, ib);
		}
	public:
		SegTree(int n) {
			while(h < n) h *= 2;
			seg.resize(2*h, 0);
			tag.resize(h, 0);
		}
		ll rangeMin(int a, int b) { return recGet(a, b+1, 1, 0, h); }
		void rangeAdd(int a, int b, ll v) { recApply(a, b+1, v, 1, 0, h); }
		int findNext(int a, int b, ll v) { return recFind(a, b+1, v, 1, 0, h); }
};

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

	int n;
	cin >> n;

	SegTree seg(n);
	for (int i = 0; i < n; ++i) seg.rangeAdd(i, i, i+1);

	vector<pair<ll, int>> vals(2*n);
	for (int i = 0; i < 2*n; ++i) {
		cin >> vals[i].first;
		vals[i].second = (i < n ? n-i-1 : i-n);
	}
	sort(vals.rbegin(), vals.rend());

	ll res = 0;
	for (auto pr : vals) {
		ll v = pr.first;
		int i = pr.second;
		if (seg.rangeMin(i, n-1) > 0) {
			seg.rangeAdd(i, n-1, -1);
			res += v;
		}
	}
	cout << res << '\n';

}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool done[3333][3333];
ll memo[3333][3333];

ll solve(int n, int k){
	int j;
	if(n<k){
		return 0ll;
	}
	// std::cout << n << " " << k << std::endl;
	if(done[n][k]){
		return memo[n][k];
	}
	done[n][k] = true;
	if(!k){
		return memo[n][k] = (!n);
	}
	for(j=k; j<=n+1; j*=2){
		add_mod(memo[n][k],solve(n-1,j-1));
	}
	return memo[n][k];
}

int main(void){
	int n,k;
	std::cin >> n >> k;
	std::cout << solve(n,k) << std::endl;
	return 0;
}

//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define pb push_back
#define len length
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)
#define frei freopen("input.txt","r",stdin)

const ll inf=1e18;
const ll mod=1e9+7;
const ll maxn=1e5+10,lg=20;
int main(){
	FAST_IO;
	string s,t;
	ll tmps=0,tmpt=0;
	cin>>s>>t;
	for(int i=0;i<s.len();i++){
		tmps+=s[i]-'0';
	}
	for(int j=0;j<t.len();j++){
		tmpt+=t[j]-'0';
	}
	cout<<max(tmps,tmpt)<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>T dup(T x, T y){return (x+y-1)/y;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}
int keta(ll n) { int ret = 0; while (n>0) { n/=10; ret++; } return ret; }

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) { cerr << head; dump(); }
template <typename Head, typename... Tail> void dump(Head &&head, Tail &&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do { cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost, k;
  edge(int to, T cost, T k) : src(-1), to(to), cost(cost), k(k) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

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

vector<bool> flg(100010, false);
int n;
vector<int> c(100010);
vector<vector<int>> g(100010);
vector<int> dist(100010, INF);
vector<int> cnt(100010, 0);

void dfs(int p, int t)
{
  cnt[c[t]]++;
  if (cnt[c[t]] == 1) flg[t] = true;
  for (auto v:g[t]) {
    if (v == p) continue;
    if (dist[v] <= dist[t]+1) continue;
    mins(dist[v], dist[t]+1);
    dfs(t, v);
  }
  cnt[c[t]]--;
}

void solve()
{
  cin>>n;
  rep(i, n) cin>>c[i];
  rep(i, n-1) {
    int a,b; cin>>a>>b; a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dist[0] = 0;
  dfs(-1, 0);
  rep(i, n) {
    if (flg[i]) cout << i+1 << "\n";
  }

}

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

  return 0;
}

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

#define rep2(i,k,n) for(i64 i=(i64)(k);i<(i64)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) begin(x),end(x)
#ifdef ENV_LOCAL
#define dump if (1) cerr
#else
#define dump if (0) cerr
#endif

using namespace std;
using namespace std::string_literals;

using i32 = int32_t;
using i64 = int64_t;
using f64 = double;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;

//using namespace harudake;

tuple<i32,i32,i32> tree_dp(const vector<vi32>& g, i32 th, i32 i, i32 p = -1) {
  i32 ans = 0;
  i32 deepest = 0;
  i32 cover = -1e8;
  for (auto&& to : g[i]) {
    if (to == p) continue;
    auto [cst, dep, cov] = tree_dp(g, th, to, i);
    ans += cst;
    cover = max(cover, cov-1);
    deepest = max(deepest, dep+1);
  }
  if (deepest <= cover) deepest = -1e8;
  if (deepest == th) {
    ++ans;
    deepest = -1e8;
    cover = th;
  }
  return make_tuple(ans, deepest, cover);
}

//void dfs(const vector<vi32>& g, vi32& d, i32 i, i32 p = -1) {
//  for (auto&& to : g[i]) {
//    if (to == p) continue;
//    d[to] = d[i] + 1;
//    dfs(g, d, to, i);
//  }
//}
//
//i32 get_to_put(const vector<vi32>& g, const vector<bool>& covered, i32 th) {
//  i32 n = size(g);
//  rep(i,n) {
//    if (!covered[i]) {
//      vi32 d(n, -1);
//      d[i] = 0;
//      dfs(g, d, i);
//      i32 mx = -1;
//      i32 mxj = 0;
//      rep(j,n) {
//        if (!covered[j]) {
//          if (d[j] > mx) {
//            mx = d[j];
//            mxj = j;
//          }
//        }
//      }
//      vi32 d2(n, -1);
//      d2[mxj] = 0;
//      dfs(g, d2, mxj);
//      mx = -1;
//      i32 j2 = 0;
//      rep(j,n) {
//        if (!covered[j]) {
//          if (d[j] > mx) {
//            mx = d[j];
//            j2 = j;
//          }
//        }
//      }
//      if (mx <= th) {
//        return j2;
//      }
//      vi32 d3(n, -1);
//      d3[j2] = 0;
//      dfs(g, d3, j2);
//      rep(j,n) {
//        if (d2[j] == th && d2[j] + d3[j] == d2[j2]) {
//          return j;
//        }
//      }
//      return -1;
//    }
//  }
//  return -1;
//}

bool check(const vector<vi32>& g, i32 k, i32 th) {
  auto [ans, deepest, cover] = tree_dp(g, th, 0);
  if (deepest >= 0) ++ans;
  return ans <= k;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i32 n,k;
  cin>>n>>k;
  vector<vi32> g(n);
  rep(i,n-1) {
    i32 u,v;
    cin>>u>>v;
    --u;--v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  i32 lt = 0;
  i32 ge = n;
  while (ge - lt > 1) {
    i32 mid = (ge + lt) / 2;
    if (check(g, k, mid)) {
      ge = mid;
    } else {
      lt = mid;
    }
  }
  cout<<ge<<endl;
  return 0;
}


#include <iostream>
#include <string>
#define rep(I, N) for (int I = 0; I < (N); ++I)
using namespace std;
int main() {
  string s;
  cin >> s;
  string t = "ZONe";
  int c = 0;
  size_t pos = -1;
  while ((pos = s.find(t, pos + 1)) != string::npos) {
    c++;
  }
  cout << c << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e18;

int n;

const int N = 2e5 + 5;
vector<string> arr;
set<string> dang;

void init() {
}

void input() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        if (s[0] == '!') {
            dang.insert(s);
        }
        else {
            arr.pb(s);
        }
    }
}

void solve() {
    for (auto s : arr) {
        string now = '!' + s;

        if (dang.find(now) != dang.end()) {
            cout << s;

            return;
        }
    }

    cout << "satisfiable";
}

void output() {
}

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

    int number_of_testcases = 1;
    //cin >> number_of_testcases;
    while (number_of_testcases--) {
        init();

        input();

        solve();

        output();
    }

    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define int long long
//#define ll int
#define all(a) a.begin(),a.end()
#define rev(a) a.rbegin(),a.rend()
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; //less_equal for multiset
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
const double pi=acosl(-1);

#warning testcases?

void solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	string t="";
	fi(0,n)
	{
		if(s[i]=='x'&&t.size()>=2&&(t.substr(t.size()-2))=="fo")
		{
			t.pop_back();
			t.pop_back();
			continue;
		}
		t.pb(s[i]);
	}
	cout<<t.size()<<'\n';

}

signed main()
{
	FAST;
	//seive();
	int tt=1;
	// cin>>tt;
	while(tt--)
	{
		solve();
	}
}

#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;cin>>x>>y;
if(min(x,y)+3>max(x,y)){cout<<"Yes";}
else{cout<<"No";}

}


/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;}
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(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; }

void solve(){
    ll N,M;
    cin >> N >> M;
    vll a(M), b(M);
    vector<vll> tree(N);
    rep(i,0,M){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        tree[a[i]].push_back(b[i]);
    }

    ll ans = 0;
    rep(i,0,N){
        vll check(N, 0);
        auto dfs = [&](auto dfs, ll cur) -> void {
            if(check[cur]) return;
            check[cur]++;
            for(auto &e: tree[cur]){
                if(!check[e]) dfs(dfs, e);
            }
        };
        dfs(dfs, i);
        rep(j,0,N){
            if(check[j]) ans++;
        }
    }
    print(ans);

}

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

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
#define vec(s) vector<s>
#define vvec(s) vector<vector<s>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout << (x ? "Yes" : "No") << endl;
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define out(s) cout << s << endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " "
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(), s.end()
void vout(vi v)
{
    for (lli i = 0; i < v.size(); i++)
        cout << v.at(i) << endl;
}
vec(bool) node;
vvi path;
vi color;
vi ans;
vi c(1e5, 0);
void dfs(lli nd)
{
    node[nd] = true;
    if (c[color[nd] - 1] == 0)
    {
        ans.pb(nd + 1);
    }
    c[color[nd] - 1]++;
    for (lli a : path[nd])
    {
        if (!node[a])
        {
            dfs(a);
        }
    }
    c[color[nd] - 1]--;
}
int main()
{
    lli n;
    cin >> n;
    node = vec(bool)(n, false);
    color = vi(n, 0);
    path = vvi(n);
    rep(i, n)
    {
        cin >> color[i];
    }
    rep(i, n - 1)
    {
        lli a, b;
        cin >> a >> b;
        a--;
        b--;
        path[a].pb(b);
        path[b].pb(a);
    }
    dfs(0);
    Sort(ans);
    vout(ans);
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(10);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
#define delif(c,pred) (c).erase(remove_if(all(c),(pred)), end(c))
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cerr << #a << ": " << a << endl;
#define dbgs(s) cerr << #s << endl;
#define dbg1(a,n) cerr<<#a<<": "; rep(i,n) cerr<<a[i]<<" "; cerr<<endl;
#define dbg2(m,h,w) cerr<<#m<<":"<<endl; rep(i,h){ rep(j,w)cerr<<m[i][j]<<" "; cerr<<endl; }
template <class T, class U> ostream& operator << (ostream& os, pair<T,U> v) {os<<v.first<<","<<v.second;return os;}
template <class T, size_t N> ostream& operator << (ostream& os, array<T,N> v) {rep(i,N)os<<v[i]<<(i+1<(ll)N?" ":"");return os;}
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }

int main() {
    fastio;
    ll N;
    cin >> N;
    vector<ll> a(N),s(N),m(N);
    rep(i,N) cin >> a[i];
    rep(i,N) s[i] = a[i] + (i?s[i-1]:0);
    rep(i,N) s[i] += (i?s[i-1]:0);
    rep(i,N) m[i] = max(a[i], (i?m[i-1]:0));
    rep(k,N) {
        ll ans = s[k] + m[k]*(k+1);
        cout << ans << newl;
    }
}

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

using namespace std;

int main(){
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    vector<int64_t> B(N);
    vector<int64_t> max(N);
    vector<int64_t> sum(N);
    vector<int64_t> total(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(i==0){
            max[i]=A[i];
            sum[i]=A[i];
            total[i]=A[i];
        }else{
            if(max[i-1]<A[i]){
                max[i]=A[i];
            }else{
                max[i]=max[i-1];
            }
            sum[i]=sum[i-1]+A[i];
            total[i]=total[i-1]+sum[i];
        }
    }
    for(int i=0;i<N;i++){
        int64_t ans=sum[i];
        int64_t m=max[i];
        ans=ans+m*(i+1);
        if(i>0){
            ans=ans+total[i-1];
        }
        cout << ans << endl;
    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 2e5+1;
void yesno(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
ll power(ll x, ll n, ll m){if(n==0)return 1;ll u=power(x,n/2,m);u=(u*u)%m;if(n%2)u=(u*x)%m;return u;}
/// * int overflow, array bounds
/// * special cases (n=1?)
/// * do something - write observations down
/// * change approaches

int main (){
fastio;

int n;
cin>>n;

int i;

ld arr[n];

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

ld ans[3]={};

for(i=0;i<n;i++)
    ans[0] += abs(arr[i]);

ld temp = 0;

for(i=0;i<n;i++){
    temp += arr[i]*arr[i];
}

ans[1] = sqrt(temp);

ans[2] = -INF;
for(i=0;i<n;i++)
    ans[2] = max(ans[2],abs(arr[i]));

cout<<fixed<<setprecision(10);
for(i=0;i<3;i++)cout<<ans[i]<<endl;

}

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

int main() {
  int x;
  cin >> x;
  long long m = 0;
  long long y = 0;
  int t = 0;
  for(int i = 0; i < x; i++){
    int a;
    cin >> a;
    if(i == 0) t = abs(a);
    m += abs(a);
    y += pow(a,2);
    t = max(t,abs(a));
  }
  double yu = sqrt(y);
  cout << m  << endl;
  cout << fixed << setprecision(16) << yu << endl;
  cout << t  << endl;
}


#include<bits/stdc++.h>
using namespace std;
int a[200010],pos[200010],vis[200010],f[200010];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,tot=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pos[a[i]]=i;
    }
    for(int i=n;i>=1;i--){
        while(pos[i]!=i){
            if(vis[pos[i]]){
                cout<<-1<<"\n";
                return 0;
            }
            f[++tot]=pos[i];
            vis[pos[i]]=true;
            pos[a[pos[i]+1]]--;
            pos[i]++;
            swap(a[pos[i]-1],a[pos[i]]);
        }
    }
    if(tot!=n-1){
        cout<<-1<<"\n";
        return 0;
    }
    for(int i=1;i<=tot;i++)
    cout<<f[i]<<"\n";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
int a[N],b[N],c[N];
int main(void)
{
    int n;
    cin >> n;
    for(int i = 1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(int i = 1;i<=n;i++)
    {
        cin >> b[i];
    }
    for(int i = 1;i<=n;i++)
    {
        cin >> c[i];
    }
    vector<int> d;
    for(int i = 1;i<=n;i++)
    {
        int temp = b[c[i]];
        d.push_back(temp);
    }
    sort(d.begin(),d.end());
    long long ans = 0;
    for(int i = 1;i<=n;i++)
    {
        ans += upper_bound(d.begin(),d.end(),a[i])-lower_bound(d.begin(),d.end(),a[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
//bool vis[1000];
//int x[]={1,-1,0,0};
//int y[]={0,0,1,-1};
//int f=0;
//"'';
int main(){
 ll n,k;
 cin>>n>>k;
ll sum=3*n;
vector<vector<ll> > dp(4,vector<ll>(sum+1,0));
vector<vector<ll> > sm(4,vector<ll>(sum+1,0));
dp[0][0]=1;
for(int i=0;i<=sum;i++){
    sm[0][i]=1;
}
for(int i=1;i<=3;i++){
    for(int j=1;j<=sum;j++){
        int mx=j-1;
        int mn=max(0ll,j-n);
        dp[i][j]=sm[i-1][mx];
        if(mn>0){
            dp[i][j]=dp[i][j]-sm[i-1][mn-1];
        }
       // cout<<i<<-1<<j<<-1<<dp[i][j]<<endl;
        sm[i][j]+=sm[i][j-1]+dp[i][j];
    }
}
int a;
for(int i=1;i<=sum;i++){
    if(sm[3][i]>=k){
            k=k-sm[3][i-1];
        a=i;
        break;
    }
}
//cout<<k<<endl;
//cout<<a<<endl;
for(int i=3;i>=1;i--){
    for(int j=1;j<=n;j++){
        if(a-j>=0&&dp[i-1][a-j]>=k){
            cout<<j<<" ";
            a=a-j;
            break;
        }
        else{
             k=k-dp[i-1][a-j];
        }
    }
}
cout<<endl;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long N, K; cin >> N >> K;
	long long A[3000010] = {};
	long long S[3000010] = {};
	for(long long i = 3; i <= N+2; i++){
		A[i] = (i-1) * (i-2) / 2; S[i] = A[i] + S[i-1];
	}
	for(long long i = N+3; i <= N*2; i++){
		A[i] = (i-1) * (i-2) / 2 - (i - N - 1) * (i - N - 2) / 2 * 3;
		S[i] = A[i] + S[i-1];
	}
	for(long long i = N*2 + 1; i <= N*3; i++){
		A[i] = A[N*3+3-i]; S[i] = A[i] + S[i-1];
	}
	long long sum = lower_bound(S, S+N*3+1, K) - S;
	long long M = K - S[sum - 1];
	long long B[1000010] = {};
	long long T[1000010] = {};
	for(long long i = 1; i <= N; i++){
		long long rem = sum - i;
		if(rem <= 1) B[i] = 0;
		else if(rem <= N+1) B[i] = rem - 1;
		else if(rem <= N*2) B[i] = N*2+1 - rem;
		else B[i] = 0;
		T[i] = B[i] + T[i-1];
	}
	long long a = lower_bound(T, T+N+1, M) - T;
	long long L = M - T[a-1];
	for(long long i = 1; i <= N; i++){
		if(sum - a - i >= 1 && sum - a - i <= N) L--;
		if(L == 0){
			cout << a << " " << i << " " << sum - a - i << "\n";
			return 0;
		}
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool testOverlap(ll x1, ll x2, ll y1, ll y2) {
  return (x1 >= y1 && x1 <= y2) ||
         (x2 >= y1 && x2 <= y2) ||
         (y1 >= x1 && y1 <= x2) ||
         (y2 >= x1 && y2 <= x2);
}
bool is_overlapping(double x1,double x2,double y1,double y2){
    return max(x1,y1) <= min(x2,y2);}
int main(){

int t;
t=1;
while(t--){
   ll n;
   cin>>n;
   vector<pair<double,double>>v;
   ll a[n];
   ll count=0;
   ll tc;
   double a1,b1;
   for(ll i=0;i<n;i++){
      cin>>tc>>a1>>b1;
      a[i]=tc;
      v.push_back({a1,b1});
         }
for(ll i=0;i<n-1;i++){
   for(ll j=i+1;j<n;j++){
    //  if(i!=j){
         ll k1=a[i];
         ll k2=a[j];
         double x1=v[i].first;
         double x2=v[i].second;
         if(k1==2){
            x2-=0.5;
         }
         else if(k1==3){
            x1+=0.5;
         }
         else if(k1==4){
            x1+=0.5,x2-=0.5;
         }
         double y1=v[j].first;
         double y2=v[j].second;
         if(k2==2){
            y2-=0.5;
         }
         else if(k2==3){
            y1+=0.5;
         }
         else if(k2==4){
            y1+=0.5,y2-=0.5;
         }
         if(is_overlapping(x1,x2,y1,y2))
            count++;

    //  }
   }
}
cout<<count;

}

}

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

#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#define debug(x)			\
    for(auto element:x)     \
        cout<<element<<" "; \
    cout<<endl
#define debugp(x)          \
for (auto element : x)     \
    cout << element.first << " " << element.second << endl
#define db(x) cout << #x << " = " << x << '\n'
#define makegraph(adj, num)   \
for (int i = 0; i < num; i++) \
{                             \
    int u, v;                 \
    cin >> u >> v;            \
    adj[u].push_back(v);      \
    adj[v].push_back(u);      \
}
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rept(i,k,n) for(auto i=k;i!=n;++i)
#define drep(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ld long double
#define int long long
#define clr(s) memset(s,0,sizeof(s))
#define valset(arr,size,val) rep(i,0,size) arr[i]=val;
#define Tj return
#define out 0
#ifdef segtree
    #define left st,(st+en)/2,2*ind+1,seg
    #define right (st+en)/2+1,en,2*ind+2,seg
    #define lidx 2*ind+1
    #define ridx 2*ind+2
    #define mid (st+en)/2
#endif // segtree
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<char,int> mci;
typedef set<int> si;
const int intmax = 2147483647;
const int intmin = -2147483648;
const int mod = 1000000007;
const int mod2 = 998244353;

template<typename... T>
void read(T&... args)
{
    ((cin >> args ), ...);
}

template<typename... T>
void print(T... args)
{
    ((cout << args << " "), ...);
    cout<<endl;
}

void solve()
{
    int n;
    cin >> n;
    vector<iii> v(n);
    rep(i,0,n) cin>>v[i].first>>v[i].second.first>>v[i].second.second;
    int ans = 0,c=0;
    rep(i,0,n){
        rep(j,i+1,n){
            if((v[i].second.first >= v[j].second.first and v[i].second.first <= v[j].second.second) or (v[i].second.second >= v[j].second.first and v[i].second.second <= v[j].second.second) or (v[j].second.first >= v[i].second.first and v[j].second.second <= v[i].second.second)) {
                //c++;
                ans++;//print(i,j);
                if((v[i].second.second == v[j].second.first and (v[i].first==2 or v[i].first == 4 or v[j].first == 3 or v[j].first == 4)) or (v[j].second.second == v[i].second.first and (v[j].first==2 or v[j].first == 4 or v[i].first == 3 or v[i].first == 4))) ans--;
            }
        }
    }
    //db(c);
    print(ans);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--)
        solve();
    Tj out;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
#define deb(x) cout << #x": " << (x) << endl;

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}
lli lcm(lli a, lli b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
int popcount(lli x) { return __builtin_popcountll(x); }

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

lli poww(lli a, lli b, lli mod){
	lli res =1;
	while(b){ if(b&1) res = (res * a)%mod; a = (a*a)%mod; b/=2; }
	return res;
}

vvc<int> graph(int n, int m, bool dir=1){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		if(dir)v[b].pb(a);
	}
	return v;
}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
// ---- コーディングはここから！ ('-')7
void solve(){
	int n; cin>>n;
	vc<lli>v(n),x(n),y(n);
	fore(i,0,n)cin>>x[i];
	fore(i,0,n)cin>>y[i];
	v[0]=x[0];
	fore(i,1,n)v[i]=max(x[i],v[i-1]);
	v[0]*=y[0];
	fore(i,1,n)v[i]=max(v[i-1],v[i]*y[i]);
	fore(i,0,n)cout<<v[i]<<ENDL;

//	cout<<ENDL;

}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}

#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9 + 1, MOD = 998244353; /// think
const ll LINF = 1e18;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    for (auto &i : a) cin >> i;
    for (auto &i : b) cin >> i;
    int mx = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        umax(mx, a[i]);
        umax(ans, (ll)mx * b[i]);
        cout << ans << '\n';
    }
}


#include<iostream>
#include<vector>
#include<unordered_set>

std::vector<int> diameter_path(const std::vector<std::vector<int>> &g){
    const int n=g.size();
    std::vector<int> d(n);
    std::vector<int> par(n);
    const auto dfs=[&](auto &Self,int v,int p,int pval)->void{
        par[v]=p;
        d[v]=pval;
        for(int ne:g[v])if(ne!=p){
            Self(Self,ne,v,pval+1);
        }
        return;
    };
    dfs(dfs,0,-1,0);
    int MAX=0;
    int u=-1;
    for(int i=0;i<n;i++){
        if(MAX<d[i]){
            MAX=d[i];
            u=i;
        }
    }

    dfs(dfs,u,-1,0);
    MAX=0;
    int v=-1;
    for(int i=0;i<n;i++){
        if(MAX<d[i]){
            MAX=d[i];
            v=i;
        }
    }

    std::vector<int> ans(d[v]+1);
    for(int i=0;i<(int)ans.size();i++){
        ans[i]=v;
        v=par[v];
    }
    return ans;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.precision(10);
/*------------------------------------*/

    int n;
    std::cin >> n;
    std::vector<std::vector<int>> g(n);
    for(int i=0;i<n-1;i++){
        int a,b;std::cin >> a >> b;
        a--,b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    auto path=diameter_path(g);
    std::unordered_set<int> last;
    for(int i:path)last.insert(i);

    std::vector<int> ans(n);

    auto dfs=[&](auto &Self,int v,int p,int val)->int{
        ans[v]=val;
        int las=-1;
        for(int ne:g[v])if(ne!=p){
            if(last.count(ne))las=ne;
            else val=Self(Self,ne,v,val+1);
        }
        if(las!=-1)val=Self(Self,las,v,val+1);
        return val+1;
    };

    dfs(dfs,path.front(),-1,1);
    for(int i=0;i<n;i++)std::cout << ans[i] << " \n"[i+1==n];
}
/*
一応,diameter_path()が他に依存していないか確認.

解説AC.
沼ったが,「番号が小さい順にたどる」ことを考えると明らかになる.
一旦E[0]<E[1]...となるようにする.(あとで適切な頂点番号の振り直しを考える.)
dist(i,i+k)<=dist(i,i+1)+...+dist(i+k-1,i+k)なので, 各iに対してdist(i,i+1)<=E[i+1]-E[i]が成り立てばいい.
よって,この頂点順序で最小化するにはdist(i,i+1)=E[i+1]-E[i]にする.
結局max(E)は, dfsで全頂点たどる時の移動距離になる.
始点-終点の距離だけ移動をさぼれることを考えれば, 直径の端点を始点/終点にするのが最適.
*/

#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>

void solve() {
	int n;
	std::cin >> n;
	std::vector<int> a(n), b(n);
	std::vector<int> in(n, -1);
	std::vector<int64_t> ans(n + 1, 0);
	std::vector<std::pair<int, int>> io(n, std::pair<int, int>(-1, -1));
	std::vector<std::vector<std::pair<int, int>>> gr(n);
	for (int i = 1; i < n; i++) {
		std::cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		gr[a[i]].push_back({ b[i], i });
		gr[b[i]].push_back({ a[i], i });
	}
	int e = 0;
	std::function<void(int, int)> dfs = [&](int v, int f) {
		in[v] = e++;
		for (auto &ed : gr[v]) {
			if (ed.first != f) {
				a[ed.second] = ed.first != a[ed.second];
				io[ed.second].first = e;
				dfs(ed.first, v);
				io[ed.second].second = e;
			}
		}
	};
	dfs(0, -1);
	int q;
	std::cin >> q;
	for (int tt = 0; tt < q; tt++) {
		int p, t, x;
		std::cin >> t >> p >> x;
		t--;
		int l = io[p].first, r = io[p].second;
		t ^= a[p];
		if (t == 0) {
			ans[l] += x;
			ans[r] -= x;
		} else {
			ans[0] += x;
			ans[l] -= x;
			ans[r] += x;
		}
	}
	for (int i = 1; i < n; i++) {
		ans[i] += ans[i - 1];
	}
	for (int i = 0; i < n; i++) {
		std::cout << ans[in[i]] << " \n"[i == (n - 1)];
	}
}

int32_t main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);

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

	return 0;
}


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

int n;
struct xyr {
  int x;
  int y;
  int r;
};
struct sq {
  int x1;
  int y1;
  int x2;
  int y2;
  int s;
};

vector<xyr> ad;
vector<sq> ans;
clock_t start;
vector<vector<int>> area(10000, vector<int>(10000, -1));

void input () {
  cin >> n;
  ad.resize(n);
	rep(i, n) cin >> ad[i].x >> ad[i].y >> ad[i].r;
}
void init() {
  ans.resize(n);
  rep(i, n) {
    ans[i].x1 = ad[i].x;
    ans[i].y1 = ad[i].y;
    ans[i].x2 = ad[i].x+1;
    ans[i].y2 = ad[i].y+1;
    ans[i].s = 1;
  }
}

bool isTimeLimit(clock_t start) {
  clock_t end = clock();
  const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if (time >= 4000) return true;
  else return false;
}

void output() {
  rep(i, n) {
    cout << ans[i].x1 << " " << ans[i].y1 << " " << ans[i].x2 << " " << ans[i].y2 << endl;
  }
}

int main() {
	// 入力
	input();
  init();
  int cnt = 0;
	while (1) {
    if (cnt%1000 == 0) {
      if (isTimeLimit(start)) break;
    }
    cnt++;
	}
  output();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vp = vector<P>;
using vs = vector<string>;
using pq = priority_queue<int,vector<int>,greater<int>>;/*top()で最小値取得*/
using pq2 = priority_queue<int, vector<int>, less<int>>;/*top()で最大値取得*/

#define INF 1000000005
#define mod 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i = 0; i < (n); ++i) /*0からn-1までのrep*/
#define rrep(i,n) for(int i = 1; i <= (n); ++i) /*1からnまでのrep*/
#define drep(i,n) for(int i = (n)-1; i >= 0; --i) /*n-1から0までのrep*/
#define srep(i,s,t) for (int i = s; i < t; ++i) /*sからt-1までのrep*/
#define each(a,b) for(auto& (a): (b)) /*よくわからん*/
#define all(v) (v).begin(),(v).end() /*全選択*/
#define sz(v) (int)(v).size() /*大きさ*/
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) /*重複削除*/
#define cmx(x,y) x=max(x,y) /*最大値*/
#define cmn(x,y) x=min(x,y) /*最小値*/
#define fi first
#define se second
#define pb push_back //a.push_back(最後に任意の数字を追加); a.pop_back();
#define rev(v) reverse((v).begin(),(v).end());
#define sob(v) sort((v).begin(), (v).end(),greater<int>()); /*大きい順にソート*/
#define so(v) sort((v).begin(), (v).end()); /*小さい順にソート*/
#define yn {puts("Yes");}else{puts("No");}
#define dame { puts("-1"); return 0;}/*だめ*/
const double eps = 1e-10;
const ll MOD = 1000000007;
constexpr ll MAX = 5000000;

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

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

ll divup(ll x, ll y){
	if(x%y==0){
		return x/y;
	} else {
		return x/y + 1;
	}
}

int main(){
	int n,w;
	cin >> n >> w;
	cout << n/w << endl;
    return 0;
}


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

#define ll              long long
#define pb              push_back
#define all(v)          v.begin(),v.end()
#define sz(a)           (ll)a.size()
#define F               first
#define S               second
#define INF             2000000000000000000
#define popcount(x)     __builtin_popcountll(x)
#define pll             pair<ll,ll>
#define pii             pair<int,int>
#define ld              long double

const int M = 1000000007;
const int MM = 998244353;
const long double PI = acos(-1);

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{
    return os<<'('<<p.F<< ","<<p.S<<')';
}

const int N = 18;

int dp[1<<N][101];

int x[101],y[101],z[101];

vector<int> v[N];

ll ans[N+2][1<<N];

int _runtimeTerror_()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i)
    {
        cin>>x[i]>>y[i]>>z[i];
        --y[i];
        v[x[i]].push_back(i);
    }
    for(int i=0;i<(1<<n);++i)
    {
        for(int j=0;j<m;++j)
        {
            if(popcount(i)+1 == x[j])
            {
                int al = 0;
                for(int k=0;k<n;++k)
                {
                    if(i&(1<<k))
                        al += k <= y[j];
                }
                if(al > z[j])
                    continue;
                for(int k=0;k<n;++k)
                {
                    if(i&(1<<k))
                        continue;
                    al += k <= y[j];
                    if(al <= z[j])
                        dp[i][j] ^= (1<<k);
                    al -= k <= y[j];
                }
            }
        }
    }
    ans[0][0] = 1;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<(1<<n);++j)
        {
            int can = (1<<n)-1;
            for(auto &k:v[i+1])
                can &= dp[j][k];
            for(int k=0;k<n;++k)
            {
                if(can&(1<<k))
                    ans[i+1][j^(1<<k)] += ans[i][j];
            }
        }
    }
    cout<<ans[n][(1<<n)-1]<<"\n";
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

#include <bits/stdc++.h>

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

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b); i-- > (a); )
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define lb(x...) lower_bound(x)
#define ub(x...) upper_bound(x)

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

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

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

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

	vector<vector<pair<int, int>>> constraint(n);
	rep(i, 0, m) {
		int x, y, z; cin >> x >> y >> z;
		constraint[--x].emplace_back(y, z);
	}

	vector<ll> dp(1 << n);
	dp[0] = 1;
	rep(S, 0, 1 << n) {
		int x = __builtin_popcount(S);
		rep(i, 0, n) {
			if (S >> i & 1) continue;

			int T = S | 1 << i;
			bool valid = 1;
			for (auto [y, z] : constraint[x])
				valid &= __builtin_popcount(T & ((1 << y) - 1)) <= z;
			if (valid) dp[T] += dp[S];
		}
	}

	cout << dp.back() << '\n';
}


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T,class U>
inline bool chmax(T &a,U b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
template<class T,class U>
inline bool chmin(T &a,U b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
constexpr int INF=1000000000;
constexpr ll llINF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
/*
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}*/
ll gcd(ll a,ll b){
    while(a%b){
        a%=b;
        swap(a,b);
    }
    return b;
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>primes;
void init_prime(int n){
    primes.push_back(2);
    for(int i=3;i<=n;i+=2){
        bool f=true;
        for(int j:primes){
            if(j*j>i)break;
            if(i%j==0){
                f=false;
                break;
            }
        }
        if(f)primes.push_back(i);
    }
}
ll modpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res*=a;
            res%=mod;
        }
        a*=a;
        a%=mod;
        b>>=1;
    }
    return res;
}
vector<ll>inv,fact,factinv;
void init_fact(int n){
    inv.resize(n+1);
    fact.resize(n+1);
    factinv.resize(n+1);
    inv[0]=0;
    inv[1]=1;
    fact[0]=1;
    factinv[0]=1;
    for(ll i=1;i<=n;i++){
        if(i>=2)inv[i]=mod-((mod/i)*inv[mod%i]%mod);
        fact[i]=(fact[i-1]*i)%mod;
        factinv[i]=factinv[i-1]*inv[i]%mod;
    }
}
ll _inv(ll a,ll m=mod){
    //gcd(a,m) must be 1
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b;swap(a,b);
        u-=t*v;swap(u,v);
    }
    u%=m;
    if(u<0)u+=m;
    return u;
}
ll comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return fact[a]*factinv[a-b]%mod*factinv[b]%mod;
}
ll multicomb(int a,int b){
    return comb(a+b-1,b);
}
void solve(){
    int k,n,m,cnt=0;
    cin>>k>>n>>m;
    vector<ll>a(k),b(k);
    vector<pair<ll,int>>v(k);
    rep(i,k){
        cin>>a[i];
        b[i]=a[i]*m/n;
        cnt+=b[i];
        v[i]={(b[i]*2+1)*n-a[i]*2*m,i};
    }
    sort(all(v));
    rep(i,m-cnt)b[v[i].se]++;
    rep(i,k)cout<<b[i]<<" ";
    cout<<endl;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef tuple<int, int, int> tiii;
typedef tuple<int, int, int, int> tiiii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector<pii> vpii;
#define F(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define f(i, a, b) for(int i = (int)a; i >= (int)b; i--)
#define F2(i, a, b) for(int i = (int)a; i <= (int)b; i+=2)
#define f2(i, a, b) for(int i = (int)a; i >= (int)b; i-=2)
#define IN insert
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define RS resize
#define trans int tm = (tl + tr)>>1, l = v<<1, r = l|1
#define RBT tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ld const PI = acos(-1);

int const N = 2e5 + 4;
list<int> gr[N];

int a[N], b[N];
bool was[N];

ll dfs(int v){
	if(was[v])
		return 0;
	ll ans = a[v] - b[v];
	was[v] = 1;
	for(int to : gr[v])
		ans += dfs(to);
	return ans;
}

//#define LOCAL
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
	int n, m;
	cin >> n >> m;
	F(i, 1, n)
		cin >> a[i];
	F(i, 1, n)
		cin >> b[i];
	F(i, 1, m){
		int a, b;
		cin >> a >> b;
		gr[a].PB(b);
		gr[b].PB(a);
	}
	F(v, 1, n){
		if(dfs(v) != 0){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int get_val(int a,int b,int c)
{
	int res=1;
	if(a==0)
	return 0;
	if(a==1)
	return 1;
	while(b)
	{
		if(b&1)
		{
			res=((res%c)*(a%c))%c;
		}
		b/=2;
		a=((a%c)*(a%c))%c;
	}
	return res%c;
}
void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<get_val(a%10,get_val(b,c,4)+4,10)%10<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
//    cin>>t;
    while(t--)
        solve();
}

#include<iostream>
using namespace std;
long long int MOD = 10;
long long int POW(long long int n,long long int k){
	long long int r;
	if(k==0)return 1;
	r=POW(n,k/2)%MOD;
	r=(r*r)%MOD;
	if(k%2)r=(n*r)%MOD;
	return r;
}
int main(){
	long long int A,B,C,bc;
	long long int mod[10]={1,1,4,4,2,1,1,4,4,2};
	cin>>A>>B>>C;A%=10;
	MOD = mod[A];
	bc=POW(B,C)+MOD;
	MOD = 10;
	cout<<POW(A,bc);
	return 0;
}


#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#endif
#if __has_include(<atcoder/all>)
#include <atcoder/all>
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i, a, b) for(int i = (int)(a); i <= (int)(b); i++)
#define rrep(i, a, b) for(int i = (int)(a); i >= (int)(b); i--)
const int MOD = 1000000007;
const int MOD2 = 998244353;
const ll INF = 1e18;
const ld PI = acos(-1);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll T,N;
    cin >> T >> N;
    int Z=N/T;
    int plus=N-Z*T;
    if(plus==0){
        Z--;
        plus+=T;
    }
    int D=0;
    int cnt=0;
    //cout << plus << endl;
    vector<int> seen(100+T,0);
    rep(i,0,99){
        seen[i*(100+T)/100]=1;
    }
    rep(i,0,99+T){
        if(seen[i]==false){
            cnt++;
        }
        if(cnt==plus){
            D=i;
            break;
        }
    }
    cout << (T+100)*Z+D << endl;
}

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

int get() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}

const int N = 114514;
int n, t;
int bin[N];

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

signed main() {
	t = get(), n = get();
	if(t == 1) return 0 * printf("%lld\n", 101 * n - 1);
	int T = t * 100 / gcd(100, t);
	for(int i = 0; i < T; i++) bin[i] = i * t / 100;
	int z = n / (bin[T - 1] + 1), r = n % (bin[T - 1] + 1);
	for(int i = 0; i < T; i++) {
		if(bin[i] == r && (z + i)) return 0 * printf("%lld\n", (z * T + i) * (100 + t) / 100 - 1);
	}
	return 0;
}


#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

#define mkp make_pair
#define mkt make_tuple
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
template <class T>
void chmin(T &a, const T &b) {
    if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
    if (a < b) a = b;
}

void add(ll &a, ll b) {
    a = (a + b) % MOD;
}

void mul(ll &a, ll b) {
    a %= MOD;
    b %= MOD;
    a = a * b % MOD;
}

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<vector<vector<int>>> idxs(N + 1, vector<vector<int>>(N + 1));
    for (int k = 1; k <= N; k++) {
        ll sum = 0;
        idxs[k][0].push_back(0);
        for (int i = 0; i < N; i++) {
            sum += A[i];
            sum %= k;
            idxs[k][sum].push_back(i + 1);
        }
    }

    vector<vector<int>> nxt(N + 1, vector<int>(N + 1, -1));
    for (int k = 1; k <= N; k++) {
        for (int rest = 0; rest < k; rest++) {
            for (int j = 0; j + 1 < idxs[k][rest].size(); j++) {
                nxt[idxs[k][rest][j]][k] = idxs[k][rest][j + 1];
            }
        }
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, -1));
    auto rec = [&](auto &&rec, int now, int divisor) -> ll {
        if (now == N) return 1;
        if (dp[now][divisor] != -1) return dp[now][divisor];

        ll sum = 0;
        ll res = 0;
        if (nxt[now][divisor] != -1) {
            add(res, rec(rec, nxt[now][divisor], divisor));
            if (nxt[now][divisor] < N) add(res, rec(rec, nxt[now][divisor], divisor + 1));
        }

        return dp[now][divisor] = res;
    };

    ll ans = rec(rec, 0, 1);
    cout << ans << endl;
}

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

    solve();

    return 0;
}

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define ld long double
#define For(i,x,y) for(ll i = (ll)(x);i <= (ll)(y);++i)
#define FOr(i,x,y) for(ll i = (ll)(x);i >= (ll)(y);--i)
#define rep(i,x,y) for(ll i = (ll)(x);i < (ll)(y);++i)
#define fi first
#define se second
#define pa pair<ll,ll>
#define pb push_back
#define y1 y11111111111111
#define debug puts("@@@@@@@@@@@@@@@@@@@")

#define cpy(a,b) memcpy(a,b,sizeof(b))
inline ll read()
{
	ll x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

void write(ll x)
{
	if(x < 0) putchar('-'), x= -x;
	if(x > 9)write(x/10);
	putchar(x%10+'0');
}
const ll N=200010;
ll n,a[N];
vector<ll>ans;
bool ok(){
	For(i,1,n-1)if(a[i]>a[i+1])return 0;
	return 1;
}
void swp(ll i,ll j){
	swap(a[i],a[j]);
	ans.pb(i);
}
int main(){
	ll T=read();
	for(;T--;){
		n=read();	ans.clear();
		For(i,1,n)a[i]=read();
		for(;;){
			if (ok())break;
			bool fl=0;
			For(i,1,n-1)if(i&1){
				if (a[i]>a[i+1]){
					swp(i,i+1);
					fl=1;
					break;
				}
			}
			if(!fl){
				if(n&1)	swp(n-2,n-1);
				else	swp(n-1,n);
			}
			if (ok())break;
			fl=0;
			For(i,1,n-1)if(!(i&1)){
				if (a[i]>a[i+1]){
					swp(i,i+1);
					fl=1;
					break;
				}
			}
			if(!fl){
				if(n&1) swp(n-1,n);
				else	swp(n-2,n-1);
			}
		}
		cout<<ans.size()<<endl;;
		rep(i,0,ans.size())write(ans[i]),putchar(' ');puts("");
	}
}


#include <bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define sz(a) (int)a.size()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define nax 100005
#define MXL 1000000000000000000
#define PI 3.14159265
#define pb push_back
#define pf push_front
#define sc second
#define fr first
#define endl '\n' //delete if interactive
#define ld long double
#define mp make_pair

void solve(){
	int n;cin>>n;
	string a,b,c;cin>>a>>b>>c;
	int lim=2*n+1;
	int x = lim/3;
	for(int i=0;i<n;i++) cout<<"1";
	for(int i=0;i<n;i++) cout<<"0";
	cout<<"1\n";
}

int main(){
	int t=1;cin>>t;
	for(int tc=1;tc<=t;tc++){
		solve();
	}
	return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define setIO(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define closefile fclose(stdin), fclose(stdout)
#define m_p make_pair
#define sz(x) (int)x.size()
#define see(x) cerr << x << " "
#define seeln(x) cerr << x << endl
#define out(x) cerr << #x << " = " << x << " "
#define outln(x) cerr << #x << " = " << x << endl
#define outarr(x, l, r) {cerr<< #x"[" << l << " ~ " << r << "] = "; for (int _i = l; _i <= r; ++_i) cerr << x[_i] << " "; cerr << endl;}
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define gc() getchar()
//#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T> void read(T &x)
{
	x = 0; int c = gc(); int flag = 0;
    while (c < '0' || c > '9') flag |= (c == '-'), c = gc();
    while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) +(c ^ 48), c = gc();
    if (flag) x = -x;
}
template <class T> T _max(T a, T b){return b < a ? a : b;}
template <class T> T _min(T a, T b){return a < b ? a : b;}
template <class T> bool checkmax(T &a, T b){return a < b ? a = b, 1 : 0;}
template <class T> bool checkmin(T &a, T b){return b < a ? a = b, 1 : 0;}
int n;
void init()
{
	read(n);
	scanf("%*s%*s%*s");
}

void solve()
{
	for (int i = 1; i <= n; ++i) printf("0");
	for (int i = 1; i <= n; ++i) printf("1");
	printf("0\n");
}

int main()
{
	int t; read(t); while (t--)
	{
		init();
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << endl;
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

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

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

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

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

tuple<ll, ll, ll> extgcd(ll a, ll b) {
  if (b == 0) return {a, 1, 0};
  ll g, x, y;
  tie(g, x, y) = extgcd(b, a % b);
  return {g, y, x - a / b * y};
}

signed main() {
  init();
  ll T;
  cin >> T;
  rep(i, T) {
    ll n, s, k;
    cin >> n >> s >> k;

    ll g, x, y;
    tie(g, x, y) = extgcd(k, n);
    if (s % g != 0) {
      cout << -1 << endl;
      continue;
    }
    n /= g;
    s /= g;
    k /= g;
    ll ans = ((x * -s) % n + n) % n;
    ANS;
  }

  return 0;
}

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

using namespace std;
//using namespace atcoder;

#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 FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

// edit

void solve() {
    int N;
    cin >> N;
    vector<string> S(2);
    {
        string tmp;
        cin >> tmp;
        S[0] = tmp.substr(0, N);
        S[1] = tmp.substr(N, 2 * N);
    }
    int a = 0, b = 1;
//    cout << S[0] << " " << S[1] << endl;

    int Q;
    cin >> Q;
    while (Q--) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            x--, y--;
            if (x < N && y < N) {
                swap(S[a][x], S[a][y]);
            } else if (x >= N && y < N) {
                swap(S[b][x - N], S[a][y]);
            } else if (x < N && y >= N) {
                swap(S[a][x], S[b][y - N]);
            } else {
                swap(S[b][x - N], S[b][y - N]);
            }
        } else {
            a = !a;
            b = !b;
        }
    }

    cout << S[a] << S[b] << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();

    return 0;
}


/*
			Saturday 13 March 2021 05:51:34 PM IST
					@uthor::astrainL3gi0N
*/

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

typedef long long int ll;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::pair<int,int> ii;
#define debg(x)	std::cerr<<(#x)<<" => "<<x<<'\n';
#define debgg(x,y)	std::cerr<<(#x)<<" => "<<x<<'\t'<<(#y)<<' '<<y<<'\n';
#define len(a) (int)(a).size()
#define all(x) x.begin(),x.end()
const int mod = 1'0000'0000'7;
//const int mod = 998244353;
//cout.unsetf(ios::floatfield);cout.precision(10);cout.setf(ios::fixed,ios::floatfield);

bool comp (int x, int y) {
    return x > y;
}
void printarr (int arr[], int n) {
    for(int i = 0; i < n; ++i)
        std::cerr<<arr[i]<<(i<n-1?' ':'\n');
}
template < typename T> void  printv (T &a) {
    for (auto it = a.begin(); it != a.end(); ++it)
        std::cerr<<*it<<' ';
    std::cerr<<'\n';
}

const int maxn = 200009;
//int t[510][510];
ll ans;
int arr[maxn];

ll calcnum (ll n)
{
    ll p1 = pow(10,n)-1;
    ll p2 = pow(10,n-1);
    return p1-p2+1;
}

void solve ()
{
    bool ok = false;
    ll n,m,k,q;  std::cin>>n;
    ans = 0;

    ll num = n;

    int d = 0;
    while (num > 0)
        num /= 10, d++;

    for (int i = 1; i < d; ++i)
        ans += ((i-1)/3) * (calcnum(i));
    ans += (n - (ll)pow(10,d-1) + 1)*((d-1)/3);

    std::cout<<ans;
    std::cout<<'\n';
}
void sol ()
{
    //test
}

int main ()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
        solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace  std;
int main(){
  int n,ans=0;
  cin >> n;
  for(int i= 1;i <= n;i ++){
    int p = n-i;
    if(p > 0)ans ++;
  }
  cout <<ans;
  return 0;
}


#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int n;
  double a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  double p,q,r,s;
  p=(a+c)/2;
  q=(b+d)/2;
  r=(a-c)/2;
  s=(b-d)/2;
  double co=cos(2*M_PI/n);
  double si=sin(2*M_PI/n);
  double x=p+co*r-si*s;
  double y=q+co*s+si*r;
  cout<<x<<" "<<y<<endl;
}

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll,ll>; const ll INF = 4e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
// clang-format on

template <class T>
class bmatrix {
   public:
    ll row;
    ll col;
    vector<vector<T>> mat;
    bmatrix(ll r, ll c) {
        row = r;
        col = c;
        mat = vector<vector<T>>(r, vector<T>(c));
    }
    void set(ll r, ll c, T v) {
        mat[r][c] = v;
    }
    void setvec(vector<vector<T>>& v) {
        mat = v;
    }
    T get(ll r, ll c) {
        return mat[r][c];
    }
    bmatrix add(bmatrix& rhs) {
        auto result = bmatrix(row, col);
        for (ll i = 0; i < row; i++) {
            for (ll j = 0; j < col; j++) {
                result.mat[i][j] = mat[i][j] + rhs.mat[i][j];
            }
        }
        return result;
    }
    bmatrix mult(bmatrix& rhs) {
        /*
             S行*T列  * T行*U列  =>  S行*U列
            [ 1 2 3    [ 10      [1*10+2*30+3*50    [220
              4 5 6] *   30   =   4*10+5*30+6*50] =  490 ]
                         50 ]
        */
        ll s = row;
        ll t = col;
        ll u = rhs.col;
        assert(rhs.row == t);
        auto result = bmatrix(s, u);
        for (ll i = 0; i < s; i++) {
            for (ll j = 0; j < u; j++) {
                for (ll k = 0; k < t; k++) {
                    result.mat[i][j] += mat[i][k] * rhs.mat[k][j];
                }
            }
        }
        return result;
    }
};
using matrix = bmatrix<double>;

using ld = long double;
int main() {
    ll n;
    ld x, y, xh, yh;
    cin >> n >> x >> y >> xh >> yh;
    xh -= x;
    yh -= y;
    ld pi = acos(-1);

    ld lkai;
    ld rkai;
    if(xh>=0&&yh>=0){
      lkai=0*pi-0.001;
      rkai=0.5*pi+0.001;
    }
    if(xh>=0&&yh<0){
      lkai=0.5*pi-0.001;
      rkai=1.0*pi+0.001;
    }
    if(xh<0&&yh<0){
      lkai=1.0*pi-0.001;
      rkai=1.5*pi+0.001;
    }
    if(xh<0&&yh>=0){
      lkai=1.5*pi-0.001;
      rkai=2.0*pi+0.001;
    }
    matrix mat(2, 2);
    matrix half(2, 1);
    half.set(0, 0, xh);
    half.set(1, 0, yh);
    ld ykai = 0;
    for (ll i = 0; i < 1000; i++) {
        ld mid1 = lkai + (rkai - lkai) / 3;
        mat.set(0, 0, cos(mid1));
        mat.set(1, 0, sin(mid1));
        mat.set(0, 1, -sin(mid1));
        mat.set(1, 1, cos(mid1));
        ld x1 = mat.mult(half).get(0, 0);

        ld mid2 = lkai + 2.0 * (rkai - lkai) / 3;
        mat.set(0, 0, cos(mid2));
        mat.set(1, 0, sin(mid2));
        mat.set(0, 1, -sin(mid2));
        mat.set(1, 1, cos(mid2));
        ld x2 = mat.mult(half).get(0, 0);
        if (abs(x1) > abs(x2)) {
            lkai = mid1;
        } else {
            rkai = mid2;
        }
        ykai = mat.mult(half).get(1, 0);
        // print(lkai, rkai, "kai");
        //print(x1);
    }
    //print(ykai);
    ykai = abs(ykai);
    ld hy2 = (ykai / 2.0) * (ykai / 2.0);
    ld p = pi * (n - 2) / n;
    ld z = sqrt(
        hy2 + hy2 - 2.0 * hy2 * cos(pi - p));
    ld ax = z * cos(pi / 2 - p / 2);
    ld ay = z * sin(pi / 2 - p / 2);
    //print(ax, ay, z, rkai, lkai, p);

    matrix fir(2, 1);
    fir.set(0, 0, ax);
    fir.set(1, 0, ay);

    mat.set(0, 0, cos(-rkai));
    mat.set(1, 0, sin(-rkai));
    mat.set(0, 1, -sin(-rkai));
    mat.set(1, 1, cos(-rkai));
    matrix an = mat.mult(fir);

    ld aax = an.get(0, 0);
    ld aay = an.get(1, 0);

    aax += x;
    aay += y;
    print(aax, aay);
}


# include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN = 100000+5;
//ll a[mxN];
int sumOfDigits(int n){
    int ret = 0;
    while(n > 0){
        ret += n%10;
        n/=10;
    }
    return ret;
}
int main()
{
    int a,b;cin>>a>>b;
    cout<<std::max(sumOfDigits(a),sumOfDigits(b));

}

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.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; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    string A, B;
    cin >> A >> B;

    ll x = 0, y = 0;
    REP(i, 3){
        x += A[i] - '0';
        y += B[i] - '0';
    }

    cout << max(x, y) << endl;

    return 0;
}


#include <bits/stdc++.h>  // This will work only for g++ compiler.

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())

using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

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

    ll t,n,i,j,k,l,q,a,b;
    string s;
    ll z=0;
    cin>>n>>s>>q;
    while(q--){
        cin>>t>>a>>b;
        if(t==2)z++;
        if(t==1){
            if(z%2==1){
                if(a<=n)
                a=a+n;
                else
                a=a-n;
                if(b<=n)
                b=b+n;
                else
                b=b-n;

                b--;
                a--;

                swap(s[a],s[b]);
            }
            else{
                swap(s[a-1],s[b-1]);
            }
        }
    }
    if(z%2==1){
        for(i=n;i<2*n;i++)cout<<s[i];
        for(i=0;i<n;i++)cout<<s[i];
    }
    else{
        cout<<s;
    }
}

#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }

int N, X;
int A[51];

map<int, int> _memo[51];
int ans = 0;

void func(int depth)
{
	if (depth == N - 1)
	{
		for (auto p : _memo[depth])
		{
			if (p.first % A[depth] == 0)
			{
				ans += p.second;
			}
		}
	}
	else
	{
		for (auto p : _memo[depth])
		{
			int n = p.first;
			int cnt = p.second;

			int m = n % A[depth + 1];
			if (m == 0)
			{
				_memo[depth + 1][n] += cnt;
			}
			else
			{
				_memo[depth + 1][n - m] += cnt;
				_memo[depth + 1][n + (A[depth + 1] - m)] += cnt;
			}
		}

		func(depth + 1);
	}
}

signed main()
{
	cin >> N >> X;
	REP(i, N) cin >> A[i];

	_memo[0][X] = 1;
	func(0);

	cout << ans << endl;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
vector<long> a(1000000, 0);
vector<long> b(1000000, 0);
vector<long> c(1000000, 0);
int main()
{
    long n;
    long t;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        cin >> t;
        a.at(t) += 1;
    }
    for (int i=0; i<n; i++)
    {
        cin >> t;
        b.at(i+1) = t;
    }
    long ans = 0;
    for (int i=0; i<n; i++)
    {
        cin >> t;
        ans += a.at(b.at(t));
    }
    cout << ans << endl;
}

#include <iostream>

#include <cmath>
#include <cstring>

#include <map>
#include <set>
#include <vector>

#include <algorithm>
#include <bitset>
#include <complex>
#include <numeric>
#include <string>
#include <utility>

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using g = vector<vector<int>>;
using vi = vector<int>;

const int INF = 1001001001;

int main()
{
    int n;
    cin>>n;
    vi a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    vi cnt(n + 1);
    rep(i, n) cnt[a[i]]++;
    ll ans = 0;
    rep(j, n) ans += cnt[b[c[j] - 1]];
    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

pair<long, long> exact(const long &B, const long &C) {
  const auto n = C / 2;
  if (C % 2) {
    return {-B - n, -B + n};
  } else {
    if (!C)
      return {B, B};
    return {B - n, B + n - 1};
  }
}

int main() {
  long B, C;
  cin >> B >> C;
  const auto [a, b] = exact(B, C);
  const auto [c, d] = exact(B, C - 1);
  cout << (b - a + 1) + (d - c + 1) - max(0l, min(b, d) - max(a, c) + 1)
       << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 7;
int n;

int main()
{
       ios_base::sync_with_stdio(0);
       cin.tie(0);
#ifndef ONLINE_JUDGE
       freopen("in.in", "r", stdin);
#endif
       int x , y; cin >> x >> y;
       if( x == y) cout << x; else cout << 3 - x - y ;
       return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int N,M;
vector<pii>adj[2005];
int taka[2005];
bool vis[2005];
int bfs(int s)
{
    fill(vis+ 1, vis + N + 1, false);
    fill(taka + 1, taka + N + 1, 0);
    priority_queue<pii, vector<pii>, greater<pii> >q;
    q.push({0,s});//node taka;
    while(!q.empty())
    {
        pii node=q.top();//node taka..
        q.pop();
        if((node.second==s) and vis[s])
        {
            cout<<node.first<<endl;
            return 0;
        }
        if(vis[node.second])continue;
        vis[node.second]=true;
        taka[node.second]=node.first;
        for(pii x:adj[node.second])
        {
            if((vis[x.second]==true) and (x.second!=s))
                continue;
            q.push({(x.first+node.first),x.second});
        }
    }
    cout<<-1<<endl;
    return 0;
}
int main()
{
    cin>>N>>M;
    for(int i=0; i<M; i++)
    {
        int u,v,c;
        cin>>u>>v>>c;
        adj[u].push_back({c,v});
    }
    for(int i=1; i<=N; i++)
        bfs(i);

    return 0;
}

#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 1600008
#define mod 998244353
#define f first
#define s second
ll arr[sz+10],brr[sz+10];
ll num=1;
char c[sz];
std::vector<ll> v[34];
long long binpow(long long a, long long b,long long mod1) {
    a %= mod1;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod1;
        a = a * a % mod1;
        b >>= 1;
    }
    return res;
}
int main()
{
  int t=1;
  //scanf("%d",&t);
  for(int cs=1;cs<=t;cs++)
  {
      ll a,b,c;
      scanf("%lld %lld %lld",&a,&b,&c);
      a%=10;
      ll n=a;
      arr[n]++;
      ll val=0;
      for(int i=2;;i++)
      {
       n=(n*a)%10;
       if(arr[n])
       {
        val=i-1;
        break;
       }
      }
      ll a1=binpow(b,c,val);
      if(a1==0)
      	a1=val;
      	n=a;
      	for(int i=2;i<=a1;i++)
      		n=(n*a)%10;
        a=n;
        printf("%lld\n",a);
  }
  return 0;
}