### Prompt

Develop a solution in cpp to the problem described below:

When the river brought Gerda to the house of the Old Lady who Knew Magic, this lady decided to make Gerda her daughter. She wants Gerda to forget about Kay, so she puts all the roses from the garden underground.

Mole, who lives in this garden, now can watch the roses without going up to the surface. Typical mole is blind, but this mole was granted as special vision by the Old Lady. He can watch any underground objects on any distance, even through the obstacles and other objects. However, the quality of the picture depends on the Manhattan distance to object being observed.

Mole wants to find an optimal point to watch roses, that is such point with integer coordinates that the maximum Manhattan distance to the rose is minimum possible.

As usual, he asks you to help.

Manhattan distance between points (x1, y1, z1) and (x2, y2, z2) is defined as |x1 - x2| + |y1 - y2| + |z1 - z2|.

Input

The first line of the input contains an integer t t (1 ≤ t ≤ 100 000) — the number of test cases. Then follow exactly t blocks, each containing the description of exactly one test.

The first line of each block contains an integer ni (1 ≤ ni ≤ 100 000) — the number of roses in the test. Then follow ni lines, containing three integers each — the coordinates of the corresponding rose. Note that two or more roses may share the same position.

It's guaranteed that the sum of all ni doesn't exceed 100 000 and all coordinates are not greater than 1018 by their absolute value.

Output

For each of t test cases print three integers — the coordinates of the optimal point to watch roses. If there are many optimal answers, print any of them.

The coordinates of the optimal point may coincide with the coordinates of any rose.

Examples

Input

1
5
0 0 4
0 0 -4
0 4 0
4 0 0
1 1 1

Output

0 0 0

Input

2
1
3 5 9
2
3 5 9
3 5 9

Output

3 5 9
3 5 9

Note

In the first sample, the maximum Manhattan distance from the point to the rose is equal to 4.

In the second sample, the maximum possible distance is 0. Note that the positions of the roses may coincide with each other and with the position of the optimal point.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long v[100005][3];
long long a, b, c, sum, dif, x, ansx, ansy, ansz;
long long a1, a2, b1, b2, c1, c2, s1, s2;
long long l, r, mid;
int n;
const long long inf = 1ll << 62;
long long div2(long long x) {
  if (x < 0)
    return (x - 1) / 2;
  else
    return x / 2;
}
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
      scanf("%I64d%I64d%I64d", &v[i][0], &v[i][1], &v[i][2]);
    l = 0, r = inf;
    while (l <= r) {
      mid = (l + r) / 2;
      a1 = b1 = c1 = s1 = -inf;
      a2 = b2 = c2 = s2 = inf;
      for (int i = 1; i <= n; i++) {
        a1 = max(v[i][1] + v[i][2] - v[i][0] - mid, a1);
        a2 = min(v[i][1] + v[i][2] - v[i][0] + mid, a2);
        b1 = max(v[i][0] + v[i][2] - v[i][1] - mid, b1);
        b2 = min(v[i][0] + v[i][2] - v[i][1] + mid, b2);
        c1 = max(v[i][0] + v[i][1] - v[i][2] - mid, c1);
        c2 = min(v[i][0] + v[i][1] - v[i][2] + mid, c2);
        s1 = max(v[i][0] + v[i][1] + v[i][2] - mid, s1);
        s2 = min(v[i][0] + v[i][1] + v[i][2] + mid, s2);
      }
      if (a1 > a2 || b1 > b2 || c1 > c2 || s1 > s2) {
        l = mid + 1;
        continue;
      }
      long long xmn = max(div2(s1 - a2 + 1), div2(b1 + c1 + 1));
      long long xmx = min(div2(s2 - a1), div2(b2 + c2));
      for (x = xmn; x <= xmx; x++) {
        for (sum = max(a1 + x, s1 - x); sum <= min(a2 + x, s2 - x); sum++) {
          for (dif = max(x - b2, c1 - x); dif <= min(x - b1, c2 - x); dif++)
            if ((sum + dif) % 2 == 0) break;
          if (dif <= min(x - b1, c2 - x)) break;
        }
        if (sum <= min(a2 + x, s2 - x)) break;
      }
      if (x <= xmx) {
        ansx = x;
        ansy = div2(sum + dif);
        ansz = div2(sum - dif);
        r = mid - 1;
      } else
        l = mid + 1;
    }
    printf("%I64d %I64d %I64d\n", ansx, ansy, ansz);
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

You are given a string s, consisting of lowercase Latin letters. While there is at least one character in the string s that is repeated at least twice, you perform the following operation:

  * you choose the index i (1 ≤ i ≤ |s|) such that the character at position i occurs at least two times in the string s, and delete the character at position i, that is, replace s with s_1 s_2 … s_{i-1} s_{i+1} s_{i+2} … s_n.

For example, if s="codeforces", then you can apply the following sequence of operations:

  * i=6 ⇒ s="codefrces";
  * i=1 ⇒ s="odefrces";
  * i=7 ⇒ s="odefrcs";

Given a given string s, find the lexicographically maximum string that can be obtained after applying a certain sequence of operations after which all characters in the string become unique.

A string a of length n is lexicographically less than a string b of length m, if:

  * there is an index i (1 ≤ i ≤ min(n, m)) such that the first i-1 characters of the strings a and b are the same, and the i-th character of the string a is less than i-th character of string b;
  * or the first min(n, m) characters in the strings a and b are the same and n < m.

For example, the string a="aezakmi" is lexicographically less than the string b="aezus".

Input

The first line contains one integer t (1 ≤ t ≤ 10^4). Then t test cases follow.

Each test case is characterized by a string s, consisting of lowercase Latin letters (1 ≤ |s| ≤ 2 ⋅ 10^5).

It is guaranteed that the sum of the lengths of the strings in all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case, output the lexicographically maximum string that can be obtained after applying a certain sequence of operations after which all characters in the string become unique.

Example

Input

6
codeforces
aezakmi
abacaba
convexhull
swflldjgpaxs
myneeocktxpqjpz

Output

odfrces
ezakmi
cba
convexhul
wfldjgpaxs
myneocktxqjpz

### Response

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

/*
find my code templates at https://github.com/galencolin/cp-templates
also maybe subscribe please thanks
*/

#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}

mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 rng(61378913);
/* usage - just do rng() */

void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}

// #include <atcoder/all>
// using namespace atcoder;

const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;

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

void solve(int tc = 0) {
	cin >> s;
	n = s.length();

	ll vis[26];
	ll cnt[26] = {0};

	for (char c: s) ++cnt[c - 'a'];
	for (ll i = 0; i < 26; i++) vis[i] = !cnt[i];

	vector<ll> inds;
	inds.push_back(-1);

	for (ll i = 0; i < 26; i++) {
		bool pos = 0;
		for (ll j = 25; j >= 0; j--) {
			if (!vis[j]) {
				for (ll k = inds.back() + 1; k < n; k++) {
					if (s[k] - 'a' == j) {
						for (ll l = inds.back() + 1; l < k; l++) {
							--cnt[s[l] - 'a'];
						}
						bool can = 1;
						for (ll v = 0; v < 26; v++) {
							if (!vis[v] && cnt[v] == 0) {
								can = 0;
								break;
							}
						}
						if (can) {
							pos = 1;
							inds.push_back(k);
							vis[j] = 1;
						} else {
							for (ll l = inds.back() + 1; l < k; l++) {
								++cnt[s[l] - 'a'];
							}
						}
						break;
					}
				}
				if (pos) break;
			}
		}
	}

	for (ll x: inds) if (x != -1) cout << s[x];
	cout << '\n';
}

int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif

	send help

	#ifndef galen_colin_local
		// usaco("code");
	#endif

	// usaco("cowland");

	// freopen("tc.cpp", "r", stdin);
	// freopen("tc2.cpp", "w", stdout);

	cout << setprecision(15) << fixed;

	int tc = 1;
	cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);

	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cerr << setprecision(4) << fixed;
		// cerr << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
}
```


### Prompt

Please create a solution in CPP to the following problem:

Your favorite shop sells n Kinder Surprise chocolate eggs. You know that exactly s stickers and exactly t toys are placed in n eggs in total.

Each Kinder Surprise can be one of three types:

  * it can contain a single sticker and no toy;
  * it can contain a single toy and no sticker;
  * it can contain both a single sticker and a single toy.

But you don't know which type a particular Kinder Surprise has. All eggs look identical and indistinguishable from each other.

What is the minimum number of Kinder Surprise Eggs you have to buy to be sure that, whichever types they are, you'll obtain at least one sticker and at least one toy?

Note that you do not open the eggs in the purchasing process, that is, you just buy some number of eggs. It's guaranteed that the answer always exists.

Input

The first line contains the single integer T (1 ≤ T ≤ 100) — the number of queries.

Next T lines contain three integers n, s and t each (1 ≤ n ≤ 10^9, 1 ≤ s, t ≤ n, s + t ≥ n) — the number of eggs, stickers and toys.

All queries are independent.

Output

Print T integers (one number per query) — the minimum number of Kinder Surprise Eggs you have to buy to be sure that, whichever types they are, you'll obtain at least one sticker and one toy

Example

Input

3
10 5 7
10 10 10
2 1 1

Output

6
1
2

Note

In the first query, we have to take at least 6 eggs because there are 5 eggs with only toy inside and, in the worst case, we'll buy all of them.

In the second query, all eggs have both a sticker and a toy inside, that's why it's enough to buy only one egg.

In the third query, we have to buy both eggs: one with a sticker and one with a toy.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, s, t, q, i, z, x;
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> n >> s >> t;
    if (n - s >= n - t && s + t >= n) {
      cout << n - s + 1 << endl;
    } else if (n - t >= n - s && s + t >= n) {
      cout << n - t + 1 << endl;
    }
  }
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Sometime the classic solution are not powerful enough and we have to design our own. For the purpose of this problem you have to implement the part of the system of task scheduling.

Each task should be executed at some particular moments of time. In our system you may set the exact value for the second, minute, hour, day of the week, day and month, when the task should be executed. Moreover, one can set a special value -1 that means any value of this parameter is valid.

For example, if the parameter string is -1 59 23 -1 -1 -1, the problem will be executed every day at 23:59:00, 23:59:01, 23:59:02, ..., 23:59:59 (60 times in total).

Seconds, minutes and hours are numbered starting from zero, while day, months and days of the week are numbered starting from one. The first day of the week is Monday.

There is one special case that is treated separately. If both day of the week and day are given (i.e. differ from -1) to execute the task only one of these two (at least one, if both match this is fine too) parameters should match the current time (of course, all other parameters should match too). For example, the string of parameters 0 0 12 6 3 7 means that the task will be executed both on Saturday, July 2nd, 2016 and on Sunday, July 3rd, 2016 at noon.

One should not forget about the existence of the leap years. The year is leap if it's number is divisible by 400, or is not divisible by 100, but is divisible by 4. Each leap year has 366 days instead of usual 365, by extending February to 29 days rather than the common 28.

The current time is represented as the number of seconds passed after 00:00:00 January 1st, 1970 (Thursday).

You are given the string of six parameters, describing the moments of time the task should be executed. You are also given a number of moments of time. For each of them you have to find the first moment of time strictly greater than the current when the task will be executed.

Input

The first line of the input contains six integers s, m, h, day, date and month (0 ≤ s, m ≤ 59, 0 ≤ h ≤ 23, 1 ≤ day ≤ 7, 1 ≤ date ≤ 31, 1 ≤ month ≤ 12). Each of the number can also be equal to  - 1. It's guaranteed, that there are infinitely many moments of time when this task should be executed.

Next line contains the only integer n (1 ≤ n ≤ 1000) — the number of moments of time you have to solve the problem for. Each of the next n lines contains a single integer ti (0 ≤ ti ≤ 1012).

Output

Print n lines, the i-th of them should contain the first moment of time strictly greater than ti, when the task should be executed.

Examples

Input

-1 59 23 -1 -1 -1
6
1467372658
1467417540
1467417541
1467417598
1467417599
1467417600

Output

1467417540
1467417541
1467417542
1467417599
1467503940
1467503940

Input

0 0 12 6 3 7
3
1467372658
1467460810
1467547200

Output

1467460800
1467547200
1468065600

Note

The moment of time 1467372658 after the midnight of January 1st, 1970 is 11:30:58 July 1st, 2016.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int sec[86500], cs, day[150000], ds, cur;
int s, m, h, d, dt, mt, T;
long long perioid, dd, ss, x, ans;
bool leap(int y) {
  if (y % 4) return false;
  if (y % 100) return true;
  if (y % 400) return false;
  return true;
}
int leap_month(int y, int m) { return (leap(y) && m == 1); }
bool valid(int _mt, int _dt, int _d) {
  if (mt != -1 && mt != _mt) return false;
  if ((dt == -1 && d == -1) || dt == _dt || d == _d) return true;
  return false;
}
const int dmon[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void prepare() {
  for (int i = 0; i < 24; i++)
    if (h == -1 || h == i)
      for (int j = 0; j < 60; j++)
        if (m == -1 || m == j)
          for (int k = 0; k < 60; k++)
            if (s == -1 || s == k) sec[cs++] = i * 3600 + j * 60 + k;
  for (int i = 0; i < 400; i++) {
    for (int j = 0; j < 12; j++) {
      int tot = dmon[j] + leap_month(i + 1970, j);
      for (int k = 0; k < tot; k++) {
        if (valid(j, k, (cur + 3) % 7)) day[ds++] = cur;
        cur++;
      }
    }
  }
  perioid = cur * 86400ll;
}
int main() {
  scanf("%d %d %d %d %d %d", &s, &m, &h, &d, &dt, &mt);
  if (d > 0) d--;
  if (dt > 0) dt--;
  if (mt > 0) mt--;
  prepare();
  for (scanf("%d", &T); T--;) {
    scanf("%I64d", &x);
    ans = x - x % perioid;
    x = x - ans;
    dd = x / 86400;
    ss = x % 86400;
    int it = lower_bound(day, day + ds, dd) - day;
    if (it == ds)
      ans += perioid + day[0] * 86400ll + sec[0];
    else if (day[it] > dd)
      ans += day[it] * 86400ll + sec[0];
    else {
      int id = upper_bound(sec, sec + cs, ss) - sec;
      if (id < cs)
        ans += day[it] * 86400ll + sec[id];
      else {
        it++;
        if (it == ds)
          ans += perioid + day[0] * 86400ll + sec[0];
        else
          ans += day[it] * 86400ll + sec[0];
      }
    }
    printf("%I64d\n", ans);
  }
}

```


