#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007//998244353//1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef  long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef ll ValType;
template<typename  T> void maxtt(T& t1, T t2) {
    t1=max(t1,t2);
}
template<typename  T> void mintt(T& t1, T t2) {
    t1=min(t1,t2);
}
#define MAX (200135)

bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
const ll MOD2 = (ll)MOD * (ll)MOD;
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD){
    x+=y; if (x>=mod) x-=mod;
    if(x<0) x+=mod;
    assert(x>=0 && x<mod);
}
void et(int x=-1) {
    printf("%d\n", x); exit(0);
}
ll fastPow(ll x, ll y, int mod=MOD) {
    ll ans = 1;
    while(y>0) {
        if(y&1) ans = (x * ans)%mod;
        x = x*x%mod;
        y>>=1;
    }
    return ans;
}
ll gcd1(ll x, ll y) {
    return y?gcd1(y,x%y):x;
}

char s[MAX];
int gn(char x) {
    if(x>='0' && x<='9') return x-'0';
    else return (x-'A') + 10;
}
int fac[MAX],inv[MAX];
void initfac(int n) {
    fac[0]=inv[0]=1;
    REQ(i,n) {
        fac[i]=(ll)fac[i-1]*i%MOD; inv[i]=fastPow(fac[i], MOD-2);
    }
}
int C(int n, int m) {
    if (n<m) return 0;
    return (ll)fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int S[MAX][17];
void init() {
    S[0][0]=1;
    REQ(i,MAX-5) {
        S[i][0]=0;
        for(int j=1;j<=min(i,16);j++) {
            S[i][j] = ((ll)S[i-1][j-1] + (ll)S[i-1][j] * (j) % MOD)%MOD;
        }
    }
}
void fmain(int tid) {
    scanf("%s%d", s+1, &k);
    n=strlen(s+1);
    initfac(MAX-5); init();

    int preM = 0;
    int ans=0;
    for(int i=2;i<=n;i++) {
        int x=n-i;
        if(x+1<k) break;

        int ccc=1;
        int ws=C(16-ccc,k-ccc);
        int pp=0;
        for(int z=k-ccc;z<=k;z++) {
           addmod(pp, (ll)C(ccc, z-(k-ccc)) * S[x][z] % MOD * fac[z] % MOD);
        }
        addmod(ans, (ll)pp*ws%MOD*15%MOD);
    }
    REQ(i,n) {
        int x=n-i;
        //1, b-all 0
        int num=gn(s[i]);
        for(int j=(i==1 ? 1 : 0);j<num;j++) {
            int tmp=preM;
            tmp |= 1<<j;
            int ccc = __builtin_popcount(tmp);
            if (ccc>k) continue;
            int ws=C(16-ccc,k-ccc);
            int pp=0;
            for(int z=k-ccc;z<=k;z++) {
               addmod(pp, (ll)C(ccc, z-(k-ccc)) * S[x][z] % MOD * fac[z] % MOD);
            }
            addmod(ans, (ll)pp*ws%MOD);
        }
        preM |= 1<<num;
    }
    if(__builtin_popcount(preM)==k) addmod(ans, 1);
    printf("%d\n", ans);
}
int main() {
    int t=1;
//    init();
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N=1002;
int n,m;
char s[2];
struct node
{
	int s,t,sp;
} r;
queue<node>q;
vector<int>a[N][26];
int ans=1e9,vis[N][N];
//把边看成点
//对于两对边(a,b)  (c,d)
//如果(a,c) 和 (b,c)之间存在边 而且边上的字母相同的话
//那么这两个边变成的点就可以联通
int bfs()
{
	while(!q.empty())
	{
		r=q.front();
		q.pop();
		if(r.sp==ans)
			return ans<<1;
		for(int i=0; i<26; ++i)
			for(int j=0; j<a[r.s][i].size(); ++j)
				for(int k=0; k<a[r.t][i].size(); ++k)
				{
					int ns=a[r.s][i][j];
					int nt=a[r.t][i][k];
					if(ns==r.t||nt==r.s)return r.sp<<1|1;
					if(ns==nt)ans=r.sp+1;
					if(vis[ns][nt])continue;
					vis[ns][nt]=1;
					q.push((node){ns,nt,r.sp+1});
				}
	}
	return -1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int x,y; m; --m)
	{
		scanf("%d%d%s",&x,&y,s);
		a[x][*s-'a'].push_back(y);
		a[y][*s-'a'].push_back(x);
	}
	vis[1][n]=1;
	q.push((node){1,n,0});
	printf("%d",bfs());
}


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

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << "\n"
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl

template<typename T_vector>
void output_vector(const T_vector &v, bool line_break = false, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
    for (int i = start; i < end; i++) {
      cout << v[i] + (add_one ? 1 : 0) << (line_break ? '\n' : i < end - 1 ? ' ' : '\n');
    }
}

const int mxN = 60;
int p[mxN];

void solve() {
    int n; cin >> n;
    // let x be root, k be LCA
    // d(i, j) = d(k, i) ^ d(k, j)
    //         = d(k, i) ^ d(k, j) ^ d(x, k) ^ d(x, k)
    //         = (d(k, i) ^ d(x, k)) ^ (d(k, j) ^ d(x, k))
    //         = d(x, i) ^ d(x, j)
    vector<vector<pll>> g(n), weight(n);
    REP(i, n - 1) {
        ll u, v, w; cin >> u >> v >> w;
        --u, --v;
        g[u].pb({v, w});
        g[v].pb({u, w});
    }
    vl dist(n, -1);
    dist[0] = 0;
    queue<int> q;
    q.push(0);
    while(!q.empty()) {
        int now = q.front(); q.pop();
        EACH(x, g[now]) {
            int next = x.fi;
            ll sum = dist[now] ^ x.se;
            if(dist[next] == -1) {
                dist[next] = sum;
                q.push(next);
            }
        }
    }
    ll ans = 0;
    REP(i, mxN) {
        vi cnt(2);
        REP(j, n) cnt[dist[j] >> i & 1]++;
        ans += (1LL << i) % MOD * cnt[0] % MOD * cnt[1];
        ans %= MOD;
    }
    OUT(ans);
}

int main()
{
    FAST_INP;

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

    // int tc; cin >> tc;
    // TC(tc) solve();
    solve();
    return 0;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=a;i<b;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,a) rrepi(i,a,0)
#define rrepi(i,a,b) for(ll i=a-1;i>=b;--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<int,int> pi;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 1000005;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};

ll m; //m次正方行列
vector<ll> matmul(vector<ll> &dp,vector<vector<ll>> &mt){
    vector<ll> ret(m,0);
    rep(i,m) rep(j,m) (ret[i] += mt[i][j]*dp[j]%MOD)%=MOD;
    return ret;
}
vector<vector<ll>> update(vector<vector<ll>> &mt){
    vector<vector<ll>> ret(m,vector<ll>(m,0));
    rep(i,m) rep(j,m) rep(k,m) (ret[i][j] += mt[i][k]*mt[k][j]%MOD)%=MOD;
    return ret;
}
void matpow(vector<ll> &dp,vector<vector<ll>> &mt,ll k){
    m = dp.size();
    while(k){
        if(k&1) dp = matmul(dp,mt);
        mt = update(mt);
        k /= 2;
    }
}

ll mod_pow(ll n, ll p, ll m){
    ll ret = 1;
    ll mul = n%m;
    while(p){
        if (p&1) ret = ret*mul%m;
        p >>= 1;
        mul = mul*mul%m;
    }
    return ret;
}

class Combination{
    public:
    ll MAX,M;
    vector<ll> fac,finv,inv;
    Combination(ll MAX_,ll MOD_):MAX(MAX_),M(MOD_){
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        rep(i,2,MAX){
            fac[i] = fac[i-1]*i%M;
            inv[i] = M-inv[M%i]*(M/i)%M;
            finv[i] = finv[i-1]*inv[i]%M;
        }
    }

    ll COM(ll n,ll k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n]*(finv[k]*finv[n-k]%M)%M;
    }
};

int main(){
    Combination com(100000,MOD);
    ll n,k; //edge
    cin >> m >> n >> k;
    vector<ll> a(m);
    cins(all(a));
    vector<vector<ll>> mat(m,vector<ll>(m,0)),g(m);
    rep(i,m) mat[i][i] = n;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        x--,y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    rep(i,m){
        ll cnt = 0;
        for (ll v:g[i]){
            mat[i][v]++;
            cnt++;
        }
        mat[i][i] += n-cnt;
    }
    rep(i,m){
        //array_output(all(mat[i]));
    }
    ll re = com.inv[2*n],mul = mod_pow(re,k,MOD);
    matpow(a,mat,k);
    rep(i,m){
        PRINT(a[i]*mul%MOD);
    }
}


