#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define int ll
#define ld long double
#define reps(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rep(i,n) reps(i,0,n)
#define rreps(i,s,n) for(int i=(int)(s-1);i>=n;i--)
#define rrep(i,n) rreps(i,n,0)
#define all(v) (v).begin(),(v).end()
#define mset(a,n) memset(a,n,sizeof(a))
#define eras(v,n) (v).erase(remove(all(v),n),(v).end())
#define uni(v) sort(all(v));(v).erase(unique(all(v)),(v).end())
#define bcnt(i)  __builtin_popcount(i)
#define fi first
#define se second
constexpr ll INF = 1e18;
constexpr ll MOD = 1000000007;
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; }
template<class T>T min(vector<T> &v) { return *min_element(v.begin(),v.end()); }
template<class T>T max(vector<T> &v) { return *max_element(v.begin(),v.end()); }
template<class T>T modpow(T a, T b, T m) { a %= m; T r = 1; while (b > 0) { if (b & 1) r = (r * a) % m; a = (a * a) % m; b >>= 1; } return r; }
ll modinv(ll a,ll m=MOD) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template<class T>string radixconv(T n, T k){ string s; while(n/k){ s=to_string(n%k)+s; n/=k; } s=to_string(n%k)+s; return s; }

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    int n,m,q;
    cin >> n >> m >> q;
    vector<pair<int,int>> vw(n);
    rep(i,n)cin >> vw[i].se >> vw[i].fi;
    sort(all(vw), [](pair<int,int> a, pair<int,int> b){
        return a.first>b.first|| (a.first==b.first && a.second<b.second);
    });
    vector<pair<int,int>> xi(m);
    rep(i,m)cin >> xi[i].fi,xi[i].se=i;
    sort(all(xi));
    vector<int> ans(q,0);
    rep(i,q){
        int l,r;
        cin >> l >> r;
        l--;r--;
        vector<bool> used(m,0);
        rep(j,n){
            rep(k,m){
                if(l<=xi[k].se&&xi[k].se<=r)continue;
                if(vw[j].se<=xi[k].fi&&!used[xi[k].se]){
                    used[xi[k].se]=1;
                    ans[i]+=vw[j].fi;
                    break;
                }
            }
        }
    }
    rep(i,q)cout << ans[i] << endl;
    return 0;
}

#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")

#include"bits/stdc++.h"
using namespace std;
const int p = 31;
const int M = 998244353;
typedef long long ll;
typedef long double d;
typedef unsigned long long ull;
typedef int in;
#define ar array
#define ff first
#define ss second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<ll>>bag;
    for (int i = 0; i < n; ++i) {
        int w, v;
        cin >> w >> v;
        // bag.push_back({w, v});
        bag.push_back({v, w});

    }

    sort(bag.begin(),bag.end());
    vector<int>box(m);
    for (int i = 0; i < m; ++i)
        cin >> box[i];

    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        vector<int>tmp;
        for (int j = 0; j < m; ++j) {
            if (j < l || j > r)
                tmp.push_back(box[j]);
        }
        int sz = tmp.size();
        sort(tmp.begin(), tmp.end());
        vector<int>seen(sz);
        ll ans = 0;
        for (int k = n-1; k >=0 ; --k) {
            for (int j = 0; j < sz; ++j) {
                if (seen[j]||tmp[j] < bag[k][1])
                    continue;
                seen[j] = 1;
                ans += bag[k][0];
                break;
            }
        }
        cout << ans << '\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"; //check time

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,a,c) for(auto it=c.begin()+a;it!=c.end();it++)
#define fr(i,a,n)   for(int i=a;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;

int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}}
bool comp(int a, int b)
{
    return (a > b);
}

bool comp1(pi a, pi b)
{
    if(a.first==b.first)return a.second<b.second;
    else return a.first>b.first;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& v)
{
    for (T& x : v) in >> x; return in;
}

template<typename T>
ostream& operator<<(ostream& out, vector<T>& v)
{
    for (T& x : v) out << x<<" "; return out;
}

// template<typename T>
int sum1(vector<int>& v)
{
    int sum=0;
    // for(auto x: v)sum+=x;
    fr(i,0,v.size())sum+=v[i];
    return sum;
}

 void solve()
{
    int n;
    cin>>n;
    vi v(n);
    cin>>v;
    if(n==1){cout<<v[0];return;}
    vvi min1(n,vi(n,0));
    fr(i,0,n)
    {
        min1[i][i]=v[i];
    }
    fr(i,0,n-1)
    {
        fr(j,i+1,n)
        {
            if(v[j]<min1[i][j-1])
                min1[i][j]=v[j];
            else
                min1[i][j]=min1[i][j-1];
        }
    }
    int ans=0;
    fr(i,0,n)
    {
        fr(j,0,n)
        {
            min1[i][j]=min1[i][j]*(j-i+1);
            ans=max(ans,min1[i][j]);

        }
    }
    cout<<ans;

}

signed main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    // int t;
    // cin>>t;
    // while(t--)
    // {
    //     solve();
    //     cout<<endl;
    // }
    solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 998244353;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

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

template<i64 MOD> struct Fp {
    i64 val;
    constexpr Fp(i64 v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }

    constexpr u64 getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        i64 a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            i64 t = a / b;
            a -= t * b; swap(a ,b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, i64 n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mi64 = Fp<MOD>;

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

void Main() {
    i32 H, W;
    cin >> H >> W;
    Vec<Vec<i32>> M(H + W - 1, Vec<i32>(3));
    for (i32 i = 0; i < H; i++) {
        for (i32 j = 0; j < W; j++) {
            char S;
            cin >> S;
            i32 index =  (S == 'R')? 0 : (S == 'B')? 1 : 2;
            M[i + j][index]++;
        }
    }
    mi64 ans = 1;
    for (i32 c = 0; c < H + W - 1; c++) {
        auto m = M[c];
        if (m[0] == 0 && m[1] == 0) ans *= 2;
        else if (m[0] != 0 && m[1] != 0) ans = 0;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1505;
int pref[N][N], block[N][N];
int main(){
	int h,w,n,m;
	scanf("%d %d %d %d",&h,&w,&n,&m);
	for(int i=0;i<=h+1;i++){
		block[i][0] = block[i][w+1] = -1;
	}
	for(int i=0;i<=w+1;i++){
		block[0][i] = block[h+1][i] = -1;
	}
	for(int i=0;i<n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		pref[x][y]++;
	}
	for(int i=0;i<m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		block[x][y] = -1;
	}
	for(int i=1;i<=h+1;i++){
		for(int j=1;j<=w+1;j++){
			pref[i][j] += pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1];
		}
	}
	for(int i=0;i<=h+1;i++){
		for(int j=0;j<=w+1;j++){
//			printf("%d ",pref[i][j]);
		}
//		puts("");
	}
	for(int i=1;i<=h;i++){
		int start = 0;
		for(int j=1;j<=w+1;j++){
			if(block[i][j] == -1){
				int pt = pref[i][j-1]-pref[i][start]-pref[i-1][j-1]+pref[i-1][start];
//				printf("%d %d\n",j,pt);
				if(pt > 0){
//					printf("%d\n",j);
					for(int k=start+1;k<j;k++){
						block[i][k] = 1;
					}
				}
				start = j;
			}
		}
	}
	for(int i=1;i<=w;i++){
		int start = 0;
		for(int j=1;j<=h+1;j++){
			if(block[j][i] == -1){
				int pt = pref[j-1][i]-pref[start][i]-pref[j-1][i-1]+pref[start][i-1];
				if(pt > 0){
					for(int k=start+1;k<j;k++){
						block[k][i] = 1;
					}
				}
				start = j;
			}
		}
	}
	int ans = 0;
	for(int i=0;i<=h+1;i++){
		for(int j=0;j<=w+1;j++){
			if(block[i][j] == 1){
				ans++;
			}
//			printf("%4d",block[i][j]);
		}
//		puts("");
	}
	printf("%d\n",ans);
}

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

const int di[] = {1, 0, -1, 0};
const int dj[] = {0, -1, 0, 1};

int h,w,n,m;
bool light[MX][MX];
bool wall[MX][MX];
bool ok[MX][MX];

bool visited[MX][MX];
bool memo[MX][MX];

bool f(int v, int i, int j) {
    if (i < 0 || i >= h || j < 0 || j >= w) return false;
    if (wall[i][j]) return false;
    if (light[i][j]) return true;

    if (visited[i][j]) return memo[i][j];

    visited[i][j] = true;
    return memo[i][j] = f(v, i + di[v], j + dj[v]);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w >> n >> m;
    rep(i,n) {
        int r,c;
        cin >> r >> c;
        --r; --c;
        light[r][c] = true;
    }
    rep(i,m) {
        int r,c;
        cin >> r >> c;
        --r; --c;
        wall[r][c] = true;
    }

    rep(v,4) {
        rep(i,h) rep(j,w) visited[i][j] = false;
        rep(i,h) rep(j, w) if (f(v,i,j)) ok[i][j] = true;
    }

    int ans = 0;
    rep(i,h) rep(j,w) if (ok[i][j]) ++ans;
    cout  << ans << endl;
    return 0;
}


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

const int mod=998244353;
int a,b,c;
int main( ) {
	cin>>a>>b>>c;
	a%=mod, b%=mod, c%=mod;
	a=1ll*a*(a+1)/2%mod;
	b=1ll*b*(b+1)/2%mod;
	c=1ll*c*(c+1)/2%mod;
	cout<<1ll*a*b%mod*c%mod;
	return 0;
}

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#define ll long long int
#define endl '\n'
#define M 998244353
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t=1,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n>>m>>k;
        ll sn = (n *(n+1))/2;
        sn = sn%M;
        ll sm = (m *(m+1))/2;
        sm = sm%M;
        ll sk = (k *(k+1))/2;
        sk = sk%M;
        ll ans = ((sn%M * sm%M)%M * sk%M)%M;
        cout<<ans<<endl;
    }
}


#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <numeric>
#include <chrono>
#include <random>

using namespace std;

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

#define debug(x) cerr << #x << " = " << (x) << endl;
#define debug_pii(x) cerr << "(" << x.first << "," << x.second << ")";
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define F first
#define S second

// template<typename _Ty1, typename _Ty2>
// ostream& operator<<(ostream& _os, const pair<_Ty1, _Ty2>& _p) {
//     _os << '(' <<_p.first << ',' << _p.second << ')';
//     return _os;
// }
//
// template<typename _Ty1, typename _Ty2>
// istream& operator>>(istream& _is, pair<_Ty1, _Ty2>& _p) {
//     _is >> _p.first >> _p.second;
//     return _is;
// }

void solve() {
  string s;
  cin>>s;
  int n = s.size();
  vector<int> F(26);
  int i = n-3, j = n-2, k = n-1;
  ll ans = 0;
  while (i >= 0) {
    if(s[i] == s[j] && s[j] != s[k]) {
      ans += n-k-1-F[s[i]-'a']+1;
      F.assign(26,0);
      F[s[i]-'a']= n-1-j;
    } else {
      F[s[k]-'a']++;
    }
    i--;j--;k--;
  }
  cout<<ans<<endl;
}

// 0123....i=j!=k......n-1

//         aababbbbb
//         aaaabbbbb
//         aaaaabbbb

// d+1, d+2, d+3, ...,  d'    ,... , M
// 0 [1]
// 1 [1]
// 2 [2,4,8,6,2]
// 3 [3,9,7,1,3]
// 4 [4,6,4]
// 5 [1]
// 6 [1]
// 7 [7,9,3,1,7]
// 8 [8,4,2,6,8]
// 9 [9,1,9]

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);
 // cout << fixed << setprecision(15);2000000000

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

 return 0;
}

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