### Prompt

Your task is to create a cpp solution to the following problem:

A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.

The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.

Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.

If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.

Input

The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).

Output

Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.

Examples

Input

1033

Output

33

Input

10

Output

0

Input

11

Output

-1

Note

In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n[100005];
char in[100005];
vector<int> m[3];
void print(int l, int p = -1, int q = -1) {
  bool flag = false;
  int c = (p < 0 ? 0 : 1) + (q < 0 ? 0 : 1);
  for (int i = 0; i < l; i++) {
    if (i != p && i != q) {
      if (!(n[i] == 0 && !flag)) {
        printf("%d", n[i]);
        flag = true;
      }
    }
  }
  if (!flag) printf("%s", l <= c ? "-1" : "0");
  puts("");
}
int main() {
  scanf("%s", in);
  int l = strlen(in), t = 0;
  for (int i = 0; i < l; i++) {
    n[i] = in[i] - '0';
    t = (t + n[i]) % 3;
    if (n[i] % 3 == 1) m[1].push_back(i);
    if (n[i] % 3 == 2) m[2].push_back(i);
  }
  if (t == 0)
    print(l);
  else {
    if (m[t].size() > 0) {
      if (m[t].size() == 1 && m[t][0] == 0 && n[1] == 0 &&
          m[t == 1 ? 2 : 1].size() >= 2)
        print(l, m[t == 1 ? 2 : 1][m[t == 1 ? 2 : 1].size() - 2],
              m[t == 1 ? 2 : 1].back());
      else
        print(l, m[t].back());
    } else if (m[t == 1 ? 2 : 1].size() >= 2)
      print(l, m[t == 1 ? 2 : 1][m[t == 1 ? 2 : 1].size() - 2],
            m[t == 1 ? 2 : 1].back());
    else
      puts("-1");
  }
  return 0;
}

```


### Prompt

Please provide a CPP coded solution to the problem described below:

You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n points, which area exceeds S.

Alyona tried to construct a triangle with integer coordinates, which contains all n points and which area doesn't exceed 4S, but, by obvious reason, had no success in that. Please help Alyona construct such triangle. Please note that vertices of resulting triangle are not necessarily chosen from n given points.

Input

In the first line of the input two integers n and S (3 ≤ n ≤ 5000, 1 ≤ S ≤ 1018) are given — the number of points given and the upper bound value of any triangle's area, formed by any three of given n points.

The next n lines describes given points: ith of them consists of two integers xi and yi ( - 108 ≤ xi, yi ≤ 108) — coordinates of ith point.

It is guaranteed that there is at least one triple of points not lying on the same line.

Output

Print the coordinates of three points — vertices of a triangle which contains all n points and which area doesn't exceed 4S.

Coordinates of every triangle's vertex should be printed on a separate line, every coordinate pair should be separated by a single space. Coordinates should be an integers not exceeding 109 by absolute value.

It is guaranteed that there is at least one desired triangle. If there is more than one answer, print any of them.

Example

Input

4 1
0 0
1 0
0 1
1 1

Output

-1 0
2 0
0 2

Note

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
long long m, res;
int n, i, j, k, cnt, tp;
struct ii {
  int x, y;
} a[5005], stk[5005], b[5005], s1, s2, s3, sm;
bool cmp(ii x, ii y) {
  if (x.x == y.x) return x.y > y.y;
  return x.x < y.x;
}
ii operator-(ii x, ii y) { return (ii){x.x - y.x, x.y - y.y}; }
ii operator+(ii x, ii y) { return (ii){x.x + y.x, x.y + y.y}; }
long long crs(ii x, ii y) { return 1ll * x.x * y.y - 1ll * x.y * y.x; }
int main() {
  read(n);
  read(m);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    read(a[i].x);
    read(a[i].y);
  }
  sort(a + 1, a + n + 1, cmp);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    while (tp > 1 && crs(stk[tp] - stk[tp - 1], a[i] - stk[tp]) >= 0) {
      tp--;
    }
    stk[++tp] = a[i];
  }
  for (((i)) = (1); ((i)) <= ((tp - 1)); ((i))++) b[++cnt] = stk[i];
  tp = 0;
  for (((i)) = ((n)); ((i)) >= (1); ((i))--) {
    while (tp > 1 && crs(stk[tp] - stk[tp - 1], a[i] - stk[tp]) >= 0) {
      tp--;
    }
    stk[++tp] = a[i];
  }
  for (((i)) = (1); ((i)) <= ((tp - 1)); ((i))++) b[++cnt] = stk[i];
  b[cnt + 1] = b[1];
  for (((i)) = (1); ((i)) <= ((cnt - 2)); ((i))++) {
    k = i + 2;
    for (j = i + 1; j <= cnt - 1; j++) {
      while (k <= cnt && crs(b[k] - b[i], b[j] - b[i]) <=
                             crs(b[k + 1] - b[i], b[j] - b[i])) {
        k++;
      }
      if (crs(b[k] - b[i], b[j] - b[i]) > res) {
        res = crs(b[k] - b[i], b[j] - b[i]);
        s1 = b[i];
        s2 = b[j];
        s3 = b[k];
      }
    }
  }
  sm = s1 + s2 + s3;
  s1 = sm - s1 - s1;
  s2 = sm - s2 - s2;
  s3 = sm - s3 - s3;
  printf("%d %d\n", s1.x, s1.y);
  printf("%d %d\n", s2.x, s2.y);
  printf("%d %d\n", s3.x, s3.y);
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.

Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence.

Here, the distance between two points s and t on a number line is represented by |s-t|.

Constraints

* 1 \leq x \leq 1000
* 1 \leq a \leq 1000
* 1 \leq b \leq 1000
* x, a and b are pairwise distinct.
* The distances between Snuke's residence and stores A and B are different.

Input

Input is given from Standard Input in the following format:

x a b

Output

If store A is closer, print `A`; if store B is closer, print `B`.

Examples

Input

5 2 7

Output

B

Input

1 999 1000

Output

A

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b; cin>>x>>a>>b;
   if(abs(x-a)<abs(x-b))
        cout<<"A"<<"\n";
    else cout<<"B"<<"\n";
}

```


### Prompt

Generate a CPP solution to the following problem:

Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.

All children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to n in the order they go in the line. Every child is associated with the value of his cofidence pi. The children take turns one after another to come into the office; each time the child that is the first in the line goes to the doctor.

While Gennady treats the teeth of the i-th child, the child is crying with the volume of vi. At that the confidence of the first child in the line is reduced by the amount of vi, the second one — by value vi - 1, and so on. The children in the queue after the vi-th child almost do not hear the crying, so their confidence remains unchanged.

If at any point in time the confidence of the j-th child is less than zero, he begins to cry with the volume of dj and leaves the line, running towards the exit, without going to the doctor's office. At this the confidence of all the children after the j-th one in the line is reduced by the amount of dj.

All these events occur immediately one after the other in some order. Some cries may lead to other cries, causing a chain reaction. Once in the hallway it is quiet, the child, who is first in the line, goes into the doctor's office.

Help Gennady the Dentist to determine the numbers of kids, whose teeth he will cure. Print their numbers in the chronological order.

Input

The first line of the input contains a positive integer n (1 ≤ n ≤ 4000) — the number of kids in the line.

Next n lines contain three integers each vi, di, pi (1 ≤ vi, di, pi ≤ 106) — the volume of the cry in the doctor's office, the volume of the cry in the hall and the confidence of the i-th child.

Output

In the first line print number k — the number of children whose teeth Gennady will cure.

In the second line print k integers — the numbers of the children who will make it to the end of the line in the increasing order.

Examples

Input

5
4 2 2
4 1 2
5 2 4
3 3 5
5 1 2

Output

2
1 3

Input

5
4 5 1
5 3 9
4 1 2
2 1 8
4 1 9

Output

4
1 2 4 5

Note