#include <bits/stdc++.h>
#define PB push_back
#define MP(x,y) make_pair(x,y)
#define F first
#define S second
#define loop(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rloop(i,m,n) for(int i=(int)(m) ; i > (int) (n) ; --i )
#define lp(i,n) loop(i,0,n)
#define rlp(i,n) rloop(i,n,0)
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;
int main(){
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    int N;
    scanf("%d", &N);
    vector<pair<int, lli> > edges[N];
    int u, v;
    lli w;
    lp(i, N-1) {
        scanf("%d%d%lld", &u, &v, &w);
        --u; --v;
        edges[u].PB(MP(v,w));
        edges[v].PB(MP(u,w));
    }
    vector<lli> XOR(N);
    vector<bool> visited(N, false);
    queue<pair<int, lli> > q;
    lli d;
    q.push(MP(0, 0));
    visited[0] = true;
    while (!q.empty()) {
        u = q.front().F;
        d = q.front().S;
        q.pop();
        XOR[u] = d;
        for(vector<pair<int, lli> >::iterator it = edges[u].begin(); it != edges[u].end(); ++it) {
            v = it->F;
            w = it->S;
            if (visited[v]) continue;
            visited[v] = true;
            q.push(MP(v, d^w));
        }
    }
    lli ans = 0, add, cnt;
    lp(bit, 60) {
        cnt = 0;
        lp(i, N)
            if (XOR[i]&(((lli)1)<<bit)) ++cnt;
        add = ((((lli)1)<<bit)%mod)*cnt;
        add %= mod;
        add = add * (N-cnt);
        add %= mod;
        // printf("%d %lld %lld\n", bit, cnt, add);
        ans += add%mod;
        ans %= mod;
    }
    // lp(i, N) {
    //     loop(j, i+1, N) {
    //         ans += XOR[i]^XOR[j];
    //         ans %= mod;
    //     }
    // }
    printf("%lld", ans);
    return 0;
}

/*
 *
 *   1 0 0 1 1 0 A
 *   0 0 1 1 0 1 B
 *
 *   1 0 1 0 1 1 A ^ B
 *   1 0 0 1 1 0 A
 * 1 0 1 0 0 0 1 A + A^B
 *
 * 0 0 1 1 0 1 0 2B
 *
 * 1 0 0 1 1 0 0 2A
 *
 *
 * 010
 * 011
 * 001
 *
 * 001
 * 011
 * 010
 *
 */

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wfloat-conversion"

#include <iostream> // IO
#include <cmath> // sqrt, trig, ceil, log
#include <utility> // swap, pair
// #include <chrono> // non c style time

// #include <algorithm> // sort, binary search, reverse, merge
// #include <bitset>
// #include <cstdio>
// #include <cstdlib> //abs, atoi, rand
// #include <iterator>
// #include <map>
// #include <queue>
// #include <set>
// #include <stack>
// #include <string> // std string
// #include <vector>

// #include <complex>
// #include <deque>
// #include <iomanip> // setprecision
// #include <tuple>

#define fo(i, a, b) for(i=a; i<=b; i++)
#define ro(i, b, a) for(i=b; i>=a; i--)
#define foe(it, x) for(auto it=x.begin(); it!=x.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define fil(x, y) memset(x, y, sizeof(x))
#define deb(x) cout << #x << " " << x << "\n"
#define sz(a) ((int)(a.size()))

using namespace std;

using ll = long long;

const ll N = 3e3+3;
const int inf = 1e9+3;
const ll M = 1e9+7;
const ll T = 998244353;
const double pi = acos(-1);

void solve()
{
    ll n,i,j,ans=0;cin>>n;
    ll dp[n+1][n+1];
    ll a[n+1];
    ll p[n+1];
    p[0]=0;
    fo(i,1,n){
        cin>>a[i];
        p[i]=p[i-1]+a[i];
    }
    fo(i,0,n){
        fo(j,0,n){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(j=1;j<=n;j++){
        ll adj[n+1];
        fo(i,0,n){
            adj[i]=0;
        }
        for(i=0;i<=n;i++){
            dp[i][j]=(dp[i][j]+(adj[p[i]%j]))%M;
            adj[p[i]%j]=(adj[p[i]%j]+dp[i][j-1])%M;
        }
    }
    for(j=1;j<=n;j++){
        ans=(ans+dp[n][j])%M;
    }
    cout << ans << "\n";
}

signed main()
{
    // auto s1 = std::chrono::system_clock::now().time_since_epoch();
    // auto start_time = std::chrono::duration_cast<std::chrono::microseconds>(s1).count();

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

    #ifdef Holmes7
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    int _t=1,i;
    //cin >> _t;
    for(i=1;i<=_t;i++){
        //cout << "Case #" << i << ": ";
        solve();
    }

    // auto s2 = std::chrono::system_clock::now().time_since_epoch();
    // auto end_time = std::chrono::duration_cast<std::chrono::microseconds>(s2).count();
    // cerr << "Time: " << (end_time-start_time) << "\n";

    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
const int N=2021,INF=2e9;
int n,a[N],b[N],c[N][N];
int read(){
	int 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;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)c[i][j]=read();
	for(int i=2;i<=n;i++)
		b[i]=c[1][i]-c[1][i-1],a[i]=c[i][1]-c[i-1][1];
	int mib=INF,mia=INF;
	for(int i=2;i<=n;i++)
		b[i]+=b[i-1],a[i]+=a[i-1],mib=min(mib,b[i]),mia=min(mia,a[i]);
	b[1]=max(0,-mib); a[1]=max(0,-mia);
	if(b[1]+a[1]>c[1][1])return puts("No"),0;
	else a[1]=c[1][1]-b[1];
	for(int i=2;i<=n;i++)
		b[i]+=b[1],a[i]+=a[1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(c[i][j]!=a[i]+b[j])
				return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";cout<<endl;
	for(int j=1;j<=n;j++)cout<<b[j]<<" ";cout<<endl;
	return 0;
}

// 2021-03-21 20:11:03
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

// clang-format on
void answer() {
  int n;
  cin >> n;
  vector<vector<int> > c(n, vector<int>(n, 0));
  rep(i, n) rep(j, n) cin >> c[i][j];
  vector<int> d(n, 0);
  rep(i, n - 1) {
    int diff = c[i + 1][0] - c[0][0];
    REP(j, 1, n) {
      if (c[i + 1][j] - c[0][j] != diff) {
        cout << "No" << '\n';
        return;
      }
    }
    d[i + 1] = diff;
  }
  cout << "Yes" << '\n';
  int mind = 0;
  rep(i, n) chmin(mind, d[i]);
  rep(i, n) {
    if (i) cout << ' ';
    cout << d[i] - mind;
  }
  cout << '\n';
  rep(i, n) {
    if (i) cout << ' ';
    cout << c[0][i] - d[0] + mind;
  }
  cout << '\n';
}

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


//Author- Vaibhav Singh

#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }

    }
}
  */

  ll powerm(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
  long long lcm(long long a, long long b){//?????????
   return a * b / gcd(a, b);
}

/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
*/
/*
bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}
*/
/*
int inv(int a){
    return powerm(a,mod-2,mod);
}

ll const N=1e5;
ll fact[N], invfact[N];

void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}

ll ncr(ll n, ll r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}
*/

//*88888*********5555555555555555******88888888$$$$$$$$$$******!!!!!!!!!!

       int main()
       {
           //????????

      fast
          ll x,y,a,b;
          cin>>x>>y>>a>>b;
          ll c=0;
          while(x<b&&x<y)
          {     if(x*a<b&&x*a<y){
              x=x*a;
              c++;}
              else
              {
                  break;
              }
          }
          if(y>x){
             c+=abs(y-x)/b;
             if((y-x)%b==0)
             {
                 c--;
             }}
           o(c)

//?????????
re}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1e9+7;
ll x,y,a,b,res;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

cin>>x>>y>>a>>b;

ll cnt=0;

while((double)a*x<=2e18 && x*a<=x+b  && x*a<y)
{
  x=x*a;
  cnt++;
}

res=((y-x-1)/b);

res=res+cnt;

cout<<res<<endl;

return 0;

}


#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int unsigned long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b

using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    int cnt = 0;
    int nt = n;
    while( nt > 0 ){
        cnt++;
        nt /= 5;
    }
    // out1(cnt);
    rep(i,1,cnt){
        int s = n - binpow(5,i);
        if ( s <= 0 ){
            break;
        }
        // out1(s);
        int st = s;
        int c = 0;
        while( s > 0 ){
            c++;
            s /= 3;
        }
        c--;
        // out1(c);
        if ( st == binpow(3,c) && c != 0 ){
            cout<<c<<" "<<i<<endl;
            return;
        }
    }

    cout<<"-1"<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<(a)<<endl
#define dumparr(a,n) cerr<<#a<<"["<<(n)<<"]="<<(a[n])<<endl
#else
#define dump(a)
#define dumparr(a,n)
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
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(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< "]";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,set<T> a){
  os << "{ ";
  for(auto itr=a.begin();itr!=a.end();++itr){
    os<< *itr << " ";
  }
  os<< "}";
  return os;
}
template<class T>
void ans_array(T begin,T end){
  if(begin==end)return;
  auto itr=begin;
  cout<<*itr;
  ++itr;
  for(;itr!=end;++itr){
    cout<<' '<<*itr;
  }
  cout<<endl;
}
template<class T>
void ans_array_newline(T begin,T end){
  if(begin==end)return;
  for(auto itr=begin;itr!=end;++itr){
    cout<<*itr<<endl;
  }
}

void solve(long long N, std::string S){
  if(S.front()!=S.back()){
    cout<<1<<endl;
    return;
  }
  char s=S[0];
  For(i,N-1){
    if(S[i]!=s&&S[i+1]!=s){
      cout<<2<<endl;
      return ;
    }
  }
  cout<< -1<<endl;
}

int main(){
  cout<<setprecision(1000);
  long long N;
    std::scanf("%lld", &N);
    std::string S;
    std::cin >> S;
  solve(N, S);
  return 0;
}


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

typedef long long ll;

int main() {

    int n; cin >> n;
    vector<ll> a(n);
    ll k = 200;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        a[i] = (a[i] + k) % k;
    }
    vector<ll> h(k);
    for(int i=0; i<n; i++) h[a[i]]++;

    ll ans = 0;
    for (int i=0; i<k; i++) {
        ans += (h[i]*(h[i] - 1)) / 2;
    }

    cout << ans << '\n';
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll val = 0, val2 = 0;
	for (ll i = 0; i < n; i++) {
		val += a[i] * a[i];
		val2 += a[i];
	}
	cout << (n * val) - (val2 * val2);
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

struct UnionFind {
  UnionFind(int n) : data(n, -1) {}

  int root(int ver) { return data[ver] < 0 ? ver : data[ver] = root(data[ver]); }

  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v) return false;
    if (data[u] > data[v]) std::swap(u, v);
    data[u] += data[v];
    data[v] = u;
    return true;
  }

  bool same(int u, int v) { return root(u) == root(v); }

  int size(int ver) { return -data[root(ver)]; }

