import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
	static final long MOD = 998244353;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner();
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] schedule = new int[N+1];
        int[][] exams = new int[M][4];
        for (int i = 0; i < M; i++) {
        	exams[i][0] = sc.nextInt();
        	exams[i][1] = sc.nextInt();
        	exams[i][2] = sc.nextInt();
        	exams[i][3] = i+1;
        	schedule[exams[i][1]] = M+1;
        }
        Arrays.sort(exams, new Comparator<int[]>() {
        	  @Override
        	  public int compare(int[] arr1, int[] arr2) {
        	    return arr1[1]-arr2[1];
        	    //Ascending order.
        	  }
        });
        int index = 0;
        for (int day = 1; day <= N; day++) {
        	if (schedule[day] == M+1) {
        		if (exams[index][2] == 0) {
        			//Fully studied for exam
        			index++;
        			if (index == M) {
        				break;
        			}
        			continue;
        		} else {
        			System.out.println(-1);
        			return;
        		}
        	}
        	for (int i = index; i < M; i++) {
        		if (exams[i][0] <= day && exams[i][2] > 0) {
        			//Study for exam i.
        			exams[i][2] -= 1;
        			schedule[day] = exams[i][3];
        			break;
        		}
        	}
        }
        for (int i = 1; i <= N; i++) {
        	System.out.print(schedule[i] + " ");
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

class Node {
	public int n;
	public HashSet<Node> children;

	public Node(int n) {
		this.n = n;
		children = new HashSet<Node>();
	}

	public void addChild(Node node) {
		children.add(node);
	}
}

class BinaryIndexedTree {
	  public long[] arr;

	  public BinaryIndexedTree (int N) {
	    arr = new long[N+1];
	    arr[0] = 0;
	  }

	  //add k to the i-th element.
	  public void add(long k, int i) {
	    int node = i+1;
	    while (node < arr.length) {
	      arr[node] += k;
	      node += node & (-node);
	    }
	  }

	  //sum up the elements from input[s_i] to input[e_i], from [s_i,e_i).
	  public long sum(int s_i, int e_i) {
	    return sum(e_i) - sum(s_i);
	  }

	  public long sum(int i) {
	    long total = 0;
	    int node = i;
	    while (node > 0) {
	      total += arr[node];
	      node -= node & (-node);
	    }
	    return total;
	  }
}

#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e9 + 5;
long long int mod = 998244353;
int main() {
  long long int m, n, i, j;
  cin >> n >> m;
  vector<long long int> days(m + 1, 0), ans(n + 1, 0);
  vector<set<pair<long long int, long long int>>> tasks(n + 1);
  long long int x, y, c;
  for (i = 1; i <= m; i++) {
    cin >> x >> y >> c;
    ans[y] = m + 1;
    days[i] = c;
    for (j = x; j < y; j++) {
      tasks[j].insert({y, i});
    }
  }
  for (i = 1; i <= n; i++) {
    if (ans[i] == 0 && tasks[i].size()) {
      auto it = tasks[i].begin();
      while (it != tasks[i].end() && !(days[it->second])) it++;
      if (it != tasks[i].end()) {
        days[it->second]--;
        ans[i] = it->second;
      }
    }
  }
  for (i = 1; i <= m; i++) {
    if (days[i]) {
      cout << -1;
      return 0;
    }
  }
  for (i = 1; i <= n; i++) cout << ans[i] << " ";
}


import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;
public class C {
	public static void main(String[] args) throws Exception {
		new C().run();
	}
	public void run() throws Exception {
		FastScanner f = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = f.nextInt();
		long[] add = new long[n];
		long[] bounds = new long[n+1];
		for(int i = 0; i < n; i++)
			add[i] = f.nextLong();
		for(int i = 0; i < n; i++)
			bounds[i+1] = f.nextLong() + bounds[i];
		for(int i = 0; i < n; i++)
			add[i] += bounds[i];
		PriorityQueue<Long> pq = new PriorityQueue<Long>();
		for(int i = 0; i < n; i++) {
			pq.add(add[i]);
			long cnt = 0;
			while(!pq.isEmpty() && pq.peek() < bounds[i+1]) {
				cnt += pq.poll()-bounds[i];
			}
			cnt += (bounds[i+1] - bounds[i])*pq.size();
			out.print(cnt);
			out.print(" ");
		}
		out.flush();
	}
	int[] BIT;
	public void add(int n, int i) {
		i++;
		while(i < BIT.length) {
			BIT[i] += n;
			i += i & -i;
		}
	}
	public int query(int i) {
		i++;
		int res = 0;
		while(i > 0) {
			res += BIT[i];
			i -= i & -i;
		}
		return res;
	}
    static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }

    }
}

#include <bits/stdc++.h>
using namespace std;
long long n, x;
multiset<long long> sets;
vector<long long> v(200200);
long long ans = 0;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> v[i];
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> x;
    ans = 0;
    while (!sets.empty() && *sets.begin() - sum <= x) {
      ans += (*sets.begin() - sum);
      sets.erase(sets.begin());
    }
    if (v[i] <= x)
      ans += v[i];
    else
      sets.insert(v[i] + sum);
    sum += x;
    cout << ((long long)sets.size() * x) + ans << " ";
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int rem = n / m;
  if (rem % 2 == 0) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}

YES YES NO YES YES YES NO NO YES YES YES YES YES YES YES YES YES NO NO YES NO YES NO YES NO NO YES YES YES NO NO NO YES YES YES NO NO NO NO YES YES YES YES NO NO YES NO NO NO YES YES YES YES NO YES YES YES YES NO YES YES YES NO YES YES NO YES NO YES YES YES YES NO YES YES NO YES YES YES NO YES YES YES NO