In the first example, Gennady first treats the teeth of the first child who will cry with volume 4. The confidences of the remaining children will get equal to  - 2, 1, 3, 1, respectively. Thus, the second child also cries at the volume of 1 and run to the exit. The confidence of the remaining children will be equal to 0, 2, 0. Then the third child will go to the office, and cry with volume 5. The other children won't bear this, and with a loud cry they will run to the exit.

In the second sample, first the first child goes into the office, he will cry with volume 4. The confidence of the remaining children will be equal to 5, - 1, 6, 8. Thus, the third child will cry with the volume of 1 and run to the exit. The confidence of the remaining children will be equal to 5, 5, 7. After that, the second child goes to the office and cry with the volume of 5. The confidences of the remaining children will be equal to 0, 3. Then the fourth child will go into the office and cry with the volume of 2. Because of this the confidence of the fifth child will be 1, and he will go into the office last.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void itval(istream_iterator<string> it) {}
template <typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  itval(++it, args...);
}
const long long int MOD = 1e9 + 7;
template <typename T>
inline void print(T x) {
  cout << x << "\n";
}
template <typename T>
inline void printvec(T x) {
  for (auto a : x) cout << a << ' ';
  cout << '\n';
}
struct custom {
  bool operator()(const pair<long long int, long long int> &p1,
                  const pair<long long int, long long int> &p2) const {
    if (p1.first == p2.first) return p2.second < p1.second;
    return p1.first < p2.first;
  }
};
long long int get_pow(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
const long long int N = 1e3 + 10, inf = 1e17;
void solve() {
  int n;
  cin >> n;
  std::vector<long long int> v(n), p(n), d(n);
  for (long long int i = (long long int)0; i < (long long int)(n); i++) {
    cin >> v[i] >> d[i] >> p[i];
  }
  vector<long long> ans;
  vector<bool> used(n, false);
  for (long long int i = (long long int)0; i < (long long int)(n); i++) {
    if (used[i]) continue;
    long long int now = v[i];
    ans.push_back(i + 1);
    queue<int> q;
    for (int j = i + 1; j < n && now > 0; j++) {
      if (used[j]) continue;
      p[j] -= now;
      if (p[j] < 0) {
        q.push(j);
        used[j] = 1;
      }
      now--;
    }
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      for (long long int j = (long long int)t + 1; j < (long long int)(n);
           j++) {
        if (!used[j]) {
          p[j] -= d[t];
          if (p[j] < 0) {
            used[j] = 1;
            q.push(j);
          }
        }
      }
    }
  }
  cout << ans.size() << '\n';
  printvec(ans);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  clock_t z = clock();
  for (long long int tes = (long long int)0; tes < (long long int)(test);
       tes++) {
    solve();
  }
  fprintf(stderr, "Total Time:%.4f\n", (double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
  return 0;
}

```


### Prompt

In CPP, your task is to solve the following problem:

Recently, the bear started studying data structures and faced the following problem.

You are given a sequence of integers x1, x2, ..., xn of length n and m queries, each of them is characterized by two integers li, ri. Let's introduce f(p) to represent the number of such indexes k, that xk is divisible by p. The answer to the query li, ri is the sum: <image>, where S(li, ri) is a set of prime numbers from segment [li, ri] (both borders are included in the segment).

Help the bear cope with the problem.

Input

The first line contains integer n (1 ≤ n ≤ 106). The second line contains n integers x1, x2, ..., xn (2 ≤ xi ≤ 107). The numbers are not necessarily distinct.

The third line contains integer m (1 ≤ m ≤ 50000). Each of the following m lines contains a pair of space-separated integers, li and ri (2 ≤ li ≤ ri ≤ 2·109) — the numbers that characterize the current query.

Output

Print m integers — the answers to the queries on the order the queries appear in the input.

Examples

Input

6
5 5 7 10 14 15
3
2 11
3 12
4 4

Output

9
7
0

Input

7
2 3 5 7 11 4 8
2
8 10
2 123

Output

0
7

Note

Consider the first sample. Overall, the first sample has 3 queries.

  1. The first query l = 2, r = 11 comes. You need to count f(2) + f(3) + f(5) + f(7) + f(11) = 2 + 1 + 4 + 2 + 0 = 9.
  2. The second query comes l = 3, r = 12. You need to count f(3) + f(5) + f(7) + f(11) = 1 + 4 + 2 + 0 = 7.
  3. The third query comes l = 4, r = 4. As this interval has no prime numbers, then the sum equals 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long d[10000005];
int snt[664600], dem;
bool p[10000005];
void sieve() {
  int i, j;
  snt[0] = 2, dem = 1;
  p[0] = p[1] = true;
  for (i = 4; i <= 1e7; i += 2) p[i] = true;
  for (i = 3; i <= 3163; i += 2)
    if (!p[i]) {
      snt[dem++] = i;
      for (j = i * i; j <= 1e7; j += i) p[j] = true;
    }
  for (; i <= 1e7; i += 2)
    if (!p[i]) snt[dem++] = i;
}
void factor(int x) {
  int i;
  if (!p[x]) {
    d[x]++;
    return;
  }
  for (i = 0; i < dem && snt[i] * snt[i] <= x; i++)
    if (x % snt[i] == 0) {
      d[snt[i]]++;
      while (x % snt[i] == 0) x /= snt[i];
    }
  if (x != 1) d[x]++;
}
void input() {
  int i, n, l, r, x, nq;
  sieve();
  scanf("%d", &n);
  for ((i) = 0; (i) < (n); (i)++) scanf("%d", &x), factor(x);
  for ((i) = (3); (i) <= (10000000); (i)++) d[i] += d[i - 1];
  scanf("%d", &nq);
  while (nq--) {
    scanf("%d %d", &l, &r);
    l = ((l) < (10000000) ? (l) : (10000000));
    r = ((r) < (10000000) ? (r) : (10000000));
    printf("%I64d\n", d[r] - d[l - 1]);
  }
}
int main() {
  input();
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You were dreaming that you are traveling to a planet named Planetforces on your personal spaceship. Unfortunately, its piloting system was corrupted and now you need to fix it in order to reach Planetforces.

<image>

Space can be represented as the XY plane. You are starting at point (0, 0), and Planetforces is located in point (p_x, p_y).

The piloting system of your spaceship follows its list of orders which can be represented as a string s. The system reads s from left to right. Suppose you are at point (x, y) and current order is s_i:

  * if s_i = U, you move to (x, y + 1);
  * if s_i = D, you move to (x, y - 1);
  * if s_i = R, you move to (x + 1, y);
  * if s_i = L, you move to (x - 1, y).

Since string s could be corrupted, there is a possibility that you won't reach Planetforces in the end. Fortunately, you can delete some orders from s but you can't change their positions.

Can you delete several orders (possibly, zero) from s in such a way, that you'll reach Planetforces after the system processes all orders?

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.

Each test case consists of two lines. The first line in each test case contains two integers p_x and p_y (-10^5 ≤ p_x, p_y ≤ 10^5; (p_x, p_y) ≠ (0, 0)) — the coordinates of Planetforces (p_x, p_y).

The second line contains the string s (1 ≤ |s| ≤ 10^5: |s| is the length of string s) — the list of orders.

It is guaranteed that the sum of |s| over all test cases does not exceed 10^5.

Output

For each test case, print "YES" if you can delete several orders (possibly, zero) from s in such a way, that you'll reach Planetforces. Otherwise, print "NO". You can print each letter in any case (upper or lower).

Example

Input

6
10 5
RRRRRRRRRRUUUUU
1 1
UDDDRLLL
-3 -5
LDLDLDDDR
1 2
LLLLUU
3 -2
RDULRLLDR
-1 6
RUDURUUUUR

Output

YES
YES
YES
NO
YES
NO

Note

In the first case, you don't need to modify s, since the given s will bring you to Planetforces.

In the second case, you can delete orders s_2, s_3, s_4, s_6, s_7 and s_8, so s becomes equal to "UR".

In the third test case, you have to delete order s_9, otherwise, you won't finish in the position of Planetforces.

### Response

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

int main() {
	// your code goes here

	long long int t;
	cin>>t;

	while(t--){

	int x,y;

	cin>>x>>y;

   string s;
	cin>>s;

	int r=0;
	int l=0;
	int d=0;
	int u=0;

	for(int i=0;i<s.size();i++){
	    if(s[i]=='R')r++;
	    else if(s[i]=='L')l++;
	    else if(s[i]=='U')u++;
	    else if(s[i]=='D')d++;
	}

// 	cout<<r<<l<<u<<d<<endl;

	if(x>=0 && y>=0){
	   // cout<<"Debug"<<endl;
	    if(x<=r && y<=u){
	        cout<<"YES"<<endl;
	    }
	    else{
	        cout<<"NO"<<endl;
	    }
	}
	else if(x>=0 && y<=0){
	    if(x<=r && abs(y)<=d){
	        cout<<"YES"<<endl;
	    }
	    else{
	        cout<<"NO"<<endl;
	    }
	}

	else if(x<=0 && y>=0){
	    if(abs(x)<=l && y<=u){
	        cout<<"YES"<<endl;
	    }
	    else{
	        cout<<"NO"<<endl;
	    }
	}
	else if(x<=0 && y<=0){
	    if(abs(x)<=l && abs(y)<=d){
	        cout<<"YES"<<endl;
	    }
	    else{
	        cout<<"NO"<<endl;
	    }
	}

	}
	return 0;
}

```


### Prompt

In cpp, your task is to solve the following problem:

After a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the first one. She wants to avoid meeting the Daleks inside the Time Vortex, so for abundance of caution she considers placing the traps only along those Corridors that are not going to be used according to the current Daleks' plan – which is to use a minimum spanning tree of Corridors. Heidi knows that all energy requirements for different Corridors are now different, and that the Daleks have a single unique plan which they are intending to use.

Your task is to calculate the number E_{max}(c), which is defined in the same way as in the easy version – i.e., the largest e ≤ 10^9 such that if we changed the energy of corridor c to e, the Daleks might use it – but now for every corridor that Heidi considers.

Input

The first line: number n of destinations, number m of Time Corridors (2 ≤ n ≤ 10^5, n - 1 ≤ m ≤ 10^6). The next m lines: destinations a, b and energy e (1 ≤ a, b ≤ n, a ≠ b, 0 ≤ e ≤ 10^9).

No pair \\{a, b\} will repeat. The graph is guaranteed to be connected. All energy requirements e are distinct.

Output

Output m-(n-1) lines, each containing one integer: E_{max}(c_i) for the i-th Corridor c_i from the input that is not part of the current Daleks' plan (minimum spanning tree).

Example

Input

3 3
1 2 8
2 3 3
3 1 4

Output

4

Note

If m = n-1, then you need not output anything.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
const int MAXN = 1e6 + 7;
vector<pair<pair<int, int>, pair<int, int>>> e;
int n, m, root[MAXN], used[MAXN];
pair<pair<int, int>, pair<int, int>> firste;
vector<pair<int, int>> G[MAXN];
int par[MAXN][20], depth[MAXN], cost[MAXN][20];
int findroot(int x) {
  if (x != root[x]) root[x] = findroot(root[x]);
  return root[x];
}
void dfs(int u, int f) {
  depth[u] = depth[f] + 1;
  par[u][0] = f;
  for (int i = 1; par[u][i - 1]; i++) {
    par[u][i] = par[par[u][i - 1]][i - 1];
    cost[u][i] = max(cost[u][i - 1], cost[par[u][i - 1]][i - 1]);
  }
  for (auto E : G[u]) {
    int v = E.first;
    int c = E.second;
    if (v == f) continue;
    cost[v][0] = c;
    dfs(v, u);
  }
}
int ikun(int u, int v) {
  int maxx = 0;
  if (depth[u] < depth[v]) swap(u, v);
  for (int i = 0; depth[u] - depth[v]; i++)
    if ((depth[u] - depth[v]) & (1 << i)) {
      maxx = max(maxx, cost[u][i]);
      u = par[u][i];
    }
  if (u == v) return maxx;
  for (int i = 19; i >= 0; i--)
    if (par[u][i] != par[v][i]) {
      maxx = max(maxx, max(cost[u][i], cost[v][i]));
      u = par[u][i];
      v = par[v][i];
    }
  return max(maxx, max(cost[u][0], cost[v][0]));
}
int main() {
  scanf("%d %d", &n, &m);
  e.resize(m);
  for (int i = 0; i < m; i++)
    scanf("%d %d %d", &e[i].first.first, &e[i].first.second,
          &e[i].second.first);
  for (int i = 0; i < m; i++) e[i].second.second = i;
  sort(e.begin(), e.end(),
       [](const pair<pair<int, int>, pair<int, int>> &A,
          const pair<pair<int, int>, pair<int, int>> &B) {
         return A.second.first < B.second.first;
       });
  for (int i = 1; i <= n; i++) root[i] = i;
  for (int i = 0; i < m; i++) {
    int u = e[i].first.first;
    int v = e[i].first.second;
    if (findroot(u) == findroot(v)) continue;
    root[findroot(u)] = findroot(v);
    used[e[i].second.second] = 1;
  }
  for (int i = 0; i < m; i++) {
    if (!used[e[i].second.second]) continue;
    auto p = e[i];
    G[p.first.first].emplace_back(make_pair(p.first.second, p.second.first));
    G[p.first.second].emplace_back(make_pair(p.first.first, p.second.first));
  }
  dfs(1, 0);
  sort(e.begin(), e.end(),
       [](const pair<pair<int, int>, pair<int, int>> &A,
          const pair<pair<int, int>, pair<int, int>> &B) {
         return A.second.second < B.second.second;
       });
  for (int i = 0; i < m; i++)
    if (!used[i]) printf("%d\n", ikun(e[i].first.first, e[i].first.second));
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

One day Igor K. stopped programming and took up math. One late autumn evening he was sitting at a table reading a book and thinking about something.

The following statement caught his attention: "Among any six people there are either three pairwise acquainted people or three pairwise unacquainted people"

Igor just couldn't get why the required minimum is 6 people. "Well, that's the same for five people, too!" — he kept on repeating in his mind. — "Let's take, say, Max, Ilya, Vova — here, they all know each other! And now let's add Dima and Oleg to Vova — none of them is acquainted with each other! Now, that math is just rubbish!"

Igor K. took 5 friends of his and wrote down who of them is friends with whom. Now he wants to check whether it is true for the five people that among them there are either three pairwise acquainted or three pairwise not acquainted people.

Input

The first line contains an integer m (0 ≤ m ≤ 10), which is the number of relations of acquaintances among the five friends of Igor's.

Each of the following m lines contains two integers ai and bi (1 ≤ ai, bi ≤ 5;ai ≠ bi), where (ai, bi) is a pair of acquainted people. It is guaranteed that each pair of the acquaintances is described exactly once. The acquaintance relation is symmetrical, i.e. if x is acquainted with y, then y is also acquainted with x.

Output

Print "FAIL", if among those five people there are no either three pairwise acquainted or three pairwise unacquainted people. Otherwise print "WIN".

Examples

Input

4
1 3
2 3
1 4
5 3

Output

WIN

Input

5
1 2
2 3
3 4
4 5
5 1

Output

FAIL

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long double pi = 3.141592653589793238;
set<long long>::iterator it;
multiset<long long>::iterator itr;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t;
  t = 1;
  while (t--) {
    long long m;
    cin >> m;
    set<pair<long long, long long>> s1;
    for (long long i = 0; i < m; i++) {
      long long x, y;
      cin >> x >> y;
      s1.insert(make_pair(x, y));
      s1.insert(make_pair(y, x));
    }
    long long fl = 0;
    for (long long p1 = 1; p1 <= 5; p1++) {
      for (long long p2 = p1 + 1; p2 <= 5; p2++) {
        for (long long p3 = p2 + 1; p3 <= 5; p3++) {
          if (s1.find(make_pair(p1, p2)) != s1.end() &&
              s1.find(make_pair(p2, p3)) != s1.end() &&
              s1.find(make_pair(p3, p1)) != s1.end()) {
            fl = 1;
          } else if (s1.find(make_pair(p1, p2)) == s1.end() &&
                     s1.find(make_pair(p2, p3)) == s1.end() &&
                     s1.find(make_pair(p3, p1)) == s1.end()) {
            fl = 1;
          }
        }
      }
    }
    if (fl == 1)
      cout << "WIN" << endl;
    else
      cout << "FAIL" << endl;
  }
}

```


### Prompt

Please provide a cpp coded solution to the problem described below:

Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:

* update(s, t, x): change as, as+1, ..., at to x.
* find(i): output the value of ai.

Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 0 ≤ s ≤ t < n
* 0 ≤ i < n
* 0 ≤ x < 231−1

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 i

The first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(i).

Output

For each find operation, print the value.

Examples

Input

3 5
0 0 1 1
0 1 2 3
0 2 2 2
1 0
1 1

Output

1
3

Input

1 3
1 0
0 0 0 5
1 0

Output

2147483647
5

### Response

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

int N, Q;
int const INF = INT_MAX;
struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;

public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }

    void lazy_evaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] = lazy[k];
                lazy[2*k+2] = lazy[k];
                lazyFlag[2*k+1] = true;
                lazyFlag[2*k+2] = true;
            }
            lazyFlag[k] = false;
        }
    }

    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazy_evaluate(k, l, r);
        if(r <= a || b <= l) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazy_evaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[k*2+1], node[k*2+2]);
        }
    }

    int find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazy_evaluate(k, l, r);
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];
        int vl = find(a, b, 2*k+1, l, (l+r)/2);
        int vr = find(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main() {
    cin >> N >> Q;
    LazySegmentTree seg( vector<int>(N, INF) );
    for(int i=0; i<Q; i++) {
        int query; cin >> query;
        if(query == 0) {
            int s, t, x; cin >> s >> t >> x;
            seg.update(s, t+1, x);
        }
        else {
            int i; cin >> i;
            cout << seg.find(i, i+1) << endl;
        }
    }
    return 0;
}
```


### Prompt

Your challenge is to write a cpp solution to the following problem:

The screen that displays digital numbers that you often see on calculators is called a "7-segment display" because the digital numbers consist of seven parts (segments).

The new product to be launched by Wakamatsu will incorporate a 7-segment display into the product, and as an employee, you will create a program to display the given number on the 7-segment display.

This 7-segment display will not change until the next switch instruction is sent. By sending a signal consisting of 7 bits, the display information of each corresponding segment can be switched. Bits have a value of 1 or 0, where 1 stands for "switch" and 0 stands for "as is".

The correspondence between each bit and segment is shown in the figure below. The signal sends 7 bits in the order of "gfedcba". For example, in order to display "0" from the hidden state, "0111111" must be sent to the display as a signal. To change from "0" to "5", send "1010010". If you want to change "5" to "1" in succession, send "1101011".

<image>

Create a program that takes n (1 ≤ n ≤ 100) numbers that you want to display and outputs the signal sequence required to correctly display those numbers di (0 ≤ di ≤ 9) on the 7-segment display. please. It is assumed that the initial state of the 7-segment display is all hidden.

Input

A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of -1. Each dataset is given in the following format:

n
d1
d2
::
dn

The number of datasets does not exceed 120.

Output

For each input dataset, output the sequence of signals needed to properly output the numbers to the display.

Example

Input

3
0
5
1
1
0
-1

Output

0111111
1010010
1101011
0111111

### Response

```cpp
#include <iostream>

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

using namespace std;

static const bool PATTERN[11][7] =
{
	0, 1, 1, 1, 1, 1, 1,
	0, 0, 0, 0, 1, 1, 0,
	1, 0, 1, 1, 0, 1, 1,
	1, 0, 0, 1, 1, 1, 1,
	1, 1, 0, 0, 1, 1, 0,
	1, 1, 0, 1, 1, 0, 1,
	1, 1, 1, 1, 1, 0, 1,
	0, 1, 0, 0, 1, 1, 1,
	1, 1, 1, 1, 1, 1, 1,
	1, 1, 0, 1, 1, 1, 1,
	0, 0, 0, 0, 0, 0, 0
};

static const int DEFAULT = 10;

int main(void){
	for(int n; cin >> n, n != -1;){
		int preNum = DEFAULT;
		while(n --){
			int num; cin >> num;
			rep(i, 7) cout << (PATTERN[preNum][i] ^ PATTERN[num][i]);
			cout << endl;
			preNum = num;
		}
	}

	return 0;
}
```


### Prompt

Your challenge is to write a CPP solution to the following problem:

Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size ai dollars.

Each player can double his bid any number of times and triple his bid any number of times. The casino has a great jackpot for making all bids equal. Is it possible that Limak and his friends will win a jackpot?

Input

First line of input contains an integer n (2 ≤ n ≤ 105), the number of players.

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109) — the bids of players.

Output

Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise.

Examples

Input

4
75 150 75 50

Output

Yes

Input

3
100 150 250

Output

No

Note

In the first sample test first and third players should double their bids twice, second player should double his bid once and fourth player should both double and triple his bid.

It can be shown that in the second sample test there is no way to make all bids equal.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int factor(int a, int b) {
  while (a % b == 0) {
    a = a / b;
  }
  return a;
}
int num[100001];
int main() {
  int n;
  cin >> n;
  cin >> num[0];
  long long lcm = num[0];
  for (int i = 1; i < n; i++) {
    cin >> num[i];
    lcm = gcd(lcm, num[i]);
  }
  for (int i = 0; i < n; i++) {
    int tmp = num[i] / lcm;
    int res = factor(tmp, 2);
    if (res == 1 || factor(res, 3) == 1) continue;
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

It's Christmas time! PolandBall and his friends will be giving themselves gifts. There are n Balls overall. Each Ball has someone for whom he should bring a present according to some permutation p, pi ≠ i for all i.

Unfortunately, Balls are quite clumsy. We know earlier that exactly k of them will forget to bring their gift. A Ball number i will get his present if the following two constraints will hold:

  1. Ball number i will bring the present he should give.
  2. Ball x such that px = i will bring his present.

What is minimum and maximum possible number of kids who will not get their present if exactly k Balls will forget theirs?

Input

The first line of input contains two integers n and k (2 ≤ n ≤ 106, 0 ≤ k ≤ n), representing the number of Balls and the number of Balls who will forget to bring their presents.

The second line contains the permutation p of integers from 1 to n, where pi is the index of Ball who should get a gift from the i-th Ball. For all i, pi ≠ i holds.

Output

You should output two values — minimum and maximum possible number of Balls who will not get their presents, in that order.

Examples

Input

5 2
3 4 1 5 2

Output

2 4

Input

10 1
2 3 4 5 6 7 8 9 10 1

Output

2 2

Note

In the first sample, if the third and the first balls will forget to bring their presents, they will be th only balls not getting a present. Thus the minimum answer is 2. However, if the first ans the second balls will forget to bring their presents, then only the fifth ball will get a present. So, the maximum answer is 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, k, p[N];
int cnt[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", p + i);
  bitset<N> vis;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    int cur = i, cnt = 0;
    while (!vis[cur]) {
      cnt++;
      vis[cur] = 1;
      cur = p[cur];
    }
    v.push_back(cnt);
  }
  sort(v.begin(), v.end());
  int tmp = k;
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    cnt[v[i]]++;
    int x = min(tmp, v[i] / 2);
    ans += x * 2;
    v[i] -= x * 2;
    tmp -= x;
  }
  for (int i = 0; i < v.size(); i++) {
    int x = min(tmp, v[i]);
    ans += x;
    tmp -= x;
  }
  vis.reset();
  vis[0] = 1;
  int ans2 = k + 1;
  for (int i = 1; i <= k; i++) {
    if (i > 50) {
      for (int j = 0; j < cnt[i]; j++) {
        vis = (vis | (vis << i));
      }
    } else {
      if (!cnt[i]) continue;
      vector<deque<int>> dq(i);
      vector<int> sum(i);
      int cur = 0;
      for (int j = 0; j <= k; j++) {
        dq[cur].push_back(vis[j]);
        sum[cur] += vis[j];
        if (sum[cur]) vis[j] = 1;
        if (dq[cur].size() > cnt[i]) {
          sum[cur] -= dq[j % i].front();
          dq[cur].pop_front();
        }
        ++cur;
        if (cur == i) cur = 0;
      }
    }
  }
  if (vis[k]) ans2 = k;
  cout << ans2 << ' ' << ans << '\n';
  return 0;
}

```


### Prompt

Your challenge is to write a cpp solution to the following problem:

AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.

Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.

Constraints

* 1≦a,b,c≦100

Input

The input is given from Standard Input in the following format:

a b c

Output

Print the number of different kinds of colors of the paint cans.

Examples

Input

3 1 4

Output

3

Input

3 3 33

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
	set<int> s; int a;
	for(int i = 0; i < 3; i++) {
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;
	return 0;
}
```


### Prompt

Please create a solution in Cpp to the following problem:

Uh oh! Applications to tech companies are due soon, and you've been procrastinating by doing contests instead! (Let's pretend for now that it is actually possible to get a job in these uncertain times.)