private:
  std::vector<int> data;
};

template <typename T>
std::vector<std::vector<T>> rotate(const std::vector<std::vector<T>> &grid, int angle, T basis = ' ') {
  int h = grid.size(), w = grid.front().size();
  std::vector<std::vector<T>> rotated_grid;
  if (angle == 45) {
    rotated_grid.assign(h + w - 1, std::vector<T>(h + w - 1, basis));
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) rotated_grid[i + j][i - j + w - 1] = grid[i][j];
  } else if (angle == 90) {
    rotated_grid.assign(w, std::vector<T>(h));
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) rotated_grid[w - 1 - j][i] = grid[i][j];
  } else {
    assert(false);
  }
  return rotated_grid;
}

int solve(const vector<vector<char>> &s) {
  int h = s.size(), w = s.front().size();
  if (h == 2) return 0;
  UnionFind uf(h);
  uf.unite(0, h - 1);
  FOR(i, 1, h - 1) {
    if (s[i].front() == '#' || s[i].back() == '#') uf.unite(0, i);
  }
  FOR(j, 1, w - 1) {
    vector<int> wall;
    REP(i, h) {
      if (s[i][j] == '#') wall.emplace_back(i);
    }
    FOR(i, 1, wall.size()) uf.unite(wall[i - 1], wall[i]);
  }
  int ans = 0;
  FOR(i, 1, h - 1) {
    if (uf.root(i) == i && uf.root(0) != i) ++ans;
  }
  return ans;
}

int main() {
  int h, w; cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w)); REP(i, h) REP(j, w) cin >> s[i][j];
  int ans = solve(s);
  s = rotate(s, 90);
  chmin(ans, solve(s));
  cout << ans << '\n';
  return 0;
}

/**
 *    Author : Tanbin_Hasan
 *    Created : 13.04.2021 02:40:07
**/
#include <bits/stdc++.h>

using namespace std ;

int main(void) {
  ios::sync_with_stdio(false) ; cin.tie(0) ;
  string a , b , c ;
  cin >> a ;
  cin >> b ;
  cin >> c ;
  string s = a + b + c ;
  unordered_set<char> tot ;
  for (auto &i : s) {
    tot.insert(i) ;
  }
  if ((int) tot.size() > 10) {
    cout << "UNSOLVABLE" ;
    return 0 ;
  }
  unordered_map<char,int> value ;
  vector<int> ar = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9} ;
  do {
    int cnt = 0 ;
    for (auto &i : tot) {
      value[i] = ar[cnt++] ;
    }
    string x = a , y = b , z = c ;
    for (auto &i : x) {
      i = (value[i] + '0') ;
    }
    for (auto &i : y) {
      i = (value[i] + '0') ;
    }
    for (auto &i : z) {
      i = (value[i] + '0') ;
    }
    if (x.front() == '0' || y.front() == '0' || z.front() == '0') {
      continue ;
    }
    long long p = stoll(x) , q = stoll(y) , r = stoll(z) ;
    if (p + q == r) {
      cout << p << '\n' ;
      cout << q << '\n' ;
      cout << r ;
      return 0 ;
    }
  } while (next_permutation(ar.begin() , ar.end())) ;
  cout << "UNSOLVABLE" ;
  return 0 ;
}


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

void solveCase() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  vector<bool> visit(26);
  for (auto& c : s1) visit[c - 'a'] = 1;
  for (auto& c : s2) visit[c - 'a'] = 1;
  for (auto& c : s3) visit[c - 'a'] = 1;
  vector<int> can;
  for (int k = 0; k < 26; ++k) {
    if (visit[k]) can.push_back(k);
  }
  int SZ = can.size();
  if (SZ > 10) {
    cout << "UNSOLVABLE" << '\n';
    return;
  }

  vector<int> p(10), v(26);
  int64_t x, y, z;
  for (int i = 0; i < 10; ++i) p[i] = i;
  bool found = false;
  do {
    for (int i = 0; i < SZ; ++i) v[can[i]] = p[i];
    x = 0, y = 0, z = 0;
    if (v[s1[0] - 'a'] == 0) continue;
    if (v[s2[0] - 'a'] == 0) continue;
    if (v[s3[0] - 'a'] == 0) continue;
    for (auto& c : s1) x = x * 10 + v[c - 'a'];
    for (auto& c : s2) y = y * 10 + v[c - 'a'];
    for (auto& c : s3) z = z * 10 + v[c - 'a'];
    if (x && y && z && x + y == z) {
      found = true;
      break;
    }
  } while (next_permutation(p.begin(), p.end()));
  if (!found) {
    cout << "UNSOLVABLE" << '\n';
  } else {
    cout << x << '\n';
    cout << y << '\n';
    cout << z << '\n';
  }
}

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

  int T = 1;
  // cin >> T;
  for (int ti = 1; ti <= T; ++ti) {
    // cout << "Case #" << ti << ": ";
    solveCase();
  }

  return 0;
}

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

int main() {
    string s[3];
    for (int i = 0; i < 3; i++) cin >> s[i];
    bool c[26] = {};
    vector<char> top;
    for (int i = 0; i < 3; i++) {
        top.push_back(s[i][0]);
        for (int j = 0; j < s[i].length(); j++) c[s[i][j] - 'a'] = true;
    }
    int n = 0;
    int d[26];
    memset(d, -1, sizeof(d));
    int cnt = 0;
    for (int i = 0; i < 26; i++)
        if (c[i]) {
            n++;
            d[i] = cnt;
            cnt++;
        }
    if (n > 10) {
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    int x[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    do {
        bool topcheck = true;
        for (int i = 0; i < top.size(); i++) {
            if (x[d[top[i] - 'a']] == 0) topcheck = false;
        }
        if (topcheck) {
            long long int m[3] = {};
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < s[i].length(); j++) {
                    m[i] += x[d[s[i][j] - 'a']] * pow(10, s[i].length() - 1 - j);
                }
            }
            if (m[0] + m[1] == m[2]) {
                for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < s[i].length(); j++) {
                        cout << x[d[s[i][j] - 'a']];
                    }
                    cout << endl;
                }
                return 0;
            }
        }
    } while (next_permutation(x, x + 10));
    cout << "UNSOLVABLE" << endl;
}


//Bismillahirrahmanirrahim
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define sz(i) (int)i.size()
#define ln "\n"
const int N = 2e5+5;
void solve(){
	string s; cin >> s;
	string ans;
	for(int i =0; i < s.size(); i++){
		if(s[i] != '.')
			ans+=s[i];
		else
			break;
	}
	cout << ans << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    ll n;
    cin>>n;
    double ans=0;
    for(int i=1;i<n;i++){
        ans+=double(n)/double(i);
    }
    printf("%.10lf\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz(a) int(a.size())
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) { out << "(" << a.first << "," << a.second << ")"; return out; }
template <typename T, size_t N> ostream& operator <<(ostream& out, const array<T, N>& a) { out << "["; bool first = true; for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]"; return out; }
template <typename T> ostream& operator <<(ostream& out, const vector<T>& a) { out << "["; bool first = true; for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]"; return out; }
template <typename T, class Cmp> ostream& operator <<(ostream& out, const set<T, Cmp>& a) { out << "{"; bool first = true; for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}"; return out; }
template <typename U, typename T, class Cmp> ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) { out << "{"; bool first = true; for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}"; return out; }
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << ": " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); }

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif

void solve() {
	int n, m;
	cin >> n >> m;
	map<int, vector<int>> mp;
	for(int i=0; i<m; i++) {
		int x, y;
		cin >> x >> y;
		mp[x].push_back(y);
	}
	unordered_set<int> s;
	s.insert(n);
	for(auto&[_, b]: mp) {
		vector<int> add;
		for(auto y: b) {
			if(s.count(y-1) or s.count(y+1)) {
				add.push_back(y);
			}
		}
		for(auto d: b) {
			s.erase(d);
		}
		for(auto a: add) {
			s.insert(a);
		}
	}
	cout << s.size() << endl;
}

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

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
// constexpr i32 mod   = 998244353;

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solve() {
  int n, m;
  cin >> n >> m;

  vector< int > cnt(10000, 0);
  range(i, 0, n + m) {
    int a = input();
    cnt[a]++;
  }

  vector< int > ans;
  range(k, 0, cnt.size()) {
    if (cnt[k] == 1) {
      ans.emplace_back(k);
    }
  }

  cout << ans << endl;
}