n,k=map(int,input().split())
if (n//k)%2!=0:
	print('YES')
else:
	print('NO')


2 3 5 4
```

These inputs cover a range of values for x, y, z, and k, including some cases where the maximum number of pieces that can be cut is less than the number of cuts available (k), and some cases where the maximum number of pieces that can be cut is greater than or equal to the number of cuts available (k).

#include <bits/stdc++.h>
using namespace std;
long long K, maxarea = 1, input;
vector<long long> side, length;
int main() {
  for (int i = 0; i < 3; i++) {
    cin >> input;
    side.push_back(input);
    side[i]--;
  }
  cin >> K;
  sort(side.begin(), side.end());
  for (int i = 0; i < 3; i++) {
    if (side[i] >= K / (3 - i)) {
      length.push_back(K / (3 - i));
      K -= K / (3 - i);
    } else {
      length.push_back(side[i]);
      K -= side[i];
    }
  }
  for (int i = 0; i < 3; i++) maxarea *= (length[i] + 1);
  cout << maxarea << endl;
  return 0;
}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		Map<Long, HashMap<Long, Long>> map = new HashMap<Long, HashMap<Long, Long>>();
		for(int i=0;i<q;i++){
			int type = sc.nextInt();
			if(type == 1){
				long v = sc.nextLong();
				long u = sc.nextLong();
				long w = sc.nextLong();

				long minCommon = 1;
				Map<Long, Boolean> found = new HashMap<Long, Boolean>();
				long x = v, y = u;
				while(x != 0){
					found.put(x, true);
					x /= 2;
				}
				while(y != 0){
					if(found.get(y) != null){
						minCommon = y;
						break;
					}
					y /= 2;
				}
				long max = Math.max(v, u);
				long min = v + u - max;
				boolean one = false;
				while(max != min){
					long prev = max / 2;
					if(map.get(max) == null && map.get(prev) == null){
						map.put(max, new HashMap<Long, Long>());
						map.put(prev, new HashMap<Long, Long>());
						map.get(prev).put(max, w);
						map.get(max).put(prev, w);
					}
					else if(map.get(max) == null){
						map.put(max, new HashMap<Long, Long>());
						map.get(max).put(prev, w);
						map.get(prev).put(max, w);
					}
					else if(map.get(prev) == null){
						map.put(prev, new HashMap<Long, Long>());
						map.get(prev).put(max, w);
						map.get(max).put(prev, w);
					}
					else{
						if(map.get(max).get(prev) == null){
							map.get(max).put(prev, w);
							map.get(prev).put(max, w);
						}
						else{
							map.get(max).put(prev, map.get(max).get(prev) + w);
							map.get(prev).put(max, map.get(prev).get(max) + w);
						}
					}
					if(prev == minCommon){
						one = true;
						break;
					}
					max = prev;
				}
				if(one){
					while(min != minCommon){
						long prev = min / 2;
						if(map.get(min) == null && map.get(prev) == null){
							map.put(min, new HashMap<Long, Long>());
							map.put(prev, new HashMap<Long, Long>());
							map.get(min).put(prev, w);
							map.get(prev).put(min, w);
						}
						else if(map.get(min) == null){
							map.put(min, new HashMap<Long, Long>());
							map.get(min).put(prev, w);
							map.get(prev).put(min, w);
						}
						else if(map.get(prev) == null){
							map.put(prev, new HashMap<Long, Long>());
							map.get(prev).put(min, w);
							map.get(min).put(prev, w);
						}
						else{
							if(map.get(min).get(prev) == null){
								map.get(min).put(prev, w);
								map.get(prev).put(min, w);
							}
							else{
								map.get(min).put(prev, map.get(min).get(prev) + w);
								map.get(prev).put(min, map.get(prev).get(min) + w);
							}
						}
						min = prev;
					}
				}
			}
			else{
				long v = sc.nextLong();
				long u = sc.nextLong();
				long minCommon = 1;
				Map<Long, Boolean> found = new HashMap<Long, Boolean>();
				long x = v, y = u;
				while(x != 0){
					found.put(x, true);
					x /= 2;
				}
				while(y != 0){
					if(found.get(y) != null){
						minCommon = y;
						break;
					}
					y /= 2;
				}
				long max = Math.max(v, u);
				long min = v + u - max;
				long path = 0;
				boolean one = false;
				while(max != min){
					long prev = max / 2;
					if(map.get(max) != null && map.get(max).get(prev) != null){
						path += map.get(max).get(prev);
					}
					if(prev == minCommon){
						one = true;
						break;
					}
					max = prev;
				}
				if(one){
					while(min != minCommon){
						long prev = min / 2;
						if(map.get(min) != null && map.get(min).get(prev) != null){
							path += map.get(min).get(prev);
						}
						min = prev;
					}
				}
				System.out.println(path);
			}
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, long long> cost;
void update(long long u, long long v, long long w) {
  if (u > v) {
    cost[u] += w;
    update(u / 2, v, w);
  } else if (v > u) {
    cost[v] += w;
    update(u, v / 2, w);
  } else
    return;
}
long long get(long long u, long long v) {
  if (u == v) return 0;
  if (u > v) {
    if (cost.find(u) != cost.end())
      return cost[u] + get(u / 2, v);
    else
      return get(u / 2, v);
  } else {
    if (cost.find(v) != cost.end())
      return cost[v] + get(u, v / 2);
    else
      return get(u, v / 2);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int q;
  scanf("%d", &q);
  while (q--) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      long long u, v, w;
      scanf("%lld %lld %lld", &u, &v, &w);
      update(u, v, w);
    } else {
      long long u, v;
      scanf("%lld %lld", &u, &v);
      printf("%lld\n", get(u, v));
    }
  }
  return 0;
}


n = int(input())
cur = 0
s = ''
for i in range(1, n + 1):
    s += str(i)
    if len(s) >= n:
        print(s[n - 1])
        exit(0)

import java.util.*;

public class tmp {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();

        if(n < 10)
            System.out.println(n);
        else if ( n < 210){
            if(n%2 == 0)
                System.out.println(((n-10)/2 + 10)/10);
            else
                System.out.println(((n-10)/2 + 10)%10);
        }else{
            if(n%3 == 1)
                System.out.println(((n-190)/3 + 100)/100);
            else if(n%3 == 2)
                System.out.println((((n-190)/3 + 100)/10)%10);
            else
                System.out.println(((n-190)/3 + 100)%10);
        }

    }

    private static long fact(long n){
        long out = 1;
        for(int i=1; i<=n; i++)
            out *= i;
        return out;
    }

}


import random

N = int(input())
prob = [float(x)/100 for x in input().strip().split()]
prob_sum = []
cur = 0
for i in range(N):
    cur += prob[i]
    prob_sum.append(cur)

def experiment():
    cur_prob = [1.] * N
    cur_exp = 0
    for i in range(200000):

        bp = [prob[i] * cur_prob[i] / (1-cur_prob[i]+1E-100) for i in range(N)]
        mn = max(bp)
        for j in range(N):
            if bp[j] == mn:
                choice = j
        cur_prob[choice] *= 1-prob[choice]
        tp = 1
        for j in range(N):
            tp *= (1-cur_prob[j])
        tp = 1 - tp
        cur_exp += tp

    return cur_exp + 1

ans = experiment()
print(ans)

#include <bits/stdc++.h>
using namespace std;
const int N = 110;
double p[N];
int n;
struct P {
  long double qk;
  int id;
  inline P(long double qk = 0.0, int id = 0) : qk(qk), id(id) {}
  inline long double calc() const { return (1 - qk * (1 - p[id])) / (1 - qk); }
  inline bool operator<(const P& o) const { return calc() < o.calc(); }
};
int main() {
  while (scanf("%d", &n) == 1) {
    long double q = 1.0;
    priority_queue<P> que;
    for (int i = 0; i < (n); ++i) {
      scanf("%lf", p + i);
      p[i] /= 100;
      q *= p[i];
      que.push(P(1 - p[i], i));
    }
    if (n == 1) {
      puts("1");
      continue;
    }
    long double ans = n + (1 - q);
    for (int i = n + 1; i <= 500000; ++i) {
      P tmp = que.top();
      que.pop();
      q *= tmp.calc();
      ans += 1 - q;
      tmp.qk *= (1 - p[tmp.id]);
      que.push(tmp);
    }
    printf("%.10f\n", (double)ans);
  }
  return 0;
}


#created by Кама Пуля
n,m=map(int,input().split())
L=[[] for i in range(n+1)]
for i in range(m) :
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)
if n not in L[1] :
    l=[1]
    D=[-1 for i in range(n+1)]
    D[1]=0
    while len(l)>=1 :
        t=l[0]
        del(l[0])
        for x in L[t] :
            if D[x]==-1 or D[x]>D[t]+1 :
                l.append(x)
                D[x]=D[t]+1
    print(D[n])
else :
    M=[[] for i in range(n+1)]
    for i in range(1,n+1) :
        L[i].append(0)
        L[i].append(n+1)
        T=sorted(L[i])
        for j in range(len(T)-1) :
            for v in range(T[j]+1,T[j+1]) :
                if v!=i :
                    M[i].append(v)

    l=[1]
    D=[-1 for i in range(n+1)]
    D[1]=0
    while len(l)>=1 :
        t=l[0]
        del(l[0])
        for x in M[t] :
            if D[x]==-1 or D[x]>D[t]+1 :
                l.append(x)
                D[x]=D[t]+1
    print(D[n])

#include <bits/stdc++.h>
using namespace std;
int v[401][401], d[401];
int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    v[x][y] = v[y][x] = 1;
  }
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 2; i <= n; i++)
      if (!d[i] && v[x][i] != v[1][n]) q.push(i), d[i] = d[x] + 1;
  }
  if (d[n])
    cout << d[n] << endl;
  else
    cout << "-1\n";
  return 0;
}


import java.io.*;
import java.util.*;

public class B
{
PrintWriter out;
BufferedReader in;
StringTokenizer ss;

   static void dbg(String s){System.out.println(s);};
   static void deb(long x){System.out.println(x);};
   String next_token() throws IOException
   {while (!ss.hasMoreTokens())ss=new StringTokenizer(in.readLine());
    return ss.nextToken();}

   Double _double() throws IOException
   {return Double.parseDouble (next_token());}

   int _int() throws IOException
   {return Integer.parseInt (next_token());}

   long _long() throws IOException
   {return Long.parseLong (next_token());}

void run()throws IOException
{

in = new BufferedReader(new InputStreamReader(System.in));
out= new PrintWriter(System.out);
String name="";
/*in = new BufferedReader(new FileReader(name+".in"));
out = new PrintWriter(new File(name+".out"));  */
ss = new StringTokenizer(" ");
int n=_int();
int m=_int();
int k=_int();
int C[][]=new int[3][m];
int Y[]=new int[k];
    for(int i=0;i<m;i++)
      for(int j=0;j<3;j++)
              C[j][i]=_int();
    for(int i=0;i<k;i++)Y[i]=_int();
long ans=0;
for(int i=0;i<m;i++)
    for(int j=0;j<k;j++){
         if(C[0][i]<=Y[j]&&C[1][i]>=Y[j])ans=ans+C[2][i]+Y[j]-C[0][i];
    }
    out.println(ans);

out.close();
}
public static void main(String[] args)throws Exception
{new B().run();}
}


//import com.sun.java_cup.internal.runtime.Scanner;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author islam
 */
public class Coins {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String test = "";
//        char[] big = new char[3];

//        char[] chars = {'A', 'B', 'C'};
        char[] small = new char[3];
        int A = 0, B = 0, C = 0;
        for (int i = 0; i < 3; i++) {
            test = in.next();
            if (test.charAt(1) == '<') {
//                big[i] = test.charAt(2);
                small[i] = test.charAt(0);
            } else {
//                big[i] = test.charAt(0);
                small[i] = test.charAt(2);
            }
//            System.out.println(big);
//            System.out.println(small);
            test = "";
        }

        for (int j = 0; j < 3; j++) {
            if (small[j] == 'A') {
                A++;
            } else if (small[j] == 'B') {
                B++;
            } else if (small[j] == 'C') {
                C++;
            }
        }
for(int i=2 ;i >=0; i--){
        if (C == i) {
            test += "C";
        } else if (B==i) {
            test += "B";
        }else if(A == i)
test += "A";
            }
    if(test.length()== 3)
            System.out.println(test);
    else
            System.out.println("Impossible");
    }

}

ACB Impossible ACB Impossible Impossible CBA BAC BCA

#include <bits/stdc++.h>
using namespace std;
int main() {
  string result;
  vector<int> weights_points(3, 0);
  for (int i = 0; i < 3; ++i) {
    cin >> result;
    if (result[1] == '>')
      ++weights_points[result[0] - 'A'];
    else if (result[1] == '<')
      ++weights_points[result[2] - 'A'];
  }
  if (weights_points[0] == weights_points[1] &&
      weights_points[0] == weights_points[2])
    cout << "Impossible\n";
  else {
    string output;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j)
        if (weights_points[j] == i) cout << (char)('A' + j);
    }
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
double szh[100100];
double szz[500];
int numx;
int maxz;
int len;
int main() {
  double ans;
  int f1;
  int f2;
  scanf("%d%d%d", &len, &maxz, &numx);
  szh[numx] = 0;
  for (f1 = numx - 1; f1 >= 0; f1--)
    szh[f1] = szh[f1 + 1] + log(maxz - f1) - log(numx - f1);
  szz[0] = 0;
  for (f1 = 1; f1 <= len; f1++)
    szz[f1] = szz[f1 - 1] + log(len - f1 + 1) - log(f1);
  ans = 0;
  for (f1 = 0; f1 <= len; f1++)
    for (f2 = 0; f2 <= len; f2++)
      if ((f1 + f2) * len - f1 * f2 <= numx)
        ans += exp(szz[f1] + szz[f2] + szh[(f1 + f2) * len - f1 * f2] - szh[0]);
  if (ans > 1e99)
    printf("1e99\n");
  else
    printf("%.12lf\n", ans);
  return 0;
}

import java.io.*;
import java.util.*;
import java.math.*;

public class p458d {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double[] f = new double[100010];
        double[][] arr = new double[310][310];
        f[0] = 1.0;
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        double max = 1e99;
        double ans = 0.0;
        for (int i = 0; i < k; i++) {
            f[i + 1] = f[i] * (k - i) / (m - i);
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                if (j == 0 || j == i) {
                    arr[i][j] = 1;
                } else {
                    arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];
                }
            }
        }
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                ans = Math.min(max, ans + f[i * n + j * n - i * j] * arr[n][i] * arr[n][j]);
            }
        }
        System.out.println(ans);
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main
{
    static PrintWriter pw = new PrintWriter(System.out);

    static void swap(int[] a , int x , int y)
    {
        while(y != x)
        {
            int t = a[y];
            a[y] = a[y-1];
            a[y-1] = t;
            y--;
        }
    }

    public static void main(String[] args)throws Exception
    {
        Reader.init(System.in);

        String s = Reader.next();
        int n = s.length();
        int k = Reader.nextInt();
        int[] a = new int[n+1];

        for(int i = 0 ; i<n ; i++)
            a[i+1] = s.charAt(i) - '0';

        for(int i = 1 ; i<n && k > 0 ; i++)
        {
            int[] pos = new int[10];
            for(int j = i + 1 ; j<= n ; j++)
            {
                int z = a[j];
                if(pos[z] == 0)pos[z] = j;
            }

            for(int j = 9 ; j> a[i] ; j--)
            {
                if(pos[j] == 0)continue;

                if(pos[j] - i <= k)
                {
                    k -= pos[j] - i;
                    swap(a , i , pos[j]);
                }
            }
        }

        StringBuilder res = new StringBuilder();
        for(int i = 1 ; i<=n ; i++)res.append(a[i]);

        pw.print(res);
        pw.close();
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens())
        {
            String line = reader.readLine();
            if(line == null || line.equals(""))throw  new IOException();
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return pars(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = (int)s.size();
  for (int i = 0; i < n; ++i) {
    char mx = s[i];
    int ind = -1;
    for (int j = i + 1; j < n && j - i <= k; ++j) {
      if (!k) {
        break;
      }
      if (mx < s[j]) {
        mx = s[j];
        ind = j;
      }
    }
    if (ind != -1) {
      for (int j = ind; j > i; j--) {
        swap(s[j], s[j - 1]);
        k--;
      }
    }
  }
  cout << s << endl;
  return 0;
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static boolean prefixCompare(char[] a,int i,int j)
	{
		if(i > j-i+1)return true;
		if(i < j-i+1)return false;
		for (int x = 0; x < i; x++)
		{
			if(a[x]<a[x+i])return false;
			if(a[x]>a[x+i])return true;
		}
		return true;
	}
	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		char[] a = sc.nextLine().toCharArray();
		int ans = 0;
		for(int i = a.length-1;i>=0;--i)
		{
			++ans;
			int j = i;
			if(a[i]=='0')
				while(j>0 && a[--j]=='0');
			if(prefixCompare(a, j, i))i=j;
			else break;
		}
		System.out.println(ans);
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String file) throws FileNotFoundException { br = new BufferedReader(new FileReader(file));}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-'){neg = true;start++;}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else{sb.append(x.charAt(i));if(dec)f *= 10;}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		public int[] nexIntArray() throws Throwable
		{
			st = new StringTokenizer(br.readLine());
			int[] a = new int[st.countTokens()];
			for(int i = 0; i < a.length;i++)a[i]=nextInt();
			return a;
		}
		public boolean ready() throws IOException {return br.ready();}
	}
}

#include <bits/stdc++.h>
using namespace std;
char str[100010];
inline bool cmp(int s1, int s2) {
  if (s1 + 1 > s2 - s1)
    return true;
  else if (s1 + 1 < s2 - s1)
    return false;
  int i, j;
  for (i = 0, j = s1 + 1; i <= s1; i++, j++) {
    if (str[i] > str[j])
      return true;
    else if (str[i] < str[j])
      return false;
  }
  return true;
}
int main() {
  char op;
  int k, n;
  int ans = 1;
  scanf("%s", str);
  n = strlen(str);
  for (int i = 0; i < n; i++) {
    if (i + 1 < n && str[i + 1] == '0') continue;
    ans = 1;
    k = i;
    for (int j = k + 1; j < n; j++) {
      if (j + 1 < n && str[j + 1] == '0') continue;
      if (cmp(k, j)) {
        ans++;
        k = j;
      } else
        break;
    }
    if (k == n - 1) break;
  }
  printf("%d\n", ans);
  return 0;
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class MaximalAreaQuadrilateral {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int N = sc.nextInt();

        int[] X = new int[N];
        int[] Y = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
            Y[i] = sc.nextInt();
        }

        int maxArea = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                int maxTop = -1;
                int maxBot = -1;
                int dx1 = X[j] - X[i];
                int dy1 = Y[j] - Y[i];
                for (int k = 0; k < N; k++) {
                    if (i == k || j == k) {
                        continue;
                    }
                    int dx2 = X[k] - X[i];
                    int dy2 = Y[k] - Y[i];
                    int prod = cross(dx1, dy1, dx2, dy2);
                    if (prod > 0) {
                        maxTop = Math.max(maxTop, prod);
                    } else {
                        maxBot = Math.max(maxBot, -prod);
                    }
                    if (maxTop > 0 && maxBot > 0) {
                        maxArea = Math.max(maxArea, maxTop + maxBot);
                    }
                }
            }
        }
        System.out.println(maxArea / 2.0);
    }

    public static int cross(int dx1, int dy1, int dx2, int dy2) {
        return (dx1 * dy2) - (dy1 * dx2);
    }

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }
}

def convex(p):
    p.sort(key = lambda x:(x.real, x.imag))
    p = p[0:1] + sorted(p[1:], key = lambda x:(x-p[0]).imag / abs(x-p[0]))
    j = 1
    for i in range(2, len(p)):
        while j > 1 and ((p[j] - p[j-1]) * (p[i] - p[j]).conjugate()).imag > -(1e-8):
            j -= 1
        else:
            j += 1
            p[j] = p[i]
    return p[:j+1]

def area(p):
    res = 0
    for i in range(2, len(p)):
        res += ((p[i] - p[i-1]) * (p[i-1] - p[0]).conjugate()).imag
    return res * 0.5

def tri(i, j, k):
    return abs(((w[i] - w[j]) * (w[i] - w[k]).conjugate()).imag) * 0.5

n = int(input())
p = [complex(*list(map(int, input().split()))) for i in range(n)]
w = convex(p)
n = len(w)
res = 0

for i in range(n):
    for j in range(i+2, n):
        if i == 0 and j == n-1:
            continue
        l, r = i + 1, j
        while l < r-1:
            m = l + r >> 1
            if tri(i, j, m) > tri(i, j, m-1):
                l = m
            else:
                r = m
        s1 = tri(i, j, l)
        l, r = j - n + 1, i
        while l < r-1:
            m = l + r >> 1
            if tri(i, j, m) > tri(i, j, m-1):
                l = m
            else:
                r = m
        s2 = tri(i, j, l)
        res = max(res, s1 + s2)

if n == 3:
    for i in p:
        if i in w:
            continue
        w.append(i)
        res = max(res, area(w))
        w.pop()

print(res)


import java.io.*;
import java.util.*;
import java.math.*;
public class Bracket {
	public static void main(String[] args) {
		Stack<String> p = new Stack<String>();
		Scanner sc = new Scanner(System.in);
		String entry = sc.nextLine();
		int ans = entry.length();
		for(int i = 0; i < entry.length(); i++) {
			if(entry.charAt(i) == ')')
				if(p.isEmpty()) ans--;
				else p.pop();
			else
				p.push("(");
		}
		while(!p.isEmpty()) {
			ans--;
			p.pop();
		}
		System.out.println(ans);
	}
}

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char s[1000005];
  cin >> s;
  int l = strlen(s), a = 0, b = 0, prob = 0;
  for (int i = 0; i < l; i++) {
    if (s[i] == '(') {
      ++a;
    } else {
      ++b;
      while (a > 0 && b > 0) {
        --a;
        --b;
      }
      if (b != 0) {
        prob += b;
        b = 0;
      }
    }
  }
  cout << l - prob - a << endl;
  return 0;
}


import java.awt.List;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Vector;

public class Main {

	public static void main(String[] args) throws IOException{
		   FastScanner sc = new FastScanner();
		   PrintWriter out = new PrintWriter(System.out);
		   int n =sc.nextInt();
		   int m=sc.nextInt();
		   int A[]=new int [n+2];int B[]=new int[m+2];
		   for(int i=0;i<n+1;i++)A[i]=sc.nextInt();
		   for(int i=0;i<m+1;i++)B[i]=sc.nextInt();
		   if(n>m){
			   if(A[0]*B[0]>=0)
				   out.println("Infinity");
			   else
				   out.print("-Infinity");
			   out.close();
			   return;
		   }
		   if(m>n)
		   {
			   out.println("0/1");
			   out.close();
			   return ;
		   }
		   if(n==m){
			   int sign = A[0]*B[0] >=0?0:-1;
			   String sdd = sign==0?"":"-";
			   out.print(sdd);
			   out.println(Math.abs(A[0]/gcd(A[0],B[0]))+"/"+Math.abs(B[0]/gcd(A[0],B[0])));
		   }
		   out.close();

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

}

class FastScanner {

    BufferedReader br;
    StringTokenizer st;

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public FastScanner(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    String nextToken() {
        while (st == null || !st.hasMoreElements()) {
            try {

                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(nextToken());
    }

    long nextLong() {
        return Long.parseLong(nextToken());
    }

    double nextDouble() {
        return Double.parseDouble(nextToken());
    }

}

#include <bits/stdc++.h>
using namespace std;
int gcd(int n, int m) {
  while (m != 0) {
    int x;
    x = n % m;
    n = m;
    m = x;
  }
  return n;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v1, v2;
  for (int i = 0; i < n + 1; i++) {
    int num;
    cin >> num;
    v1.push_back(num);
  }
  for (int j = 0; j < m + 1; j++) {
    int num;
    cin >> num;
    v2.push_back(num);
  }
  if (m > n) {
    cout << "0/1";
    return 0;
  }
  if (n > m) {
    if ((v1[0] * v2[0]) < 0) cout << "-";
    cout << "Infinity";
    return 0;
  }
  if ((v1[0] * v2[0]) < 0) cout << "-";
  v1[0] = abs(v1[0]);
  v2[0] = abs(v2[0]);
  cout << v1[0] / gcd(v1[0], v2[0]) << "/" << v2[0] / gcd(v1[0], v2[0]);
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Meeting {

    public void solve() throws IOException {

        Scanner sc = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

        int i = 0, j = 0, k = 0;
        long ans = 0, sum = 0, count = 0;
        int xa = sc.nextInt();
        int xb = sc.nextInt();
        int ya = sc.nextInt();
        int yb = sc.nextInt();
        int n = sc.nextInt();

        ArrayList<Point> Plist = new ArrayList<Point>();
        for (i = Math.min(xa, ya); i <= Math.max(xa, ya); ++i) {
            for (j = Math.min(yb, xb); j <= Math.max(yb, xb); ++j) {
                if (i == xa || i == ya) {
                    Plist.add(new Point(i, j));
                } else {
                    Plist.add(new Point(i, yb));
                    Plist.add(new Point(i, xb));
                    break;
                }
            }
        }
        //  System.out.println(Plist.size());
        sum = Plist.size();
        ArrayList<heater> hlist = new ArrayList<heater>();
        for (i = 0; i < n; ++i) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int r = sc.nextInt();
            if (hlist.contains(new heater(x, y, r, true))) {
                int rr = hlist.get(hlist.indexOf(new heater(x, y, r, true))).r;
                if (r > rr) {
                    hlist.remove(new heater(x, y, r, true));
                    hlist.add(new heater(x, y, r, true));
                }
            } else {
                hlist.add(new heater(x, y, r, true));
            }
        }

        heater hset[] = hlist.toArray(new heater[hlist.size()]);
        //   System.out.println(Arrays.toString(hset));

        for (i = 0; i < hlist.size(); ++i) {
            int x = hset[i].x;
            int y = hset[i].y;
            int r = hset[i].r;

            for (j = 0; j < Plist.size(); ++j) {
                int xx = Plist.get(j).x;
                int yy = Plist.get(j).y;
                if (xx != Integer.MAX_VALUE && yy !=Integer.MAX_VALUE) {
                    if (r * r >= (x - xx) * (x - xx) + (y - yy) * (y - yy)) {
                        Plist.get(j).setLocation(Integer.MAX_VALUE, Integer.MAX_VALUE);
                        count++;
                    }
                }

            }
            //System.out.println(Arrays.toString(Plist.toArray(new Point[Plist.size()])));

        }

        System.out.println(sum - count);

    }

    public static void main(String[] args) throws IOException {
        new Meeting().solve();

    }
}

class heater {

    int x;
    int y;
    int r;
    boolean gotit;

    public heater(int x, int y, int r, boolean gotit) {
        this.x = x;
        this.y = y;
        this.r = r;
        this.gotit = gotit;
    }

    public void setR(int r) {
        this.r = r;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getR() {
        return r;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof heater && ((heater) o).x == this.x && ((heater) o).y == this.y) {
            return true;
        } else {
            return false;
        }
    }

    public String toString() {
        return "(" + x + " " + y + " " + r + ")";
    }
}

#include <bits/stdc++.h>
using namespace std;
double eps = 1e-9;
int n;
int ox[10000], oy[10000], r[10000];
bool can(int x, int y) {
  for (int i = 0; i < n; i++)
    if ((x - ox[i]) * (x - ox[i]) + (y - oy[i]) * (y - oy[i]) <= r[i] * r[i])
      return true;
  return false;
}
int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2 >> n;
  for (int i = 0; i < n; i++) cin >> ox[i] >> oy[i] >> r[i];
  int sx, gx, sy, gy;
  sx = min(x1, x2);
  gx = max(x1, x2);
  sy = min(y1, y2);
  gy = max(y1, y2);
  int r = 0;
  for (int i = sx; i <= gx; i++) {
    if (!can(i, sy)) r++;
    if (!can(i, gy)) r++;
  }
  for (int i = sy + 1; i < gy; i++) {
    if (!can(sx, i)) r++;
    if (!can(gx, i)) r++;
  }
  cout << r << endl;
  return 0;
}


from collections import defaultdict
n, m = [int(y) for y in input().split()]
d=defaultdict(list)
for i in range(m):
    a, b = [int(y) for y in input().split()]
    d[a].append(b)
    d[b].append(a)
cnt=0
while True:
    f=0
    vis=[False]*n
    for k, v in d.items():
        if len(v)==1 and not vis[k-1]:
            temp=v.pop(0)
            d[temp].pop(d[temp].index(k))
            vis[temp-1]=True
            f=1
    if f==0:break
    cnt+=1
    f=0
print(cnt)

import java.util.*;
public class Main {
    public static void main(String args[]) {
     Scanner scan = new Scanner(System.in);
     int n = scan.nextInt();
     int m = scan.nextInt();
     boolean adj[][]=new boolean[n][n];
     for(int i =0;i<m;i++)
     {
         int a = scan.nextInt();
         int b = scan.nextInt();
         a--;
         b--;
         adj[a][b]=true;
         adj[b][a]=true;
     }
     int visited[]=new int[n];
     for(int i=0;i<n;i++)
     visited[i]=-1;
     int grp=0;
     while(true)
     {

      boolean run =false;

      for(int i =0;i<n;i++)
      {
          int cnt=0;
          int index=-1;
        for(int j =0;j<n;j++)
        {
            if(adj[i][j]==true)
            {
                cnt++;
                index=j;
            }
        }
        if(cnt==1)
        {
            run =true;
            visited[i]=index;
        }
      }
      if(run==false)
      break;
      else
      {
       grp++;
       for(int i =0;i<n;i++)
       {
           if(visited[i]!=-1)
           {
               int x = visited[i];
               adj[i][x]=false;
               adj[x][i]=false;
               visited[i]=-1;
           }
        }
      }
     }
     System.out.println(grp);
    }
}


x=int(input())
from math import ceil
s=list(map(int,input().split()))
id=[]
for n in range(x):
    if s[n]:
        id.append(n)

if len(id)==1:
    print(-1)
    exit(0)

sm=len(id)
res=1e9
divs=set()
for n in range(2,int(sm**.5)+1):
    if sm%n==0:
        divs.add(n)
        divs.add(sm//n)
divs.add(sm)

dv=[]
for n in divs:
    dv.append(n)
res=5e9
for divisor in dv:
    tm=0
    md=divisor//2
    for n in range(0,sm,divisor):
        mid=id[n+md]
        for k in range(n,n+divisor):
            tm+=abs(id[k]-mid)
    res=min(res,tm)

print(res)

#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> v;
long long solve(long long x) {
  long long sol = 0, cnt = 0;
  for (long long i = 0; i < n - 1; i++) {
    cnt += v[i];
    sol += min(cnt % x, x - cnt % x);
  }
  return sol;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long a, summ = 0, sol = LLONG_MAX;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    summ += a;
    v.push_back(a);
  }
  for (long long i = 2; i * i <= summ; i++) {
    if (summ % i) continue;
    sol = min(sol, solve(i));
    while (summ % i == 0) summ /= i;
  }
  if (summ > 1) sol = min(sol, solve(summ));
  if (sol == LLONG_MAX) sol = -1;
  cout << sol << "\n";
  return 0;
}


import java.math.*;
import java.text.*;

import java.util.*;

public class CompleteSearch {
 public static Scanner in =new Scanner(System.in);
    int n;

    public static void main(String[] args){
        int n=in.nextInt();
        String a=in.next();
        Stack stack=new Stack();
        for(int i=0;i<n;i++){
            if(stack.isEmpty())
                stack.push(a.charAt(i));
            else{
                char top=(char) stack.getTop();
                char cur=a.charAt(i);
                if(top=='('&&cur==')')
                    stack.pop();
                else
                    stack.push(cur);
            }
        }
        if(stack.size()==0)
            System.out.println("Yes");
        else if(stack.size()==2){
            char x=(char) stack.getTop();stack.pop();
            char y=(char) stack.getTop();stack.pop();
            if(x!=y)
                System.out.println("Yes");
            else
                System.out.println("No");
        }
        else
            System.out.println("No");
    }
    public static class House{
        int r,g,b;
        public House(int a, int b, int c){
        r=a;g=b;this.b=c;
        }
    }
     private static class Stack
    {
    private int Size;
    Node top;
    Stack(){

    Size=0;
    top=null;
    }
    public int size(){
    return this.Size;
    }
    public void push(Object item){
    Node node=new Node();
    node.data=item;
    node.next=top;
    top=node;
    Size++;
    }
    public void pop(){
    if(top!=null)
        top=top.next;
    Size--;
    }
    public boolean isEmpty(){
    return top==null;
    }
    public Object getTop(){
    if(top!=null)
        return top.data;
    else
        return null;
    }
    public void display(){
    if(top!=null){
        Node temp=top;
    while(temp!=null){
        System.out.print(temp.data+" ");
        temp=temp.next;
    }
        System.out.println();
    }
    }
  private class Node {
  Object data;
  Node next;
  }
}
}

Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes No Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No

#include <bits/stdc++.h>
using namespace std;
int f[300007];
int main() {
  int n;
  scanf("%d", &n);
  string s;
  cin >> s;
  s = '#' + s;
  for (auto i = (1); i <= (n); ++i) {
    if (s[i] == '(')
      f[i] = f[i - 1] + 1;
    else
      f[i] = f[i - 1] - 1;
  }
  if (f[n] != 0) {
    puts("No");
    return 0;
  }
  int mn = 0;
  for (auto i = (1); i <= (n); ++i) {
    mn = min(mn, f[i]);
  }
  if (mn >= -1)
    puts("Yes");
  else
    puts("No");
  return 0;
}


n=int(input())
ar=list(map(int,input().split()))
m=max(ar)
ind=-1
for i in range(n):
    if(ar[i]==m):
        ind=i
ans="YES"
a1=[]
a2=[]
for i in range(ind):
    a1.append(ar[i])
    a2.append(ar[i])
a2.sort()

for i in range(ind):
    if(a1[i]!=a2[i]):
        ans="NO"

a3=[]
a4=[]
for i in range(ind+1,n):
    a3.append(ar[i])
    a4.append(ar[i])

a4.sort(reverse=True)
for i in range(len(a3)):
    if(a3[i]!=a4[i]):
        ans="NO"

print(ans)

NO NO NO YES NO NO YES NO YES YES NO NO YES YES YES NO NO NO NO YES NO NO YES YES NO NO NO NO YES YES NO NO YES NO NO NO YES NO YES NO NO NO NO NO NO NO NO NO NO YES

import java.util.*;

public class Result {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args){
        int n = scanner.nextInt();
        int[] a = new int[n];
        int i;
        for (i=0;i<n;i++)
            a[i] = scanner.nextInt();
        int max = n,index=0,posCount=0,negCount=0;
        for (i=0;i<n;i++)
            if (a[i]==max){
                index = i;
                break;
            }

        if (index<n-1)
            posCount=1;
        if (index>0)
            negCount=1;

        for(i=1;i<=n-1;i++){
            if (a[index+posCount]==max-i) {
                if (index + posCount + 1 < n)
                    posCount++;
            }
            else if (a[index-negCount]==max-i) {
                if (index - negCount - 1 >= 0)
                    negCount++;
            }
            else {
                break;
            }
        }
        scanner.close();
        if (i==n)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


n=int(input())-1
a=sorted(map(int,input().split()))
ans='NO'
for i in range(n):
	if a[i]<a[i+1]and a[i]*2>a[i+1]:
		ans='YES'
print(ans)

YES NO YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES NO YES YES NO YES YES YES YES NO NO NO YES YES NO YES NO YES YES YES YES

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Date 25.11.2011
 * Time 20:43:22
 * Author Woodey
 * $
 */

public class B108 {

	final int INF = Integer.MAX_VALUE;

	private void Solution() throws IOException {
		int n = nextInt();
		int[] mas = new int[n];
		boolean win = false;
		for (int i = 0; i < n; i ++)
			mas[i] = nextInt();
		Arrays.sort(mas);
		for (int i = 0; i < n-1; i ++)
			if (mas[i]*2 > mas[i+1] && mas[i] != mas[i+1])
				win = true;
		System.out.println(win ? "YES" : "NO");
	}

	public static void main(String[] args) {
		new B108().run();
	}

	BufferedReader in;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			Solution();
			in.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(in.readLine());
		return tokenizer.nextToken();
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class n1{
    public static long D(long a,long b){
        while(b!=0){
            long t=a;
            a=b;
            b=t%b;
        }
        return a;
    }
    public static void main(String[] args) throws Exception{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        int n=Integer.parseInt(in.readLine());
        for(int qq=0;qq<n;qq++){
            StringTokenizer st=new StringTokenizer(in.readLine());
            long p=Long.parseLong(st.nextToken());
            long q=Long.parseLong(st.nextToken());
            long base=Long.parseLong(st.nextToken());
            if(p==0){
                out.println("Finite");
            }else{
                long d=D(p,q);
                p/=d;
                q/=d;
                long div;
                while((div=D(q,base))>1){
                    while(q%div==0){
                        q/=div;
                    }
                }
                if(q==1){// q|base^k
                    out.println("Finite");
                }else{
                    out.println("Infinite");
                }
            }
        }
        out.close();
    }
}

Infinite
Finite
Finite
Infinite
Infinite
Finite
Finite
Finite
Infinite
Finite

Finite
Infinite
Infinite
Finite
Infinite
Infinite
Finite
Finite
Finite
Finite

Finite
Finite
Infinite
Finite
Infinite
Infinite
Finite
Finite
Finite
Finite

#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (x > y) {
    swap(x, y);
  }
  if (x == 0) {
    return y;
  } else {
    return gcd(x, y % x);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long p, q, b;
    cin >> p >> q >> b;
    long long g = gcd(p, q);
    p /= g;
    q /= g;
    while (true) {
      g = gcd(q, b);
      if (g == 1) {
        break;
      } else {
        while (q % g == 0) {
          q /= g;
        }
      }
    }
    if (q == 1) {
      cout << "Finite\n";
    } else {
      cout << "Infinite\n";
    }
  }
  return 0;
}


import java.util.Scanner;

public class TaskA {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] firstName = in.next().toCharArray();
        char[] lastName = in.next().toCharArray();

        String res = "" + firstName[0];
        for (int i = 1; i < firstName.length; i++) {
            if (firstName[i] < lastName[0]) {
                res += firstName[i];
            } else {
                res += lastName[0];
                System.out.println(res);
                return;
            }
        }

        res += lastName[0];
        System.out.println(res);
    }
}

noah brown
apple pie
liam johnson
oliver johnson
liam johnson
ethan thomas
jjxwj kxccwx
charlotte wilson
john smith
ella johnson
sarah jones
olivia wilson
oliver johnson
dtbqya fyyymv
sophia wilson
amelia brown
harry potter
jessica brown
oliver williams
amy wilson
ethan williams
isabella wilson
ava williams
liam thomas
liam johnson
isabella wilson
tom riddle
olivia williams
amelia brown
amelia brown
olivia williams
isabella thomas
amolfed pun
emma thomas
mia brown
david brown
ava johnson
ab b
mia johnson
charlotte wilson
ava williams
emma watson
ca cf
emma thomas
emma thomas
charlotte wilson
tom riddle
benjamin thomas
mia brown
ethan thomas

ethanw jjk charlottew charlottew isabellaw liaj oliverw liaj ej mb emmaw ab benjamint et df ab ab oliviaw aj ap sophiaw isabellaw hap isabellat tomr miaj emmat liaj dab amolfedp avaw mb johns nb oj ab amw charlottew oliviaw jb saj tomr oliviaw liamt emmat et avaw emmat oj cac

#include <bits/stdc++.h>
using namespace std;
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cout << b << "=" << a << " ";
    call(++it, ed, rest...);
  }
};
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  string f, l, login = "zzzzzzzzzzzzzzzzzzzzz";
  cin >> f >> l;
  for (int i = (int)(0); i < (int)(f.size()); ++i) {
    for (int j = (int)(0); j < (int)(l.size()); ++j) {
      login = min(login, f.substr(0, i + 1) + l.substr(0, j + 1));
    }
  }
  cout << login << endl;
  return 0;
}


import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Arrays.copyOf;
import static java.util.Arrays.fill;
import static java.util.Arrays.sort;
import static java.util.Collections.reverseOrder;
import static java.util.Collections.sort;
import static java.util.Map.Entry;

public class Main {
    private FastScanner in;
    private PrintWriter out;

    private void solve() throws IOException {
        int[] a = new int[6];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
        }

        if (sum % 2 == 1) {
            out.println("NO");
            return;
        }
        sum /= 2;

        HashSet<Integer>[] arr = new HashSet[7];
        for (int i = 0; i < 7; i++) {
            arr[i] = new HashSet<>();
        }

        for (int i = 0; i < a.length; i++) {
            for (int j = arr.length - 2; j > 0; j--) {
                for (int k : arr[j])
                    arr[j + 1].add(k + a[i]);
            }
            arr[1].add(a[i]);
        }

        if (arr[3].contains(sum))
            out.print("YES");
        else
            out.print("NO");
    }

    class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        boolean hasNext() throws IOException {
            return br.ready() || (st != null && st.hasMoreTokens());
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        boolean hasNextLine() throws IOException {
            return br.ready();
        }

    }

    private void run() throws IOException {
        in = new FastScanner(System.in); // in = new FastScanner(new FileInputStream(".in"));
        out = new PrintWriter(System.out); // out = new PrintWriter(new FileOutputStream(".out"));

        solve();

        out.flush();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}

NO YES YES YES YES YES YES NO NO YES NO NO NO YES YES NO YES YES YES NO NO NO YES YES NO NO NO YES YES YES NO YES YES YES NO NO YES NO NO NO YES NO YES YES NO YES YES NO NO NO

a = list(map(int, input().split()))
summ = sum(a)
res = 'NO'
if summ % 2 != 1 :
    summ //= 2
    for i in range(4) :
        for j in range(i + 1, 5) :
            for k in range(j + 1, 6) :
                if a[i] + a[j] + a[k] == summ :
                    res = 'YES'
print(res)


def computeTiling(n):
    if n == 1:
        print("a\na\nf\nf")
        return

    for tiling in generateRowTilings(n):
        print("".join(tiling))

def generateRowTilings(n):
    for (rowNum, firstTile, pattern) in generateRowTilingPatterns(n):
        yield makeRowTiling(rowNum, firstTile, pattern, n)

def generateRowTilingPatterns(n):
    rows = (1, 2, 3, 4)
    firstTiles = ('a', 'a', 'd', 'e')
    patterns = ('bbcc', 'ccbb', 'deed', 'edde')
    return zip(rows, firstTiles, patterns)

def makeRowTiling(row, prefix, pattern, n):
    yield prefix
    yield from (pattern[i%4] for i in range(n-2))
    yield pattern[(n-2)%4] if (n%2 != (row-1)//2) else 'f'

if __name__ == '__main__':
    n = int(input())
    computeTiling(n)

accbbccbbcc
abbccbbccbb
eeddeeddeef
ddeeddeeddf

accbbccbbccbbccbbccbbccbbcc
abbccbbccbbccbbccbbccbbccbb
eeddeeddeeddeeddeeddeeddeef
ddeeddeeddeeddeeddeeddeeddf

aabbaabbaabbaabbaabb
bddccddccddccddccddf
bccddccddccddccddccf
eeaaeeaaeeaaeeaaeeaa

accbbccbbccbbccbbccbbccbb
abbccbbccbbccbbccbbccbbcc
eeddeeddeeddeeddeeddeeddf
ddeeddeeddeeddeeddeeddeef

aabbaabbaabbaabbaa
bddccddccddccddccf
bccddccddccddccddf
eeaaeeaaeeaaeeaaee

aabbaabbaabbaabbaabbaa
bddccddccddccddccddccf
bccddccddccddccddccddf
eeaaeeaaeeaaeeaaeeaaee

accbbccbbccbbccbb
abbccbbccbbccbbcc
eeddeeddeeddeeddf
ddeeddeeddeeddeef

aabbaabbaabbaabbaabbaabb
bddccddccddccddccddccddf
bccddccddccddccddccddccf
eeaaeeaaeeaaeeaaeeaaeeaa

accbbccbbccbbccbbccbb
abbccbbccbbccbbccbbcc
eeddeeddeeddeeddeeddf
ddeeddeeddeeddeeddeef

aabbaabbaabbaabbaabbaabbaabb
bddccddccddccddccddccddccddf
bccddccddccddccddccddccddccf
eeaaeeaaeeaaeeaaeeaaeeaaeeaa

aabbaabbaa
bddccddccf
bccddccddf
eeaaeeaaee

accbbccbbccbbcc
abbccbbccbbccbb
eeddeeddeeddeef
ddeeddeeddeeddf

aabbaabbaabb
bddccddccddf
bccddccddccf
eeaaeeaaeeaa

accbbccbbccbb
abbccbbccbbcc
eeddeeddeeddf
ddeeddeeddeef

accbbccbbccbbccbbcc
abbccbbccbbccbbccbb
eeddeeddeeddeeddeef
ddeeddeeddeeddeeddf

aabbaabbaabbaabbaabbaabbaa
bddccddccddccddccddccddccf
bccddccddccddccddccddccddf
eeaaeeaaeeaaeeaaeeaaeeaaee

aabbaabbaabbaabb
bddccddccddccddf
bccddccddccddccf
eeaaeeaaeeaaeeaa

aabbaabbaabbaa
bddccddccddccf
bccddccddccddf
eeaaeeaaeeaaee

accbbccbbccbbccbbccbbccbbccbb
abbccbbccbbccbbccbbccbbccbbcc
eeddeeddeeddeeddeeddeeddeeddf
ddeeddeeddeeddeeddeeddeeddeef

accbbccbbccbbccbbccbbcc
abbccbbccbbccbbccbbccbb
eeddeeddeeddeeddeeddeef
ddeeddeeddeeddeeddeeddf

#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  if (n & 1) {
    int l = (n - 1) / 2;
    printf("a");
    for (int i = 0; i < l; i++) printf(i & 1 ? "bb" : "cc");
    puts("");
    printf("a");
    for (int i = 0; i < l; i++) printf(!(i & 1) ? "bb" : "cc");
    puts("");
    for (int i = 0; i < l; i++) printf(i & 1 ? "dd" : "ee");
    printf("f");
    puts("");
    for (int i = 0; i < l; i++) printf(!(i & 1) ? "dd" : "ee");
    printf("f");
    puts("");
  } else {
    int l = n / 2;
    for (int i = 0; i < l; i++) printf(i & 1 ? "bb" : "aa");
    puts("");
    putchar('b');
    for (int i = 0; i < l - 1; i++) printf(i & 1 ? "cc" : "dd");
    putchar('f');
    puts("");
    putchar('b');
    for (int i = 0; i < l - 1; i++) printf(!(i & 1) ? "cc" : "dd");
    putchar('f');
    puts("");
    for (int i = 0; i < l; i++) printf(i & 1 ? "aa" : "ee");
    puts("");
  }
  return 0;
}


s = input()
l = s.split()

n = int(l[0])
k = int(l[1])

s = input()
l = s.split()

b = [-1]

for i in range(1, n + 1):
    b.append(int(l[i - 1]))

for i in range(1, n + 1):

    j = 1
    while b[j] != 0:
        j += 1

    b[j] -= 1
    print(j, end = ' ')

    for t in range(1, n + 1):
        if j - k >= t:
            b[t] -= 1

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;

public class Main {
	private static StreamTokenizer in = new StreamTokenizer(new BufferedReader(
			new InputStreamReader(System.in)));
	private static PrintWriter out = new PrintWriter(System.out);

	private static int nextInt() throws Exception {
		in.nextToken();
		return (int) in.nval;
	}

	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}

	public static void main(String[] args) throws Exception {
		int n = nextInt();
		int k = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		ArrayList<Integer> w = new ArrayList<Integer>();
		for (int i = n - k; i < n; i++) {
			w.add(i+1);
		}
		for (int e = n - k - 1; e >= 0; e--) {

			int p = 0, in = 0;
			for (int j : w) {
				if (p == a[e]) {
					break;
				}
				if (j >= (e + k + 1)) {
					p++;
				}
				in++;

			}
			w.add(in, e+1);
		}
		for (int j : w) {
			out.print(j + " ");
		}
		out.println();
		out.flush();
	}
}


#include <bits/stdc++.h>
using namespace std;
int check(vector<int> m, vector<int> r, int d) {
  int flag = 0;
  for (int i = 0; i < m.size(); i++) {
    if ((d % m[i] == r[i])) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    return 1;
  else
    return 0;
}
int main() {
  int n, k, l;
  double c = 0.0;
  cin >> n;
  vector<int> m, r;
  for (int i = 0; i < n; i++) {
    cin >> k;
    m.push_back(k);
  }
  for (int i = 0; i < n; i++) {
    cin >> k;
    r.push_back(k);
  }
  for (int i = 0; i < 1000000; i++) {
    c += (double)check(m, r, i);
  }
  cout << (c / 1000000);
}

n = int(input())
m = list(map(int, input().split()))
r = list(map(int, input().split()))

days = 0

for day in range(1, 100001):
    for index in range(n):
        if day % m[index] == r[index]:
            days += 1
            break

print(days / 100000)


n=int(input())
l=list(map(int,input().split()));print(1 if 1 not in l else -1)

import java.util.*;
public class CurrencySystem {

	public static void main(String[] args) {
		Scanner obj = new Scanner(System.in) ;
		int n = obj.nextInt() ;
		Vector<Integer> v = new Vector<Integer>() ;
		for(int i=0 ; i<n ; i++)
		{
			v.add(obj.nextInt()) ;
		}
		Collections.sort(v);
		if(v.elementAt(0)==1) System.out.println(-1);
		else System.out.println(1);

	}

}


import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Map;

public class R230C{
    public static void main(String args[]){
        FasterScanner s=new FasterScanner();
        PrintWriter out=new PrintWriter(System.out);
        StringBuilder sb=new StringBuilder();
        long n=s.nextLong();
        if(n==0){
            System.out.println(1);
            return;
        }
        long t=1;
        long cnt=1;
        long prev=0;
        for(long i=n-1;i>=1;--i){
            while(t*t+i*i<n*n)
                t++;
            if(t*t+i*i>n*n)
                t--;
            cnt+=t-prev;
            if(t-prev==0)
                    cnt+=1;
            prev=t;
        }
        System.out.println(cnt*4);
    }

    public static class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
}

from math import sqrt, floor

def calc(n):
    if n == 0:
       return 1

    # y = n
    # x = 1
    # c = 0
    # while x - y < 0:
    #     if x ** 2 + y ** 2 <= n ** 2:
    #         c += 1
    #         x += 1
    #         continue
    #     if x ** 2 + y ** 2 > n ** 2:
    #         y -= 1
    x = floor(sqrt(n**2/2))
    y = floor(sqrt(n**2-x**2))
    #print(x, y)
    if x == y:
        return x*8
    else:
        return x * 8 +4

n = int(input())
print(calc(n))


#include <bits/stdc++.h>
using namespace std;
long long power(long x, long n) {
  if (n == 0) return 1;
  if (n == 1) return x;
  long n2 = n / 2;
  long long po = power(x, n2);
  if (n % 2) return po * po * x;
  return po * po;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
class CAliceAndBob {
 public:
  void solve(std::istream &cin, std::ostream &cout) {
    long long n, i, mx = 0, x, gc = 0;
    cin >> n;
    for (i = 0; i < n; i++) cin >> x, mx = max(x, mx), gc = gcd(gc, x);
    if ((mx / gc - n) % 2)
      cout << "Alice\n";
    else
      cout << "Bob\n";
  }
};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  CAliceAndBob solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Alice Bob Alice Alice Bob Bob Bob Bob Alice Alice Alice Bob Alice

import java.util.*;
import java.io.*;
/*
 * author:yanghui
 */
public class A {

	class InputReader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader() throws FileNotFoundException {
			reader = new BufferedReader(new FileReader("d:/input.txt"));
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}

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

	public void run() {

		InputReader reader = new InputReader(System.in);
		int n = reader.nextInt();
		int a[] = new int[n];
		int max = -1;
		for(int i = 0 ; i < n ; i ++){
			a[i] = reader.nextInt();
		}
		int gcd =0;
		for(int i = 1 ;i < n ; i++){
			if(i == 1)
				gcd = gcd(a[i],a[i-1]);
			else
				gcd = gcd(a[i],gcd);
		}
		for(int i = 0 ; i < n ; i ++){
			a[i] = a[i]/gcd;
		}
		for(int i = 0 ; i < n ; i ++){
			max = Math.max(a[i], max);
		}
		int ans = max - n;
		if(ans % 2 == 1)
			System.out.println("Alice");
		else
			System.out.println("Bob");
	}

	public static void main(String args[]) {
		new A().run();
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.text.*;
public class Main {
    static long mod = (long)1e9 + 7;
    static long mod1 = 998244353;
    static boolean fileIO = false;
    static FastScanner f;
    static PrintWriter pw = new PrintWriter(System.out);
    static Scanner S = new Scanner(System.in);
    public static void main(String[] args)throws IOException {
        init();
        double l = f.nextDouble(); double d = f.nextDouble(); double v = f.nextDouble(); double g = f.nextDouble(); double r = f.nextDouble();
        double t1 = d / v; double wt = 0; double tt = 0;
        if(g > t1) wt = 0;
        else if(g == t1) wt = r;
        else {
            double l1 = 0 , r1 = g;
            int i = 0;
            while(true) {
                if(t1 < r1 && t1 >= l1) break;
                double temp = r1;
                if(ise(i)) r1 += r; else r1 += g;
                l1 = temp; ++i;
            }
            wt += (r1 - t1);
        }
        tt = t1 + wt + ((l - d) / v);
        System.out.printf("%.9f" , tt);
        pw.flush();
        pw.close();
    }

/******************************END OF MAIN PROGRAM*******************************************/
    public static void init()throws IOException{if(fileIO){f=new FastScanner("");}else{f=new FastScanner(System.in);}}
    public static class FastScanner {
        BufferedReader br;StringTokenizer st;
        FastScanner(InputStream stream){try{br=new BufferedReader(new InputStreamReader(stream));}catch(Exception e){e.printStackTrace();}}
        FastScanner(String str){try{br=new BufferedReader(new FileReader("!a.txt"));}catch(Exception e){e.printStackTrace();}}
        String next(){while(st==null||!st.hasMoreTokens()){try{st=new StringTokenizer(br.readLine());}catch(IOException e){e.printStackTrace();}}return st.nextToken();}
        String nextLine()throws IOException{return br.readLine();}int nextInt(){return Integer.parseInt(next());}long nextLong(){return Long.parseLong(next());}double nextDouble(){return Double.parseDouble(next());}
    }
    public static void pn(Object o){pw.println(o);}
    public static void p(Object o){pw.print(o);}
    public static void pni(Object o){pw.println(o);pw.flush();}
    static class Point implements Comparator<Point>{int x;int y;Point(int x,int y){this.x=x;this.y=y;}Point(){}public int compare(Point a, Point b){if(a.x==b.x)return a.y-b.y;return a.x-b.x;}}
    static int gcd(int a,int b){if(b==0)return a;else{return gcd(b,a%b);}}
    static long gcd(long a,long b){if(b==0)return a;else{return gcd(b,a%b);}}
    static long pow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=res*a;b>>=1;a=a*a;}return res;}
    static long mpow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=((res%mod)*(a%mod))%mod;b>>=1;a=((a%mod)*(a%mod))%mod;}return res;}
    static boolean isPrime(long n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static HashSet<Long> factors(long n){HashSet<Long> hs=new HashSet<Long>();for(long i=1;i<=(long)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static int[] inpint(int n){int arr[]=new int[n];for(int i=0;i<n;i++){arr[i]=f.nextInt();}return arr;}
    static long[] inplong(int n){long arr[] = new long[n];for(int i=0;i<n;i++){arr[i]=f.nextLong();}return arr;}
    static HashSet<Integer> hsi(){return new HashSet<Integer>();}static HashSet<Long> hsl(){return new HashSet<Long>();}
    static ArrayList<Integer> ali(){return new ArrayList<Integer>();}static ArrayList<Long> all(){return new ArrayList<Long>();}
    static HashMap<Integer,Integer> hii(){return new HashMap<Integer,Integer>();}
    static HashMap<Integer,ArrayList<Integer>> g(){return new HashMap<Integer,ArrayList<Integer>>();}
    static boolean ise(int x){return ((x&1)==0);}static boolean ise(long x){return ((x&1)==0);}
}

# n=int(input())
l,d,v,g,r=map(int,input().split())
z=d/v
y=(l-d)/v
temp=z
light=True
x=0
# print(z,y)
while(1):
    if(x%2==0):
        if(temp>=g):
            temp-=g
            light=False
        else:
            break
    else:
        if(temp>=r):
            temp-=r
            light=True
        else:
            break
    x+=1
if(light):
    print("{0:.8f}".format(z+y))
else:
    print("{0:.8f}".format(z+(r-temp)+y))


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> nums = new ArrayList<Integer>();
		int c = 0;
		for(int i = 0; i < 4; i++){
			int cur = sc.nextInt();
			if(!nums.contains(cur)){
				c++;
			}
			nums.add(cur);
		}
		System.out.println(4-c);
	}
}

#include <bits/stdc++.h>
using namespace std;
long long n, m, k, h;
long long a, b, c;
long long x, y;
long long mn = 1005;
set<long long> st;
long double ans;
int main() {
  for (int i = 0; i < 4; i++) {
    cin >> x;
    st.insert(x);
  }
  cout << 4 - st.size();
}


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

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

    ll t;
    cin>>t;

    while(t--){
        int a,b;
        cin>>a>>b;
        cout<<a-1<<' '<<b<<'\n';
    }
	return 0;
}

import sys
import math
from collections import defaultdict,deque

input = sys.stdin.readline
def inar():
    return [int(el) for el in input().split()]
def main():
    t=int(input())
    for _ in range(t):
        alice,bob=inar()
        print(alice-1,bob)

if __name__ == '__main__':
    main()


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {

		int n = input.nextInt();

		char[] s = input.nextLine().toCharArray();
		long sum = 1;
		int x = 0;

		for (; x < s.length - 1 && s[x] == s[x + 1]; x++)
			;

		int y = n - 1;
		for (; y >= 1 && s[y] == s[y - 1]; y--)
			;

		sum += (x + 1) + (n - y);

		if (s[x] == s[y]) {
			sum += (long) (x + 1) * (n-y);
		}

		System.out.println(sum % 998244353);

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}

		boolean hasNext() throws IOException {
			return br.ready();
		}
	}

}

#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 2e5 + 5;
long long QuickMul(long long A, long long B) {
  long long Ans = 0;
  while (B) {
    if (B & 1) {
      Ans = (Ans + A) % mod;
    }
    A = (A + A) % mod;
    B >>= 1;
  }
  return Ans;
}
int N;
char Str[maxn];
long long Left, Right;
int main(int argc, char *argv[]) {
  scanf("%d%s", &N, Str + 1);
  int Left = 0, Right = N + 1;
  for (int i = 2; i <= N; ++i) {
    if (Str[i] != Str[i - 1]) {
      Left = i;
      break;
    }
  }
  for (int i = N - 1; i >= 1; --i) {
    if (Str[i] != Str[i + 1]) {
      Right = i;
      break;
    }
  }
  Right = (N - Right) + 1;
  if (Str[1] == Str[N]) {
    printf("%lld\n", QuickMul(Left, Right));
  } else {
    printf("%lld\n",
           ((Left + Right) % (long long)mod - 1 * 1LL + (long long)mod) %
               (long long)mod);
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> neighbors;
vector<int> appleSteps;
void dfs(int index, int steps) {
  appleSteps[steps]++;
  for (int i = 0; i < neighbors[index].size(); i++) {
    int neighborIndex = neighbors[index][i];
    dfs(neighborIndex, steps + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  appleSteps.resize(n + 1);
  neighbors.resize(n + 1);
  for (int i = 1; i < n; i++) {
    int input;
    cin >> input;
    input--;
    neighbors[input].push_back(i);
  }
  dfs(0, 0);
  int result = 0;
  for (int i = 0; i < appleSteps.size(); i++) {
    if (appleSteps[i] % 2 == 1) {
      result++;
    }
  }
  cout << result;
  return 0;
}

from collections import Counter

tree = []

class Node:
    def __init__(self, num=None):
        self.length = 0 if num is None else tree[num-1].length + 1

def main():
    n = int(input())
    global tree
    tree = [Node()]

    for x in input().split():
        tree.append(Node(int(x)))

    print(sum([value & 1 for key, value in Counter([x.length for x in tree]).items()]))

if __name__ == "__main__":
    main()


#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int x[3], i;
  for (i = 0; i < 3; ++i) scanf("%d", x + i);
  for (i = 0; x[0] || x[1] || x[2]; ++i)
    if (x[i % 3] >= 2)
      x[i % 3] -= 2;
    else
      x[i % 3] = 0;
  printf("%d\n", i + 29);
  return 0;
}


n=list(input())
m=len(n)
e=0
s=1
if n.count('1')==0:
    s=0
for i in range(0,m):
    if n[i]=='1':
        e=i
        break
k=n[e:]
if s==1:
    if k.count('0')>=6:
        print('yes')
    else:
        print('no')
else:
    print('no')

YES NO YES YES YES YES YES YES YES NO YES YES NO YES YES YES NO YES YES YES YES NO YES NO YES YES YES YES NO YES YES NO

import java.util.*;
import java.io.*;
public class codeforces {
    public static void main(String[] args) throws Exception {
        Scanner in=new Scanner(System.in);
        String s=in.next();
        boolean found=false;
        int i=0,count=0;
        while(i<s.length()){
            if(s.charAt(i)=='1'){
                found=true;
                break;
            }
         i++;
        }
        int j=i+1;
        while(found==true && j<s.length()){
              if(s.charAt(j)=='0'){
                  count++;
              }
            j++;
        }
        if(count>=6){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
        in.close();
        return;
    }
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class CF858D {

	public static class LongSet {

		int size = 0;

		public long[][] table;

		public LongSet(int size) {
			table = new long[1 << (32 - Integer.numberOfLeadingZeros(size - 1))][1];
			for (int i = 0; i < table.length; i++) {
				table[i][0] = 1;
			}
		}

		final void add(long key) {
			int idx = (int) (key & (table.length - 1));
			long[] vec = table[idx];
			/*
			 * resize the bucket if needed. vec[0] stores the number of keys in
			 * the bucket
			 */
			if (vec[0] >= vec.length) {
				vec = Arrays.copyOf(vec, 2 * vec.length);
				table[idx] = vec;
			}
			/*
			 * if key is already in bucket don't do anything
			 */
			for (int i = 1; i < vec[0]; i++) {
				if (vec[i] == key) {
					return;
				}
			}
			/*
			 * add the key snd increment bucket and table size
			 */
			vec[(int) vec[0]] = key;
			vec[0]++;
			size++;
		}

		void remove(long key) {
			int idx = (int) (key & (table.length - 1));
			long[] vec = table[idx];

			for (int i = 1; i < vec[0]; i++) {
				if (vec[i] == key) {
					vec[i] = vec[(int) (vec[0] - 1)];
					vec[0]--;
					size--;
				}
			}
			if (vec[0] >= 1 && vec[0] <= vec.length / 4) {
				vec = Arrays.copyOf(vec, vec.length / 2);
				table[idx] = vec;
			}
		}

		boolean contains(long value) {
			int idx = (int) (value & (table.length - 1));
			long[] vec = table[idx];
			for (int i = 1; i < vec[0]; i++) {
				if (vec[i] == value) {
					return true;
				}
			}
			return false;
		}
	}

	static MyScanner in = new MyScanner();
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

	public static void main(String[] args) {

		LongSet set1 = new LongSet(1 << 20);
		LongSet set2 = new LongSet(1 << 20);
		int n = in.nextInt();
		String[] strings = new String[n];
		for (int i = 0; i < n; i++) {
			Set<Long> used = new HashSet<>();
			String s = in.next();
			strings[i] = s;
			char[] arr = s.toCharArray();
			for (int l = 0; l < arr.length; l++) {
				long h = 1;
				for (int j = l; j < arr.length; j++) {
					h = h * 5381 + arr[j] - '0' + 1;
					if (!used.contains(h) && set1.contains(h)) {
						set2.add(h);
					} else {
						set1.add(h);
					}
					used.add(h);
				}
			}
		}
		for (int i = 0; i < n; i++) {
			String s = strings[i];
			int min = 100;
			int left = 0, right = 0;
			char[] arr = s.toCharArray();
			for (int l = 0; l < arr.length; l++) {
				long h = 1;
				for (int j = l; j < arr.length; j++) {
					h = h * 5381 + arr[j] - '0' + 1;
					if (set1.contains(h) && !set2.contains(h)) {
						if (j - l + 1 <= min) {
							left = l;
							right = j;
							min = j - l + 1;
						}
					}
				}
			}
			out.println(s.substring(left, right + 1));
		}

		/*
		 * Dont delete
		 */
		out.close();
		/*
		 *
		 */
	}

	// BIN seach
	// while (l != r) {
	// mid = (l + r) / 2;
	// if (check(mid)) {
	// ans = mid;
	// l = mid + 1;
	// } else {
	// r = mid;
	// }
	// }
	public static long GCD(long a, long b) {
		return b == 0 ? a : GCD(b, a % b);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

n = int(input())

s, p = {}, [''] * n

for k in range(n):

    p[k] = t = input()

    for q in [t[i: j] for i in range(9) for j in range(i + 1, 10)]:

        s[q] = -1 if q in s and s[q] != k else k

for q, k in s.items():

    if k >= 0 and len(p[k]) > len(q): p[k] = q

print('\n'.join(p))

# Made By Mostafa_Khaled


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class B {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        int h = Integer.parseInt(st.nextToken());
        StringBuilder sb = new StringBuilder();
        for(int i=1; i<=n-1; i++) {
          double val = Math.sqrt(i*1.0/(n))*h;
          sb.append(val + " ");

        }
        out.println(sb.toString());
        out.close(); System.exit(0);
    }
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j;
  long long N, H;
  cin >> N >> H;
  for (i = 1; i < N; i++) printf("%.6f ", ((float)sqrt(i) * H) / sqrt(N));
  return 0;
}


import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
public class subset {
	static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String str=scn.next();
		char ch=str.charAt(str.length()-1);
		long n = Long.valueOf(str.substring(0,str.length()-1));
		//System.out.println(n);
		long tot=0;
		if(n%4==1||n%4==2)
		{
			long cunt=n/2;
			tot=6*cunt+n-1;
			if(ch=='f')	tot+=1;
			if(ch=='e')	tot+=2;
				if(ch=='d')	tot+=3;
					if(ch=='a')	tot+=4;
						if(ch=='b')tot+=5;
							if(ch=='c')	tot+=6;
		}
		else if(n%4==3||n%4==0)
		{
			long cunt=(n-2)/2;
			tot=6*cunt+n-3;
			if(ch=='f')	tot+=1;
			if(ch=='e')	tot+=2;
				if(ch=='d')	tot+=3;
					if(ch=='a')	tot+=4;
						if(ch=='b')tot+=5;
							if(ch=='c')	tot+=6;
		}
		System.out.println(tot);
	}

}


# from __future__ import division, print_function

import sys
import os
from io import BytesIO, IOBase

# def inp(): return sys.stdin.readline().rstrip("\r\n") #for fast input

# n = int(os.read(0,100))
# if(n==1):
#     os.write(1,b'! 1')
#     sys.stdout.flush()
# else:
#     per = [0]*n
#     # print('? 2 1')
#     # sys.stdout.flush()
#     a1 = query(1,0)
#     # print('? 1 2')
#     # sys.stdout.flush()
#     a2 = int(query(0,1))
#     if(a2>a1):
#         max = 2
#         per[0] = a2
#     else:
#         max = 1
#         per[1] = a1
#     # print(per)
#     for i in range(3,n+1):
#         # print('? '+str(i)+" "+str(max))
#         # sys.stdout.flush()
#         a1 = int(query(i-1,max-1))
#         # print('? '+str(max)+' '+str(i))
#         # sys.stdout.flush()
#         a2  = int(query(max-1,i-1))
#         if(a1>a2):
#             per[i-1] = a1
#         else:
#             per[max-1] = a2
#             max = i
#         # print(per)
#     per[max-1] = n
#     # print('! ',end="")
#     # print(' '.join(str(per[i]) for i in range(len(per))))
#     # sys.stdout.flush()
#     os.write(1, b'! ')
#     os.write(1, b' '.join(str(x).encode('ascii') for x in per))

def isPrime(n) :
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def query(a):
    # print(1)
    os.write(1,b"%d\n" % a)
    return str(os.read(0,100))

def solve(case):
    cnt = 0
    primes = [2,3,5,7]
    div = []
    for i in range(len(primes)):
        # print(primes[i])
        # sys.stdout.flush()
        # ans = inp()
        ans = query(primes[i])
        # print(ans)
        if('yes' in ans):
            div.append(primes[i])
            cnt+=1

    if(cnt == 0):
        print('prime')
    else:
        if(len(div) == 1):
            i = div[0]
            x = 2
            cnt = 0
            while((i**x)<101):
                # print(i**x)
                # sys.stdout.flush()
                if('yes' in query(i**x)):
                    cnt+=1
                    break
                x+=1
            new = []
            for i in range(10,50):
                if(isPrime(i)):
                    new.append(i)
            for i in new:
                if(div[0]*i>100):
                    break
                # print(i)
                # sys.stdout.flush()
                if('yes' in query(i)):
                    cnt+=1
            if(cnt == 0):
                print('prime')
            else:
                print('composite')
        else:
            print('composite')

solve(1)

#include <bits/stdc++.h>
using namespace std;
bool prime(int x) {
  int cnt = 0;
  for (int i = 1; i <= x; i++)
    if (x % i == 0) cnt++;
  return (cnt <= 2);
}
void fl() { fflush(stdout); }
int kul[] = {4, 9, 25, 49};
char odg[5];
int main() {
  int prosti = 1;
  for (int i = 0; i < 4; i++) {
    printf("%d\n", kul[i]);
    fl();
    scanf("%s", odg);
    if (odg[0] == 'y') prosti = 0;
  }
  if (prosti) {
    int cnt = 0;
    for (int i = 2; i <= 50; i++) {
      if (prime(i)) {
        printf("%d\n", i);
        fl();
        scanf("%s", odg);
        if (odg[0] == 'y') cnt++;
      }
    }
    if (cnt >= 2) prosti = 0;
  }
  if (prosti == 1) {
    printf("prime\n");
    fl();
  } else {
    printf("composite\n");
    fl();
  }
  return 0;
}


n,c = map(int,input().split())
p=input().split()
t=input().split()
sl=0
sr=0
ti=0
for i in range(n):
    ti+=int(t[i])
    if int(p[i])-c*ti>=0:
        sl+=int(p[i])-c*ti
ti=0
for i in range(n):
    ti+=int(t[n-i-1])
    if int(p[n-i-1])-c*ti>=0:
        sr+=int(p[n-i-1])-c*ti
if sl == sr:
    print('Tie')
elif sl>sr:
    print('Limak')
else:
    print('Radewoosh')

Tie Tie Tie Tie Tie Tie Tie Tie Tie Tie Tie Limak Tie Radewoosh Tie Limak Tie Tie Tie Radewoosh Tie Tie Tie Tie Tie Tie Radewoosh Limak Tie Tie

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, c;
  cin >> n >> c;
  int p[n], t[n], a[n], b[n];
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  a[0] = t[0];
  for (int i = 1; i < n; i++) a[i] = t[i] + a[i - 1];
  a[0] = max(0, p[0] - (c * a[0]));
  for (int i = 1; i < n; i++) a[i] = max(0, p[i] - (c * a[i]));
  b[n - 1] = t[n - 1];
  for (int i = n - 2; i >= 0; i--) b[i] = t[i] + b[i + 1];
  b[n - 1] = max(0, p[n - 1] - (c * b[n - 1]));
  for (int i = n - 2; i >= 0; i--) b[i] = max(0, p[i] - (c * b[i]));
  int l = 0, r = 0;
  for (int i = 0; i < n; i++) {
    l += a[i];
    r += b[i];
  }
  if (l == r) cout << "Tie";
  if (l > r) cout << "Limak";
  if (l < r) cout << "Radewoosh";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  double m;
  cin >> n;
  m = n;
  m = m / 2 + 0.5;
  n = n * m;
  cout << n * 6 + 1;
  return 0;
}


import java.util.*;

public class NEED {
    public static void main(String[] args) {
        String str;
        String com = "CODEFORCES";
        Scanner sca = new Scanner(System.in);
        while (sca.hasNext()) {
            str = sca.next();
            boolean flag = false;
            if (str.length() <= 10) {
                System.out.println("NO\n");
                continue;
            }

            if (str.substring(str.length() - 10, str.length()).equals(com)) {
                flag = true;
                // System.out.println("ss");

            }

            if (str.substring(0, 10).equals(com)) {
                flag = true;
                // System.out.println("ss");

            }

            // System.out.println(str.substring(0, 0));
            for (int i = 0; i < str.length(); i++) {
                for (int j = i + 2; j < str.length(); j++) {
                    if ((str.substring(0, i + 1) + str.substring(j,
                            str.length())).equals(com)) {
                        flag = true;
                        break;
                    }
                }
            }
            if (flag) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }
}

No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No Yes No No No Yes No No No No No No No No No No No No No No No No No No No No No No No No No Yes No No No No No

inp=input()
fl=False
for i in range(len(inp)):
	for j in range(i,len(inp)+1):
		if inp[:i]+inp[j:]=='CODEFORCES':
			fl=True
if fl:
	print('Yes')
else:
	print('No')


n = int(input())
arr = list(map(int,input().split()))
ans = []
for i in range(n):
	k = i
	for j in range(i+1,n):
		if arr[j]<arr[k]:
			k=j
	if k!=i:
		arr[k],arr[i]=arr[i],arr[k]
		ans.append([i,k])
print(len(ans))
if len(ans)>0:
	for i in ans:
		print(*i)


import java.util.ArrayList;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String letter =  in.nextLine();
       // letter = in.nextLine();
        if(letter.length()<=1000){
        letter = letter.substring(1, letter.length()-1);
        String [] all = letter.split(", ");
        String s="";
        for(int i=0; i<all.length; i++){
           if(!s.contains(all[i]))
               s = s + all[i];
        }

        System.out.println(s.length());
        }

    }

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  int i, x;
  set<char> b;
  getline(cin, a);
  for (i = 1; i < a.size() - 1; i += 3) {
    b.insert(a[i]);
  }
  cout << b.size() << endl;
  return 0;
}