You have completed many programming projects. In fact, there are exactly n types of programming projects, and you have completed a_i projects of type i. Your résumé has limited space, but you want to carefully choose them in such a way that maximizes your chances of getting hired.

You want to include several projects of the same type to emphasize your expertise, but you also don't want to include so many that the low-quality projects start slipping in. Specifically, you determine the following quantity to be a good indicator of your chances of getting hired:

$$$ f(b_1,…,b_n)=∑_{i=1}^n b_i(a_i-b_i^2). $$$

Here, b_i denotes the number of projects of type i you include in your résumé. Of course, you cannot include more projects than you have completed, so you require 0≤ b_i ≤ a_i for all i.

Your résumé only has enough room for k projects, and you will absolutely not be hired if your résumé has empty space, so you require ∑_{i=1}^n b_i=k.

Find values for b_1,…, b_n that maximize the value of f(b_1,…,b_n) while satisfying the above two constraints.

Input

The first line contains two integers n and k (1≤ n≤ 10^5, 1≤ k≤ ∑_{i=1}^n a_i) — the number of types of programming projects and the résumé size, respectively.

The next line contains n integers a_1,…,a_n (1≤ a_i≤ 10^9) — a_i is equal to the number of completed projects of type i.

Output

In a single line, output n integers b_1,…, b_n that achieve the maximum value of f(b_1,…,b_n), while satisfying the requirements 0≤ b_i≤ a_i and ∑_{i=1}^n b_i=k. If there are multiple solutions, output any.