using namespace std;

struct Edge {
  int to;
  long long weight;
  Edge(int to, long long weight) : to(to), weight(weight) {}
};

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  int n = s.length();
  ll ans = 0;
  vector<vector<int>> dp(26, vector<int>(n+1, 0));
  for(int i=n-1;i>=0;i--){
    int num = s[i]-'a';
    if(i-1 >= 0 && s[i]==s[i-1]){
      ans += n-1-i-dp[num][i+1];
      // cout << "s[i]: " << s[i] << " ans: " << n-1-i-dp[num][i+1] << endl;
      for(int j=0;j<26;j++){
        if(j==num) dp[j][i]=n-i;
        else dp[j][i]=0;
      }
    } else {
      for(int j=0;j<26;j++){
        if(j==num) dp[j][i] = dp[j][i+1]+1;
        else dp[j][i] = dp[j][i+1];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
#include <climits>
using namespace std;
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ps(x,y) fixed<<setprecision(y)<<x
#define int long long

int solve(int arr[],int n,int sum){
	bool dp[n+1][sum+1];
	memset(dp,false,sizeof(dp));
	for(int i=0;i<=n;i++){
		dp[i][0]=true;
	}
	for(int i=1;i<=n;i++){
		dp[0][i]=false;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=sum;j++){
			dp[i][j]=dp[i-1][j];
			if(arr[i-1]<=j){
				dp[i][j] |= dp[i-1][j-arr[i-1]];
			}
		}
	}
	for(int j=sum/2;j>=0;j--){
		if(dp[n][j]==true){
			return (sum-j);
		}
	}
	return -1;
}

int32_t main(){

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

	FIO;
	int n,sum=0;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++) {
		cin >> arr[i];
		sum+=arr[i];
	}
	int ans = solve(arr,n,sum);
	cout << ans << "\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b)  for(ll i=ll(a); i<=ll(b); i++)//  a<=i<=b i++ のforの開始
#define ALL(a) (a).begin(),(a).end()//全要素，min,max,findなどで使う
#define ITE(e,a,i) auto ite=find(ALL(a),e);\
 (i)=distance((a).begin(),ite);\
  if(ite==(a).end()) i=-1;
#define EACH(i,a) for(auto (i): (a))
#define ERASE(a,i) (a).erase((a).begin()+i);//iは0始まり
#define ERASES(a,i,j) (a).erase((a).begin()+i,(a).begin()+j);//i,jは0始まり i<= u <jの範囲を消す i!=j
#define SORT(a)  sort(begin(a),end(a))//小さい順にsort 1,2,3
#define SORT_(a) sort(begin(a),end(a),greater<ll>{})//大きい順にsort 5,4,3
#define OI(s) cout<<(s)<<endl
#define OII(s) printf("%8.7lf\n",(s));//double 小数点上8桁まで，下7桁まで出力
#define OI2(s0,s1) cout<<(s0)<<" "<<(s1)<<endl
#define OI3(s0,s1,s2) cout<<(s0)<<" "<<(s1)<<" "<<(s2)<<endl
#define OI4(s0,s1,s2,s3) cout<<(s0)<<" "<<(s1)<<" "<<(s2)<<" "<<(s3)<<endl
#define OIV(a) for(ll (iii)=0;(iii)<(a).size();(iii)++){cout<<(a)[(iii)]<<" ";} cout<<""<<endl
#define OIVV(a) for(ll (iii)=0;(iii)<(a).size();(iii)++){for(ll (jjj)=0;(jjj)<(a[(iii)]).size();(jjj)++){cout<<(a)[(iii)][(jjj)]<<" ";}cout<<" "<<endl;}
// vector<vector<ll>> a(5,vector<ll>(3,0));
//vector<vector<vector<double>>> abc(A, vector<vector<double>>(B, vector<double>(C,0)));
//vector<pair<ll,ll>> event;
// 20210606 Dまでいけなくてもいい，今週の成果をみせる

int main()
{
    ll N;
    cin >>N;
    vector<ll> T(N);
    ll sum=0;
    FOR(i,0,N-1)
    {
        cin>>T[i];
        sum+=T[i];
    }
    if(N==1)
    {
        OI(T[0]);
        return 0;
    }

    vector<vector<bool>> dp(N,vector<bool>(sum+1,false));
    FOR(i,0,N-1) dp[i][0] = true;

    FOR(i,0,N-2)
    {
        FOR(j,0,sum)
        {
            if(dp[i][j])
            {   // i番目を選ばない
                dp[i+1][j] = true;
                // i番目を選ぶ
                dp[i+1][j+T[i]] = true;

            }
        }
    }

    //OIVV(dp);

    ll S2;
    if(sum%2==0) S2=sum/2;
    else S2 = sum/2 +1;
    ll ans = 1000000000001;

    FOR(i,1,N-1)
    {
        FOR(j,S2,sum)
        {
            //OI3(i,j,dp[i][j]);
            if(dp[i][j]) ans = min(j,ans);
        }
    }

    OI(ans);
    return 0;
}


/******************************
Author: jhnah917(Justice_Hui)
g++ -std=c++14 -DLOCAL
******************************/

#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

int N, K, A[9][9], R;

int main(){
    cin >> N >> K;
    for(int i=1; i<=N; i++) for(int j=1; j<=N; j++) cin >> A[i][j];
    vector<int> ord(N);
    iota(all(ord), 1);
    do{
        int now = 0, flag = 1;
        for(int i=1; i<N; i++){
            if(!A[ord[i-1]][ord[i]]) flag = 0;
            now += A[ord[i-1]][ord[i]];
        }
        if(!A[ord.back()][ord[0]]) flag = 0;
        now += A[ord.back()][ord[0]];
        if(flag && now == K) R++;
    }while(next_permutation(ord.begin()+1, ord.end()));
    cout << R;
}

#include <bits/stdc++.h>

using namespace std;

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

const int dy[4] = { -1, 0, 1, 0 }, dx[4] = { 0, 1, 0, -1 };

char mp[1000][1000];
vector<int> gph[2000];
bool chk[2000];

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

	int r, c;
	cin >> r >> c;
	gph[0].push_back(r);
	gph[r].push_back(0);
	gph[0].push_back(r + c - 1);
	gph[r + c - 1].push_back(0);
	gph[r - 1].push_back(r);
	gph[r].push_back(r - 1);
	gph[r - 1].push_back(r + c - 1);
	gph[r + c - 1].push_back(r - 1);
	for (int i = 0; i < r; ++i)
		for (int j = 0; j < c; ++j) {
			cin >> mp[i][j];
			if (mp[i][j] == '#') {
				gph[i].push_back(r + j);
				gph[r + j].push_back(i);
			}
		}

	int cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < r + c; ++i)
		if (!chk[i]) {
			queue<int> q;
			chk[i] = true;
			q.push(i);

			bool chk0 = false, chk1 = false;
			while (!q.empty()) {
				int now = q.front();
				q.pop();

				if (now < r)
					chk0 = true;
				else
					chk1 = true;

				for (int nxt : gph[now])
					if (!chk[nxt]) {
						chk[nxt] = true;
						q.push(nxt);
					}
			}

			if (chk0)
				cnt0++;
			if (chk1)
				cnt1++;
		}

	cout << min(cnt0, cnt1) - 1;

	return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
	const int MAXIOSIZE = 1 << 24 | 1;
	unsigned char buf[MAXIOSIZE], *p1, *p2;
//	#define gc (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2) ? EOF : *p1++)
	#define gc getchar()
	template <typename T> void read(T& x) {
		x = 0; char ch = gc; bool flg = false;
		for (; ch < '0' || '9' < ch; ch = gc) if (ch == '-') flg |= true;
		for (; '0' <= ch && ch <= '9'; ch = gc) x = x * 10 + ch - '0';
		flg ? x = -x : 0;
	}
	template <typename T> void out(const T& x) { if (x > 9) out(x / 10); putchar(x % 10 + '0'); }
	template <typename T> inline void write(const T& x, const char& ed = ' ') { if (x < 0) putchar('-'), out(-x); else out(x); putchar(ed); }
}

const int MAXN = 5000 + 10;
const int P = 998244353;