signed main() {
  solve();
}


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include <atcoder/all>
using namespace std;
//using namespace boost::multiprecision;
//using namespace atcoder;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(firstsecond) '(' << first< ',' << second< ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-8;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

random_device seed_gen;
mt19937_64 rnd(seed_gen());

ll range_rand(ll a,ll b){
    uniform_int_distribution<ll> dist_res(a,b);
    return dist_res(rnd);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;

// MOD確認

ll N;
ll x[110],y[110],x2[110],y2[110];
double X[110],Y[110];
ll D[60][60],D1[60][60];

int main(){
    cin >> N;
    rep(i,N) cin >> x[i] >> y[i];
    rep(i,N) cin >> x2[i] >> y2[i];
    ll a = x[0],b = y[0];
    rep(i,N){
        x[i] -= a;
        y[i] -= b;
        D[x[i] + 30][y[i] + 30]++;
    }

    rep(i,N){
        ll dx = x[0] - x2[i],dy = y[0] - y2[i];
        ll M = 0;
        rep(j,N){
            x2[j] += dx;
            y2[j] += dy;
            M = max({M,abs(x2[j]),abs(y2[j])});
        }
        FOR(j,-M,M+1) FOR(k,-M,M+1){
            long double theta = atan2(j,k);
            bool flag = 1;
            rep(l,60) rep(m,60) D1[l][m] = 0;
            rep(l,N){
                X[l] = x2[l] * cos(theta) - y2[l] * sin(theta);
                Y[l] = x2[l] * sin(theta) + y2[l] * cos(theta);
                if(abs(X[l] - round(X[l])) > 0.2 || abs(Y[l] - round(Y[l])) > 0.2) flag = 0;
                D1[(ll)round(X[l]) + 30][(ll)round(Y[l]) + 30]++;
            }
            rep(l,60) rep(m,60) if(D[l][m] != D1[l][m]) flag = 0;
            if(flag){
                cout << "Yes" << endl;
                //cout << theta / PI * 180 << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

#include <iostream>
#include <vector>
#include  <set>
#include <math.h>
#include <algorithm>
#define MAXA 1000000
#define ll long long
using namespace std;

int GetNorm(int x,int y) {
    return x*x+y*y;
}
int A[111];
int B[111];
int C[111];
int D[111];

bool Check(int N) {
    if (N == 1) return true;
    vector<pair<ll,ll> > right_pts;
    for(int i=1;i<=N;i++) {
        right_pts.push_back({C[i],D[i]});
    }
    sort(right_pts.begin(),right_pts.end());
    int xans, yans, denomans;
    denomans=-1;
    for(int i=1;i<=N;i++) {
        for(int j=1;j<=N;j++) {
            if (i == j) continue;
            ll dA = A[1]-A[2];
            ll dB = B[1]-B[2];
            ll dC = C[i]-C[j];
            ll dD = D[i]-D[j];
            // A[i]-A[j], B[j]-B[j]
            if (GetNorm(dA, dB) != GetNorm(dC, dD)) {
                continue;
            }
            ll x = dC*dA+dD*dB;
            ll y = dA*dD-dC*dB;
            ll denom = GetNorm(dA, dB);
            // x/denom+j*y/denom
            // (A[1]+j*B[1])*(x+j*y) + delta = C[i]+j*D[i]

            ll delta_1 = C[i]*denom-(A[1]*x-y*B[1]);
            ll delta_2 = D[i]*denom-(A[1]*y+x*B[1]);

            vector<pair<ll,ll> > pts;
            bool ok=true;
            for(int k=1;k<=N;k++) {
                // (A[i]+j*B[i])*(x+j*y) + delta
                ll X = A[k]*x-B[k]*y+delta_1;
                ll Y = A[k]*y+B[k]*x+delta_2;
                if (X%denom != 0 || Y%denom != 0) ok=false;
                pts.push_back({X/denom,Y/denom});
            }
            if (!ok) continue;

            sort(pts.begin(),pts.end());

            if (pts==right_pts) return true;
        }
    }
    return false;

}

int main() {
    int N;
    cin>>N;
    for(int i=1;i<=N;i++) {
        cin>>A[i]>>B[i];
    }
    for(int i=1;i<=N;i++) {
        cin>>C[i]>>D[i];
    }
    if (Check(N)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int a[4];
    int ans = INF;
    rep(i, 4) {
        cin >> a[i];
        ans = min(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

vector<int> dij(vector<vector<pair<int,int>>> graph, int source){
    int n=graph.size();
    vector<int> dists(n,MOD);
    vector<bool> mark(n,false);
    dists[source]=0;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
    pq.push({dists[source],source});
    while(!pq.empty()){
        auto cur=pq.top();
        pq.pop();
        int v=cur.second;
        //cout<<v<<" "<<dists[v]<<" "<<cur.first<<endl;
        if(mark[v]) continue;
        mark[v]=true;
        for(auto& p:graph[v]){
            if(dists[p.first]>dists[v]+p.second){
                dists[p.first]=dists[v]+p.second;
                pq.push({dists[p.first],p.first});
            }
        }
    }
    return dists;

}

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

    int a,b,x,y;
    cin>>a>>b>>x>>y;

    vector<vector<pair<int,int>>> gr(202);

    for(int i=1; i<=100; i++){
        gr[i].push_back({100+i,x});
        gr[100+i].push_back({i,x});
    }

    for(int i=2; i<=100; i++){
        gr[i].push_back({100+i-1,x});
        gr[100+i-1].push_back({i,x});

    }

    for(int i=1; i<=99; i++){
        gr[i].push_back({i+1,y});
        gr[i+1].push_back({i,y});
        gr[100+i].push_back({100+i+1,y});
        gr[100+i+1].push_back({100+i,y});
    }

    auto v=dij(gr,a);
    cout<<v[100+b];

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define int long long
template<typename T>
void dbg_a(T *a,int l,int r){cout<<" {";for(int i = l;i<r;i++) cout<<a[i]<<", ";cout<<a[r]<<"}"<<endl;}
typedef long long ll;
template<typename T = int>
inline T read(){
    T f = 1,r = 0;
    char c = getchar();
    while(c<'0'||c>'9'){if(c == '-') f = -1; c = getchar();}
    while(c>='0'&&c<='9'){ r = (r<<1) + (r<<3) + c - '0';c = getchar();}
    return f*r;
}
typedef pair<int,int> PII;
#define fi first
#define se second
#define mst(a,b) memset(a,b,sizeof(a))
#define For(i,a,b) for(int i = a;i<=b;i++)
#define For_(i,a,b) for(int i = a;i>=b;i--)
#define _for(i,a) for(int i = 0;i<a;i++)
#define All(x) x.begin(),x.end()

//    For(i,1,n) For(j,1,m) printf("f[%lld][%lld] = %lld\n",i,j,f[i][j]);

const int N = 2e5 + 10,M = 2*N + 10,INF = 0x3f3f3f3f;
const int mod = 998244353;
int h[N],ne[M],e[M],idx;
void add(int a,int b){
    e[++idx] = b;ne[idx] = h[a];h[a] = idx;
}
int exgcd(int a,int b,int &x,int &y){
    int d = a;
    if(b){ d = exgcd(b, a%b, y, x);y -= (a/b)*x;}
    else{x = 1;y = 0;}
    return d;
}
int inv(int a,int mo){
    int x,y;
    int d = exgcd(a,mo,x,y);
    return d == 1 ? (x + mo)%mo : -1;//-1表示不存在，并对逆元调整
}
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool merge(int a1,int m1,int a2,int m2,int &A,int &mo){
    int c = (a2 - a1),d = gcd(m1,m2);
    if(c % d) return 0;//gcd(m1,m2)|(a2 - a1)时才有解
    c = (c%m2 + m2)%m2;//将c变为[0,m2)之间的数
    c /= d;m1 /= d;m2 /= d;//两边除以d
    c = c*inv(m1,m2) % m2;//将m1/d 移到右边
    mo = m1*m2*d;// mo = m1 * m2 /d
    A = (c*m1%mo*d%mo + a1)%mo;
    return 1;
}
int EXCRT(int n,int a[],int mo[]){
    int a1 = a[1],m1 = mo[1],A,Mo;
    for(int i = 2;i<=n;i++){
        if(!merge(a1,m1,a[i],mo[i],A,Mo)) return -1;//不合法
        a1 = A;m1 = Mo;
    }
    return (a1 + m1)%m1;
}
int n;
void solve(){
    int x,y,p,q;
    cin>>x>>y>>p>>q;
    int a[3] = {},mo[3] = {};
    int ans = 3e18;
    For(i,x,x+y-1){
        For(j,p,p+q-1){
            a[1] = i,mo[1] = 2*(x+y);
            a[2] = j,mo[2] = p + q;
            int res = EXCRT(2,a,mo);
            if(res == -1) continue;
            ans = min(res,ans);
        }
    }
    if(ans == 3e18)cout<<"infinity"<<"\n";
    else cout<<ans<<"\n";
}
signed main(){
    int T = 1;
    T = read();
    while(T--) solve();
    system("pause");
    return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <climits>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

// a*x - b*y = return value = GCD(a,b). x,y >= 0
ll egcd(ll a, ll b, ll& x, ll& y) { // MINUS B*Y
	if (b == 0) {
		x = 1; y = 0;
		return a;
	}

	ll d = egcd(b, a % b, y, x);
	y = a - x * (a / b) - y;
	x = b - x;
	return d;
}
// modular inverse; works for any mod p (coprime with a)
ll inverse(ll a, ll p) {
	ll x, y;
	egcd(a % p + p, p, x, y);
	return x % p;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// solves the system of congruences:
// x = a (mod m)
// x = b (mod n)
// returns res such that x = res (mod lcm(m,n))
// no such res => return -1
ll CRT(ll a, ll m, ll b, ll n) {
	b = (b + n - (a % n)) % n;
	ll d = gcd(m, n);
	if (b % d != 0) return -1;

	ll oldM = m;
	m /= d; b /= d; n /= d;
	return ((b * inverse(m, n)) % n) * oldM + a;
}

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

	int t; cin >> t;
	while (t--) {
		ll X, Y, P, Q; cin >> X >> Y >> P >> Q;
		ll ans = LLONG_MAX;
		for (int i = X; i < X + Y; i++) {
			for (int j = P; j < P + Q; j++) {
				ll curT = CRT(i, 2 * (X + Y), j, P+Q);
				if (curT == -1) { continue; }
				ans = min(ans, curT);
			}
		}
		if (ans == LLONG_MAX) { cout << "infinity" << '\n'; }
		else { cout << ans << '\n'; }
	}
}


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

int main(){
  int h=0,w=0;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w,0));
  vector<vector<int>> b(h,vector<int>(w,0));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a.at(i).at(j);
      if(a.at(i).at(j)=='#')
        b.at(i).at(j)=1;
      else
        b.at(i).at(j)=0;
    }
  }
  int ans=0;
  for(int i=0;i<h-1;i++){
    for(int j=0;j<w-1;j++){
      int check;
      check=b.at(i).at(j)+b.at(i).at(j+1)+b.at(i+1).at(j)+b.at(i+1).at(j+1);
      if(check==1||check==3)
        ans++;
    }
  }
  cout<<ans<<endl;

  return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;
ll mmod= 998244353;

int main() {
  int h,w;
  cin >> h >>w;
  bool a[h][w];
  rep(i,h)rep(j,w){
    char q;
    cin >> q;
    if(q=='.'){a[i][j]=0;}else{a[i][j]=1;}
  }

  int ans=0;
  rep(i,h-1)rep(j,w-1){
    int k=0;
    if(a[i][j])k++;
    if(a[i+1][j])k++;
    if(a[i][j+1])k++;
    if(a[i+1][j+1])k++;

    if(k%2==1)ans++;
  }
  cout << ans << endl;
}


//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h> // __builtin_popcount(int x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) int(x.size())
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template <typename T> void print(T a) {cout << a << ' ';}
template <typename T> void printe(T a) {cout << a << endl;}
template <typename T> void printv(T a) {rep(i, sz(a))print(a[i]); cout<<endl;}
template <typename T> void printp(pair<T, T> a) {print(a.first); cout<<a.second<<endl;}
template <typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

// 宣言 C z(x, y) -> z = x+yi
using C = complex<double>;

C input () {
    double x, y; cin >> x >> y;
    return C(x, y);
}

int main () {
    int n; cin >> n;
    C z0 = input(), z1 = input();
    C c = (z0 + z1) / 2.0;
    double theta = (double) 2 * M_PI / n;
    //C r(cos(theta), sin(theta));
    C r = C(cos(theta), sin(theta));
    C ans = c + (z0-c) * r;
    printf("%.10lf %.10lf\n", ans.real(), ans.imag());
    return 0;
}

#include <iostream>
#include <random>
#include <cmath>
using namespace std;
struct Point
{
  int i;
  int j;
};

string calculate_path(Point s, Point t) {
  int di = s.i - t.i;
  int dj = s.j - t.j;

  char ci = 'U', cj = 'L';
  if (di < 0) {
    ci = 'D';
    di = -di;
  }
  if (dj < 0) {
    cj = 'R';
    dj = -dj;
  }

  string path;
  mt19937 mt(3017);

  while (di > 0 && dj > 0) {
    bernoulli_distribution dist((double)di / (double)dj);
    if (dist(mt)) {
      path.push_back(ci);
      di--;
    } else {
      path.push_back(cj);
      dj--;
    }
  }
  while (di > 0) {
    path.push_back(ci);
    di--;
  }
  while (dj > 0) {
    path.push_back(cj);
    dj--;
  }
  return path;
}

int main() {

  // main
  for (int k = 0; k < 1000; ++k) {
    // input start and terminal point
    Point s, t;
    cin >> s.i >> s.j >> t.i >> t.j;
    // calculate path
    cout << calculate_path(s, t) << endl << flush;
    // output path
    // input path length
    int b;
    cin >> b;
  }
  return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef pair<int, int> P;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define fi first
#define se second
// #include <atcoder/all>
// using namespace atcoder;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T, class U>
inline bool chmax(T& a, U b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& a, U b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, pair<T, U>& p) {
    cout << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <class T>
inline void dump(T& v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
template <class T, class U>
inline void dump(map<T, U>& v) {
    if (v.size() > 100) {
        cout << "ARRAY IS TOO LARGE!!!" << endl;
    } else {
        irep(i, v) { cout << i->first << " " << i->second << '\n'; }
    }
}
template <class T, class U>
inline void dump(pair<T, U>& p) {
    cout << p.first << " " << p.second << '\n';
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 61;
constexpr ll MOD = 1000000007;  // 998244353; //
constexpr ld EPS = 1e-11;
void Case(int i) { printf("Case #%d: ", i); }
/* --------------------   ここまでテンプレ   -------------------- */

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vvi v(2);
    vvi w(2);
    rep(i, n) {
        if (s[i] == '0') w[0].pb(i);
        if (t[i] == '0') w[1].pb(i);
        if (s[i] != t[i]) {
            v[s[i] != '0'].pb(i);
        }
    }
    if (v[0].size() != v[1].size()) {
        fin(-1);
        return 0;
    } else if (s == t) {
        fin(0);
        return 0;
    }
    int ans = 0;
    rep(i, w[0].size()) { ans += w[0][i] != w[1][i]; }
    fin(ans);
}

#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <functional>
#include <climits>
#include <set>
#include <map>
#include <cassert>
using namespace std;

using ll = long long;

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

	int n; cin >> n;
	string s, t; cin >> s >> t;
	vector<int> a, b;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '0') a.push_back(i);
	}
	for (int i = 0; i < n; i++)
	{
		if (t[i] == '0') b.push_back(i);
	}
	if (a.size() != b.size()) { cout << -1; return 0; }
	int ans = a.size();
	for (int i = 0; i < a.size(); i++)
	{
		if (a[i] == b[i])
			ans--;
	}
	cout << ans;
}


#if _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#ifndef ONLINE_JUDGE
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

// Reads a 1D vector
template <class T>
void read1d(vector<T> & arg) {
	const int l = arg.size();
	for (int i = 0; i < l; ++i) cin >> arg[i];
}

void read() {}
// Reads arbitrary values
template <class T1, class... T2>
void read(T1& var1, T2&... var2) { cin >> var1; read(var2...); }

void pln() { cout << (DEBUG ? "]\n" : "\n"); }
template <class T1, class... T2>
void pln(const T1& var1, const T2& ... var2) { cout << var1 << " "; pln(var2...); }

// Prints arbitrary values and goes to next line
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout << (DEBUG ? " [ " : ""); pln(var1, var2...); }

// Prints arbitrary values and goes to next line ONLY IF IN DEBUG MODE
template <class T1, class... T2>
constexpr void debug(const T1& var1, const T2& ... var2) { if (!DEBUG) return;  cout << " debug : [ "; pln(var1, var2...); }

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define all(x) begin(x), end(x)

const bool MULTIPLE_TEST_CASES = 0;

ll ans = 0;
int h, w, a, b;

unordered_set<string> coll;

void calc(string& grid, int a) {
	if (a == 0) {
		++ans;
		if (!coll.count(grid))
			coll.insert(grid);
		return;
	}

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (grid[i * w + j] != '.') continue;

			// try HH
			if (j < w - 1 && grid[i * w + j + 1] == '.') {
				grid[i * w + j] = grid[i * w + j + 1] = 'H';
				calc(grid, a - 1);
				grid[i * w + j] = grid[i * w + j + 1] = '.';
			}

			// try VV
			if (i < h - 1 && grid[(i + 1) * w + j] == '.') {
				grid[i * w + j] = grid[(i + 1) * w + j] = 'V';
				calc(grid, a - 1);
				grid[i * w + j] = grid[(i + 1) * w + j] = '.';
			}
		}
	}
}
//void calc(vector<vector<char>>& grid, int a) {
//	if (a == 0) {
//		++ans;
//		string hash;
//		for (int i = 0; i < h; ++i) {
//			for (char c : grid[i]) hash.push_back(c);
//			//cout << endl;
//		}
//		//cout << endl;
//		coll.insert(hash);
//		return;
//	}
//
//	for (int i = 0; i < h; ++i) {
//		for (int j = 0; j < w; ++j) {
//			if (grid[i][j] != '.') continue;
//
//			// try HH
//			if (j < w - 1 && grid[i][j + 1] == '.') {
//				grid[i][j] = grid[i][j + 1] = 'H';
//				calc(grid, a - 1);
//				grid[i][j] = grid[i][j + 1] = '.';
//			}
//
//			// try VV
//			if (i < h - 1 && grid[i + 1][j] == '.') {
//				grid[i][j] = grid[i+1][j] = 'V';
//				calc(grid, a - 1);
//				grid[i][j] = grid[i+1][j] = '.';
//			}
//		}
//	}
//}

void exec()
{
	read(h, w, a, b);

	//vector<vector<char>> taken(h, vector<char>(w, '.'));
	string taken(16, '.');

	calc(taken, a);

	print(coll.size());
}

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

	if (!MULTIPLE_TEST_CASES)
		exec();
	else {
		int n;
		cin >> n;

		while (n--) exec();
	}

    return 0;
}

// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace __gnu_cxx;

using namespace std;

#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl
#define filler(arr, n)          \
    for (int i = 0; i < n; i++) \
        cin >> arr[i];
#define filler2(arr, n , m)          \
    for (int i = 0; i < n; i++) \
        for(int j=0; j<m; j++)  \
            cin >> arr[i][j];

const int N = 1000000007;

// int n;

int X[2000005] = {};
int Y[2000005] = {};

void calc(int arr[] , int n , int x[] , int c){

    for(int i=0; i<power(2 , n); i++) {
        int sum = 0;

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

            if((1<<j)&i){

                sum += arr[j + c];
            }
        }

        x[i] = sum;
    }

}

void solve(){

    int n ,a,b,c,t ,  ans=0, count=0, sum=0;
    cin>>n>>t;
    int arr[n];
    filler(arr , n);

    calc(arr , n/2, X , 0);
    calc(arr , n - n/2, Y , n/2);

    int x_size = power(2 , n/2) , y_size = power( 2, n - n/2);

    sort(Y , Y + y_size);

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

        if(X[i] > t)continue;

        int it = lower_bound(Y , Y + y_size , t - X[i]) - Y;

        if (it == y_size  || Y[it] != (t-X[i]))
                it--;

            ans = max(ans , Y[it] + X[i]);
        // if(Y[it] + X[i] <= t){
        // }
    }

    cout<<ans<<endl;

}

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

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

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int dp[101][1000004];
int solve(int a[],int n, int cursum, int sum)
{
    if(n==-1)
    {
        return abs(sum-cursum-cursum);
    }

    if(dp[n][cursum]!=-1)
    return dp[n][cursum];

    return  dp[n][cursum]=min(solve(a,n-1,cursum,sum),solve(a,n-1,cursum+a[n],sum));
}
int main()
{
    int n;
    cin>>n;
    int a[n],sum=0;
    for(int i=0;i<n;i++)
    { cin>>a[i]; sum+=a[i]; }

    if(n==1)
    {
        cout<<a[0];
    }
    else if(n==2)
    {
        cout<<max(a[0],a[1]);
    }
    else{
    memset(dp,-1,sizeof dp);
    int diff=solve(a,n-1,0,sum);
    cout<<(diff+sum)/2;
    }
}

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

#define int long long
#define double long double
using pii = pair<int, int>;
template<typename T>
using Prior = std::priority_queue<T>;
template<typename T>
using prior = std::priority_queue<T, vector<T>, greater<T>>;

#define X first
#define Y second
#define eb emplace_back
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)

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