Note that you do not have to output the value f(b_1,…,b_n).

Examples

Input

10 32
1 2 3 4 5 5 5 5 5 5

Output

1 2 3 3 3 4 4 4 4 4

Input

5 8
4 4 8 2 1

Output

2 2 2 1 1

Note

For the first test, the optimal answer is f=-269. Note that a larger f value is possible if we ignored the constraint ∑_{i=1}^n b_i=k.

For the second test, the optimal answer is f=9.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void print(vector<long long int>& arr) {
  for (auto p : arr) cout << p << " ";
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k, c = 0, v = 0;
  cin >> n >> k;
  vector<long long int> A(n), B, C;
  for (long long int i = 0; i < n; i++) cin >> A[i];
  auto f = [&](long long int a, long long int b) {
    return a - 3 * b * b - 3 * b - 1;
  };
  long long int l = -3e18 - 5e15, r = 3e18 + 5e15;
  while (l <= r) {
    long long int m = (l + r) / 2;
    c = k;
    vector<long long int> t(n, 0);
    for (long long int i = 0; i < n; i++) {
      long long int L = 0, R = A[i];
      while (L <= R) {
        long long int M = (L + R) / 2;
        if (f(A[i], M) >= m) {
          t[i] = M;
          L = M + 1;
        } else
          R = M - 1;
      }
      c -= t[i];
    }
    if (c >= 0)
      r = m - 1, B = t, v = m;
    else
      l = m + 1;
  }
  c = k;
  for (long long int i = 0; i < n; i++) c -= B[i];
  for (long long int i = 0; i < n && c; i++) {
    if (B[i] < A[i] && f(A[i], B[i] + 1) >= v - 1) B[i]++, c--;
  }
  print(B);
}

```


### Prompt

Please create a solution in cpp to the following problem:

As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC).

A team is to be formed of n players, all of which are GUC students. However, the team might have players belonging to different departments. There are m departments in GUC, numbered from 1 to m. Herr Wafa's department has number h. For each department i, Herr Wafa knows number si — how many students who play basketball belong to this department.

Herr Wafa was also able to guarantee a spot on the team, using his special powers. But since he hates floating-point numbers, he needs your help at finding the probability that he will have at least one teammate belonging to his department.

Note that every possible team containing Herr Wafa is equally probable. Consider all the students different from each other.

Input

The first line contains three integers n, m and h (1 ≤ n ≤ 100, 1 ≤ m ≤ 1000, 1 ≤ h ≤ m) — the number of players on the team, the number of departments in GUC and Herr Wafa's department, correspondingly.

The second line contains a single-space-separated list of m integers si (1 ≤ si ≤ 100), denoting the number of students in the i-th department. Note that sh includes Herr Wafa.

Output

Print the probability that Herr Wafa will have at least one teammate from his department. If there is not enough basketball players in GUC to participate in ABC, print -1. The answer will be accepted if it has absolute or relative error not exceeding 10 - 6.

Examples

Input

3 2 1
2 1

Output

1

Input

3 2 1
1 1

Output

-1

Input

3 2 1
2 2

Output

0.666667

Note

In the first example all 3 players (2 from department 1 and 1 from department 2) must be chosen for the team. Both players from Wafa's departments will be chosen, so he's guaranteed to have a teammate from his department.

In the second example, there are not enough players.

In the third example, there are three possibilities to compose the team containing Herr Wafa. In two of them the other player from Herr Wafa's department is part of the team.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int i, j, k, n, t;
  int m, dept[1008], h, sum;
  scanf("%d%d%d", &n, &m, &h);
  sum = 0;
  for (i = 0; i < m; i++) {
    scanf("%d", &dept[i]);
    sum += dept[i];
  }
  double prob = 1.000000000;
  if (sum < n)
    printf("-1.0\n");
  else if (dept[h - 1] == 1)
    printf("0.0\n");
  else {
    dept[h - 1]--;
    n--;
    sum--;
    for (i = 0; i < dept[h - 1]; i++) {
      prob *= (sum - n - i);
      prob /= (sum - i);
    }
    {
      prob = 1.0 - prob;
      printf("%0.12lf", prob);
      printf("\n");
    }
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

In Berland prime numbers are fashionable — the respectable citizens dwell only on the floors with numbers that are prime numbers. The numismatists value particularly high the coins with prime nominal values. All the prime days are announced holidays!

Yet even this is not enough to make the Berland people happy. On the main street of the capital stand n houses, numbered from 1 to n. The government decided to paint every house a color so that the sum of the numbers of the houses painted every color is a prime number.

However it turned out that not all the citizens approve of this decision — many of them protest because they don't want many colored houses on the capital's main street. That's why it is decided to use the minimal possible number of colors. The houses don't have to be painted consecutively, but every one of n houses should be painted some color. The one-colored houses should not stand consecutively, any way of painting is acceptable.

There are no more than 5 hours left before the start of painting, help the government find the way when the sum of house numbers for every color is a prime number and the number of used colors is minimal.

Input

The single input line contains an integer n (2 ≤ n ≤ 6000) — the number of houses on the main streets of the capital.

Output

Print the sequence of n numbers, where the i-th number stands for the number of color for house number i. Number the colors consecutively starting from 1. Any painting order is allowed. If there are several solutions to that problem, print any of them. If there's no such way of painting print the single number -1.

Examples

Input

8

Output

1 2 2 1 1 1 1 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
int t;
int color[10005];
bool prime[50000000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    color[i] = 0;
  }
  t = n * (n + 1) / 2;
  for (int i = 0; i <= t; i++) {
    prime[i] = true;
  }
  for (int i = 2; i * i <= t; i++) {
    if (prime[i] == false) {
      continue;
    }
    for (int j = i * i; j <= t; j += i) {
      prime[j] = false;
    }
  }
  if (prime[t] == true) {
    for (int i = 1; i <= n; i++) {
      color[i] = 1;
    }
  } else {
    int flag = -1;
    for (int i = 2; i < t - 1; i++) {
      if (prime[i] == true && prime[t - i] == true) {
        flag = i;
      }
    }
    if (flag == -1) {
      color[3] = 3;
      t -= 3;
      flag = -1;
      for (int i = 2; i < t - 1; i++) {
        if (prime[i] && prime[t - i]) {
          flag = i;
        }
      }
    }
    for (int i = n; i >= 1; i--) {
      if (color[i] == 0 && i <= flag) {
        color[i] = 1;
        flag -= i;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (color[i] == 0) {
        color[i] = 2;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", color[i]);
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:

  * a12 + a22 + ... + an2 ≥ x
  * a1 + a2 + ... + an ≤ y

Input

The first line contains three space-separated integers n, x and y (1 ≤ n ≤ 105, 1 ≤ x ≤ 1012, 1 ≤ y ≤ 106).

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is recommended to use cin, cout streams or the %I64d specificator.

Output

Print n positive integers that satisfy the conditions, one integer per line. If such numbers do not exist, print a single number "-1". If there are several solutions, print any of them.

Examples

Input

5 15 15

Output

4
4
1
1
2

Input

2 3 2

Output

-1

Input

1 99 11

Output

11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 5;
long long a[maxn];
int main() {
  long long n, x, y;
  scanf("%I64d%I64d%I64d", &n, &x, &y);
  if (n > y)
    printf("-1\n");
  else if ((y - n + 1) * (y - n + 1) + n - 1 < x)
    printf("-1\n");
  else {
    for (int i = 1; i <= n - 1; i++) printf("1\n");
    printf("%I64d\n", y - n + 1);
  }
  return 0;
}

```