int H, W, K, cntrow[MAXN][MAXN], cntcol[MAXN][MAXN], f[MAXN][MAXN][3], tag[MAXN][MAXN][3];
int pow3[MAXN];

int qpower(int a, int x) {
	int ret = 1;
	for (; x; x >>= 1, a = 1ll * a * a % P) ret = 1ll * ret * a % P;
	return ret;
}

int toint(char ch) { return (ch == 'D' ? 0 : (ch == 'R' ? 1 : 2)); }

void add(int& a, int b) { a = a + b >= P ? a + b - P : a + b; }

int main() {
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif
	IO::read(H), IO::read(W), IO::read(K);
	pow3[0] = 1;
	rep(i, 1, max(H, W)) pow3[i] = 1ll * pow3[i - 1] * 3 % P;
	rep(i, 1, K) {
		int x, y; char c[10]; IO::read(x), IO::read(y); scanf("%s", c + 1);
		tag[x][y][toint(c[1])] = true;
	}
	rep(i, 1, H) rep(j, 1, W) cntrow[i][j] = cntrow[i][j - 1] + ((tag[i][j][0] + tag[i][j][1] + tag[i][j][2]) == 0);
	rep(i, 1, W) rep(j, 1, H) cntcol[j][i] = cntcol[j - 1][i] + ((tag[j][i][0] + tag[j][i][1] + tag[j][i][2]) == 0);

	int tt = -1;
	rep(v, 0, 2) if (tag[1][1][v]) tt = v;
	if (tt != -1) f[1][1][tt] = true;
	else {
		rep(v, 0, 2) f[1][1][v] = true;
	}
	rep(i, 1, H) rep(j, 1, W) {
		if (i == 1 && j == 1) continue;
		int tt = -1;
		rep(v, 0, 2) {
			if (tag[i][j][v]) tt = v;
			add(f[i][j][v], 1ll * (f[i - 1][j][2] + f[i - 1][j][0]) * pow3[cntrow[i][j - 1]] % P);
			add(f[i][j][v], 1ll * (f[i][j - 1][2] + f[i][j - 1][1]) * pow3[cntcol[i - 1][j]] % P);
		}
		if (tt != -1) {
   			rep(v, 0, 2) if (v != tt) f[i][j][v] = 0;
		}
	}
	int ans = 0;
	rep(v, 0, 2) add(ans, f[H][W][v]);
	IO::write(ans);
	return 0;
}

#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first
#define ss second
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
string tostr(ll n)
{ stringstream rr;rr<<n;return rr. str();}
ll toint(string s)
{stringstream ss(s);ll x;ss>>x;return x;}
void solve()
{
  ll n, a,m=0,b=0, c=0,k=0, i, j,l=998244353;
  string s, r, y;
  ll hit=0, yog;
  cin>>n;
  rep(i, 1,n+1)
  cout<<(2*i-1)%n+1<<" "<<(2*i)%n+1<<endl;
}
int main()
{

 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int P = 998244353;
const int N = 5050;
int n,m;
LL pw[N][N],pre[N][N];
int main(){
//	cerr << sizeof(pw)*2.0/1024/1024<<'\n';
	register int i,j;
	LL ans = 0;
	read(n),read(m);
	for (i = 1; i <= 5000; ++i)
	for (pw[i][0] = j = 1; j <= 5000; ++j) pw[i][j] = pw[i][j-1] * i % P;
	pw[0][0] = 1;
	for (i = 1; i < n; ++i)
	for (j = 0; j <= m; ++j){
		if (j) pre[i][j] = (pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1] + pw[j][i-1] * pw[m][n-i-1]) % P;
		else pre[i][j] = (pre[i-1][j] + pw[j][i-1] * pw[m][n-i-1]) % P;
	}

	LL s1,s2,s3 = 0;
	for (i = 1; i <= n; ++i){
		s1 = pw[m-1][i-1] * pw[m][n-i] % P;
		s2 = (pw[m][n] - s1 + P) % P;
		ans = (ans + s1 + s2) % P;
		s3 = pre[i-1][m-1];
		ans = (ans - s3 + P) % P;
	}
	ans = (ans % P + P) % P;
	cout << ans << '\n';
	return 0;
}

#include<stdio.h>

int n,m,a[1002],b[1002],dp[1002][1002];