inline int getRand(int L, int R) {
    if (L > R) swap(L, R);
    return (int)(rng() % ((uint64_t)R - L + 1) + L);
}

template<typename T1, typename T2>
ostream& operator << (ostream &os, pair<T1, T2> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template<typename T>
ostream& operator << (ostream &os, vector<T> &vec) {
    for (int i = 0; i < vec.size(); ++i) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}

const int maxn = 100 + 5;
const int maxc = 1000 + 5;

bitset<maxn * maxc> dp;

void solve() {
    int N, sum = 0; cin >> N;

    dp[0] = 1;
    while (N--) {int tmp; cin >> tmp, sum += tmp, dp |= dp << tmp;}

    for (int i = sum/2; i >= 0; --i) {
        if (dp[i]) return cout << sum - i << "\n", void();
    }
}

int32_t main() {
    fastIO();

    int t = 1; // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case #" << _ << ": ";
        solve();
    }

    return 0;
}


//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
vector<ll> x[3];
ll n,t;
ll a[50];
void solve(ll i,ll so,ll cn, ll et)
{
	if(i==et){
        x[cn].pb(so);
        return;
	}
	solve(i+1,so,cn,et);
	solve(i+1,so+a[i],cn,et);
}
signed main()
{
    fast;

    ll i,j,ans=0;
    cin>>n>>t;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    }
    solve(0,0,0,n/2);

    solve(n/2,0,1,n);
    sort(all(x[0]));
    for(auto u: x[1]){
    	if(u>t) continue;
    	auto it = upper_bound(x[0].begin(),x[0].end(),t-u);
    	ll ha = u;
    	if(it!=x[0].begin()) {
    		it--;
            ha += *it;
    	}
    	ans = max(ans,ha);
    }
    cout<<ans;

}

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define endl "\n"
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const double PI=acos(-1.0);
const double eps=1e-6;
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e2+10;
const int maxm=100+10;
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x&(-x))
using namespace std;
ll n,m,k;
ll a[maxn];
ll dp[maxn];
int vis[maxn];
ll ans = 0;
ll sum[maxn];
int r;
void dfs(ll sum1,int r){
    if(sum1 > k)
       return ;
    ans = max(ans,sum1);
    if(sum[r] + sum1 <= k){
        ans = max(sum[r] + sum1,ans);
        return ;
    }
    if(ans == k){
        return ;
    }
    for(int i = 1; i<=r; i++){
        if(vis[i] == 1)
            continue;
        if(sum1 + a[i] > k){
            return ;
        }
        vis[i] = 1;
        dfs(sum1+a[i],i-1);
        vis[i] = 0;
    }
}
void run_case(){
    cin>>n>>k;
    ll sum1 = 0;
    for(int i = 1; i<=n; i++){
        cin>>a[i];
        sum1 += a[i];
    }
    if(sum1 <= k){
        cout<<sum1<<endl;
        return ;
    }
    sort(a+1,a+n+1);
    for(int i = 1; i<=n; i++)
        sum[i] = sum[i-1] + a[i];
    for(int i = n; i>=1; i--){
        vis[i] = 1;
        dfs(a[i],i-1);
        vis[i] = 0;
    }
    cout<<ans<<endl;
}