### Prompt

Your task is to create a CPP solution to the following problem:

Authors have come up with the string s consisting of n lowercase Latin letters.

You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which contains each integer from 1 to n exactly once.

For all i from 1 to n-1 the following properties hold: s[p_i] ≤ s[p_{i + 1}] and s[q_i] ≤ s[q_{i + 1}]. It means that if you will write down all characters of s in order of permutation indices, the resulting string will be sorted in the non-decreasing order.

Your task is to restore any such string s of length n consisting of at least k distinct lowercase Latin letters which suits the given permutations.

If there are multiple answers, you can print any of them.

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ k ≤ 26) — the length of the string and the number of distinct characters required.

The second line of the input contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, all p_i are distinct integers from 1 to n) — the permutation p.

The third line of the input contains n integers q_1, q_2, ..., q_n (1 ≤ q_i ≤ n, all q_i are distinct integers from 1 to n) — the permutation q.

Output

If it is impossible to find the suitable string, print "NO" on the first line.

Otherwise print "YES" on the first line and string s on the second line. It should consist of n lowercase Latin letters, contain at least k distinct characters and suit the given permutations.

If there are multiple answers, you can print any of them.

Example

Input

3 2
1 2 3
1 3 2

Output

YES
abb

### Response

```cpp
#include <bits/stdc++.h>
template <class... Args>
inline __attribute__((always_inline)) void read(Args&... args) {
  (std::cin >> ... >> args);
}
template <class... Args>
inline __attribute__((always_inline)) void write(Args&&... args) {
  (std::cout << ... << std::forward<Args>(args));
}
template <class... Args>
inline __attribute__((always_inline)) void writeln(Args&&... args) {
  write(std::forward<Args>(args)..., '\n');
}
inline __attribute__((always_inline)) void flush_write() {
  std::flush(std::cout);
}
class graph_t {
  using node_list_t = std::vector<int>;
  using holder_t = std::vector<node_list_t>;
  holder_t gr;

 public:
  graph_t(int n) : gr(n) {}
  void add_edge(int a, int b) { gr[b].push_back(a); }

 protected:
  void fill_comp(int v, std::vector<char>& used, std::vector<int>& comp) {
    used[v] = true;
    comp.push_back(v);
    for (int u : gr[v])
      if (!used[u]) fill_comp(u, used, comp);
  }

 public:
  std::vector<std::vector<int>> get_blocks(const std::vector<int>& order) {
    std::vector<std::vector<int>> blocks;
    std::vector<char> used(gr.size(), false);
    for (int v : order) {
      if (!used[v]) {
        blocks.emplace_back();
        fill_comp(v, used, blocks.back());
      }
    }
    return blocks;
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::fixed(std::cout).precision(20);
  std::cin.exceptions(std::ios_base::failbit);
  std::cin.tie(nullptr);
  int n, k;
  read(n, k);
  std::vector<int> p1(n), p2(n);
  for (int& x : p1) read(x), --x;
  for (int& x : p2) read(x), --x;
  graph_t g(n);
  for (int i = 1; i < n; ++i)
    g.add_edge(p1[i - 1], p1[i]), g.add_edge(p2[i - 1], p2[i]);
  auto blocks = g.get_blocks(p1);
  if ((int)blocks.size() < k) {
    writeln("NO");
  } else {
    writeln("YES");
    std::string res(n, '-');
    int m = blocks.size();
    for (int i = 0; i < m; ++i)
      for (int x : blocks[i]) res[x] = 'a' + std::min(i, k - 1);
    writeln(res);
  }
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Sereja has an n × m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, that is, if a component form a rectangle of size h × w, then the component must contain exactly hw cells.

A connected component of the same values is a set of cells of the table that meet the following conditions:

  * every two cells of the set have the same value;
  * the cells of the set form a connected region on the table (two cells are connected if they are adjacent in some row or some column of the table);
  * it is impossible to add any cell to the set unless we violate the two previous conditions.

Can Sereja change the values of at most k cells of the table so that the table met the described requirement? What minimum number of table cells should he change in this case?

Input

The first line contains integers n, m and k (1 ≤ n, m ≤ 100; 1 ≤ k ≤ 10). Next n lines describe the table a: the i-th of them contains m integers ai1, ai2, ..., aim (0 ≤ ai, j ≤ 1) — the values in the cells of the i-th row.

Output

Print -1, if it is impossible to meet the requirement. Otherwise, print the minimum number of cells which should be changed.

Examples

Input

5 5 2
1 1 1 1 1
1 1 1 1 1
1 1 0 1 1
1 1 1 1 1
1 1 1 1 1

Output

1

Input

3 4 1
1 0 0 0
0 1 1 1
1 1 1 0

Output

-1

Input

3 4 1
1 0 0 1
0 1 1 0
1 0 0 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int box[101][101];
int dp[101][2];
int aox[101];
int fox[2000];
void ini() {
  fox[0] = 1;
  for (int i = 1; i <= 10; i++) fox[i] = fox[i - 1] << 1;
}
int main() {
  ini();
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &box[i][j]);
  if (n > 10) {
    bool find = 0;
    int mi = 2000000000;
    for (int i = 1; i <= n; i++) {
      int sum = 0;
      for (int j = i - 1; j >= 1; j--) {
        int fr = 0, se = 0;
        for (int u = 1; u <= m; u++)
          if (box[j][u] != box[i][u])
            fr++;
          else
            se++;
        sum += min(fr, se);
        if (sum > k) break;
      }
      for (int j = i + 1; j <= n; j++) {
        int fr = 0, se = 0;
        for (int u = 1; u <= m; u++)
          if (box[j][u] != box[i][u])
            fr++;
          else
            se++;
        sum += min(fr, se);
        if (sum > k) break;
      }
      if (sum <= k) {
        find = 1;
        mi = min(sum, mi);
      }
    }
    if (find)
      printf("%d\n", mi);
    else
      printf("-1\n");
  } else if (m > 10) {
    bool find = 0;
    int mi = 2000000000;
    for (int i = 1; i <= m; i++) {
      int sum = 0;
      for (int j = i - 1; j >= 1; j--) {
        int fr = 0, se = 0;
        for (int u = 1; u <= n; u++)
          if (box[u][i] != box[u][j])
            fr++;
          else
            se++;
        sum += min(fr, se);
        if (sum > k) break;
      }
      for (int j = i + 1; j <= m; j++) {
        int fr = 0, se = 0;
        for (int u = 1; u <= n; u++)
          if (box[u][j] != box[u][i])
            fr++;
          else
            se++;
        sum += min(fr, se);
        if (sum > k) break;
      }
      if (sum <= k) {
        find = 1;
        mi = min(sum, mi);
      }
    }
    if (find)
      printf("%d\n", mi);
    else
      printf("-1\n");
  } else {
    bool find = 0;
    int mi = 2000000000;
    for (int i = 0; i < 1 << m; i++) {
      int sum = 0;
      for (int j = 1; j <= m; j++) {
        if (i & fox[j - 1]) {
          if (box[1][j] == 0) sum++;
        } else {
          if (box[1][j] == 1) sum++;
        }
      }
      if (sum > k) continue;
      for (int j = 2; j <= n; j++) {
        int fr = 0;
        int se = 0;
        for (int u = 1; u <= m; u++) {
          if (i & fox[u - 1]) {
            if (box[j][u] == 1)
              fr++;
            else
              se++;
          } else {
            if (box[j][u] == 0)
              fr++;
            else
              se++;
          }
        }
        sum += min(se, fr);
        if (sum > k) break;
      }
      if (sum <= k) {
        find = 1;
        mi = min(mi, sum);
      }
    }
    if (find)
      printf("%d\n", mi);
    else
      printf("-1\n");
  }
  return 0;
}

```


### Prompt

Your challenge is to write a CPP solution to the following problem:

There are n programmers that you want to split into several non-empty teams. The skill of the i-th programmer is a_i. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all programmers in the team must be at least x.

Each programmer should belong to at most one team. Some programmers may be left without a team.

Calculate the maximum number of teams that you can assemble.

Input

The first line contains the integer t (1 ≤ t ≤ 1000) — the number of test cases.

The first line of each test case contains two integers n and x (1 ≤ n ≤ 10^5; 1 ≤ x ≤ 10^9) — the number of programmers and the restriction of team skill respectively.

The second line of each test case contains n integers a_1, a_2, ... , a_n (1 ≤ a_i ≤ 10^9), where a_i is the skill of the i-th programmer.

The sum of n over all inputs does not exceed 10^5.

Output

For each test case print one integer — the maximum number of teams that you can assemble.

Example

Input

3
5 10
7 11 2 9 5
4 8
2 4 2 3
4 11
1 3 3 7

Output

2
1
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int n, x;
  while (t--) {
    cin >> n >> x;
    int a[n + 1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    int s = 0, j, shu = 1;
    for (j = n; j > 0; j--) {
      if (a[j] * shu >= x) {
        s++;
        shu = 1;
      } else
        shu++;
    }
    cout << s << endl;
  }
}