inline int min(int x,int y){return x<y?x:y; }
inline int min(int x,int y,int z){ return min(x,min(y,z)); }

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),dp[i][0]=i;
	for(int i=1;i<=m;i++)
		scanf("%d",&b[i]),dp[0][i]=i;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+(a[i]!=b[j]));
	printf("%d",dp[n][m]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 3000005;
int main()
{
  int n;
  ll k;
  ll dp[4][N] = {0};
  cin >> n >> k;
  dp[0][0] = 1;
  for (int i = 0; i < 3; i ++ )
  {
    for (int j = 0; j <= i * n; j ++ )
    {
      //只在1~n之间加上
      dp[i + 1][j + 1] += dp[i][j];
      dp[i + 1][j + n + 1] -= dp[i][j];
    }
    for (int j = 1; j <= (i + 1) * n; j ++ )
      dp[i + 1][j] += dp[i + 1][j - 1];
  }
  int x;
  for (int i = 3; i <= 3 * n; i ++ )
    if (k <= dp[3][i]) {x = i; break;}
    else k -= dp[3][i];
  for (int i = 1; i <= n; i ++ )
  {
    //现在i是确定的，那么j和k就只会在l到r这个区间变换
    //而且，变化的个数也就是r-1+1个
    int l = max(1, x - n - i);
    int r = min(n, x - i - 1);
    if (l > r) continue;
    if (k > r - l + 1) {k -= r - l + 1; continue;}
    int y = l + k - 1;
    int z = x - i - y;
    cout << i << " " << y << " " << z << endl;
    return 0;
  }
}

#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define clr(x) memset(x, 0, sizeof(x))
#define all(a) a.begin(),a.end()
#define s second
#define f first
#define forn(i, a,b) for(int i = int(a); i < int(b); ++i)
#define forn_r(i, b, a) for(int i = int(b); i > int(a); i--)
#define trav(a,x) for (auto& a : x)
#define printArray(array, length) for(int i = 0; i < length; i++) cout<< array[i] << (i == length - 1 ? '\n' : ' ');
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define debug(x) cout << #x << "=" << x << endl
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
template<class T> bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

using namespace std;
typedef long long ll;
const int INF = INT_MAX;
const ll LNF  = LONG_LONG_MAX;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

bool test(){
	int a[4];
		cin>>a[0]>>a[1]>>a[2]>>a[3];
		int k=1<<4;
		//debug(k);
		forn(i,0,k){
			int sum1=0,sum2=0;
			forn(j,0,4){
				if(1<<j&i){
					sum1+=a[j];
				}
				else{
					sum2+=a[j];
				}
			}
			//debug2(sum1,sum2);
			if(sum1==sum2){
				return 1;
			}
		}
		return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t =1;
   // cin>>t;
    while(t--){
    	if(test()){
    		print("Yes");
    	}
    	else{
    		print("No");
    	}

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
// #pragma GCC target("sse2,sse3,ssse3,sse4,popcnt,avx,avx2,tune=native")
// #pragma GCC optimaze("O3")
// #pragma GCC optimaze("unroll-loops")

#define int long long
typedef long long ll;

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

int mod = 1e9 + 7;

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

int pw(int a, int k) {
    if (k == 0) return 1;
    if (k % 2) return mul(pw(a, k - 1), a);
    return pw(mul(a, a), k / 2);
}

int sm(int a, int b) {
    if (a + b < mod) return a + b;
    return a + b - mod;
}
int df(int a, int b) {
    if (a >= b) return a - b;
    return a + mod - b;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; cin >> t;
    int n; cin >> n;

    int A = (n * 100 + t - 1) / t;
    cout << ((A * (100 + t)) / 100) - 1 << endl;

    return 0;
}

#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <numeric>
#include <iterator>
#include <climits>

using namespace std;

template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}

int main()
{
  int n;
  cin >> n;
  long long res = 0;

  while (n > 0)
  {
    long long a, b;
    cin >> a >> b;
    long long sum = (b - a + 1) * (a + b) / 2;//(100000-1+1)*(1+1000000)/2
    res += sum;
    // cout << "n: " << n << " sum: " << sum << endl;
    n--;
  }
  cout << res;
  return 0;
}


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

////////////////////////////////////////////////////////////////////////////<editor-fold desc="macros">
//#define mod 9999991
long mod=9999991;
#define endl "\n"
#define long long long
#define all(v) (v).begin(),(v).end()
#define makeset(v) (v).resize(unique((v).begin(),(v).end())-(v).begin())
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define filein freopen("input.txt", "r", stdin);
#define fileout freopen("output.txt", "w", stdout);
#define getline(x) getline(cin,x)
#define makelower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
bool sortby(pair<int,int> a,pair<int,int> b){
    double x=(double )a.first/a.second;
    double y=(double )b.first/b.second;
    return x<y;}
long Pow(long x, long y) {
    if(y == 0)return 1;
    long res=Pow(x,y/2)%mod;
    res=(res*res)%mod;
    if(y&1)res=(res*x)%mod;
    return res;
}
#define printcase(x)  cout<<"Case "<<in++<<": "<<x<<endl
#define memset(a,b) memset(a,b,sizeof(a))
#define print1d(ary) cout<<"[";for(auto x:(ary)){cout<<x<<",";}cout<<"]"<<endl;
#define print2d(x) for(int m = 0; m <sizeof(x)/sizeof(x[0]) ; ++m){for(int l = 0; l <sizeof(x[0])/sizeof(x[0][0]) ; ++l){cout<<x[m][l]<<" ";}cout<<endl;}
#define pi acos(-1)
#define esp 1e-9
////////////////////////////////////////////////////////////////////////////</editor-fold>
long t,n,m,f=0,ans,a,b;
long tmp;

int main() {
///<editor-fold desc="ios">
    IOS
#ifdef _AD_
    filein //fileout
#endif
///</editor-fold>
    int in=1,o;
    cin>>n>>m;
    vector<vector<int>> idx(n+1,{0});
    for(int i = 1; i <=n ; ++i){
        cin>>tmp;
        idx[tmp].push_back(i);
    }
    for(int i = 0; i <=n ; ++i){
        idx[i].push_back(n+1);
    }
    for(int i = 0; i <= n; ++i){
        for(int j = 1; j <idx[i].size() ; ++j){
            if(idx[i][j]-idx[i][j-1]-1>=m){
                cout<<i<<endl;
                return 0;
            }
        }
    }

}

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/rational.hpp>

// using bigint = boost::multiprecision::cpp_int;
// using fraction = boost::rational<bigint>;
using namespace std;

#define pb push_back
#define eb emplace_back
#define unused [[maybe_unused]]
#define tempT template<class T>
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl
#define ans_exit(x) { cout << x << endl; exit(0); }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (ll i = (ll)(n); i < (ll)(m); i++)

using ll   unused = long long;
using ld   unused = long double;
using vl   unused = vector<ll>;
using vvl  unused = vector<vl>;
using vvvl unused = vector<vvl>;
using lp   unused = pair<ll, ll>;
using lmap unused = map<int, int>;

unused constexpr ll MOD = 998244353;
unused constexpr ll INF = 1 << 30;
unused constexpr ll LINF = 1LL << 62;
unused constexpr int DX[8] = {0, 1, 0,-1, 1, 1,-1,-1};
unused constexpr int DY[8] = {1, 0,-1, 0, 1,-1, 1,-1};
unused inline bool bit(ll b, ll i) { return b & (1LL << i); }
unused inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
unused inline ll mod(ll a, ll m = MOD) { return (a % m + m) % m; }
unused inline ll floordiv(ll a, ll b) { return a / b - (a < 0 && a % b); }
unused inline ll ceildiv(ll a, ll b) { return floordiv(a + b - 1, b); }
tempT unused inline bool in_range(T a, T x, T b) { return a <= x && x < b; }
unused inline bool in_range(ll x, ll b) { return in_range(0LL, x, b); }
tempT unused bool chmin(T &a, T b) { if(a > b) {a = b; return 1;} return 0; }
tempT unused bool chmax(T &a, T b) { if(a < b) {a = b; return 1;} return 0; }

int main() {
    ll n, m;
    cin >> n >> m;
    if(m < 0) ans_exit(-1);

    ll cnt = 0;
    vector<lp> ans;

    if(m != 0) {
        ans.pb({++cnt, -1});
        rep(i, m+1) {
            ans.pb({++cnt, 0});
            ans.back().second = ++cnt;
        }
        ans[0].second = ++cnt;
    }

    if(n < ans.size()) ans_exit(-1);

    while(ans.size() < n) {
        ans.pb({++cnt, 0});
        ans.back().second = ++cnt;
    }

    rep(i, n) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
#define LL_MAX LLONG_MAX

#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define lb(v,x) lower_bound(v.begin(),v.end(),x)

#define mod 1000000007
int exp(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x){return exp(x,mod-2);}
int add(int a,int b){a%=mod,b%=mod;a=((a+b)%mod+mod)%mod;return a;}
int sub(int a,int b){a%=mod,b%=mod;a=((a-b)%mod+mod)%mod;return a;}
int mul(int a,int b){a%=mod,b%=mod;a=((a*b)%mod+mod)%mod;return a;}
int fac[1000009];int ncr_mod(int n,int k){int ans=fac[n];ans*=modinv(fac[k]);ans%=mod;ans*=modinv(fac[n-k]);ans%=mod;return ans;}

vector<int>v_prime;void Sieve(int n){bool prime[n + 1];memset(prime,true,sizeof(prime));for (int p = 2; p*p <=n;p++){if(prime[p] ==true) {for(int i = p*p; i<= n; i += p)prime[i]=false;}}for(int p = 2;p<= n;p++)if (prime[p])v_prime.pb(p);}
vector<int>v_factor;void factor(int n){ for (int i=1; i<=sqrt(n); i++) {if (n%i == 0) {if (n/i == i) v_factor.pb(i);else { v_factor.pb(i),v_factor.pb(n/i);};} } sort(all(v_factor)); }

int power(int x, int y){int temp;if( y == 0)return 1; temp = power(x, y / 2);if (y % 2 == 0) return temp * temp;else return x * temp * temp;}
int gcd(int a, int b){if (b == 0)return a; return gcd(b, a % b);}
int log2n( int n){ return (n > 1) ? 1 + log2n(n / 2) : 0;}

void out(vector<int>&a){for(int i=0;i<a.size();i++) cout<<a[i]<<" ";  cout<<endl;}
void sout(set<int>s){for(auto it=s.begin();it!=s.end();++it)cout<<*it<<" ";  cout<<endl;}
void mout(map<int,int>mm){for(auto it=mm.begin();it!=mm.end();++it) cout<<it->fi<<" "<<it->se<<endl;}

#define ms(a,x)  memset(a, x, sizeof(a));

#define decimal(n,k) cout<<fixed<<setprecision(k)<<n<<endl
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl

// debug functions
#define deb1(x) cout << #x <<" " << x <<endl
#define deb2(x,y) cout << #x <<" "<< x << " " << #y <<" " << y <<endl
#define deb3(x, y, z) cout << #x <<" " << x << " "  << #y <<" " << y << " "  << #z << " " << z<<endl

// In binary search always report l-1

signed main()
{

      run;

/*
open for mod factorial

     fac[0]=1;
      for(int i=1;i<1000009;i++)
      {
          fac[i]=mul(fac[i-1],i);

      }
*/

/*
  for sieve open this and use v_prime

          int pp=pow(10,6)+100000;
               Sieve(pp);
*/

 // factor(n)  &&   USE v_factor For calculating factors && don't forget v_factor.clear();

int  t=1;

while(t--)
{
             //  map<int,int>mm; // it->second-->frequency

             int  n,i,x,y,ok=0,sum=0,ans=0,j,k,cnt=0,m,c=0,q,z;
             int  h[100009]={0};

                  cin>>x>>y>>z;

                if(z%2==1)
                  z=1;
                  else
                  z=2;

                  x=pow(x,z);
                  y=pow(y,z);

                  if(x>y)
                  cout<<">";
                else  if(y>x)
                  cout<<"<";
                  else
                  cout<<"=";

}
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <queue>

#define lc u << 1
#define rc u << 1 | 1

using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
LL n,s,k;

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

void solve()
{
    scanf("%lld%lld%lld",&n,&s,&k);
    LL x,y;
    LL d = exgcd(k,n,x,y);
    n /= d;
    if(s % d) puts("-1");
    else
    {
        printf("%lld\n",(-x * (s / d) % n + n) % n);
    }
}

int main()
{
    #ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #else

    #endif // LOCAL
    int T = 1;
    scanf("%d",&T);
    while(T --)
    {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int T;
long long L, R;
long long solve(int L, int R) {
    if (R < 2*L) return 0;
    long long c = R - 2*L + 1;
    return c * (c+1) / 2;
}
int main() {
    scanf("%d", &T);
    while (T --) {
        scanf("%lld%lld", &L, &R);
        printf("%lld\n", solve(L, R));
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

const ll MAXN=1e2+5,MAXlg=__lg(MAXN)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;
const int MAXM = 1e4+5;

vector<pii> edge;
int c[MAXN], ans[MAXM]; // 0:-> 1:<-
vector<pii> e[MAXN];
bool vis[MAXN];
void print(int x){
    if (x) cout << "<-" << endl;
    else cout << "->" << endl;
}
void dfs(int x){
    vis[x] = true;
    for (auto i:e[x]) {
        pii cur = edge[i.X];
        int to;
        if (i.Y == 0) to = cur.Y;
        else to = cur.X;
        ans[i.X] = i.Y;
        if (vis[to]) continue;
        dfs(to);
    }
}
signed main(){
    IOS();
    int n,m;
    cin >> n >> m;
    for (int i=0;i<m;++i) {
        int u,v;
        cin >> u >> v;
        u--, v--;
        edge.eb(u,v);
        ans[i] = -1;
    }
    for (int i=0;i<n;++i) cin >> c[i];
    for (int i=0;i<m;++i) {
        int u = edge[i].X, v = edge[i].Y;
        if (c[u] == c[v]) {
            e[u].eb(i,0);
            e[v].eb(i,1);
            continue;
        }
        if (c[u] > c[v]) ans[i] = 0;
        else ans[i] = 1;
    }
    for (int i=0;i<n;++i) {
        if (vis[i]) continue;
        dfs(i);
    }
    for (int i=0;i<m;++i) print(ans[i]);
}

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
template<typename T>void ckmn(T&a,T b){a=min(a,b);}
template<typename T>void ckmx(T&a,T b){a=max(a,b);}
void rd(int&x){scanf("%i",&x);}
void rd(ll&x){scanf("%lld",&x);}
void rd(char*x){scanf("%s",x);}
void rd(ldb&x){scanf("%lf",&x);}
void rd(string&x){scanf("%s",&x);}
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&i:x)rd(i);}
template<typename T,typename...A>void rd(T&x,A&...args){rd(x);rd(args...);}
template<typename T>void rd(){T x;rd(x);return x;}
int ri(){int x;rd(x);return x;}
template<typename T>vector<T> rv(int n){vector<T> x(n);rd(x);return x;}
template<typename T>void ra(T a[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]);}
template<typename T1,typename T2>void ra(T1 a[],T2 b[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]),rd(b[st+i]);}
template<typename T1,typename T2,typename T3>void ra(T1 a[],T2 b[],T3 c[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]),rd(b[st+i]),rd(c[st+i]);}
void re(vector<int> E[],int m,bool dir=0){for(int i=0,u,v;i<m;++i){rd(u,v);E[u].pb(v);if(!dir)E[v].pb(u);}}
template<typename T>void re(vector<pair<int,T>> E[],int m,bool dir=0){for(int i=0,u,v;i<m;++i){T w;rd(u,v,w);E[u].pb({v,w});if(!dir)E[v].pb({u,w});}}

const int mod=998244353;
int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
void ckadd(int&a,int b){a=add(a,b);}
int sub(int a,int b){a-=b;return a<0?a+mod:a;}
void cksub(int&a,int b){a=sub(a,b);}
int mul(int a,int b){return (ll)a*b%mod;}
void ckmul(int&a,int b){a=mul(a,b);}
int powmod(int x,int k){int ans=1;for(;k;k>>=1,ckmul(x,x))if(k&1)ckmul(ans,x);return ans;}
int inv(int x){return powmod(x,mod-2);}

const int N=1000050;
int F[N],I[N];
int binom(int n, int k){ return mul(F[n],mul(I[k],I[n-k]));}
void calc()
{
	F[0]=1;
	for(int i=1;i<N;i++) F[i]=mul(F[i-1],i);
	I[N-1]=inv(F[N-1]);
	for(int i=N-2;~i;i--) I[i]=mul(I[i+1],i+1);
}

const int M=5050;
const int L=14;
int dp[L][M];
int main(){
	calc();
	int n,m;
	rd(n,m);
	dp[0][0]=1;
	for(int i=1;i<L;i++){
		for(int j=0;j<=m;j++){
			dp[i][j]=0;
			for(int take=0;(take<<i)<=j&&take*2<=n;take++){
				ckadd(dp[i][j],mul(dp[i-1][j-(take<<i)],binom(n,take*2)));
			}
		}
	}
	printf("%i\n",dp[L-1][m]);
	return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    int main(){
      int N, M;
      cin >> N >> M;
      vector<vector<pair<int, int>>> E(N);
      for (int i = 0; i < M; i++){
        int A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        E[A].push_back(make_pair(C, B));
      }
      for (int i = 0; i < N; i++){
        vector<int> d(N, -1);
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
        pq.push(make_pair(0, i));
        while (!pq.empty()){
          int dd = pq.top().first;
          int v = pq.top().second;
          pq.pop();
          if (d[v] == -1){
            if (dd > 0){
              d[v] = dd;
            }
            for (auto P : E[v]){
              int w = P.second;
              if (d[w] == -1){
                pq.push(make_pair(dd + P.first, w));
              }
            }
          }
        }
        cout << d[i] << endl;
      }
    }

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
typedef int64_t ll;
#define PA pair<ll,ll>
#define TU tuple<ll,ll,ll>
#define vi vector<ll>
#define vii vector<vector<ll> >
#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define rep2(i,m,n) for(ll (i)=(m); (i)<(ll)(n); (i)++)
const ll INF = 1ll<<30;
const ll INF2 = 1ll<<32;

ll n,m;
vector<vector<PA>> graph;
vector<vector<PA>> graph_r;
vi self;
vi dist;
vi dist_r;

void dijkstra(vector<vector<PA>> &graph, ll sta, vi &dist) {
  priority_queue<PA,vector<PA>,greater<PA>> pq;
  pq.push(MP(0,sta));
  dist.at(sta) = 0;
  while(!pq.empty()) {
    PA state = pq.top();
    pq.pop();
    if(dist.at(state.second) < state.first) continue;
    for(auto nv: graph.at(state.second)) {
      if(dist.at(nv.first) > dist.at(state.second) + nv.second) {
        dist.at(nv.first) = dist.at(state.second) + nv.second;
        pq.push(MP(dist.at(state.second) + nv.second,nv.first));
      }
    }
  }

}

int main() {
  cin >>n>>m;
  graph.assign(n,vector<PA>(0));
  graph_r.assign(n,vector<PA>(0));

  self.assign(n,INF);
  ll a,b,c;
  rep(i,m) {
    cin >>a>>b>>c;
    if(a==b) self.at(a-1) = min(self.at(a-1),c);
    else {
      graph.at(a-1).push_back(MP(b-1,c));
      graph_r.at(b-1).push_back(MP(a-1,c));
    }
  }

  rep(sta,n) {
    dist.assign(n,INF);
    dist_r.assign(n,INF);
    dijkstra(graph, sta, dist);
    dijkstra(graph_r, sta, dist_r);
    vi dist_all(n);
    rep(i,n) dist_all.at(i) = dist.at(i) + dist_r.at(i);
    ll mini = INF2;
    rep(i,n) {
      if(i!= sta) mini = min(mini,dist_all.at(i));
    }
    mini = min(self.at(sta),mini);
    if(mini<INF) cout << mini << endl;
    else cout << -1 << endl;

  }

}


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

const int N = 1e5 + 7;
int n, m, fa[N];

int main() {
    int x;
    cin >> x;
    for (int i = x + 1; ; i++) {
        if (i % 100 == 0) {
            cout << i - x << endl;
            return 0;
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    string s=to_string(n);
    int x=s.size();
    int ans=0;
    if(x<=2) ans=n/11;
    else if(x==3) ans=9;
    else if(x<=4) ans=n/101;
    else if(x==5) ans=99;
    else if(x<=6) ans=n/1001;
    else if(x==7) ans=999;
    else if(x<=8) ans=n/10001;
    else if(x==9) ans=9999;
    else if(x<=10) ans=n/100001;
    else if(x==11) ans=99999;
    else if(x<=12) ans=n/1000001;
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
vector<ll>vec;
int main()
{
    string s,s1="";
    cin>>s;
    if(s.size()==1)
    {
        cout<<0<<endl;
        exit(0);
    }
    ll n=s.size(),ans=0;
    for(ll i=0; i<=n/2; i++)
    {
        s1+=s[i];
    }
    ll val=stoll(s1),tar=stoll(s);
    for(ll i=1; i<=val; i++)
    {
        string temp="";
        temp=to_string(i);
        temp+=temp;
        ll now=stoll(temp);
        if(now<=tar)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

// DEBUG
#ifdef _DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif
// iter
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i <= (int)(b); i++)
#define FORD(i, a, b) for (int i = a; i >= (int)(b); i--)
#define FORA(i, I) for (const auto& i : I)
// vec
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ((int)(x.size()))
// 定数
// 2.147483647×10^{9}:32bit整数のinf
#define INF32 2147483647
// 9.223372036854775807×10^{18}:64bit整数のinf
#define INF64 9223372036854775807
// 問題による
#define MOD 1000000007

int main() {
  // 小数の桁数の出力指定
  // cout << fixed << setprecision(10);
  // 入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll N;
  cin >> N;

  // N=3桁のとき 2桁のは全部 9こ
  // 11,22,33,..,99
  // 1010,1111,1212,...9999
  // N=5桁のとき 2桁4桁
  // N=6桁のとき 2桁4桁と6桁の途中まで
  // 100100,101101,...,555555,...9999999

  int ans = 0;

  string nst = to_string(N);
  int len = nst.length();
  for (int i = 1; i <= len / 2; i++) {
    ll keta = pow(10, i);
    // debug(i); debug(keta);
    for (int j = keta / 10; j < keta; j++) {
      ll num = j * keta + j;
      // debug(num);
      if (num <= N) {
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ar array

/*

*/

const int N = (1<<20);
int n, m;
int adj[20][20], dp[N];
bool ok[N];

int INF = 1e9;

void solve(){
    cin>>n>>m;
    for(int i = 0; i < m; i++){
        int a, b; cin>>a>>b; a--, b--;
        adj[a][b] = 1;
    }
    for(int mask = 0; mask < 1<<n; mask++){
        ok[mask] = true;
        for(int i = 0; i < n; i++){
            if(mask >> i & 1){
                for(int j = i+1; j < n; j++){
                    if(mask >> j & 1) ok[mask] &= adj[i][j];
                }
            }
        }
    }
    for(int mask = 0; mask < 1<<n; mask++){
        dp[mask] =  ok[mask]? 1 : INF;
        for(int sub = (mask-1)&mask; sub; sub = (sub-1)&mask){
            dp[mask] = min(dp[mask], dp[sub] + dp[ mask^sub ]);
        }
    }
    cout << dp[ (1<<n)-1 ] << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#ifdef _DEBUG
#define line cout << "-----------------------------\n"
#define stop system("pause")
#define debug(x) print(x)
#endif
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }
template<class T>inline T sum(const vector<T>& a, int l, int r) { return a[r] - (l == 0 ? 0 : a[l - 1]); }
template<class T>inline void END(T s) { print(s); exit(0); }
void END() { exit(0); }

int main() {
    init();

    int n, m; cin >> n >> m;
    auto e = vec<bool>(n, n);
    FOR(i, 0, m) {
        int a, b; cin >> a >> b;
        --a, --b;
        e[a][b] = e[b][a] = true;
    }

    vector<bool> ok(1 << n, true);
    FOR(bit, 0, 1 << n)FOR(i, 0, n)if (bit & (1 << i))FOR(j, i + 1, n) {
        if (bit & (1 << j))ok[bit] = ok[bit] && e[i][j];
    }

    auto dp = defvec<int>(INF, 1 << n);
    FOR(bit, 0, 1 << n) {
        if (ok[bit])dp[bit] = 1;
        for (int sub = bit; sub >= 0; --sub) {
            sub &= bit;
            int bus = bit ^ sub;
            if (ok[sub] && ok[bus])chmin(dp[bit], 2);
            chmin(dp[bit], dp[sub] + dp[bus]);
        }
    }
    print(dp[(1 << n) - 1]);

    return 0;
}


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

int main() {
    long long n, count=0;
    cin >> n;
    map<long long, int> m;
    for(int i=2; i<=sqrt(n); i++){
        long long a;
        a=i;
        a*=i;
        while(a<=n){
            if(!(m.count(a))){
                count++;
                m[a]=0;
            }
            a*=i;
        }
    }
    cout << n-count;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{	int t=1;
	//cin>>t;
	while(t--)
	{
	string s,p;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!='.')
		{
			p+=s[i];
		}
		else
		break;
	}

		cout<<p<<"\n";
	}
	return 0;
}


/*  -*- coding: utf-8 -*-
 *
 * f.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef map<int,int> mii;

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];
  UFT() {}

  void init(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (r0 == r1) return r0;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

mii cvs[MAX_N];
UFT uft;

/* subroutines */

/* main */

int main() {
  int n, qn;
  scanf("%d%d", &n, &qn);

  for (int i = 0; i < n; i++) {
    int ci;
    scanf("%d", &ci);
    ci--;
    cvs[i][ci] = 1;
  }

  uft.init(n);

  while (qn--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    x--, y--;

    if (op == 1) {
      if (! uft.same(x, y)) {
	int rx = uft.root(x), ry = uft.root(y);
	int u = uft.merge(rx, ry), v = (u == rx) ? ry : rx;

	mii &cvu = cvs[u], &cvv = cvs[v];
	if (cvu.size() < cvv.size()) swap(cvu, cvv);

	for (mii::iterator mit = cvv.begin(); mit != cvv.end(); mit++)
	  cvu[mit->first] += mit->second;
      }
    }
    else {
      mii &cvr = cvs[uft.root(x)];

      mii::iterator mit = cvr.find(y);
      if (mit == cvr.end() || mit->first != y) puts("0");
      else printf("%d\n", mit->second);
    }
  }
  return 0;
}

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
//using namespace __gnu_pbds;

//template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());//uniform_int_distribution<int> (l, r)

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 1e5 + 123;
const int M = 1e6 + 123;
const double pi = 3.14159265359;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

struct edge{
    int u, v, c, d, opt;
}e[N];

vector<int> g[N];

ll dis[N];

void solve(){
    int n, m;
    cin >> n >> m;
    for (int i = 1, u, v, c, d; i <= m; i++){
        cin >> u >> v >> c >> d;
        g[u].pb(i);
        g[v].pb(i);
        int l = 0;
        if (d){
            l = sqrt(d)-1;
            while (l+(d/(l+1)) > l+1+(d/(l+2))){
                l++;
            }
        }
        e[i] = {u, v, c, d, l};

        //cout << l << ndl;
    }
    memset(dis, 0x3f, sizeof dis);
    dis[1] = 0;
    priority_queue<pli, vector<pli>, greater<pli>> q;
    q.push({0, 1});

    while (!q.empty()){
        ll d;
        int v;
        tie(d, v) = q.top();
        q.pop();
        if (dis[v] != d) continue;
        for (int i : g[v]){

            ll x = max(e[i].opt+0ll, d);

            int u = e[i].v+e[i].u - v;

            if (dis[u] > x + e[i].c + e[i].d/(x+1)){
                dis[u] = x + e[i].c + e[i].d/(x+1);
                q.push({dis[u], u});
            }
        }
    }
    if (dis[n] > INF){
        cout << -1;
    }
    else{
        cout << dis[n];
    }
}

int main(){
    #ifdef me
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "Case #" << i << ": ";
        solve();
    }
    #ifdef KAZAKH
      //  cout << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 100000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void pv(vector<int> v) {
    cout << v[0];
    for (int i = 1; i < sz(v); i++) {
        cout << " " << v[i];
    }
    cout << endl;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> v(n);
    vector<ll> sum(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(all(v));
    sum[0] = v[0];
    for (int i = 1; i < n; i++) {
        sum[i] = v[i] + sum[i - 1];
    }
    ll res = 0;
    for (int i = 1; i < n; i++) {
        res += ((v[i] * i) - sum[i - 1]);
    }

    cout << res << "\n";

    return 0;
}

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

ll funcy(ll a[], ll n)
{

ll sum = 0;
ll i;
for(i=0;i<n;i++)
{
sum += (a[i]*(i) - a[i]*(n-i-1));
}
return sum;
}

int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll i,n;cin>>n;ll v[n+1];
for(i=0;i<n;i++)cin>>v[i];
sort(&v[0],&v[n]);
cout<<funcy(v,n);
return 0;
}


/*
    author : Aryan Agarwal, IIT KGP
    created : 20-February-2021 17:32:16 IST
*/

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

const int mxn = 1e5;
const long long INF = 2e18;
const int32_t M = 1000000007; /*more than 1e9 */ /*7 + 1e9*/
// const int32_t M = 998244353; /*less than 1e9 */   /*1 + 7*17*(1<<23) */
const long double pie = acos(-1);

#define X first
#define Y second
#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define F(i, a, b) for (int i = a; i <= b; i++)
#define RF(i, a, b) for (int i = a; i >= b; i--)

#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::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...);
}

void solve_LOG()
{
    string s;
    cin>>s;
    s='#'+s;

    F(i,1,sz(s)-1)
    {
        if(i%2)
        {
            if(s[i]<'a' || s[i]>'z')
            {
                cout<<"No";
                return;
            }
        }
        if(i%2==0)
        {
            if(s[i]<'A' || s[i]>'Z')
            {
                cout<<"No";
                return;
            }
        }
    }

    cout<<"Yes";
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
#ifdef ARYAN_SIEVE
    // defualt mxn_sieve = 1e5
    sieve();
#endif
#ifdef ARYAN_SEG_SIEVE
    // default [L,R] = [1,1e5]
    segmented_sieve();
#endif
#ifdef ARYAN_FACT
    // default mxn_fact = 1e5
    fact_init();
#endif
    // cout<<fixed<<setprecision(10);
    int _t=1;
    // cin>>_t;
    for (int i=1;i<=_t;i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve_LOG();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	bool b=true;
	char a[10000];
	cin>>a;
	for(int i=0;i<strlen(a);i++)
	{
		if(i%2==0)
		{
			if(a[i]<97||a[i]>122)
			{
				b=false;
				break;
			}
		}
		else
		{
			if(a[i]<65||a[i]>90)
			{
				b=false;
				break;
			}
		}
	}
	if(b==true)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mod 1000000007
#define mod2 998244353
#define ll long long
#define gi(n) long long n;cin>>n
#define ga(a,n) long long a[n];for(ll i=0;i<n;i++)cin>>a[i]
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define TEST(t) ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define flo(i,a,b) for(ll i=a;i<b;i++)
#define floe(i,a,b) for(ll i=a;i<=b;i++)
#define newline cout<<"\n"
#define gis(s) string s;cin>>s
#define p(a) cout<<a
#define pn(a) cout<<a<<endl
char a[1000][1000];

typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef map<ll,ll> mll;

ll gcd(ll x, ll y)
{
    if(x==0) return y;
    return gcd( y%x ,x);
}

ll powM(ll x, ll y, ll m)
{
    ll ans=1, r=1;
    x=x%m;
    while(r>0 && r<=y)
    {
        if(r & y)
        {
            ans=ans*x;
            ans=ans%m;
        }
        r=r<<1;
        x=x*x;
        x=x%m;
    }
    return ans;
}

ll countbits(ll n)
{
    ll cot=0;
    while(n)
    {
        cot++;
        n >>= 1;
    }
    return cot;
}

ll comb2(ll n)
{
    return n*(n-1)/2;
}
ll sum_of_digits(ll n){
    ll b=0;
    while(n!=0){
        b=b+(n%10);
        n=n/10;
    }
    return b;
}
ll no_of_digits(ll n){
    ll b=0;
    while(n!=0){
        b=b+1;
        n=n/10;
    }
    return b;
}
bool check(int array[], int n)
{
    bool flag = 0;

    for(int i = 0; i < n - 1; i++)
    {
        if(array[i] != array[i + 1])
            flag = 1;
    }

    return flag;
}
long long int factorial(long long int n){
    ll ans=1;
    flo(i,1,n+1){
        ans*=i;
    }
    return ans;
}
bool spure(int i,int j,int h,int m){
 if(a[i][j]=='.'){
    return false;
 }
else{
    if(h==1){
        if(a[i][j]=='*'){
            return true;
        }
        return false;
    }
    else{
        if(j-1>=0 && j+1<m){
        bool pk=spure(i+1,j+1,h-1,m) && spure(i+1,j,h-1,m) && spure(i+1,j-1,h-1,m);
        return pk;
    }
    else{
        return false;
    }
    }
}

}
int main(){
    fastio;
    gi(a);
    gi(b);
    gi(c);
    gi(d);
    cout<<min(a,min(b,min(c,d)));
return 0;

}

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

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

using ll = long long;
using P = pair<int, int>;
using vvi = vector<vector<int>>;
using vi = vector<int>;

const ll MOD = 1e9 + 7;
const int INF = 1001001001;
const double PI = 3.14159265358979323846;

const int lim = 1e5+5;
int n;
double A[lim];

double func(double x) {
    double res = 0;
    rep(i, n) {
        res += x + A[i] - min(A[i], x*2);
    }
    return res;
}

void solve() {
    cin >> n;
    rep(i, n) cin >> A[i];

    double low = 0;
    double high = 1e10;

    int cnt = 500;
    while (cnt--) {
        double c1 = (low*2 + high) / 3;
        double c2 = (low + high*2) / 3;
        if (func(c1) > func(c2)) low = c1;
        else high = c2;
    }

    double ans = func(low) / n;
    cout << setprecision(20) << fixed << ans << endl;
}

int main() {

    solve();

    return 0;
}


//ΔAGC053B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 444444;
int n,a[N];
priority_queue<int,vector<int>,greater<int> > Q;
int main()
{
	int i,x,y;
	LL s=0;
	scanf("%d",&n);
	for(i=1;i<=n*2;i=i+1)
		scanf("%d",a+i);
	for(i=1;i<=n;i=i+1){
		x=a[n+i],y=a[n-i+1];
		if(x<y)
			swap(x,y);
		Q.push(x);
		if(Q.top()<y){
			Q.pop();
			Q.push(y);
		}
	}
	while(!Q.empty()){
		s+=Q.top();
		Q.pop();
	}
	cout<<s;
	return 0;
}

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

bool check(string S, string pass) {
  vector<bool> b(10, false);

  b.at(pass.at(0) - '0') = true;
  b.at(pass.at(1) - '0') = true;
  b.at(pass.at(2) - '0') = true;
  b.at(pass.at(3) - '0') = true;

  for (int i = 0; i < 10; i++) {
    if (S.at(i) == 'o' && b.at(i) == false)
      return false;
    if (S.at(i) == 'x' && b.at(i) == true)
      return false;
  }

  return true;
}

int main() {
  int ans = 0;
  string S;
  cin >> S;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        for (int l = 0; l < 10; l++) {
          string pass;
          pass += i + '0';
          pass += j + '0';
          pass += k + '0';
          pass += l + '0';
          if (check(S, pass))
            ans++;
        }
      }
    }
  }

  cout << ans << endl;
}


//
// Created by David on 2020/10/03 0003.
//

#include <iostream>
#include <cstring>
#include <map>

using namespace std;

string str;
int n;

struct complex {
    int real, imagine;

    explicit complex(int re = 0, int im = 0) : real(re), imagine(im) {}

    friend complex operator+(complex a, complex b) {
        complex c;
        c.real = a.real + b.real;
        c.imagine = a.imagine + b.imagine;
        return c;
    }

    friend complex operator-(complex a, complex b) {
        complex c;
        c.real = a.real - b.real;
        c.imagine = a.imagine - b.imagine;
        return c;
    }

    friend bool operator==(complex a, int b) {
        return a.imagine == 0 && a.real == b;
    }
};

complex a[5004], s[5004];
int ans;

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

    cin >> n >> str;
    for (int i = 1; i <= n; i++) {
        char ch = str[i - 1];
        if (ch == 'A') a[i] = complex(1, 0);
        if (ch == 'T') a[i] = complex(-1, 0);
        if (ch == 'C') a[i] = complex(0, 1);
        if (ch == 'G') a[i] = complex(0, -1);
        s[i] = s[i - 1] + a[i];
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < i; j++) {
            if (s[i] - s[j] == 0 || s[j] - s[i] == 0) ans++;
        }
    }
    cout << ans;

    return 0;
}

/*
_/_/_/_/    _/_/_/_/_/  _/_/_/
_/      _/      _/    _/      _/
_/      _/      _/    _/      _/
_/      _/      _/    _/      _/
_/      _/      _/    _/  _/  _/
_/      _/  _/  _/    _/    _/_/
_/_/_/_/      _/_/     _/_/_/_/_/

_/_/_/_/    _/    _/  _/      _/
_/      _/   _/  _/   _/_/  _/_/
_/      _/    _/_/    _/ _/_/ _/
_/      _/     _/     _/  _/  _/
_/      _/    _/_/    _/      _/
_/      _/   _/  _/   _/      _/
_/_/_/_/    _/    _/  _/      _/

_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/         _/     _/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/     _/_/_/_/_/ _/_/_/_/_/

_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/         _/     _/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/     _/_/_/_/_/ _/_/_/_/_/
*/
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <iomanip>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v)
    is >> x;
  return is;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int P = 998244353;

int norm(int x) { return x >= P ? (x - P) : x; }

void add(int &x, int y) { if ((x += y) >= P) x -= P; }

void sub(int &x, int y) { if ((x -= y) < 0) x += P; }

void exGcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  exGcd(b, a % b, y, x);
  y -= a / b * x;
}

int inv(int a) {
  int x, y;
  exGcd(a, P, x, y);
  return norm(x + P);
}

const int N = 3010, L = 15;

int A[L], B[L];
int f[L][N];
int ans[N], q[N];

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;

  for (int i = 1; i != L; ++i) {
    B[i] = (1 << i) - 1;
    A[i] = A[i - 1] + B[i];
  }

  f[0][0] = 1;
  for (int i = 0; i <= n; ++i) {
    for (int j = 1; A[j] <= i; ++j)
      sub(f[0][i], f[j][i - A[j]]);
    int j;
    for (j = 1; B[j] <= i; ++j)
      f[j][i] = norm(P - f[j - 1][i] + f[j][i - B[j]]);
    for (; B[j] <= n; ++j)
      f[j][i] = norm(P - f[j - 1][i]);
  }

  {
    int C = 0;
    for (int i = 0; C <= n; ++i, C = A[i]) {
      if (i)
        for (int j = B[i]; j <= n; ++j) add(f[0][j], f[0][j - B[i]]);
      memset(q, 0, sizeof(q));
      if (i & 1)
        for (int j = 0; j <= n - C; ++j) sub(q[j + C], f[0][j]);
      else for (int j = 0; j <= n - C; ++j) add(q[j + C], f[0][j]);
      for (int j = 1; j <= n >> i; ++j)
        add(ans[j], q[n - j * (1 << i)]);
    }
  }

  cout << ans[k] << '\n';

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
      -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    char a, b; cin >> a >> b;
    if(a == 'Y') cout << char(b-32) << endl;
    else cout << b << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>

using namespace std;

long long int  tab[100006];
long long int tab2[100006];

int main(int argc, char** argv)
{
	long long int n,m,a;
	int sum, k,dif;
	sum = 0;
    multiset <pair<long long int,int> > ppl;
    multiset <pair<long long int, int> > :: iterator itr;
	cin>>k>>n>>m;
	for(int i=0; i<k; i++){
		cin>>tab[i];
		long long int np = (tab[i]*m/n);
		tab2[i] = np;
		sum += np;
		pair<long long int , int> x = make_pair(abs(tab[i]*m-(np+1)*n), i);
        ppl.insert(x);
	}
	dif = m-sum;
	for(int i=0; i<dif; i++){
        pair<long long int,int> tmp = *(ppl.begin());
        ppl.erase(ppl.begin());
        tab2[tmp.second]++;
        int nt = tab2[tmp.second];
        pair<long long, int> x = make_pair(abs(tab[tmp.second]*m - (tab2[tmp.second]+1)*n), tmp.second);
        ppl.insert(x);
	}
    for(int i=0; i<k; i++){
        cout<<tab2[i]<<" ";
    }
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 200010;
const int MOD = 1e9 + 7;

int n;
ll a[N], fib[N];

inline ll get (int x) {
  return x < 0 ? 1 : fib[x + 2];
}

int main() {
  fib[1] = 1;
  for (int i = 2; i < N; ++i) {
    fib[i] = fib[i - 1] + fib[i - 2];
    if (fib[i] >= MOD) fib[i] -= MOD;
  }
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
  }
  ll ans = get(n - 1) * a[1] % MOD;
  for (int i = 2; i <= n; ++i) {
    ll cur = get(i - 2) * get(n - i) % MOD * a[i] % MOD;
    ans += cur;
    cur = get(i - 3) * get(n - i - 1) % MOD * (MOD - a[i]) % MOD;
    ans += cur;
  }
  ans %= MOD;
  cout << ans << '\n';
  return 0;
}

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

int main(){
    ll t,n;
    cin >> t >> n;
    ll nos =0; // nowStart
    vector<ll> j;
    ll jOfSet = 0;
    while(1){
        ll jum = (100-nos + t -1) / t; // jump
        ll nes = (nos + t* jum) % 100; // nextStart
        j.push_back(jum);
        jOfSet += jum;
        if(nes == 0) break;
        nos = nes;
    }
    ll fracJ = 0;
    // rep(i, n%t) fracJ += j[i];
    int lcnt =  n % (int)j.size();
    for(int i=0; i < lcnt; i++) {
        fracJ += j[i];
    }
    ll nA = (ll)jOfSet * (n/(int)j.size()) + fracJ;
    ll ans = ((100+t)*nA) / 100 -1;
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int M = 10000;

ll cnt(ll X, ll Y, ll R, ll lim) {
    ll a = 0;
    ll b = M;
    ll res = 0;

    auto fn = [&](int t, int i) {
        return (t - X) * (t - X) + (i - Y) * (i - Y) <= R * R;
    };

    for (ll i = (Y + R) - (Y + R) % M; i >= lim; i -= M) {
        while (fn(b, i)) {
            b += M;
        }
        while (fn(a, i)) {
            a -= M;
        }

        res += (b - a - M) / M;
    }
    return res;
}

int main() {
    ld x, y, r;
    cin >> x >> y >> r;

    ll ans = 0;
    ll X = round(x * M);
    ll Y = round(y * M);
    ll R = round(r * M);
    X %= M;
    Y %= M;

    ans += cnt(X, Y, R, M);
    ans += cnt(X, -Y, R, 0);

    cout << ans << endl;

    return 0;
}

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

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

    int x, y, r, res = 0;

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

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

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

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

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

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


#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)6e18
#define pii pair<ll,ll>
#define mod 998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define rev(v)  if(!v.empty())reverse(v.begin(),v.end())
#define PI 3.141592653589793238
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

ll inv_mod(ll x){
    return pow_mod(x,mod-2);
}

const ll N=(ll)3e5;
ll inv[N];
ll fac[N];

void init(){
  fac[0]=1;

  for(ll i=1;i<N;i++)
  fac[i]=(i*fac[i-1])%mod;

  for(ll i=0;i<N;i++)
  inv[i]=inv_mod(fac[i]);
}

ll ncr(ll n,ll r){
    if(n<r)
    return 0;

    if(n==r||r==0)
    return 1LL;

    ll x=fac[n];
    ll y=inv[n-r];
    ll z=inv[r];

    return ((x*y)%mod*z)%mod;
}
bool test_cases=0;
bool is(string &s){
    for(ll i=0,j=(ll)s.size()-1;i<j;i++,j--){
        if(s[i]!=s[j])
        return false;
    }
    return true;
}
void solve()
{
  ll rad,x,y;
  cin>>rad>>x>>y;

  ll ans=0;

  ll dis_sqr=x*x+y*y;

  // k*r<=sqrt()
  //(k*r)^2<=

  ll k=-1;

  ll l=0;
  ll r=(ll)6e5;

  while(l<=r){
      ll mid=(l+r)/2;

      if(mid*rad>1000000000)
      {
          r=mid-1;
          continue;
      }

      if((mid*rad)*(mid*rad)<=dis_sqr){
          k=mid;
          l=mid+1;
      }
      else
      r=mid-1;
  }

  if(k*rad*k*rad==dis_sqr)
  ans=k;
  else
  {
      ans=k+2;
      if(k>0)
      ans--;

  }

  cout<<ans<<endl;

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

   // init();   //factorial calculations

   //Start from Here.

  ll t;
  t=1;

  if(test_cases)
  cin>>t;

  while(t--)
  solve();
//Good Bye!
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int res=0;
    char c;
    bool zf=0;
    while(((c=getchar())<'0'||c>'9')&&c!= '-');
    if(c=='-')zf=1;
    else res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0';
    if(zf)return -res;
    return res;
}
signed main(){
	double a=read(),b=read(),c=read(),d=read();
	printf("%.10lf\n",(c+a*d/b)/(1+d/b));
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

class BIT {
	int lg;
	std::vector<int> bit;
public:
	BIT(int size) :bit(size + 1, 0) {
		lg = size;
		while (lg & lg - 1)lg &= lg - 1;
	}
	void add(int i, int x) {
		i++;
		while (i < (int)bit.size()) {
			bit[i] ^= x;
			i += i & -i;
		}
	}
	int sum(int a)const {
		a++;
		int res = 0;
		while (0 < a) {
			res ^= bit[a];
			a -= a & -a;
		}
		return res;
	}
};

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

	int n, q;
	cin >> n >> q;
	BIT bit(n);
	rep(i, n) {
		int a;
		cin >> a;
		bit.add(i, a);
	}

	rep(_, q) {
		int t, x, y;
		cin >> t >> x >> y;
		if (t==1) {
			bit.add(x - 1, y);
		}
		else {
			int ans = bit.sum(y - 1);
			if (1 < x)ans ^= bit.sum(x - 2);
			cout << ans << endl;
		}
	}

	return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 3e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define maxn 300001
vector<ll>a(maxn);
ll seg[4*maxn];
void build(ll v,ll l,ll r)
{
	if(l==r)
	{
		seg[v]=a[l];
		return;
	}
	ll mid=(l+r)/2;
	build(2*v,l,mid);
	build(2*v+1,mid+1,r);
	seg[v]=seg[2*v]^seg[2*v+1];
}
void update(ll v,ll l,ll r,ll pos,ll val)
{
	if(l==r)
	{
		seg[v]^=val;
		return;
	}
	ll mid=(l+r)/2;
	if(pos<=mid)
	{
		update(2*v,l,mid,pos,val);
	}
	else
	{
		update(2*v+1,mid+1,r,pos,val);
	}
	seg[v]=seg[2*v]^seg[2*v+1];
}
ll query(ll v,ll l,ll r,ll x,ll y)
{
	if(y<x)
	{
		return 0;
	}
	if(x<=l && r<=y)
	{
		return seg[v];
	}
	ll mid=(l+r)/2,val,val1;
	val=query(2*v,l,mid,x,min(y,mid));
	val1=query(2*v+1,mid+1,r,max(mid+1,x),y);
	return val^val1;
}
int main()
{
	fastIO;
	ll n,q;
	cin>>n>>q;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	build(1,0,n-1);
	ll x,y,z,val;
	while(q--)
	{
		cin>>x>>y>>z;
		if(x==1)
		{
			y--;
			update(1,0,n-1,y,z);
		}
		else
		{
			y--;
			z--;
			val=query(1,0,n-1,y,z);
			cout<<val<<endl;
		}
	}
}


#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> used(2 * N);
  auto out = []() {
    cout << "No" << endl;
    exit(0);
  };
  REP(i, N) {
    int A, B;
    cin >> A >> B;
    if (A != -1 && B != -1 && A >= B) {
      out();
    }
    if (A != -1) {
      if (used[A - 1] != 0) out();
      used[A - 1] = i + 1;
    }
    if (B != -1) {
      if (used[B - 1] != 0) out();
      used[B - 1] = -(i + 1);
    }
  }
  vector<bool> dp(N + 1);
  dp[0] = 1;
  FOR(i, 1, N + 1) {
    REP(j, i)
    if (dp[j]) {
      bool ng = 0;
      int width = i - j;
      REP(k, width) {
        int a = used[2 * j + k], b = used[2 * j + k + width];
        ng |= (a < 0);
        ng |= (b > 0);
        ng |= (a > 0 && b < 0 && b != -a);
      }
      if (!ng) {
        dp[i] = 1;
        break;
      }
    }
  }
  cout << (dp[N] ? "Yes" : "No") << endl;
  return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[220][2];
int p[220][2];

bool solve(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>n;
    memset(t,-1,sizeof(t));
    set<P> s1;
    for(i=0;i<n;i++){
        cin>>a>>b;
        if(a!=-1){
            a--;
            if(t[a][0]!=-1)return false;
            t[a][0]=i,t[a][1]=0;
        }
        if(b!=-1){
            b--;
            if(t[b][0]!=-1)return false;
            t[b][0]=i,t[b][1]=1;
        }
        p[i][0]=a,p[i][1]=b;
        if(a!=-1 && b!=-1 && a>=b)return false;
    }
    vector<char> good(2*n+10,0);
    good[2*n]=1;
    for(i=2*n-1;i>=0;i--){
        for(j=1;i+2*j<=2*n;j++){
            if(!good[i+2*j])continue;
            for(k=0;k<j;k++){
                a=t[i+k][0];
                if(a==-1)a=t[i+j+k][0];
                else if(t[i+j+k][0]!=-1 && a!=t[i+j+k][0])break;
                if(a==-1)continue;
                if(p[a][0]!=-1 && p[a][0]!=i+k)break;
                if(p[a][1]!=-1 && p[a][1]!=i+j+k)break;
            }
            if(k==j){
                good[i]=1;
                break;
            }
        }
    }
    return good[0];
}

int main(){
    if(solve())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


#line 1 "main_b.cpp"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...)                                                    \
  std::cerr << "LINE: " << __LINE__ << "  [" << #__VA_ARGS__ << "]:", \
      debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cout << " :";
  debug_out(t...);
}

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

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

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

template <typename Num>
constexpr Num mypow(Num a, u64 b, Num id = 1) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x *= a;
    a *= a;
    b >>= 1;
  }
  return x;
}

template <typename T>
std::vector<std::pair<std::size_t, T>> enumerate(const std::vector<T>& data) {
  std::vector<std::pair<std::size_t, T>> ret;
  for (std::size_t index = 0; index < data.size(); index++)
    ret.emplace_back(index, data[index]);
  return ret;
}

/* template end */

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

  i64 n;
  std::cin>>n;

  std::string s;
  std::cin>>s;

  std::stack<char> st;

  st.emplace('0');
  st.emplace('0');

  i64 ans=n;

  for(const auto& e:s){
    st.emplace(e);

    char f,o,x;
    x = st.top();st.pop();
    o = st.top();st.pop();
    f = st.top();st.pop();

    if(f == 'f' && o == 'o' && x == 'x'){
      ans-=3;
    }else{
      st.emplace(f);
      st.emplace(o);
      st.emplace(x);
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}

/******************************************************/
/******************************************************/
/**                                                  **/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         REAZ AHAMMED CHOWDHURY - reaziii         **/
/**  Department of Computer Science and Engineering  **/
/*         INSTITUTE OF SCIENCE AND TECHNOLOGY       **/
/**                                                  **/
/******************************************************/
/******************************************************/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pcase(x)     printf("Case %d: ",x++)
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x)     memset(x,-1,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define linfi        LLONG_MAX
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mgraph       map<int,vector<int> >
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define fro(i,x,y)   for(int i=x;i<y;i++)
#define ech(x,a)     for(auto &x : a)
#define ff           first
#define ss           second
#define vi           vector<int>
#define vl           vector<ll>
#define pi           acos(-1.0)

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type,
        less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        Ordered_set;
template<class T> void read(T& x) {cin >> x;}
template<class H, class... T> void read(H& h, T&... t) {read(h); read(t...);}
template<class A> void read(vector<A>& x) {for (auto &a : x) read(a);}
template<class H> void print(vector<H> &x) {ech(a, x) cout << a << " "; cout << endl;}
template<class P> void debug(P h) {
#ifndef ONLINE_JUDGE
    cerr << h << " ";
#endif
}
template<class W, class... V> void debug(W h, V... t) {
#ifndef ONLINE_JUDGE
    debug(h);
    debug(t...);
    cerr << endl;
#endif

}

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;

bool checkbitt(ll num, int pos) {return (num >> pos) & 1;}
ll setbitt(ll num, ll pos) {return (1 << pos) | num;}
ll resetbitt(ll num, int pos) {if (!checkbitt(num, pos)) return num; else return (1 << pos)^num;}
ll bigmod(ll a, ll b, ll mod) {if (b == 0) return 1; if (b == 1) return a; if (b & 1) {return ((a % mod) * (bigmod(a, b - 1, mod) % mod)) % mod;} ll x = bigmod(a, b / 2, mod); return (x * x) % mod;}
ll geti() {ll x; read(x); return x;}
ll cdiv(ll a, ll b) {ll ret = a / b; if (a % b) ret++; return ret;}
const ll mod =  1e9 + 7;
const ll N   =  2e5 + 10;
int dx[4] = { +0, +0, +1, -1};
int dy[4] = { -1, +1, +0, +0};

//................................___Start from here___...............................//
//................................_____________________..............................//

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

    ll a = bigmod(10, n, k * k);
    a /= k;
    a %= k;

    cout << a << endl;

    return 0;
}
int main(int argc, char* argv[]) {

    if (argc <= 1) {
#ifndef ONLINE_JUDGE
        input;
        output;
#endif
#ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
#endif
    }

    int cs = 1, cn = 1;
    // read(cs);
    while (cs--) {
        solve();

    }
}