int main(){
    ios;
    run_case();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mem(a,val) memset(a,(val),sizeof((a)))
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define decimal(n)  cout << fixed ; cout << setprecision((n));
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define endl "\n"
#define lcm(m,n) (m)*((n)/__gcd((m),(n)))
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(ll (i)=1;(i)<(n);(i)++)
#define repa(i,n,a) for(ll (i)=(a);(i)<(n);(i)++)
#define repr(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define pll pair<ll,ll>
#define pii pair<int, int>
#define mll map<ll,ll>
#define vll vector<ll>
#define sz(x) (ll)x.size()
#define ub upper_bound
#define lb lower_bound
#define pcnt(x) __builtin_popcountll(x)
const long long N=1e9;
const long long NN=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}

void solve()
{
  //code begins from here//
  ll a,b,c;
  cin>>a>>b>>c;
  ll ans=21-a-b-c;
  cout<<ans;
}

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

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

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<21-(a+b+c);
}


#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

const int N = (int) 2e5 + 7;
int n;
int m;
int k;
int x[N];
bool is[N];
ld dp[N];

ld algo(ld dp0) {
  ld sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (is[i]) {
      dp[i] = dp0;
    } else {
      dp[i] = 1 + sum / (ld) m;
    }
    sum += dp[i];
    sum -= dp[i + m];
  }
  return dp[0];
 /// cout << dp0 << " " << dp[0] << "\n";
}

bool ok(ld dp0) {
  return dp0 - algo(dp0) < 1e-14;
}

const ld INF = (ld) 1e12;

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

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

  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    int x;
    cin >> x;
    is[x] = 1;
  }
  ld l = 0, r = INF;
  if (ok(r)) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 1; i <= 100; i++) {
    ld m = (l + r) * 0.5;
    if (ok(m)) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << fixed << setprecision(3) << l << "\n";
  return 0;
  ld x = 0;
  while (1) {
    algo(x);
    ld y = dp[0];
    if (fabs(x - y) < 1e-14) {
      break;
    }
    x = y;
  }
  cout << fixed << setprecision(6) << x << "\n";
}

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