```


### Prompt

Generate a Cpp solution to the following problem:

Your company’s next product will be a new game, which is a three-dimensional variant of the classic game “Tic-Tac-Toe”. Two players place balls in a three-dimensional space (board), and try to make a sequence of a certain length.

People believe that it is fun to play the game, but they still cannot fix the values of some parameters of the game. For example, what size of the board makes the game most exciting? Parameters currently under discussion are the board size (we call it n in the following) and the length of the sequence (m). In order to determine these parameter values, you are requested to write a computer simulator of the game.

You can see several snapshots of the game in Figures 1-3. These figures correspond to the three datasets given in the Sample Input.

<image>

Figure 1: A game with n = m = 3

Here are the precise rules of the game.

1. Two players, Black and White, play alternately. Black plays first.
2. There are n × n vertical pegs. Each peg can accommodate up to n balls. A peg can be specified by its x- and y-coordinates (1 ≤ x, y ≤ n). A ball on a peg can be specified by its z-coordinate (1 ≤ z ≤ n). At the beginning of a game, there are no balls on any of the pegs.

<image>

Figure 2: A game with n = m = 3 (White made a 3-sequence before Black)

3. On his turn, a player chooses one of n × n pegs, and puts a ball of his color onto the peg. The ball follows the law of gravity. That is, the ball stays just above the top-most ball on the same peg or on the floor (if there are no balls on the peg). Speaking differently, a player can choose x- and y-coordinates of the ball, but he cannot choose its z-coordinate.
4. The objective of the game is to make an m-sequence. If a player makes an m-sequence or longer of his color, he wins. An m-sequence is a row of m consecutive balls of the same color. For example, black balls in positions (5, 1, 2), (5, 2, 2) and (5, 3, 2) form a 3-sequence. A sequence can be horizontal, vertical, or diagonal. Precisely speaking, there are 13 possible directions to make a sequence, categorized as follows.

<image>

Figure 3: A game with n = 4, m = 3 (Black made two 4-sequences)

(a) One-dimensional axes. For example, (3, 1, 2), (4, 1, 2) and (5, 1, 2) is a 3-sequence. There are three directions in this category.
(b) Two-dimensional diagonals. For example, (2, 3, 1), (3, 3, 2) and (4, 3, 3) is a 3-sequence. There are six directions in this category.
(c) Three-dimensional diagonals. For example, (5, 1, 3), (4, 2, 4) and (3, 3, 5) is a 3- sequence. There are four directions in this category.

Note that we do not distinguish between opposite directions.

As the evaluation process of the game, people have been playing the game several times changing the parameter values. You are given the records of these games. It is your job to write a computer program which determines the winner of each recorded game.

Since it is difficult for a human to find three-dimensional sequences, players often do not notice the end of the game, and continue to play uselessly. In these cases, moves after the end of the game, i.e. after the winner is determined, should be ignored. For example, after a player won making an m-sequence, players may make additional m-sequences. In this case, all m-sequences but the first should be ignored, and the winner of the game is unchanged.

A game does not necessarily end with the victory of one of the players. If there are no pegs left to put a ball on, the game ends with a draw. Moreover, people may quit a game before making any m-sequence. In such cases also, the game ends with a draw.

Input

The input consists of multiple datasets each corresponding to the record of a game. A dataset starts with a line containing three positive integers n, m, and p separated by a space. The relations 3 ≤ m ≤ n ≤ 7 and 1 ≤ p ≤ n3 hold between them. n and m are the parameter values of the game as described above. p is the number of moves in the game.

The rest of the dataset is p lines each containing two positive integers x and y. Each of these lines describes a move, i.e. the player on turn puts his ball on the peg specified. You can assume that 1 ≤ x ≤ n and 1 ≤ y ≤ n. You can also assume that at most n balls are put on a peg throughout a game.

The end of the input is indicated by a line with three zeros separated by a space.

Output

For each dataset, a line describing the winner and the number of moves until the game ends should be output. The winner is either “Black” or “White”. A single space should be inserted between the winner and the number of moves. No other extra characters are allowed in the output.

In case of a draw, the output line should be “Draw”.

Example

Input

3 3 3
1 1
1 1
1 1
3 3 7
2 2
1 3
1 1
2 3
2 1
3 3
3 1
4 3 15
1 1
2 2
1 1
3 3
3 3
1 1
3 3
3 3
4 4
1 1
4 4
4 4
4 4
4 1
2 2
0 0 0

Output

Draw
White 6
Black 15

### Response

```cpp
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

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

int board[7][7][7], cnt[7][7];

int main() {
	int n, m, p;
	while (cin >> n >> m >> p, n) {
		vector<int> ix(p + 1), iy(p + 1);
		for (int i = 1; i <= p; ++i) cin >> ix[i] >> iy[i];
		memset(board, -1, sizeof(board));
		memset(cnt, 0, sizeof(cnt));
		int flag = -1;
		int i;
		for (i = 1; i <= p; ++i) {
			int color = i & 1;
			int x = ix[i], y = iy[i];
			--x, --y;
			int z = cnt[x][y]++;
			board[x][y][z] = color;
			for (int j = 0; j < 13; ++j) {
				int tmp = 1;
				int nx = x + dx[j], ny = y + dy[j], nz = z + dz[j];
				while (0 <= nx && nx < n && 0 <= ny && ny < n && 0 <= nz && nz < n) {
					if (board[nx][ny][nz] == color) tmp++;
					else break;
					nx += dx[j], ny += dy[j], nz += dz[j];
				}
				nx = x - dx[j], ny = y - dy[j], nz = z - dz[j];
				while (0 <= nx && nx < n && 0 <= ny && ny < n && 0 <= nz && nz < n) {
					if (board[nx][ny][nz] == color) tmp++;
					else break;
					nx -= dx[j], ny -= dy[j], nz -= dz[j];
				}
				if (tmp >= m) {
					flag = color;
					goto output;
				}
			}
		}
	output:
		if (flag == 1) cout << "Black " << i;
		else if (flag == 0) cout << "White " << i;
		else cout << "Draw";
		cout << endl;
	}

	return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of n light bulbs in a single row. Each bulb has a number from 1 to n (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland. Now Vadim wants to put them back on.

<image>

Vadim wants to put all bulb back on the garland. Vadim defines complexity of a garland to be the number of pairs of adjacent bulbs with numbers with different parity (remainder of the division by 2). For example, the complexity of 1 4 2 3 5 is 2 and the complexity of 1 3 5 7 6 4 2 is 1.

No one likes complexity, so Vadim wants to minimize the number of such pairs. Find the way to put all bulbs back on the garland, such that the complexity is as small as possible.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of light bulbs on the garland.

The second line contains n integers p_1,\ p_2,\ …,\ p_n (0 ≤ p_i ≤ n) — the number on the i-th bulb, or 0 if it was removed.

Output

Output a single number — the minimum complexity of the garland.

Examples

Input

5
0 5 0 2 3

Output

2

Input

7
1 0 0 5 0 0 2

Output

1

Note

In the first example, one should place light bulbs as 1 5 4 2 3. In that case, the complexity would be equal to 2, because only (5, 4) and (2, 3) are the pairs of adjacent bulbs that have different parity.

In the second case, one of the correct answers is 1 7 3 5 6 4 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    long long int n = 0, m = 0, k = 0, i = 0, j = 0, p = 0, q = 0, x = 0, y = 0,
                  z = 0, ans = 0, cnt = 0, l = 0, r = 0, mid = 0, lo = 0,
                  hi = 0;
    string s;
    bool flag = false;
    cin >> n;
    long long int a[n + 1];
    for (i = 1; i <= n; i++) cin >> a[i];
    long long int dp[n + 1][n + 1][2];
    long long int even = n / 2;
    long long int odd = (n % 2 == 0) ? n / 2 : (n / 2) + 1;
    for (i = 0; i <= n; i++)
      for (j = 0; j <= n; j++)
        for (k = 0; k < 2; k++) dp[i][j][k] = 1000000007;
    dp[0][0][0] = 0;
    dp[0][0][1] = 0;
    for (i = 1; i <= n; i++)
      if (a[i] == 0)
        for (j = 0; j <= even; j++)
          if (j > i || (i - j) > odd)
            continue;
          else
            dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j - 1][0]),
            dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j - 1][1] + 1),
            dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][1]),
            dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][0] + 1);
      else
        for (j = 0; j <= even; j++) {
          if (j > i || (i - j) > odd) continue;
          if (a[i] % 2 == 0)
            dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j - 1][0]),
            dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j - 1][1] + 1);
          else
            dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][1]),
            dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][0] + 1);
        }
    ans = 1000000007;
    for (j = 0; j <= even; j++)
      ans = min(ans, dp[n][j][0]), ans = min(ans, dp[n][j][1]);
    cout << ans << endl;
    ;
  }
  return 0;
}

```


### Prompt

Your challenge is to write a CPP solution to the following problem:

You are given an array a of length 2^n. You should process q queries on it. Each query has one of the following 4 types:

  1. Replace(x, k) — change a_x to k;
  2. Reverse(k) — reverse each subarray [(i-1) ⋅ 2^k+1, i ⋅ 2^k] for all i (i ≥ 1);
  3. Swap(k) — swap subarrays [(2i-2) ⋅ 2^k+1, (2i-1) ⋅ 2^k] and [(2i-1) ⋅ 2^k+1, 2i ⋅ 2^k] for all i (i ≥ 1);
  4. Sum(l, r) — print the sum of the elements of subarray [l, r].

Write a program that can quickly process given queries.

Input

The first line contains two integers n, q (0 ≤ n ≤ 18; 1 ≤ q ≤ 10^5) — the length of array a and the number of queries.

The second line contains 2^n integers a_1, a_2, …, a_{2^n} (0 ≤ a_i ≤ 10^9).

Next q lines contains queries — one per line. Each query has one of 4 types:

  * "1 x k" (1 ≤ x ≤ 2^n; 0 ≤ k ≤ 10^9) — Replace(x, k);
  * "2 k" (0 ≤ k ≤ n) — Reverse(k);
  * "3 k" (0 ≤ k < n) — Swap(k);
  * "4 l r" (1 ≤ l ≤ r ≤ 2^n) — Sum(l, r).

It is guaranteed that there is at least one Sum query.

Output

Print the answer for each Sum query.

Examples

Input

2 3
7 4 9 9
1 2 8
3 1
4 2 4

Output

24

Input

3 8
7 0 8 8 7 1 5 2
4 3 7
2 1
3 2
4 1 6
2 3
1 5 16
4 8 8
3 0

Output

29
22
1

Note

In the first sample, initially, the array a is equal to \{7,4,9,9\}.

After processing the first query. the array a becomes \{7,8,9,9\}.

After processing the second query, the array a_i becomes \{9,9,7,8\}

Therefore, the answer to the third query is 9+7+8=24.

In the second sample, initially, the array a is equal to \{7,0,8,8,7,1,5,2\}. What happens next is:

  1. Sum(3, 7) → 8 + 8 + 7 + 1 + 5 = 29;
  2. Reverse(1) → \{0,7,8,8,1,7,2,5\};
  3. Swap(2) → \{1,7,2,5,0,7,8,8\};
  4. Sum(1, 6) → 1 + 7 + 2 + 5 + 0 + 7 = 22;
  5. Reverse(3) → \{8,8,7,0,5,2,7,1\};
  6. Replace(5, 16) → \{8,8,7,0,16,2,7,1\};
  7. Sum(8, 8) → 1;
  8. Swap(0) → \{8,8,0,7,2,16,1,7\}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, q, position;
long long seg[1 << 20];
long long query(int s, int e, int l, int r, int node, int lev) {
  if (position & (1 << lev)) {
    l = s + e - l;
    r = s + e - r;
    swap(l, r);
  }
  if (e < l || r < s) return 0LL;
  if (s == l && e == r) return seg[node];
  int m = (s + e) / 2;
  if (r <= m) return query(s, m, l, r, node * 2, lev - 1);
  if (l > m) return query(m + 1, e, l, r, node * 2 + 1, lev - 1);
  return query(s, m, l, m, node * 2, lev - 1) +
         query(m + 1, e, m + 1, r, node * 2 + 1, lev - 1);
}
int main() {
  scanf("%d %d", &n, &q);
  int sze = 1 << n;
  for (int i = sze; i < 2 * sze; i++) scanf("%lld", &seg[i]);
  for (int i = sze - 1; i > 0; i--) seg[i] = seg[2 * i] + seg[2 * i + 1];
  while (q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x;
      long long k;
      scanf("%d %lld", &x, &k);
      x--;
      int l = 0, r = sze - 1;
      for (int i = n; i > 0; i--) {
        if (position & (1 << i)) x = l + r - x;
        int m = (l + r) / 2;
        if (x <= m)
          r = m;
        else
          l = m + 1;
      }
      x += sze;
      long long diff = k - seg[x];
      while (x) {
        seg[x] += diff;
        x /= 2;
      }
    } else if (t == 2) {
      int k;
      scanf("%d", &k);
      position ^= (1 << k);
    } else if (t == 3) {
      int k;
      scanf("%d", &k);
      position ^= (3 << k);
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      printf("%lld\n", query(0, sze - 1, l - 1, r - 1, 1, n));
    }
  }
}

```


### Prompt

In CPP, your task is to solve the following problem:

Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.

You have an array a of length 2n and m queries on it. The i-th query is described by an integer qi. In order to perform the i-th query you must:

  * split the array into 2n - qi parts, where each part is a subarray consisting of 2qi numbers; the j-th subarray (1 ≤ j ≤ 2n - qi) should contain the elements a[(j - 1)·2qi + 1], a[(j - 1)·2qi + 2], ..., a[(j - 1)·2qi + 2qi];
  * reverse each of the subarrays;
  * join them into a single array in the same order (this array becomes new array a);
  * output the number of inversions in the new a.

Given initial array a and all the queries. Answer all the queries. Please, note that the changes from some query is saved for further queries.

Input

The first line of input contains a single integer n (0 ≤ n ≤ 20).

The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array.

The third line of input contains a single integer m (1 ≤ m ≤ 106).

The fourth line of input contains m space-separated integers q1, q2, ..., qm (0 ≤ qi ≤ n), the queries.

Note: since the size of the input and output could be very large, don't use slow output techniques in your language. For example, do not use input and output streams (cin, cout) in C++.

Output

Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.

Examples

Input

2
2 1 4 3
4
1 2 0 2

Output

0
6
6
0

Input

1
1 2
3
0 1 1

Output

0
1
0

Note

If we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.

The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i < j and x[i] > x[j].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int getPow(int n) {
  for (int i = 0;; i++)
    if (n == (1 << i)) {
      return i;
    }
  return -1;
}
int status;
long long cnt[2][22] = {0};
int b[1048590];
inline void mergg(int ar[], int low, int mid, int high, int pow) {
  for (int i = low; i <= high; ++i) {
    b[i] = ar[i];
  }
  int i = low, j = mid + 1, k = low;
  while (i <= mid && j <= high) {
    if (b[i] <= b[j]) {
      ar[k++] = b[i++];
    } else {
      ar[k++] = b[j++];
      cnt[status][pow] += (long long)mid - i + 1;
    }
  }
  while (i <= mid) {
    ar[k++] = b[i++];
  }
  while (j <= high) {
    ar[k++] = b[j++];
  }
}
inline void merge_sort(int ar[], int low, int high, int pow) {
  if (low < high) {
    int mid = low + (high - low) / 2;
    merge_sort(ar, low, mid, pow - 1);
    merge_sort(ar, mid + 1, high, pow - 1);
    mergg(ar, low, mid, high, pow);
  }
}
int a[1048590];
int tmp[1048590];
int main() {
  int npow;
  cin >> npow;
  for (int i = 1; i <= (1 << npow); i++) scanf("%d", &a[i]);
  memcpy(tmp, a, sizeof a);
  status = 0;
  merge_sort(a, 1, 1 << npow, npow - 1);
  int sz = (1 << npow);
  for (int i = 1; i <= sz; i++) a[i] = tmp[sz - i + 1];
  status = 1;
  merge_sort(a, 1, 1 << npow, npow - 1);
  int m;
  cin >> m;
  int flag[22] = {0};
  while (m--) {
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
      flag[i] ^= 1;
    }
    long long ans = 0;
    for (int i = 0; i <= npow; i++) {
      ans += cnt[flag[i]][i];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

The Cereal Guy's friend Serial Guy likes to watch soap operas. An episode is about to start, and he hasn't washed his plate yet. But he decided to at least put in under the tap to be filled with water. The plate can be represented by a parallelepiped k × n × m, that is, it has k layers (the first layer is the upper one), each of which is a rectangle n × m with empty squares ('.') and obstacles ('#'). The water can only be present in the empty squares. The tap is positioned above the square (x, y) of the first layer, it is guaranteed that this square is empty. Every minute a cubical unit of water falls into the plate. Find out in how many minutes the Serial Guy should unglue himself from the soap opera and turn the water off for it not to overfill the plate. That is, you should find the moment of time when the plate is absolutely full and is going to be overfilled in the next moment.

Note: the water fills all the area within reach (see sample 4). Water flows in each of the 6 directions, through faces of 1 × 1 × 1 cubes.

Input

The first line contains three numbers k, n, m (1 ≤ k, n, m ≤ 10) which are the sizes of the plate. Then follow k rectangles consisting of n lines each containing m characters '.' or '#', which represents the "layers" of the plate in the order from the top to the bottom. The rectangles are separated by empty lines (see the samples). The last line contains x and y (1 ≤ x ≤ n, 1 ≤ y ≤ m) which are the tap's coordinates. x is the number of the line and y is the number of the column. Lines of each layer are numbered from left to right by the integers from 1 to n, columns of each layer are numbered from top to bottom by the integers from 1 to m.

Output

The answer should contain a single number, showing in how many minutes the plate will be filled.

Examples

Input

1 1 1

.

1 1

Output

1

Input

2 1 1

.

#

1 1

Output

1

Input

2 2 2

.#
##

..
..

1 1

Output

5

Input

3 2 2

#.
##

#.
.#

..
..

1 2

Output

7

Input

3 3 3

.#.
###
##.

.##
###
##.

...
...
...

1 1

Output

13

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[1000];
int sx, sy;
int k, n, m;
int cnt;
char s[11][11][11];
int vis[11][11][11];
int dir1[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};
int dir2[2] = {1, -1};
struct node {
  int x, y, z;
};
void bfs() {
  cnt = 1;
  queue<node> q;
  int i, j;
  node no, ne;
  no.x = sx - 1;
  no.y = sy - 1;
  no.z = 0;
  vis[0][no.x][no.y] = 1;
  q.push(no);
  while (!q.empty()) {
    no = q.front();
    q.pop();
    for (i = 0; i < 4; i++) {
      ne.x = no.x + dir1[i][0];
      ne.y = no.y + dir1[i][1];
      ne.z = no.z;
      if (ne.z < 0 || ne.x < 0 || ne.y < 0 || ne.x >= n || ne.y >= m ||
          ne.z >= k || vis[ne.z][ne.x][ne.y] || s[ne.z][ne.x][ne.y] == '#')
        continue;
      vis[ne.z][ne.x][ne.y] = 1;
      cnt++;
      q.push(ne);
    }
    for (j = 0; j < 2; j++) {
      ne.x = no.x;
      ne.y = no.y;
      ne.z = no.z + dir2[j];
      if (ne.z >= 0 && ne.x >= 0 && ne.y >= 0 && ne.x < n && ne.y < m &&
          ne.z < k && !vis[ne.z][ne.x][ne.y] && s[ne.z][ne.x][ne.y] == '.') {
        vis[ne.z][ne.x][ne.y] = 1;
        cnt++;
        q.push(ne);
      }
    }
  }
}
int main() {
  int i, j, t;
  scanf("%d%d%d", &k, &n, &m);
  getchar();
  for (t = 0; t < k; t++) {
    bool flag = false;
    getchar();
    for (i = 0; i < n; i++) {
      int cnt = 0;
      for (j = 0; j < m; j++) {
        vis[t][i][j] = 0;
        scanf("%c", &s[t][i][j]);
      }
      getchar();
    }
  }
  scanf("%d%d", &sx, &sy);
  bfs();
  cout << cnt << endl;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

One day Petya got a birthday present from his mom: a book called "The Legends and Myths of Graph Theory". From this book Petya learned about a hydra graph.

A non-oriented graph is a hydra, if it has a structure, shown on the figure below. Namely, there are two nodes u and v connected by an edge, they are the hydra's chest and stomach, correspondingly. The chest is connected with h nodes, which are the hydra's heads. The stomach is connected with t nodes, which are the hydra's tails. Note that the hydra is a tree, consisting of h + t + 2 nodes.

<image>

Also, Petya's got a non-directed graph G, consisting of n nodes and m edges. Petya got this graph as a last year birthday present from his mom. Graph G contains no self-loops or multiple edges.

Now Petya wants to find a hydra in graph G. Or else, to make sure that the graph doesn't have a hydra.

Input

The first line contains four integers n, m, h, t (1 ≤ n, m ≤ 105, 1 ≤ h, t ≤ 100) — the number of nodes and edges in graph G, and the number of a hydra's heads and tails.

Next m lines contain the description of the edges of graph G. The i-th of these lines contains two integers ai and bi (1 ≤ ai, bi ≤ n, a ≠ b) — the numbers of the nodes, connected by the i-th edge.

It is guaranteed that graph G contains no self-loops and multiple edges. Consider the nodes of graph G numbered with integers from 1 to n.

Output

If graph G has no hydra, print "NO" (without the quotes).

Otherwise, in the first line print "YES" (without the quotes). In the second line print two integers — the numbers of nodes u and v. In the third line print h numbers — the numbers of the nodes that are the heads. In the fourth line print t numbers — the numbers of the nodes that are the tails. All printed numbers should be distinct.

If there are multiple possible answers, you are allowed to print any of them.

Examples

Input

9 12 2 3
1 2
2 3
1 3
1 4
2 5
4 5
4 6
6 5
6 7
7 5
8 7
9 1

Output

YES
4 1
5 6
9 3 2

Input

7 10 3 3
1 2
2 3
1 3
1 4
2 5
4 5
4 6
6 5
6 7
7 5

Output

NO

Note

The first sample is depicted on the picture below:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, m, h, t, vis[N];
vector<int> H, T, e[N];
bool check(int u, int v) {
  if (((int)(e[u]).size()) < h + 1 || ((int)(e[v]).size()) < t + 1)
    return false;
  for (int i = (0), I = (min(h + t + 1, ((int)(e[u]).size()))); i < I; ++i) {
    int x = e[u][i];
    vis[x] = u;
  }
  vector<int> C;
  H.clear(), T.clear();
  for (int i = (0), I = (min(h + t + 1, ((int)(e[v]).size()))); i < I; ++i) {
    int x = e[v][i];
    if (x == u) continue;
    if (vis[x] == u)
      C.push_back(x);
    else
      T.push_back(x);
    vis[x] = v;
  }
  for (int i = (0), I = (min(h + t + 1, ((int)(e[u]).size()))); i < I; ++i) {
    int x = e[u][i];
    if (x == v) continue;
    if (vis[x] != v) H.push_back(x);
  }
  for (int i = (0), I = (((int)(C).size())); i < I; ++i)
    if (((int)(H).size()) < h) {
      H.push_back(C[i]);
    } else if (((int)(T).size()) < t) {
      T.push_back(C[i]);
    } else
      break;
  return ((int)(H).size()) >= h && ((int)(T).size()) >= t;
}
void solve() {
  for (int u = (1), I = (n + 1); u < I; ++u) {
    for (int i = (0), I = (((int)(e[u]).size())); i < I; ++i) {
      int v = e[u][i];
      if (check(u, v)) {
        puts("YES");
        printf("%d %d\n", u, v);
        for (int i = (0), I = (h); i < I; ++i)
          printf("%d%c", H[i], " \n"[i == h - 1]);
        for (int i = (0), I = (t); i < I; ++i)
          printf("%d%c", T[i], " \n"[i == t - 1]);
        return;
      }
    }
  }
  puts("NO");
}
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = (0), I = (m); i < I; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v), e[v].push_back(u);
  }
  solve();
  return 0;
}

```