#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
*/
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rrep(i,a,b) for(ll i=a;i>=b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll INF = 1e18+7;
const ll mod = 998244353;
const ll MAXN = 1e5+10;

ll poww(ll a, ll b) {
    if(b<0) return 0LL;
    ll ans = 1;
    while (b) {
        if (b & 1)ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
ll binpow(ll a, ll b)
{
    if (b < 0) return 0LL;
    if (a <= 0)return 0LL;
    a %= mod;

    ll ans = 1LL;
    while (b) {
        if (b & 1)ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll modinv(ll n) {
    return binpow(n, mod - 2);
}

void solve() {
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> pos(n+1,0);
    FOR(i,k) {
        ll x; cin>>x;
        pos[x] = 1;
    }
    ll ct = 0, flg = 0;
    for(ll i=1; i<n; i++) {
        if(pos[i]==0) {
            if(ct>=m) flg = 1;
            ct = 0;
        }
        else ct++;
    }
    if(ct>=m) flg = 1;
    if(flg) { cout<<-1; return; }

    vector<ld> a(n+1), b(n+1);
    FOR(i,n+1) a[i] = b[i] = 0.0;

    ld r1=0.0,r2=0.0;
    for(ll i=n-1; i>=0; i--) {
        if(pos[i]) {
            a[i] = 1.0; b[i] = 0.0;
        }
        else {
            ld x = 0.0, y = 0.0;
            x = r1; y = r2;
            x /= (m*1.0); y /= (m*1.0); y += 1.0;
            a[i] = x; b[i] = y;
        }
        r1 += a[i]; r2 += b[i];
        if(i+m<=n) {
            r1 -= a[i+m]; r2 -= b[i+m];
        }
    }

    ld ans = b[0] / (1-a[0]);
    cout<<ans;
}

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

    //ll no_of_test_cases; cin>>no_of_test_cases;
    ll no_of_test_cases = 1;
    cout<<setprecision(10);

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


#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repr(i, a) for (int i = (int)(a)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si()
{
  int x;
  scanf("%d", &x);
  return x;
}
long long sl()
{
  long long x;
  scanf("%lld", &x);
  return x;
}
string ss()
{
  string x;
  cin >> x;
  return x;
}
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }
typedef pair<int, int> P;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;
const ll N = 2001;

string s;
ll a, b, c;
string result;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> a >> b >> c;
  if (c % 2)
  {
    if (a == b)
    {
      result = "=";
    }
    else if (a <= 0 && b >= 0)
    {
      result = "<";
    }
    else if (a >= 0 && b <= 0)
    {
      result = ">";
    }
    else if (a >= 0)
    {
      result = a > b ? ">" : "<";
    }
    else
    {
      result = a > b ? "<" : ">";
    }
  }
  else
  {
    if (abs(a) > abs(b))
    {
      result = ">";
    }
    else if (abs(a) < abs(b))
    {
      result = "<";
    }
    else
      result = "=";
  }

  cout << result << endl;
}

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

int main() {
    long long A, B, C;
    cin >> A >> B >> C;
    bool aNeg = A < 0 && (C % 2 == 1);
    bool bNeg = B < 0 && (C % 2 == 1);
    if (!aNeg && !bNeg) {
        if (abs(A) == abs(B)) {
            cout << "=" << endl;
            return 0;
        }
        cout << (abs(A) > abs(B) ? ">" : "<") << endl;
        return 0;
    }
    if (!aNeg && bNeg) {
        cout << ">" << endl;
        return 0;
    }
    if (aNeg && !bNeg) {
        cout << "<" << endl;
        return 0;
    }
    if (abs(A) == abs(B)) {
        cout << "=" << endl;
        return 0;
    }
    cout << (abs(A) > abs(B) ? "<" : ">") << endl;
}


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

using namespace std;
//using namespace atcoder;

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 +7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = modint1000000007;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL x(n);
	rep(i, n) cin >>x[i];

	ll a=0;
	rep(i, n) a += abs(x[i]);
	double b=0;
	rep(i, n) b +=x[i]*x[i];
	b = sqrt(b);
	ll c=-9999999999;
	rep(i, n) c=max(c, abs(x[i]));
	printf("%lld\n",a);
	printf("%.16f\n",b);
	printf("%lld\n",c);
	return 0;
}

//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
template<typename T>void rearrange(vector<ll>&ord, vector<T>&v){
  auto tmp = v;
  for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<ll>&ord,Head&& head, Tail&&... tail){
  rearrange(ord, head);
  rearrange(ord, tail...);
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  vector<vector<ll>>g(n);
  rep(i,0,m){
    ll u,v;cin>>u>>v;u--;v--;
    g[u].PB(v);
  }
  res=-INF;
  vector<ll>dp(n,INF);
  rep(i,0,n){
    chmax(res,a[i]-dp[i]);
    chmin(dp[i],a[i]);
    for(auto to:g[i]){
      chmin(dp[to],dp[i]);
    }
  }
  cout<<res<<endl;
  return 0;
}


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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MASK(i) (1ll<<(i))
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;

/***End of Template***/
int n, m, k;
const int N = 2e6+5;
int fact[N];
const int MOD = 1e9+7;

int modPow(int a, int b) {
	if (b == 0) return 1;
	int half = modPow(a, b/2);
	if (b&1) return (1LL*a*(1LL*half*half%MOD) % MOD);
	else return 1LL*half*half%MOD;
}

int inv(int a) {return modPow(a, MOD-2);}

int C(int n, int k) {
	if (n < k) return 0;
	return 1LL * fact[n] * inv(1LL * fact[k] * fact[n-k] % MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    fact[0] = 1;
    FOR(i, 1, N-1) fact[i] = 1LL*fact[i-1]*i % MOD;
    scanf("%d%d%d", &n, &m, &k);
   	int ans = (n <= m+k) ? (C(m+n, m) - C(m+n, m+k+1) + MOD) % MOD : 0;
   	printf("%d", ans);
    return 0;
}

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

const ll MOD = 1000000007;
const ll MAX = 2000010;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using namespace std;

int main() {
	ll N, M, K;
	cin >> N >> M >> K;

	COMinit();

	if (N > M + K) {
		cout << 0 << "\n";
		return 0;
	}

	ll ans = (COM(N+M, N) + MOD - COM(N+M, M+K+1)) % MOD;

	cout << ans << "\n";

	return 0;
}


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

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

void solve(std::istream& in, std::ostream& out) {
    int n; in >> n;
    string s, t;
    in >> s >> t;
    queue<int> spos, tpos;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') spos.push(i);
        if (t[i] == '1') tpos.push(i);
    }
    long long ans = 0;
    while (!spos.empty() && !tpos.empty()) {
        int si = spos.front();
        int ti = tpos.front();
        if (si == ti) {
            spos.pop();
            tpos.pop();
        } else if (si < ti) {
            spos.pop();
            if (spos.empty()) {
                out << -1 << '\n';
                return;
            }
            int nsi = spos.front();
            spos.pop();
            //cout << nsi << " " << si << '\n';
            ans += nsi - si;
        } else {
            spos.pop();
            tpos.pop();
            //cout << si << " " << ti << '\n';
            ans += si - ti;
        }
    }
    while (!spos.empty()) {
        int si = spos.front();
        spos.pop();
        if (spos.empty()) {
            out << -1 << '\n';
            return;
        }
        int nsi = spos.front();
        spos.pop();
        //cout << nsi << " " << si << '\n';
        ans += nsi - si;
    }
    if (!tpos.empty() || !spos.empty()) {
        out << -1 << '\n';
        return;
    }
    out << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
char S[505050], T[505050];
vector<int> A, B;

int main()
{
	scanf("%d%s%s", &N, S, T);

    for (int i = 0; i < N; ++i) if (S[i] == '1') A.push_back(i);
    for (int i = 0; i < N; ++i) if (T[i] == '1') B.push_back(i);

    int a = 0, b = 0;
    i64 ret = 0;
    while (a < A.size() || b < B.size()) {
        if (a == A.size()) {
            ret = -1;
            break;
        }
        if (b < B.size() && A[a] >= B[b]) {
            ret += A[a] - B[b];
            ++a;
            ++b;
            continue;
        } else {
            if (a + 2 > A.size()) {
                ret = -1;
                break;
            }
            ret += A[a + 1] - A[a];
            a += 2;
            continue;
        }
    }
    printf("%lld\n", ret);
	return 0;
}


#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define repu(i,a,b) for(ull i = a; i<b; i++)
#define rep(i,a,b) for(int i = a; i<b; i++)
using namespace std;

int n,res;
double per;
int main() {
	per = 1.08;

	cin>>n;

	res = floor(n*per);

	if(res<206){
		cout<<"Yay!";
	} else if(res>206){
		cout<<":(";
	} else {
		cout<<"so-so";
	}
	return 0;
}

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

string str;

int cal(int x, int size)
{
	string tp;
	for (int k = 0; k < size; ++k) {
		if (x >> k & 1) tp += str[k];
	}
	ll val = stol(tp);
	return (0 == val % 3) ? tp.size() : -1;
}

int solve(void)
{
	int res = 0;
	int size = str.size();
	for (int k = 1; k < (1 << size); ++k) {
		res = max(res, cal(k, size));
	}
	return (0 == res) ? -1 : size - res;
}

int main(int argc, char** argv)
{
	while (cin >> str) {
		cout << solve() << endl;
	}
	return 0;
}


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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;

using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;

#define pb push_back
#define mp make_pair
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) reps(i, 1, n + 1)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)

#define debug(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" <<endl;
#define kd(x) cerr << "\033[33m" << #x << ": " << x << ", \033[m";
#define kdl(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << ", \033[m";
#define kde(x) cerr << "\033[33m" << #x << ": " << x << ", \033[m" << endl;

inline int in_int() {int x; cin >> x; return x;}
inline ll in_ll() {ll x; cin >> x; return x;}
inline string in_str() {string x; cin >> x; return x;}
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}

int main()
{
    int n = in_int();
    ll C = in_ll();
    priority_queue<pii,vector<pii>,greater<pii>> q;
    vector<tuple<int,int,int>> v(n);
    rep(i,n) {
        int a = in_int();
        int b = in_int() + 1;
        int c = in_int();
        v[i] = {a,b,c};
        q.emplace(mp(a,i));
        q.emplace(mp(b,i));
    }
    int time = 1;
    ll cost = 0;
    ll ans =0;
    while (!q.empty()) {
        auto [new_time,_] = q.top();
        ans += min(cost, C) * (new_time - time);
        time = new_time;
        //kde(time);
        bool retry = true;
        do {
            if (cost < 0) return 1;
            auto [t,i] = q.top();
            if (t > time) retry = false;
            else {
                q.pop();
                auto [a,b,c] = v[i];
                if (t == a) {
                    //kd("\tin"); kd(c);
                    cost += c;
                } else if (t == b) {
                    //kd("\tout"); kd(c);
                    cost -= c;
                } else {
                    debug("raise");
                    return 1;
                }
                //kde(cost);
            }
        } while (retry && !q.empty());
    }
    cout << ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using i128 = __int128_t;
using u128 = __uint128_t;

//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int

//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< std::vector<int> > vvi;
typedef std::vector< std::vector<long long> > vvl;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;

const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long double PI = 3.141592653589793238;
const long long pi = 31415926;
const long long inf = 1000000000000000000;
const long long small_inf = 100000000000000;

ll modpow(ll x, ll n, ll mod = MOD){ ll res=1; while(n>0){ if(n&1) res=res*x%mod; x=x*x%MOD; n>>=1;} return res;}
ll power(ll x, ll n){ ll res=1; while(n>0){ if(n&1) res=res*x; x=x*x; n>>=1; } return res;}

void init()
{

}

void solve()
{
    ll ans=0;
    string s;
    cin>>s;
    int n = s.length();
    vll v(26,0);
    repd(i,n-1,0)
    {
        v[s[i]-'a']++;
        if(i==n-1)
            continue;
        if(s[i]==s[i+1])
        {
            int x  = 0, y=v[s[i]-'a'];
            rep(i,26)
            {
                x+=v[i];
                v[i]=0;
            }
            ans+=x-y;
            v[s[i]-'a']=x;
        }
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t23 = 1, tt23=1;
    // cin>>t23;
    init();
    while(tt23<=t23)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt23++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

#define llong long long
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#ifdef testing/*{{{*/
mt19937 rng(177013);
#else
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
#endif
#define rand() (int)(rng() >> 1)
#define CONCAT_(x, y) x##y
#define CONCAT(x, y) CONCAT_(x, y)
#define SPEC(name) CONCAT(name, __LINE__)
#ifdef LOCAL_DEBUG
int __db_level = 0;
#define clog cerr << string(__db_level * 2, ' ')
struct debug_block {
    string msg;
    debug_block(const string& s): msg(s) { clog << "{ " << msg << endl; ++__db_level; }
    ~debug_block() { --__db_level; clog << "} " << msg << endl; }
};
#define DB(args...) stringstream SPEC(ss); SPEC(ss)<< args; debug_block SPEC(dbbl)(SPEC(ss).str())
#else
#define clog if (0) cerr
#define DB(...)
#endif
#define db(val) "[" #val " = " << val << "]; "
template<class U, class V> ostream& operator<<(ostream& out, const pair<U, V>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<size_t i, class T> ostream& print_tuple_utils(ostream& out, const T& tup) {
    if constexpr(i == tuple_size<T>::value) return out << ")";
    else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup);
}
template<class ...U>
ostream& operator<<(ostream& out, const tuple<U...>& tup) { return print_tuple_utils<0, tuple<U...>>(out, tup); }
template<class, typename = void> struct has_const_iterator : false_type {};
template<class T> struct has_const_iterator<T, void_t<typename T::const_iterator>> : true_type {};
template<class T>
typename enable_if<has_const_iterator<T>::value && !is_same<T, string>::value, ostream&>::type
operator<<(ostream& out, const T& container) {
    auto beg = container.begin(), end = container.end();
    out << "(" << container.size() << ") {";
    if (beg != end) out << *(beg++);
    while (beg != end) out << ", " << *(beg++);
    return out << "}";
}
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION START HERE ////////////////////////////////////////////////////////////////

const int maxn = 201010;
int n;
int a[maxn], b[maxn], p[maxn], rev[maxn];

vector<pair<int, int>> ans;
void do_swap(int u, int v) {
    clog << db(u) << db(v) << endl;
    assert(a[u] > b[p[u]]);
    assert(a[v] > b[p[v]]);
    swap(p[u], p[v]);
    ans.emplace_back(u, v);
}

bool vis[maxn];

int main(void) {
#ifdef LOCAL
    freopen("main.inp", "r", stdin);
    freopen("main.out", "w", stdout);
    freopen(".log", "w", stderr);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    rep1(i, n) cin >> a[i];
    rep1(i, n) cin >> b[i];
    rep1(i, n) cin >> p[i];
    rep1(i, n) rev[p[i]] = i;

    rep1(i, n) {
        if (vis[i] or p[i] == i) continue;
        vector<int> x;
        for (int u = i; !vis[u]; u = rev[u]) {
            vis[u] = true;
            x.push_back(u);
        }

        clog << db(i) << db(x) << endl;

        for (auto u: x) if (a[u] <= b[p[u]]) {
            clog << db(u) << db(a[u]) << db(p[u]) << db(b[p[u]]) << endl;
            cout << "-1";
            return 0;
        }

        auto it = min_element(x.rbegin(), x.rend(), [&](int u, int v) { return b[p[u]] < b[p[v]]; });
        rotate(x.rbegin(), it, x.rend());

        clog << db(x) << endl;

        for (int prev = len(x) - 1, cur = 0; cur < len(x) - 1; prev = cur++) {
            do_swap(x[prev], x[cur]);
        }
    }

    cout << len(ans) << '\n';
    rep1(i, n) assert(p[i] == i);
    for (auto [u, v]: ans) cout << u << ' ' << v << '\n';

    return 0;
}

// vim: foldmethod=marker

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

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

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

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

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

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

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

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

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

ll conbinationMemo[201][12];

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

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

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    ll sum = 0;
    ll ma = INF;
    ll mi = -INF;

    rep(i, n){
        ll a, t;
        cin >> a >> t;
        if(t == 1){
            sum += a;
            ma += a;
            mi += a;
        } else if(t == 2){
            mi = max(mi, a);
            ma = max(ma, a);
        } else {
            ma = min(ma, a);
            mi = min(mi, a);
        }
    }
    assert(mi <= ma);
    ll q;
    cin >> q;
    rep(i, q){
        ll x;
        cin >> x;
        cout << min(ma, max(mi, x + sum)) << endl;
    }
}


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

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

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

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

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

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

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

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

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

ll conbinationMemo[100][100];

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

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

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll r1, c1;
    cin >> r1 >> c1;
    ll r2, c2;
    cin >> r2 >> c2;

    if(r1 == r2 && c1 == c2){
        cout << 0 << endl;
        return 0;
    }

    if(abs(r1 - r2) + abs(c1 - c2) <= 3){
        cout << 1 << endl;
        return 0;
    }

    if(r1 + c1 == r2 + c2 || r1 - c1 == r2 - c2){
        cout << 1 << endl;
    } else {
        if(abs((r1 + c1) - (r2 + c2)) <= 3 || abs((r1 - c1) - (r2 - c2)) <= 3){
            cout << 2 << endl;
        } else {
            if((r1 + c1) % 2 == (r2 + c2) % 2){
                cout << 2 << endl;
            } else {
                cout << 3 << endl;
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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

	int N, L;
	cin >> N >> L;

	int A[100100], B[100100];
	rep1(i, N) cin >> A[i];
	rep1(i, N) cin >> B[i];
	A[0] = 0;
	B[0] = 0;
	A[N + 1] = L + 1;
	B[N + 1] = L + 1;

	ll kotae = 0;
	int k = 0;
	int a = 1;
	rep1(b, N + 1) {
		chmax(a, b);
		if (A[b] < B[b]) {
			while (A[a] < B[b] + k) {
				a++;
				k++;
			}
			if (A[a] == B[b] + k) {
				kotae += k;
				k--;
				while (k && B[b] + 1 == B[b + 1]) {
					b++;
					k--;
				}
			}
		}
		else if (k) {
			co(-1);
			return 0;
		}
	}

	reverse(A, A + N + 2);
	reverse(B, B + N + 2);
	rep(i, N + 2) A[i] = L + 1 - A[i];
	rep(i, N + 2) B[i] = L + 1 - B[i];
	k = 0;
	a = 1;
	rep1(b, N + 1) {
		chmax(a, b);
		if (A[b] < B[b]) {
			while (A[a] < B[b] + k) {
				a++;
				k++;
			}
			if (A[a] == B[b] + k) {
				kotae += k;
				k--;
				while (k && B[b] + 1 == B[b + 1]) {
					b++;
					k--;
				}
			}
		}
		else if (k) {
			co(-1);
			return 0;
		}
	}

	co(kotae);

	Would you please return 0;
}