### Prompt

Please create a solution in cpp to the following problem:

Tachibana Kanade likes Mapo Tofu very much. One day, the canteen cooked all kinds of tofu to sell, but not all tofu is Mapo Tofu, only those spicy enough can be called Mapo Tofu.

Each piece of tofu in the canteen is given a m-based number, all numbers are in the range [l, r] (l and r being m-based numbers), and for every m-based integer in the range [l, r], there exists a piece of tofu with that number.

To judge what tofu is Mapo Tofu, Tachibana Kanade chose n m-based number strings, and assigned a value to each string. If a string appears in the number of a tofu, the value of the string will be added to the value of that tofu. If a string appears multiple times, then the value is also added that many times. Initially the value of each tofu is zero.

Tachibana Kanade considers tofu with values no more than k to be Mapo Tofu. So now Tachibana Kanade wants to know, how many pieces of tofu are Mapo Tofu?

Input

The first line contains three integers n, m and k (1 ≤ n ≤ 200; 2 ≤ m ≤ 20; 1 ≤ k ≤ 500). Where n denotes the number of strings, m denotes the base used, and k denotes the limit of the value for Mapo Tofu.

The second line represents the number l. The first integer in the line is len (1 ≤ len ≤ 200), describing the length (number of digits in base m) of l. Then follow len integers a1, a2, ..., alen (0 ≤ ai < m; a1 > 0) separated by spaces, representing the digits of l, with a1 being the highest digit and alen being the lowest digit.

The third line represents the number r in the same format as l. It is guaranteed that 1 ≤ l ≤ r.

Then follow n lines, each line describing a number string. The i-th line contains the i-th number string and vi — the value of the i-th string (1 ≤ vi ≤ 200). All number strings are described in almost the same format as l, the only difference is number strings may contain necessary leading zeros (see the first example). The sum of the lengths of all number strings does not exceed 200.

Output

Output the number of pieces of Mapo Tofu modulo 1000000007 (109 + 7). The answer should be a decimal integer.

Examples

Input

2 10 1
1 1
3 1 0 0
1 1 1
1 0 1

Output

97

Input

2 10 12
2 5 9
6 6 3 5 4 9 7
2 0 6 1
3 6 7 2 1

Output

635439

Input

4 2 6
6 1 0 1 1 1 0
6 1 1 0 1 0 0
1 1 2
3 0 1 0 5
4 0 1 1 0 4
3 1 0 1 2

Output

2

Note

In the first sample, 10, 11 and 100 are the only three decimal numbers in [1, 100] with a value greater than 1. Here the value of 1 is 1 but not 2, since numbers cannot contain leading zeros and thus cannot be written as "01".

In the second sample, no numbers in the given interval have a value greater than 12.

In the third sample, 110000 and 110001 are the only two binary numbers in the given interval with a value no greater than 6.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int lsize, rsize;
int l[205], r[205];
int len[205], str[205][205], p[205];
int nex[205][25];
int gain[205];
long long dp[2][505][205][2][2];
string al = "abcdefghijklmnopqrstuvwxyz";
vector<string> pfx;
void pre() {
  for (int i = 0; i < n; i++) {
    string s;
    for (int j = 0; j <= len[i]; j++) {
      pfx.push_back(s);
      if (j != len[i]) s.push_back(('a' + str[i][j]));
    }
  }
  sort(pfx.begin(), pfx.end());
  pfx.erase(unique(pfx.begin(), pfx.end()), pfx.end());
  int kk = pfx.size();
  for (int i = 0; i < kk; i++) {
    for (int j = 0; j < n; j++) {
      if (pfx[i].size() < len[j]) continue;
      bool ok = true;
      for (int a = 0; a < len[j]; a++) {
        if (('a' + str[j][len[j] - 1 - a]) != pfx[i][pfx[i].size() - 1 - a]) {
          ok = false;
          break;
        }
      }
      if (ok) gain[i] += p[j];
    }
    for (int j = 0; j < m; j++) {
      string s = pfx[i];
      s.push_back('a' + j);
      int x;
      while (1) {
        x = lower_bound(pfx.begin(), pfx.end(), s) - pfx.begin();
        if (x < kk && pfx[x] == s) break;
        s = s.substr(1);
      }
      nex[i][j] = x;
    }
  }
}
long long calcl() {
  memset(dp, 0, sizeof(dp));
  int cur = 0, nxt = 1;
  dp[0][0][0][1][0] = 1;
  for (int i = 0; i < lsize; i++) {
    memset(dp[nxt], 0, sizeof(dp[nxt]));
    for (int j = 0; j <= k; j++) {
      for (int a = 0; a < pfx.size(); a++) {
        if (!dp[cur][j][a][0][1]) goto nxt;
        for (int ch = 0; ch < m; ch++) {
          int tugi = nex[a][ch];
          if (j + gain[tugi] > k) continue;
          dp[nxt][j + gain[tugi]][tugi][0][1] =
              (dp[nxt][j + gain[tugi]][tugi][0][1] + dp[cur][j][a][0][1]) %
              1000000007;
        }
      nxt:;
        if (!dp[cur][j][a][1][1]) goto nxt2;
        for (int ch = 0; ch <= l[i]; ch++) {
          int tugi = nex[a][ch];
          if (j + gain[tugi] > k) continue;
          dp[nxt][j + gain[tugi]][tugi][ch == l[i] ? 1 : 0][1] =
              (dp[nxt][j + gain[tugi]][tugi][ch == l[i] ? 1 : 0][1] +
               dp[cur][j][a][1][1]) %
              1000000007;
        }
      nxt2:;
        if (!dp[cur][j][a][0][0]) goto nxt3;
        for (int ch = 0; ch < m; ch++) {
          int tugi = nex[a][ch];
          if (ch && j + gain[tugi] <= k) {
            dp[nxt][j + gain[tugi]][tugi][0][!!ch] =
                (dp[nxt][j + gain[tugi]][tugi][0][!!ch] + dp[cur][j][a][0][0]) %
                1000000007;
          } else if (!ch) {
            dp[nxt][0][0][0][0] =
                (dp[nxt][0][0][0][0] + dp[cur][j][a][0][0]) % 1000000007;
          }
        }
      nxt3:;
        if (!dp[cur][j][a][1][0]) continue;
        for (int ch = 0; ch <= l[i]; ch++) {
          int tugi = nex[a][ch];
          if (ch && j + gain[tugi] <= k) {
            dp[nxt][j + gain[tugi]][tugi][ch == l[i] ? 1 : 0][!!ch] =
                (dp[nxt][j + gain[tugi]][tugi][ch == l[i] ? 1 : 0][!!ch] +
                 dp[cur][j][a][1][0]) %
                1000000007;
          } else if (!ch) {
            dp[nxt][0][0][ch == l[i] ? 1 : 0][0] =
                (dp[nxt][0][0][ch == l[i] ? 1 : 0][0] + dp[cur][j][a][1][0]) %
                1000000007;
          }
        }
      }
    }
    swap(cur, nxt);
  }
  long long res = 0LL;
  for (int j = 0; j <= k; j++)
    for (int a = 0; a < pfx.size(); a++)
      res = (res + dp[cur][j][a][0][1] + dp[cur][j][a][1][1]) % 1000000007;
  return res;
}
long long calcr() {
  memset(dp, 0, sizeof(dp));
  int cur = 0, nxt = 1;
  dp[0][0][0][1][0] = 1;
  for (int i = 0; i < rsize; i++) {
    memset(dp[nxt], 0, sizeof(dp[nxt]));
    for (int j = 0; j <= k; j++) {
      for (int a = 0; a < pfx.size(); a++) {
        if (!dp[cur][j][a][0][1]) goto nxtt;
        for (int ch = 0; ch < m; ch++) {
          int tugi = nex[a][ch];
          if (j + gain[tugi] > k) continue;
          dp[nxt][j + gain[tugi]][tugi][0][1] =
              (dp[nxt][j + gain[tugi]][tugi][0][1] + dp[cur][j][a][0][1]) %
              1000000007;
        }
      nxtt:;
        if (!dp[cur][j][a][1][1]) goto nxtt2;
        for (int ch = 0; ch <= r[i]; ch++) {
          int tugi = nex[a][ch];
          if (j + gain[tugi] > k) continue;
          dp[nxt][j + gain[tugi]][tugi][ch == r[i] ? 1 : 0][1] =
              (dp[nxt][j + gain[tugi]][tugi][ch == r[i] ? 1 : 0][1] +
               dp[cur][j][a][1][1]) %
              1000000007;
        }
      nxtt2:;
        if (!dp[cur][j][a][0][0]) goto nxtt3;
        for (int ch = 0; ch < m; ch++) {
          int tugi = nex[a][ch];
          if (ch && j + gain[tugi] <= k) {
            dp[nxt][j + gain[tugi]][tugi][0][!!ch] =
                (dp[nxt][j + gain[tugi]][tugi][0][!!ch] + dp[cur][j][a][0][0]) %
                1000000007;
          } else if (!ch) {
            dp[nxt][0][0][0][0] =
                (dp[nxt][0][0][0][0] + dp[cur][j][a][0][0]) % 1000000007;
          }
        }
      nxtt3:;
        if (!dp[cur][j][a][1][0]) continue;
        for (int ch = 0; ch <= r[i]; ch++) {
          int tugi = nex[a][ch];
          if (ch && j + gain[tugi] <= k) {
            dp[nxt][j + gain[tugi]][tugi][ch == r[i] ? 1 : 0][1] =
                (dp[nxt][j + gain[tugi]][tugi][ch == r[i] ? 1 : 0][1] +
                 dp[cur][j][a][1][0]) %
                1000000007;
          } else if (!ch) {
            dp[nxt][0][0][ch == r[i] ? 1 : 0][0] =
                (dp[nxt][0][0][ch == r[i] ? 1 : 0][0] + dp[cur][j][a][1][0]) %
                1000000007;
          }
        }
      }
    }
    swap(cur, nxt);
  }
  long long res = 0LL;
  for (int j = 0; j <= k; j++)
    for (int a = 0; a < pfx.size(); a++)
      res = (res + dp[cur][j][a][0][1] + dp[cur][j][a][1][1]) % 1000000007;
  return res;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  scanf("%d", &lsize);
  for (int i = 0; i < lsize; i++) scanf("%d", &l[i]);
  vector<int> vec;
  l[lsize - 1]--;
  for (int i = lsize - 1; i >= 0; i--) {
    if (l[i] == -1) {
      l[i] = m - 1;
      l[i - 1]--;
    } else {
      break;
    }
  }
  for (int i = 0; i < lsize; i++) vec.push_back(l[i]);
  if (vec.size() == lsize) {
    if (!vec[0]) {
      lsize--;
      for (int i = 0; i < lsize; i++) l[i] = vec[i + 1];
    } else {
      for (int i = 0; i < lsize; i++) l[i] = vec[i];
    }
  }
  scanf("%d", &rsize);
  for (int i = 0; i < rsize; i++) scanf("%d", &r[i]);
  for (int i = 0; i < n; i++) {
    scanf("%d", &len[i]);
    for (int j = 0; j < len[i]; j++) {
      scanf("%d", &str[i][j]);
    }
    scanf("%d", &p[i]);
  }
  pre();
  printf("%lld\n", (calcr() - calcl() + 1000000007) % 1000000007);
}

```


### Prompt

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

Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave ai points.

Polycarp does not remember how many points the participant had before this k marks were given, but he remembers that among the scores announced after each of the k judges rated the participant there were n (n ≤ k) values b1, b2, ..., bn (it is guaranteed that all values bj are distinct). It is possible that Polycarp remembers not all of the scores announced, i. e. n < k. Note that the initial score wasn't announced.

Your task is to determine the number of options for the score the participant could have before the judges rated the participant.

Input

The first line contains two integers k and n (1 ≤ n ≤ k ≤ 2 000) — the number of jury members and the number of scores Polycarp remembers.

The second line contains k integers a1, a2, ..., ak ( - 2 000 ≤ ai ≤ 2 000) — jury's marks in chronological order.

The third line contains n distinct integers b1, b2, ..., bn ( - 4 000 000 ≤ bj ≤ 4 000 000) — the values of points Polycarp remembers. Note that these values are not necessarily given in chronological order.

Output

Print the number of options for the score the participant could have before the judges rated the participant. If Polycarp messes something up and there is no options, print "0" (without quotes).

Examples

Input

4 1
-5 5 0 20
10

Output

3

Input

2 2
-2000 -2000
3998000 4000000

Output

1

Note

The answer for the first example is 3 because initially the participant could have  - 10, 10 or 15 points.

In the second example there is only one correct initial score equaling to 4 002 000.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[2003], b[2003], s[2003];
int main() {
  int n, k, ans = 0;
  bool ok;
  int a[2003], b[2003], s[2003], x[2003];
  cin >> k >> n;
  set<int> points;
  multiset<int> res1, res;
  for (int i = 0; i < k; i++) {
    cin >> a[i];
    s[i] = (i == 0) ? a[0] : s[i - 1] + a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    if (!i)
      for (int j = 0; j < k; j++) points.insert(x[i] - s[j]);
  }
  int imposs = k - n, imposs1 = 0;
  map<int, set<int> > pts;
  for (set<int>::iterator it = points.begin(); it != points.end(); it++) {
    ok = true;
    for (int j = 0; j < k; j++) {
      pts[*it].insert(*it + s[j]);
    }
    for (int j = 0; j < n; j++) {
      if (pts[*it].find(x[j]) == pts[*it].end()) {
        ok = false;
      }
    }
    if (ok) ans++;
  }
  cout << ans;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.

Input

The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 300).

Output

Print a single number — the length of a sought sequence.

Examples

Input

4 3
3 1 4 2

Output

5

Note

The array given in the sample looks like that: 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2. The elements in bold form the largest non-decreasing subsequence.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int lis(vector<int>& a) {
  if (a.empty()) return 0;
  int n = a.size();
  int INF = 1000;
  vector<int> b(n + 1, INF);
  b[0] = -INF;
  for (int i = 0; i < n; ++i) {
    int val = a[i];
    int pos = upper_bound(b.begin(), b.end(), val) - b.begin();
    b[pos] = min(b[pos], val);
  }
  int res = 0;
  for (int j = n; j >= 0; --j)
    if (b[j] != INF) {
      res = j;
      break;
    }
  return res;
}
int brute(int n, int t, vector<int> a) {
  for (int i = 0; i < t - 1; ++i)
    for (int j = 0; j < n; ++j) a.push_back(a[j]);
  int res = lis(a);
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int t0 = 400;
  int t1 = 401;
  int res = -1;
  if (t <= t0) {
    res = brute(n, t, a);
  } else {
    int res0 = brute(n, t0, a);
    int res1 = brute(n, t1, a);
    res = res1 + (t - t1) * (res1 - res0);
  }
  cout << res << endl;
  return 0;
}

```


### Prompt

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

Bizon the Champion is called the Champion for a reason.

Bizon the Champion has recently got a present — a new glass cupboard with n shelves and he decided to put all his presents there. All the presents can be divided into two types: medals and cups. Bizon the Champion has a1 first prize cups, a2 second prize cups and a3 third prize cups. Besides, he has b1 first prize medals, b2 second prize medals and b3 third prize medals.

Naturally, the rewards in the cupboard must look good, that's why Bizon the Champion decided to follow the rules:

  * any shelf cannot contain both cups and medals at the same time;
  * no shelf can contain more than five cups;
  * no shelf can have more than ten medals.

Help Bizon the Champion find out if we can put all the rewards so that all the conditions are fulfilled.

Input

The first line contains integers a1, a2 and a3 (0 ≤ a1, a2, a3 ≤ 100). The second line contains integers b1, b2 and b3 (0 ≤ b1, b2, b3 ≤ 100). The third line contains integer n (1 ≤ n ≤ 100).

The numbers in the lines are separated by single spaces.

Output

Print "YES" (without the quotes) if all the rewards can be put on the shelves in the described manner. Otherwise, print "NO" (without the quotes).

Examples

Input

1 1 1
1 1 1
4

Output

YES

Input

1 1 3
2 3 4
2

Output

YES

Input

1 0 0
1 0 0
1

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a1, a2, a3, b1, b2, b3, n, m = 10, sc, sm, c = 5;
  cin >> a1 >> a2 >> a3 >> b1 >> b2 >> b3 >> n;
  sc = a1 + a2 + a3;
  sm = b1 + b2 + b3;
  sm % m == 0 ? m = sm / m : m = (sm / m) + 1;
  sc % c == 0 ? c = sc / c : c = (sc / c) + 1;
  (c + m) <= n ? cout << "YES" : cout << "NO";
  return 0;
}

```


### Prompt

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

Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previous element, each element except the last has exactly one next element. The list is not closed in a cycle.

In this problem you are given n memory cells forming one or more doubly linked lists. Each cell contains information about element from some list. Memory cells are numbered from 1 to n.

For each cell i you are given two values:

  * li — cell containing previous element for the element in the cell i;
  * ri — cell containing next element for the element in the cell i.

If cell i contains information about the element which has no previous element then li = 0. Similarly, if cell i contains information about the element which has no next element then ri = 0.

<image> Three lists are shown on the picture.

For example, for the picture above the values of l and r are the following: l1 = 4, r1 = 7; l2 = 5, r2 = 0; l3 = 0, r3 = 0; l4 = 6, r4 = 1; l5 = 0, r5 = 2; l6 = 0, r6 = 4; l7 = 1, r7 = 0.

Your task is to unite all given lists in a single list, joining them to each other in any order. In particular, if the input data already contains a single list, then there is no need to perform any actions. Print the resulting list in the form of values li, ri.

Any other action, other than joining the beginning of one list to the end of another, can not be performed.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of memory cells where the doubly linked lists are located.

Each of the following n lines contains two integers li, ri (0 ≤ li, ri ≤ n) — the cells of the previous and the next element of list for cell i. Value li = 0 if element in cell i has no previous element in its list. Value ri = 0 if element in cell i has no next element in its list.

It is guaranteed that the input contains the correct description of a single or more doubly linked lists. All lists have linear structure: each element of list except the first has exactly one previous element; each element of list except the last has exactly one next element. Each memory cell contains information about one element from some list, each element of each list written in one of n given cells.

Output

Print n lines, the i-th line must contain two integers li and ri — the cells of the previous and the next element of list for cell i after all lists from the input are united in a single list. If there are many solutions print any of them.

Example

Input

7
4 7
5 0
0 0
6 1
0 2
0 4
1 0

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 105;
struct node {
  int l, r;
  void read() { cin >> l >> r; }
} a[maxn];
int head[maxn], rear[maxn];
int tot;
int main() {
  tot = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].l, &a[i].r);
  }
  for (int i = 1; i <= n; i++) {
    if (a[i].l == 0) {
      int j = i;
      while (a[j].r != 0) {
        j = a[j].r;
      }
      head[++tot] = i;
      rear[tot] = j;
    }
  }
  for (int i = 2; i <= tot; i++) {
    int u = rear[1], v = head[i];
    a[u].r = v;
    a[v].l = u;
    rear[1] = rear[i];
  }
  for (int i = 1; i <= n; i++) {
    printf("%d %d\n", a[i].l, a[i].r);
  }
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Construct a dice from a given sequence of integers in the same way as Dice I.

You are given integers on the top face and the front face after the dice was rolled in the same way as Dice I. Write a program to print an integer on the right side face.

<image>

Constraints

* $0 \leq $ the integer assigned to a face $ \leq 100$
* The integers are all different
* $1 \leq q \leq 24$

Input

In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, the number of questions $q$ is given.

In the following $q$ lines, $q$ questions are given. Each question consists of two integers on the top face and the front face respectively.

Output

For each question, print the integer on the right side face.

Example

Input

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

Output

3
5
6

### Response

```cpp
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<iostream>
using namespace std;

int main() {
	const int n = 6;
	int dice[n];
	int top, front;
	int p;
	int dice_result[6];
	const int dice_tem[4][6] = { { 3,2,6,1,5,4 },{ 2,6,3,4,1,5 },
	{ 5,1,3,4,6,2 },{ 4,2,1,6,5,3 } };
	for (int i = 0; i < n; i++) {
		cin >> dice[i];
	}
	int num;
	cin >> num;
	for (int v = 0; v < num; v++) {
		cin >> top >> front;
		for (int d = 0; dice[0] != top ; d++) {
			if (d == 0)continue;

			for (int i = 0; i < n; i++) {
				dice_result[i] = dice[dice_tem[d % 2][i] - 1];
			}
			for (int i = 0; i < n; i++)dice[i] = dice_result[i];
		}

		for (p = 0; p < 4; p++) {
			for (int i = 0; i < n; i++) {
			dice_result[i] = dice[dice_tem[p][i]-1];
		}
			if (front == dice_result[0]) break;
		}
		int a = p == 0 ? 2 : p == 1 ? 0 : p == 2 ? 3 : p == 3 ? 1 : -1;
		int y[6];
		for (int i = 0; i < n; i++)y[i] = dice[dice_tem[a][i] - 1];
		cout << y[0]  << endl;

	}
	return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to one of the empty cells and a small insect in another empty cell. The grasshopper wants to eat the insect.

Ostap knows that grasshopper is able to jump to any empty cell that is exactly k cells away from the current (to the left or to the right). Note that it doesn't matter whether intermediate cells are empty or not as the grasshopper makes a jump over them. For example, if k = 1 the grasshopper can jump to a neighboring cell only, and if k = 2 the grasshopper can jump over a single cell.

Your goal is to determine whether there is a sequence of jumps such that grasshopper will get from his initial position to the cell with an insect.

Input

The first line of the input contains two integers n and k (2 ≤ n ≤ 100, 1 ≤ k ≤ n - 1) — the number of cells in the line and the length of one grasshopper's jump.

The second line contains a string of length n consisting of characters '.', '#', 'G' and 'T'. Character '.' means that the corresponding cell is empty, character '#' means that the corresponding cell contains an obstacle and grasshopper can't jump there. Character 'G' means that the grasshopper starts at this position and, finally, 'T' means that the target insect is located at this cell. It's guaranteed that characters 'G' and 'T' appear in this line exactly once.

Output

If there exists a sequence of jumps (each jump of length k), such that the grasshopper can get from his initial position to the cell with the insect, print "YES" (without quotes) in the only line of the input. Otherwise, print "NO" (without quotes).

Examples

Input

5 2
#G#T#

Output

YES

Input

6 1
T....G

Output

YES

Input

7 3
T..#..G

Output

NO

Input

6 2
..GT..

Output

NO

Note

In the first sample, the grasshopper can make one jump to the right in order to get from cell 2 to cell 4.

In the second sample, the grasshopper is only able to jump to neighboring cells but the way to the insect is free — he can get there by jumping left 5 times.

In the third sample, the grasshopper can't make a single jump.

In the fourth sample, the grasshopper can only jump to the cells with odd indices, thus he won't be able to reach the insect.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  string input;
  cin >> input;
  int g_p, t_p;
  for (int i = 0; i < n; i++) {
    if (input[i] == 'G') {
      g_p = i;
    } else if (input[i] == 'T') {
      t_p = i;
    }
  }
  int first = g_p, second = g_p;
  bool marker = false;
  int i;
  for (i = first; i >= 0; i -= k) {
    if (input[i] == 'T') {
      printf("YES\n");
      return 0;
    } else if (input[i] == '#') {
      break;
    }
  }
  i = second;
  for (; i < n; i += k) {
    if (input[i] == 'T') {
      printf("YES\n");
      return 0;
    } else if (input[i] == '#') {
      break;
    }
  }
  printf("NO\n");
  return 0;
}

```


### Prompt

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

Two players A and B have a list of n integers each. They both want to maximize the subtraction between their score and their opponent's score.

In one turn, a player can either add to his score any element from his list (assuming his list is not empty), the element is removed from the list afterward. Or remove an element from his opponent's list (assuming his opponent's list is not empty).

Note, that in case there are equal elements in the list only one of them will be affected in the operations above. For example, if there are elements \{1, 2, 2, 3\} in a list and you decided to choose 2 for the next turn, only a single instance of 2 will be deleted (and added to the score, if necessary).

The player A starts the game and the game stops when both lists are empty. Find the difference between A's score and B's score at the end of the game, if both of the players are playing optimally.

Optimal play between two players means that both players choose the best possible strategy to achieve the best possible outcome for themselves. In this problem, it means that each player, each time makes a move, which maximizes the final difference between his score and his opponent's score, knowing that the opponent is doing the same.

Input

The first line of input contains an integer n (1 ≤ n ≤ 100 000) — the sizes of the list.

The second line contains n integers a_i (1 ≤ a_i ≤ 10^6), describing the list of the player A, who starts the game.

The third line contains n integers b_i (1 ≤ b_i ≤ 10^6), describing the list of the player B.

Output

Output the difference between A's score and B's score (A-B) if both of them are playing optimally.

Examples

Input

2
1 4
5 1

Output

0

Input

3
100 100 100
100 100 100

Output

0

Input

2
2 1
5 6

Output

-3

Note

In the first example, the game could have gone as follows:

  * A removes 5 from B's list.
  * B removes 4 from A's list.
  * A takes his 1.
  * B takes his 1.

Hence, A's score is 1, B's score is 1 and difference is 0.

There is also another optimal way of playing:

  * A removes 5 from B's list.
  * B removes 4 from A's list.
  * A removes 1 from B's list.
  * B removes 1 from A's list.

The difference in the scores is still 0.

In the second example, irrespective of the moves the players make, they will end up with the same number of numbers added to their score, so the difference will be 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, x, scoreA = 0, scoreB = 0;
  cin >> n;
  vector<long long> a, b;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  for (long long i = 0; i < n; i++) {
    cin >> x;
    b.push_back(x);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (long long i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      if (a.size() == 0) {
        b.pop_back();
      } else if (b.size() == 0) {
        scoreA = scoreA + a[a.size() - 1];
        a.pop_back();
      } else {
        if (a[a.size() - 1] > b[b.size() - 1]) {
          scoreA = scoreA + a[a.size() - 1];
          a.pop_back();
        } else {
          b.pop_back();
        }
      }
    } else {
      if (b.size() == 0) {
        a.pop_back();
      } else if (a.size() == 0) {
        scoreB = scoreB + b[b.size() - 1];
        b.pop_back();
      } else {
        if (b[b.size() - 1] > a[a.size() - 1]) {
          scoreB = scoreB + b[b.size() - 1];
          b.pop_back();
        } else {
          a.pop_back();
        }
      }
    }
  }
  cout << scoreA - scoreB << endl;
  return 0;
}

```


### Prompt

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

In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know if in the zoo there are two camels, which spitted at each other. Help him to solve this task.

The trajectory of a camel's spit is an arc, i.e. if the camel in position x spits d meters right, he can hit only the camel in position x + d, if such a camel exists.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the amount of camels in the zoo. Each of the following n lines contains two integers xi and di ( - 104 ≤ xi ≤ 104, 1 ≤ |di| ≤ 2·104) — records in Bob's notepad. xi is a position of the i-th camel, and di is a distance at which the i-th camel spitted. Positive values of di correspond to the spits right, negative values correspond to the spits left. No two camels may stand in the same position.

Output

If there are two camels, which spitted at each other, output YES. Otherwise, output NO.

Examples

Input

2
0 1
1 -1

Output

YES

Input

3
0 1
1 1
2 -2

Output

NO

Input

5
2 -10
3 10
0 5
5 -5
10 1

Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct node {
  int pos, dis;
  node() {}
  node(int a, int b) {
    pos = a;
    dis = b;
  }
};
vector<node> ve;
int main() {
  int t, a, b;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    scanf("%d %d", &a, &b);
    ve.push_back(node(a, b));
  }
  for (int i = 0; i < t; ++i) {
    for (int j = 0; j < t; ++j) {
      if (i == j) continue;
      if (ve[i].pos + ve[i].dis == ve[j].pos &&
          ve[j].pos + ve[j].dis == ve[i].pos) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

You are given an array a consisting of 500000 integers (numbered from 1 to 500000). Initially all elements of a are zero.

You have to process two types of queries to this array:

  * 1 x y — increase a_x by y;
  * 2 x y — compute ∑_{i ∈ R(x, y)} a_i, where R(x, y) is the set of all integers from 1 to 500000 which have remainder y modulo x.

Can you process all the queries?

Input

The first line contains one integer q (1 ≤ q ≤ 500000) — the number of queries.

Then q lines follow, each describing a query. The i-th line contains three integers t_i, x_i and y_i (1 ≤ t_i ≤ 2). If t_i = 1, then it is a query of the first type, 1 ≤ x_i ≤ 500000, and -1000 ≤ y_i ≤ 1000. If t_i = 2, then it it a query of the second type, 1 ≤ x_i ≤ 500000, and 0 ≤ y_i < x_i.

It is guaranteed that there will be at least one query of type 2.

Output

For each query of type 2 print one integer — the answer to it.

Example

Input

5
1 3 4
2 3 0
2 4 3
1 4 -4
2 1 0

Output

4
4
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long llINF = 0x3f3f3f3f3f3f3f3f;
inline bool read(long long &num) {
  char in;
  bool IsN = false;
  in = getchar();
  if (in == EOF) return false;
  while (in != '-' && (in < '0' || in > '9')) in = getchar();
  if (in == '-') {
    IsN = true;
    num = 0;
  } else
    num = in - '0';
  while (in = getchar(), in >= '0' && in <= '9') {
    num *= 10, num += in - '0';
  }
  if (IsN) num = -num;
  return true;
}
long long A[N], SUM[301][301];
int main() {
  long long q, op, x, y;
  read(q);
  while (q--) {
    read(op);
    read(x);
    read(y);
    if (op == 1) {
      A[x] += y;
      for (int i = (1); i <= (300); i++) SUM[i][x % i] += y;
    } else {
      long long ans = 0;
      if (x > 300) {
        for (int i = y; i <= 500000; i += x) ans += A[i];
        printf("%lld\n", ans);
      } else {
        printf("%lld\n", SUM[x][y]);
      }
    }
  }
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

A rooted tree is a non-directed connected graph without any cycles with a distinguished vertex, which is called the tree root. Consider the vertices of a rooted tree, that consists of n vertices, numbered from 1 to n. In this problem the tree root is the vertex number 1.

Let's represent the length of the shortest by the number of edges path in the tree between vertices v and u as d(v, u).

A parent of vertex v in the rooted tree with the root in vertex r (v ≠ r) is vertex pv, such that d(r, pv) + 1 = d(r, v) and d(pv, v) = 1. For example, on the picture the parent of vertex v = 5 is vertex p5 = 2.

One day Polycarpus came across a rooted tree, consisting of n vertices. The tree wasn't exactly ordinary: it had strings written on its edges. Polycarpus positioned the tree on the plane so as to make all edges lead from top to bottom if you go from the vertex parent to the vertex (see the picture). For any edge that lead from vertex pv to vertex v (1 < v ≤ n), he knows string sv that is written on it. All strings are written on the edges from top to bottom. For example, on the picture s7="ba". The characters in the strings are numbered starting from 0.

<image> An example of Polycarpus's tree (corresponds to the example from the statement)

Polycarpus defines the position in this tree as a specific letter on a specific string. The position is written as a pair of integers (v, x) that means that the position is the x-th letter of the string sv (1 < v ≤ n, 0 ≤ x < |sv|), where |sv| is the length of string sv. For example, the highlighted letters are positions (2, 1) and (3, 1).

Let's consider the pair of positions (v, x) and (u, y) in Polycarpus' tree, such that the way from the first position to the second goes down on each step. We will consider that the pair of such positions defines string z. String z consists of all letters on the way from (v, x) to (u, y), written in the order of this path. For example, in the picture the highlighted positions define string "bacaba".

Polycarpus has a string t, he wants to know the number of pairs of positions that define string t. Note that the way from the first position to the second in the pair must go down everywhere. Help him with this challenging tree-string problem!

Input

The first line contains integer n (2 ≤ n ≤ 105) — the number of vertices of Polycarpus's tree. Next n - 1 lines contain the tree edges. The i-th of them contains number pi + 1 and string si + 1 (1 ≤ pi + 1 ≤ n; pi + 1 ≠ (i + 1)). String si + 1 is non-empty and consists of lowercase English letters. The last line contains string t. String t consists of lowercase English letters, its length is at least 2.

It is guaranteed that the input contains at most 3·105 English letters.

Output

Print a single integer — the required number.

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

Examples

Input

7
1 ab
5 bacaba
1 abacaba
2 aca
5 ba
2 ba
aba

Output

6

Input

7
1 ab
5 bacaba
1 abacaba
2 aca
5 ba
2 ba
bacaba

Output

4

Note

In the first test case string "aba" is determined by the pairs of positions: (2, 0) and (5, 0); (5, 2) and (6, 1); (5, 2) and (3, 1); (4, 0) and (4, 2); (4, 4) and (4, 6); (3, 3) and (3, 5).

Note that the string is not defined by the pair of positions (7, 1) and (5, 0), as the way between them doesn't always go down.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int Maxs = 300 * 1000 + 5, Maxn = 100 * 1000 + 5;
int n, dp[Maxs], nxt[Maxs][26];
char s[Maxs];
long long ans;
string t;
vector<int> adj[Maxn];
vector<string> str[Maxn];
void kmp() {
  dp[0] = -1;
  for (int i = 0; i < (int)t.size(); i++) {
    int pt = i;
    while (dp[pt] != -1 && t[dp[pt]] != t[i]) pt = dp[pt];
    dp[i + 1] = dp[pt] + 1;
  }
  return;
}
void dfs(int v, int indt) {
  for (int i = 0; i < adj[v].size(); i++) {
    int indt2 = indt;
    for (int j = 0; j < (int)str[v][i].size(); j++) {
      if (indt2 == (int)t.size()) ans++;
      indt2 = nxt[indt2 + 1][str[v][i][j] - 'a'];
    }
    if (indt2 == (int)t.size()) {
      ans++;
      indt2 = dp[indt2];
    }
    dfs(adj[v][i], indt2);
  }
  return;
}
int main() {
  scanf("%d", &n);
  int par;
  for (int i = 1; i < n; i++) {
    scanf("%d%s", &par, s);
    par--;
    adj[par].push_back(i);
    str[par].push_back(s);
  }
  scanf("%s", s);
  t = s;
  kmp();
  for (int i = 1; i <= (int)t.size() + 1; i++) {
    for (int j = 0; j < 26; j++) {
      if (i <= (int)t.size() && t[i - 1] - 'a' == j)
        nxt[i][j] = i;
      else
        nxt[i][j] = nxt[dp[i - 1] + 1][j];
    }
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

The nation of Panel holds an annual show called The Number Games, where each district in the nation will be represented by one contestant.

The nation has n districts numbered from 1 to n, each district has exactly one path connecting it to every other district. The number of fans of a contestant from district i is equal to 2^i.

This year, the president decided to reduce the costs. He wants to remove k contestants from the games. However, the districts of the removed contestants will be furious and will not allow anyone to cross through their districts.

The president wants to ensure that all remaining contestants are from districts that can be reached from one another. He also wishes to maximize the total number of fans of the participating contestants.

Which contestants should the president remove?

Input

The first line of input contains two integers n and k (1 ≤ k < n ≤ 10^6) — the number of districts in Panel, and the number of contestants the president wishes to remove, respectively.

The next n-1 lines each contains two integers a and b (1 ≤ a, b ≤ n, a ≠ b), that describe a road that connects two different districts a and b in the nation. It is guaranteed that there is exactly one path between every two districts.

Output

Print k space-separated integers: the numbers of the districts of which the contestants should be removed, in increasing order of district number.

Examples

Input

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

Output

1 3 4

Input

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

Output

1 3 4 5

Note

In the first sample, the maximum possible total number of fans is 2^2 + 2^5 + 2^6 = 100. We can achieve it by removing the contestants of the districts 1, 3, and 4.

### Response

```cpp
#include <bits/stdc++.h>
#pragma optimize("Ofast")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
using namespace std;
const int inf = 0x3f3f3f3f;
const long long inf2 = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int mod = 1000000007;
namespace fastio {
char in[100000];
int itr = 0, llen = 0;
char get() {
  if (itr == llen) llen = fread(in, 1, 100000, stdin), itr = 0;
  if (llen == 0) return EOF;
  return in[itr++];
}
char out[100000];
int itr2 = 0;
void put(char c) {
  out[itr2++] = c;
  if (itr2 == 100000) {
    fwrite(out, 1, 100000, stdout);
    itr2 = 0;
  }
}
int clear() {
  fwrite(out, 1, itr2, stdout);
  itr2 = 0;
  return 0;
}
int getint() {
  int r = 0;
  bool ng = 0;
  char c;
  c = get();
  while (c != '-' && (c < '0' || c > '9')) c = get();
  if (c == '-') ng = 1, c = get();
  while (c >= '0' && c <= '9') r = r * 10 + c - '0', c = get();
  return ng ? -r : r;
}
string getstr() {
  string ret = "";
  char ch = get();
  while (ch == ' ' || ch == '\n') ch = get();
  while (ch != ' ' && ch != '\n') ret.push_back(ch), ch = get();
  return ret;
}
void putstr(string s) {
  for (int i = 0; i < s.size(); i++) put(s[i]);
}
void putint(int x) {
  if (x < 0) {
    put('-');
    x = -x;
  }
  if (x == 0) {
    put('0');
    return;
  }
  char c[20];
  int pos = 0;
  while (x) {
    c[pos++] = '0' + x % 10;
    x /= 10;
  }
  for (int i = pos - 1; i >= 0; i--) put(c[i]);
}
void getarr(int arrname[], int size) {
  for (int i = 0; i < size; i++) arrname[i] = getint();
}
}  // namespace fastio
using namespace fastio;
int number[1000005], BITN = 1e6;
void modify(int x, int y) {
  while (x <= BITN) {
    number[x] += y;
    x += x & -x;
  }
}
int sum(int x) {
  int ret = 0;
  while (x) {
    ret += number[x];
    x &= x - 1;
  }
  return ret;
}
void add(int l, int r, int v) {
  modify(l, v);
  modify(r, -v);
}
int qry(int x) { return sum(x); }
int n, k;
vector<int> g[1000005];
vector<int> ord;
int pos[1000005];
bool used[1000005];
int par[1000005];
int sz[1000005], depth[1000005];
void dfs(int x, int pr) {
  depth[x] = x == n ? 0 : depth[pr] + 1;
  pos[x] = ord.size() + 1;
  ord.push_back(x);
  sz[x] = 1;
  for (auto to : g[x])
    if (to != pr) par[to] = x, dfs(to, x), sz[x] += sz[to];
}
int main() {
  n = getint();
  k = getint();
  for (int i = 1; i < n; i++) {
    int a = getint(), b = getint();
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  for (int i = 0; i < ord.size(); i++) {
    modify(i + 1, depth[ord[i]] - (i == 0 ? 0 : depth[ord[i - 1]]));
  }
  used[n] = true;
  int rest = n - k - 1;
  for (int v = n - 1; v > 0 && rest; v--) {
    if (used[v]) continue;
    int len = qry(pos[v]);
    if (len <= rest) {
      int cur = v;
      while (!used[cur]) {
        used[cur] = true;
        add(pos[cur], pos[cur] + sz[cur], -1);
        cur = par[cur];
        rest--;
      }
    }
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++)
    if (!used[i]) ans.push_back(i);
  for (int i = 0; i < ans.size(); i++) putint(ans[i]), put(' ');
  clear();
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

There are n cities in Berland. Some pairs of cities are connected by roads. All roads are bidirectional. Each road connects two different cities. There is at most one road between a pair of cities. The cities are numbered from 1 to n.

It is known that, from the capital (the city with the number 1), you can reach any other city by moving along the roads.

The President of Berland plans to improve the country's road network. The budget is enough to repair exactly n-1 roads. The President plans to choose a set of n-1 roads such that:

  * it is possible to travel from the capital to any other city along the n-1 chosen roads,
  * if d_i is the number of roads needed to travel from the capital to city i, moving only along the n-1 chosen roads, then d_1 + d_2 + ... + d_n is minimized (i.e. as minimal as possible).

In other words, the set of n-1 roads should preserve the connectivity of the country, and the sum of distances from city 1 to all cities should be minimized (where you can only use the n-1 chosen roads).

The president instructed the ministry to prepare k possible options to choose n-1 roads so that both conditions above are met.

Write a program that will find k possible ways to choose roads for repair. If there are fewer than k ways, then the program should output all possible valid ways to choose roads.

Input

The first line of the input contains integers n, m and k (2 ≤ n ≤ 2⋅10^5, n-1 ≤ m ≤ 2⋅10^5, 1 ≤ k ≤ 2⋅10^5), where n is the number of cities in the country, m is the number of roads and k is the number of options to choose a set of roads for repair. It is guaranteed that m ⋅ k ≤ 10^6.

The following m lines describe the roads, one road per line. Each line contains two integers a_i, b_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i) — the numbers of the cities that the i-th road connects. There is at most one road between a pair of cities. The given set of roads is such that you can reach any city from the capital.

Output

Print t (1 ≤ t ≤ k) — the number of ways to choose a set of roads for repair. Recall that you need to find k different options; if there are fewer than k of them, then you need to find all possible different valid options.

In the following t lines, print the options, one per line. Print an option as a string of m characters where the j-th character is equal to '1' if the j-th road is included in the option, and is equal to '0' if the road is not included. The roads should be numbered according to their order in the input. The options can be printed in any order. All the t lines should be different.

Since it is guaranteed that m ⋅ k ≤ 10^6, the total length of all the t lines will not exceed 10^6.

If there are several answers, output any of them.

Examples

Input

4 4 3
1 2
2 3
1 4
4 3

Output

2
1110
1011

Input

4 6 3
1 2
2 3
1 4
4 3
2 4
1 3

Output

1
101001

Input

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

Output

2
111100
110110

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<pair<int, int> > edge[200001];
vector<int> d;
vector<int> v_choose;
char choose[200001];
void read_data() {
  cin >> n >> m >> k;
  int a, b;
  d.resize(n + 1);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    edge[a].push_back(make_pair(b, i));
    edge[b].push_back(make_pair(a, i));
  }
}
void deal() {
  queue<int> q;
  vector<bool> isv;
  isv.resize(n + 1, 0);
  d.resize(n + 1);
  q.push(1);
  d[1] = 0;
  isv[1] = true;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto &i : edge[u]) {
      int v = i.first;
      if (!isv[v]) {
        isv[v] = true;
        d[v] = d[u] + 1;
        q.push(v);
      }
    }
  }
  for (int v = 2; v <= n; v++) {
    vector<pair<int, int> > all = edge[v];
    edge[v].clear();
    for (int l = 0; l < all.size(); l++) {
      int u = all[l].first;
      if (d[u] + 1 == d[v]) {
        edge[v].push_back(make_pair(u, all[l].second));
      }
    }
  }
  long long int ans = 1;
  for (int v = 2; v <= n; v++)
    if (edge[v].size() > 0) {
      ans = ans * edge[v].size();
      if (ans > k) {
        ans = k;
        break;
      }
    }
  cout << ans << endl;
  memset(choose, '0', sizeof(choose));
  choose[m] = 0;
  v_choose.resize(n + 1);
  for (int v = 2; v <= n; v++) {
    v_choose[v] = 0;
    choose[edge[v][0].second] = '1';
  }
  printf("%s\n", choose);
  for (int i = 1; i < ans; i++) {
    for (int v = n; v >= 2; v--) {
      int evs = edge[v].size();
      if (evs - 1 == v_choose[v]) {
        choose[edge[v][evs - 1].second] = '0';
        v_choose[v] = 0;
        choose[edge[v][0].second] = '1';
      } else {
        int &vc = v_choose[v];
        choose[edge[v][vc].second] = '0';
        vc++;
        choose[edge[v][vc].second] = '1';
        break;
      }
    }
    printf("%s\n", choose);
  }
}
int main() {
  read_data();
  deal();
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Constraints

* 1 ≤ a,b ≤ 10000
* a and b are integers.

Input

Input is given from Standard Input in the following format:

a b

Output

If the product is odd, print `Odd`; if it is even, print `Even`.

Examples

Input

3 4

Output

Even

Input

1 21

Output

Odd

### Response

```cpp
#include <iostream>
using namespace std;
int main(){int a,b;cin>>a>>b;if(a&b&1)puts("Odd");else puts("Even");return 0;}
```


### Prompt

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

Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.

Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.

Find the maximum number of tasty cookies that Takahashi can eat.

Constraints

* 0 \leq A,B,C \leq 10^9
* A,B and C are integers.

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the maximum number of tasty cookies that Takahashi can eat.

Examples

Input

3 1 4

Output

5

Input

5 2 9

Output

10

Input

8 8 1

Output

9

### Response

```cpp
#include <iostream>
using namespace std;

int main() {
	long a,b,c;
	cin>>a>>b>>c;
	if(a+b<c)cout<<a+2*b+1<<endl;
	else cout<<b+c<<endl;
	return 0;
}
```


### Prompt

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

Let A = {a1, a2, ..., an} be any permutation of the first n natural numbers {1, 2, ..., n}. You are given a positive integer k and another sequence B = {b1, b2, ..., bn}, where bi is the number of elements aj in A to the left of the element at = i such that aj ≥ (i + k).

For example, if n = 5, a possible A is {5, 1, 4, 2, 3}. For k = 2, B is given by {1, 2, 1, 0, 0}. But if k = 3, then B = {1, 1, 0, 0, 0}.

For two sequences X = {x1, x2, ..., xn} and Y = {y1, y2, ..., yn}, let i-th elements be the first elements such that xi ≠ yi. If xi < yi, then X is lexicographically smaller than Y, while if xi > yi, then X is lexicographically greater than Y.

Given n, k and B, you need to determine the lexicographically smallest A.

Input

The first line contains two space separated integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ n). On the second line are n integers specifying the values of B = {b1, b2, ..., bn}.

Output

Print on a single line n integers of A = {a1, a2, ..., an} such that A is lexicographically minimal. It is guaranteed that the solution exists.

Examples

Input

5 2
1 2 1 0 0

Output

4 1 5 2 3

Input

4 2
1 0 0 0

Output

2 3 1 4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2100;
int a[MAXN];
int b[MAXN];
int z[MAXN];
char used[MAXN];
int n;
int k;
int main() {
  int i;
  cin >> n >> k;
  for (i = 1; i <= n; ++i) cin >> b[i];
  memset(used, 0, sizeof(used));
  int j;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) {
      z[j]++;
      if (!used[j] && b[j] == z[j + k]) {
        a[i] = j;
        used[j] = 1;
        break;
      }
    }
  for (i = 1; i <= n; ++i) cout << a[i] << ' ';
  cout << endl;
  return 0;
}

```


### Prompt

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

You are both a shop keeper and a shop assistant at a small nearby shop. You have n goods, the i-th good costs a_i coins.

You got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More precisely you decided to set the same price for all n goods you have.

However, you don't want to lose any money so you want to choose the price in such a way that the sum of new prices is not less than the sum of the initial prices. It means that if you sell all n goods for the new price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.

On the other hand, you don't want to lose customers because of big prices so among all prices you can choose you need to choose the minimum one.

So you need to find the minimum possible equal price of all n goods so if you sell them for this price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.

You have to answer q independent queries.

Input

The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.

The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of goods. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^7), where a_i is the price of the i-th good.

Output

For each query, print the answer for it — the minimum possible equal price of all n goods so if you sell them for this price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.

Example

Input

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

Output

3
2
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
void solve() {
  int n;
  cin >> n;
  int arr[n];
  long long maj = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    maj += arr[i];
  }
  cout << (maj + n - 1) / n << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}

```


### Prompt

Generate a CPP solution to the following problem:

You are given names of two days of the week.

Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.

In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.

Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".

Input

The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".

Output

Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).

Examples

Input

monday
tuesday

Output

NO

Input

sunday
sunday

Output

YES

Input

saturday
tuesday

Output

YES

Note

In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.

In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int M = 1e6 + 15;
const int Q = 1e9 + 7;
int num(string x) {
  if (x[0] == 'm') return 0;
  if (x[0] == 't') {
    if (x[1] == 'u') return 1;
    return 3;
  }
  if (x[0] == 'w') return 2;
  if (x[0] == 'f') return 4;
  if (x[1] == 'a') return 5;
  return 6;
}
int ar[11] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
int main() {
  srand(time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  string ax, bx;
  cin >> ax >> bx;
  int a = num(ax), b = num(bx);
  for (int i = 0; i < 11; i++) {
    if ((ar[i] + a) % 7 == b) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}

```


### Prompt

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

Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:

  * 2 and 4 are similar (binary representations are 10 and 100);
  * 1337 and 4213 are similar (binary representations are 10100111001 and 1000001110101);
  * 3 and 2 are not similar (binary representations are 11 and 10);
  * 42 and 13 are similar (binary representations are 101010 and 1101).

You are given an array of n integers a_1, a_2, ..., a_n. You may choose a non-negative integer x, and then get another array of n integers b_1, b_2, ..., b_n, where b_i = a_i ⊕ x (⊕ denotes bitwise XOR).

Is it possible to obtain an array b where all numbers are similar to each other?

Input

The first line contains one integer n (2 ≤ n ≤ 100).

The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 2^{30} - 1).

Output

If it is impossible to choose x so that all elements in the resulting array are similar to each other, print one integer -1.

Otherwise, print any non-negative integer not exceeding 2^{30} - 1 that can be used as x so that all elements in the resulting array are similar.

Examples

Input

2
7 2

Output

1

Input

4
3 17 6 0

Output

5

Input

3
1 2 3

Output

-1

Input

3
43 12 12

Output

1073709057

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
struct Node {
  int value{0};
  int x{-1};
  Node* children[31]{};
  Node() {
    for (auto& child : children) {
      child = nullptr;
    }
  }
};
Node* root = new Node();
int kol1[33000][110], kol2[33000][110], del[33000][110];
int main() {
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<int> v(n);
  for (int i = 0; i < n; i++) {
    std::cin >> v[i];
  }
  for (int cur_x = 0; cur_x < (1 << 15); cur_x++) {
    for (int i = 0; i < n; i++) {
      int cur_kol = 0;
      for (int bit_pos = 0; bit_pos < 15; bit_pos++) {
        if (((cur_x & (1 << bit_pos)) > 0 && (v[i] & (1 << bit_pos)) == 0) ||
            ((cur_x & (1 << bit_pos)) == 0 && (v[i] & (1 << bit_pos)) > 0)) {
          cur_kol++;
        }
      }
      kol1[cur_x][i] = cur_kol;
    }
    for (int i = 0; i < n - 1; i++) {
      del[cur_x][i] = kol1[cur_x][i + 1] - kol1[cur_x][i];
    }
    for (int i = 0; i < n; i++) {
      int cur_kol = 0;
      for (int bit_pos = 0; bit_pos < 15; bit_pos++) {
        if (((cur_x & (1 << bit_pos)) > 0 &&
             (v[i] & (1 << (bit_pos + 15))) == 0) ||
            ((cur_x & (1 << bit_pos)) == 0 &&
             (v[i] & (1 << (bit_pos + 15))) > 0)) {
          cur_kol++;
        }
      }
      kol2[cur_x][i] = cur_kol;
    }
    Node* cur_node = root;
    for (int i = 0; i < n - 1; i++) {
      int to_add = kol2[cur_x][i + 1] - kol2[cur_x][i];
      if (cur_node->children[to_add + 15] == nullptr) {
        cur_node->children[to_add + 15] = new Node();
      }
      cur_node = cur_node->children[to_add + 15];
      if (i + 1 == n - 1) {
        cur_node->x = cur_x;
      }
    }
  }
  for (int cur_x = 0; cur_x < (1 << 15); cur_x++) {
    Node* cur_node = root;
    bool ok = true;
    for (int i = 0; i < n - 1; i++) {
      int to_find = del[cur_x][i];
      if (cur_node->children[-to_find + 15] == nullptr) {
        ok = false;
        break;
      }
      cur_node = cur_node->children[-to_find + 15];
    }
    if (ok) {
      std::cout << (cur_node->x << 15) + cur_x;
      return 0;
    }
  }
  std::cout << -1;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

You are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.

For example, if n=3, and k=7, then all numbers that are not divisible by 3 are: 1, 2, 4, 5, 7, 8, 10, 11, 13 .... The 7-th number among them is 10.

Input

The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases in the input. Next, t test cases are given, one per line.

Each test case is two positive integers n (2 ≤ n ≤ 10^9) and k (1 ≤ k ≤ 10^9).

Output

For each test case print the k-th positive integer that is not divisible by n.

Example

Input

6
3 7
4 12
2 1000000000
7 97
1000000000 1000000000
2 1

Output

10
15
1999999999
113
1000000001
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    int diff = (k - 1) / (n - 1);
    cout << diff + k << "\n";
  }
  return 0;
}

```


### Prompt

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

Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".

To play Mau-Mau, you need a pack of 52 cards. Each card has a suit (Diamonds — D, Clubs — C, Spades — S, or Hearts — H), and a rank (2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, or A).

At the start of the game, there is one card on the table and you have five cards in your hand. You can play a card from your hand if and only if it has the same rank or the same suit as the card on the table.

In order to check if you'd be a good playing partner, Gennady has prepared a task for you. Given the card on the table and five cards in your hand, check if you can play at least one card.

Input

The first line of the input contains one string which describes the card on the table. The second line contains five strings which describe the cards in your hand.

Each string is two characters long. The first character denotes the rank and belongs to the set \{{\tt 2}, {\tt 3}, {\tt 4}, {\tt 5}, {\tt 6}, {\tt 7}, {\tt 8}, {\tt 9}, {\tt T}, {\tt J}, {\tt Q}, {\tt K}, {\tt A}\}. The second character denotes the suit and belongs to the set \{{\tt D}, {\tt C}, {\tt S}, {\tt H}\}.

All the cards in the input are different.

Output

If it is possible to play a card from your hand, print one word "YES". Otherwise, print "NO".

You can print each letter in any case (upper or lower).

Examples

Input

AS
2H 4C TH JH AD

Output

YES

Input

2H
3D 4C AC KD AS

Output

NO

Input

4D
AS AC AD AH 5H

Output

YES

Note

In the first example, there is an Ace of Spades (AS) on the table. You can play an Ace of Diamonds (AD) because both of them are Aces.

In the second example, you cannot play any card.

In the third example, you can play an Ace of Diamonds (AD) because it has the same suit as a Four of Diamonds (4D), which lies on the table.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = (int)s[0] - 48;
  char rang = s[1];
  for (int i = 0; i < 5; ++i) {
    string s_i;
    cin >> s_i;
    int n_i = (int)s_i[0] - 48;
    char rang_i = s_i[1];
    if (n == n_i || rang == rang_i) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it.

The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present.

For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one).

When the guesser is answered "4 bulls 0 cows", the game is over.

Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one.

Input

The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present.

Output

If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes.

Examples

Input

2
1263 1 2
8103 2 1

Output

Need more data

Input

2
1234 2 2
1256 0 2

Output

2134

Input

2
0123 1 1
4567 1 2

Output

Incorrect data

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int ok[10];
int a[20][5];
int b[20][10];
int q[20];
int y[20];
int now[10];
int main() {
  int n;
  int ans = 0;
  memset(q, 0, sizeof(q));
  memset(y, 0, sizeof(y));
  memset(b, 0, sizeof(b));
  memset(a, 0, sizeof(a));
  cin >> n;
  int num = 0;
  for (int i = 1; i <= n; i++) {
    int e, r, t;
    char p;
    for (int j = 1; j <= 4; j++) {
      p = getchar();
      if (p == '\n') p = getchar();
      a[i][j] = p - '0';
      b[i][p - '0'] = 1;
    }
    cin >> r >> t;
    q[i] = r;
    y[i] = t;
  }
  for (int i = 1; i <= 9999; i++) {
    int z = i;
    memset(ok, 0, sizeof(ok));
    memset(now, 0, sizeof(now));
    int isok = 1;
    for (int j = 1; j <= 4; j++) {
      int g = z % 10;
      if (ok[g]) {
        isok = 0;
        break;
      } else {
        ok[g] = 1;
        now[j] = g;
      }
      z = z / 10;
    }
    if (!isok) continue;
    for (int j = 1; j <= n; j++) {
      int num1 = 0;
      int num2 = 0;
      for (int k = 1; k <= 4; k++) {
        if (a[j][k] == now[5 - k]) {
          num1++;
        }
      }
      for (int k = 0; k <= 9; k++) {
        if (ok[k] == 1 && b[j][k] == 1) num2++;
      }
      if (num1 != q[j] || (num2 - num1) != y[j]) {
        isok = 0;
      }
    }
    if (isok) {
      num++;
      ans = i;
    }
  }
  if (num == 1) {
    if (ans > 1000)
      cout << ans << endl;
    else
      cout << "0" << ans << endl;
  }
  if (num == 0) cout << "Incorrect data" << endl;
  if (num > 1) cout << "Need more data" << endl;
  return 0;
}

```


### Prompt

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

Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture:

<image>

Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap.

Input

The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday).

Output

Print single integer: the number of columns the table should have.

Examples

Input

1 7

Output

6

Input

1 1

Output

5

Input

11 6

Output

5

Note

The first example corresponds to the January 2017 shown on the picture in the statements.

In the second example 1-st January is Monday, so the whole month fits into 5 columns.

In the third example 1-st November is Saturday and 5 columns is enough.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  int m, d;
  cin >> m >> d;
  a[m] -= 7 - d + 1;
  if (a[m] % 7 == 0)
    cout << a[m] / 7 + 1 << endl;
  else
    cout << a[m] / 7 + 2 << endl;
}

```


### Prompt

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

Gerald found a table consisting of n rows and m columns. As a prominent expert on rectangular tables, he immediately counted the table's properties, that is, the minimum of the numbers in the corners of the table (minimum of four numbers). However, he did not like the final value — it seemed to be too small. And to make this value larger, he decided to crop the table a little: delete some columns on the left and some on the right, as well as some rows from the top and some from the bottom. Find what the maximum property of the table can be after such cropping. Note that the table should have at least two rows and at least two columns left in the end. The number of cropped rows or columns from each of the four sides can be zero.

Input

The first line contains two space-separated integers n and m (2 ≤ n, m ≤ 1000). The following n lines describe the table. The i-th of these lines lists the space-separated integers ai, 1, ai, 2, ..., ai, m (0 ≤ ai, j ≤ 109) — the m numbers standing in the i-th row of the table.

Output

Print the answer to the problem.

Examples

Input

2 2
1 2
3 4

Output

1

Input

3 3
1 0 0
0 1 1
1 0 0

Output

0

Note

In the first test case Gerald cannot crop the table — table contains only two rows and only two columns.

In the second test case if we'll crop the table, the table will contain zero in some corner cell. Also initially it contains two zeros in the corner cells, so the answer is 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, N;
bool b[2000][2000], c[2000][2000];
struct num {
  int x, y, v;
} a[2000000];
bool cpr(num x, num y) { return x.v > y.v; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= (n); ++i)
    for (int j = 1; j <= (m); ++j) {
      scanf("%d", &a[++N].v);
      a[N].x = i, a[N].y = j;
    }
  sort(a + 1, a + N + 1, cpr);
  for (int i = 1; i <= (N); ++i) {
    for (int j = 1; j <= (m); ++j)
      if (c[a[i].x][j]) {
        if (b[j][a[i].y]) {
          printf("%d\n", a[i].v);
          return 0;
        }
        b[j][a[i].y] = b[a[i].y][j] = true;
      }
    c[a[i].x][a[i].y] = true;
  }
}

```


### Prompt

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

You are given two integers n and k.

You need to construct k regular polygons having same [circumcircle](https://en.wikipedia.org/wiki/Circumscribed_circle), with distinct number of sides l between 3 and n.

<image> Illustration for the first example.

You can rotate them to minimize the total number of distinct points on the circle. Find the minimum number of such points.

Input

The only line of input contains two integers n and k (3 ≤ n ≤ 10^{6}, 1 ≤ k ≤ n-2), the maximum number of sides of a polygon and the number of polygons to construct, respectively.

Output

Print a single integer — the minimum number of points required for k polygons.

Examples

Input

6 2

Output

6

Input

200 50

Output

708

Note

In the first example, we have n = 6 and k = 2. So, we have 4 polygons with number of sides 3, 4, 5 and 6 to choose from and if we choose the triangle and the hexagon, then we can arrange them as shown in the picture in the statement.

Hence, the minimum number of points required on the circle is 6, which is also the minimum overall possible sets.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INFi = 1e9 + 5;
const int maxN = 1e6 + 5;
const int md = 998244353;
const long long INF = 2e18;
double getTime() { return clock() / (double)CLOCKS_PER_SEC; }
int phi[maxN];
int mp[maxN];
vector<int> primes;
void init() {
  for (int i = 2; i < maxN; ++i) {
    if (!mp[i]) {
      mp[i] = i;
      primes.push_back(i);
      phi[i] = i - 1;
    }
    for (auto &p : primes) {
      if (1ll * p * i >= maxN || p > mp[i]) break;
      mp[p * i] = p;
      if (p == mp[i]) {
        phi[p * i] = phi[i] * p;
      } else {
        phi[p * i] = phi[i] * (p - 1);
      }
    }
  }
}
void solve() {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << "3\n";
    return;
  }
  init();
  vector<int> ord;
  k++;
  for (int i = 2; i <= n; ++i) ord.push_back(phi[i]);
  sort((ord).begin(), (ord).end());
  ord.resize(k);
  cout << accumulate((ord).begin(), (ord).end(), 0ll) + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tests = 1;
  for (int _ = 0; _ < (tests); ++_) {
    solve();
  }
  return 0;
}

```


### Prompt

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

Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card.

Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written.

The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same.

Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair.

Input

The first line contains a single integer n (2 ≤ n ≤ 100) — number of cards. It is guaranteed that n is an even number.

The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≤ ai ≤ 100) — numbers written on the n cards.

Output

If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more.

In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers — number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them.

Examples

Input

4
11
27
27
11

Output

YES
11 27

Input

2
6
6

Output

NO

Input

6
10
20
30
20
10
20

Output

NO

Input

6
1
1
2
2
3
3

Output

NO

Note

In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards — Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards.

In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct.

In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards — for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j = 0, k = 0, x, y, n, a[100];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  x = a[0];
  for (i = 1; i < n; i++) {
    if (a[i] == x)
      continue;
    else {
      y = a[i];
      break;
    }
  }
  for (i = 0; i < n; i++) {
    if (a[i] == x)
      j++;
    else if (a[i] == y)
      k++;
  }
  if (j == k and (j + k == n)) {
    cout << "YES" << endl;
    cout << x << " " << y;
  } else
    cout << "NO" << endl;
}

```


### Prompt

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

Unlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has some power and a knight can kill another knight if and only if his power is greater than the power of victim. However, even such a knight will torment his conscience, so he can kill no more than k other knights. Also, each knight has some number of coins. After a kill, a knight can pick up all victim's coins.

Now each knight ponders: how many coins he can have if only he kills other knights?

You should answer this question for each knight.

Input

The first line contains two integers n and k (1 ≤ n ≤ 10^5, 0 ≤ k ≤ min(n-1,10)) — the number of knights and the number k from the statement.

The second line contains n integers p_1, p_2 ,…,p_n (1 ≤ p_i ≤ 10^9) — powers of the knights. All p_i are distinct.

The third line contains n integers c_1, c_2 ,…,c_n (0 ≤ c_i ≤ 10^9) — the number of coins each knight has.

Output

Print n integers — the maximum number of coins each knight can have it only he kills other knights.

Examples

Input

4 2
4 5 9 7
1 2 11 33

Output

1 3 46 36

Input

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

Output

1 3 5 7 9

Input

1 0
2
3

Output

3

Note

Consider the first example.

  * The first knight is the weakest, so he can't kill anyone. That leaves him with the only coin he initially has.
  * The second knight can kill the first knight and add his coin to his own two.
  * The third knight is the strongest, but he can't kill more than k = 2 other knights. It is optimal to kill the second and the fourth knights: 2+11+33 = 46.
  * The fourth knight should kill the first and the second knights: 33+1+2 = 36.

In the second example the first knight can't kill anyone, while all the others should kill the one with the index less by one than their own.

In the third example there is only one knight, so he can't kill anyone.

### Response

```cpp
#include <bits/stdc++.h>
const int MAXN = 1e5 + 5;
std::map<int, int> set;
long long ret[MAXN]{};
int k, n;
struct Knight {
  int c, i, p;
} kni[MAXN];
int main() {
  scanf(" %d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", &kni[i].p);
  for (int i = 0; i < n; ++i) scanf("%d", &kni[i].c);
  for (int i = 0; i < n; ++i) kni[i].i = i;
  std::sort(kni, kni + n,
            [](const Knight& lft, const Knight& rgt) { return lft.p < rgt.p; });
  long long sum = 0LL;
  for (int i = 0; i < n; ++i) {
    ++set[kni[i].c];
    sum += kni[i].c;
    ret[kni[i].i] = sum;
    if (i >= k) {
      int min = set.begin()->first;
      if (!--set[min]) set.erase(min);
      sum -= min;
    }
  }
  for (int i = 0; i < n; ++i) printf("%lld\n", ret[i]);
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You may also refer to the guide on interactive problems: <https://codeforces.com/blog/entry/45307>.

There is a city in which Dixit lives. In the city, there are n houses. There is  exactly one directed road between every pair of houses. For example, consider two houses A and B, then there is a directed road either from A to B or from B to A but not both. The number of roads leading to the i-th house is k_i.

Two houses A and B are bi-reachable if A is reachable from B and B is reachable from A. We say that house B is reachable from house A when there is a path from house A to house B.

Dixit wants to buy two houses in the city, that is, one for living and one for studying. Of course, he would like to travel from one house to another. So, he wants to find a pair of bi-reachable houses A and B. Among all such pairs, he wants to choose one with the maximum value of |k_A - k_B|, where k_i is the number of roads leading to the house i. If more than one optimal pair exists, any of them is suitable.

Since Dixit is busy preparing CodeCraft, can you help him find the desired pair of houses, or tell him that no such houses exist?

In the problem input, you are not given the direction of each road. You are given — for each house — only the number of incoming roads to that house (k_i).

You are allowed to ask only one type of query from the judge: give two houses A and B, and the judge answers whether B is reachable from A. There is no upper limit on the number of queries. But, you cannot ask more queries after the judge answers "Yes" to any of your queries. Also, you cannot ask the same query twice.

Once you have exhausted all your queries (or the judge responds "Yes" to any of your queries), your program must output its guess for the two houses and quit.

See the Interaction section below for more details.

Input

The first line contains a single integer n (3 ≤ n ≤ 500) denoting the number of houses in the city. The next line contains n space-separated integers k_1, k_2, ..., k_n (0 ≤ k_i ≤ n - 1), the i-th of them represents the number of incoming roads to the i-th house.

Interaction

To ask a query, print "? A B" (1 ≤ A,B ≤ N, A≠ B). The judge will respond "Yes" if house B is reachable from house A, or "No" otherwise.

To output the final answer, print "! A B", where A and B are bi-reachable with the maximum possible value of |k_A - k_B|. If there does not exist such pair of houses A and B, output "! 0 0".

After outputting the final answer, your program must terminate immediately, otherwise you will receive Wrong Answer verdict.

You cannot ask the same query twice. There is no upper limit to the number of queries you ask, but, you cannot ask more queries after the judge answers "Yes" to any of your queries. Your program must now output the final answer ("! A B" or "! 0 0") and terminate.

If you ask a query in incorrect format or repeat a previous query, you will get Wrong Answer verdict.

After printing a query do not forget to output the end of the line and flush the output. Otherwise, you will get the Idleness limit exceeded error. To do this, use:

  * fflush(stdout) or cout.flush() in C++;
  * System.out.flush() in Java;
  * flush(output) in Pascal;
  * stdout.flush() in Python;
  * see documentation for other languages.

Examples

Input

3
1 1 1
Yes

Output

? 1 2
! 1 2

Input

4
1 2 0 3
No
No
No
No
No
No

Output

? 2 1
? 1 3
? 4 1
? 2 3
? 4 2
? 4 3
! 0 0

Note

In the first sample input, we are given a city of three houses with one incoming road each. The user program asks one query: "? 1 2": asking whether we can reach from house 1 to house 2. The judge responds with "Yes". The user program now concludes that this is sufficient information to determine the correct answer. So, it outputs "! 1 2" and quits.

In the second sample input, the user program queries for six different pairs of houses, and finally answers "! 0 0" as it is convinced that no two houses as desired in the question exist in this city.

### Response

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

template<typename A, typename B>
string to_string(pair<A, B> p);

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template<typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s) {
	return '"' + s + '"';
}

string to_string(const char *s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template<size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template<typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template<typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", "
			+ to_string(get<2>(p)) + ")";
}

template<typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", "
			+ to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void dbg_out() {
	cout << endl;
}

template<typename Head, typename ... Tail>
void dbg_out(Head H, Tail ... T) {
	cout << " " << to_string(H);
	dbg_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]:", dbg_out(__VA_ARGS__)
#else
#define dbg(...) ;
#endif

#define import ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define read(x) cin >> x
#define out(x) cout << x
#define readInt(x) scanf("%d",&x)
#define readLong(x) scanf("%lld",&x)
#define readDouble(x) scanf("%Lf",&x)
#define readString(x) scanf("%s",&x)
#define outInt(x) printf("%d",x)
#define outLong(x) printf("%lld",x)
#define outDouble(x) printf("%Lf",x)
#define outString(x) printf("%s",x)
#define outLine(x) cout << x << endl
#define readArr(x,size) for(int i=0;i<size;i++)read(x[i])
#define outArr(x,size) for(int i=0;i<size;i++){cout << x[i] << " ";}out(endl)
#define ll long long
#define ld long double
#define pii pair<int,int>
#define len(s) (int)(s.length())
#define bitCnt(msk) __builtin_popcount(msk)
#define ff first
#define ss second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mrand(int a) {
	return rng() % a;
}

void test_case() {
	int n;
	cin >> n;
	vector<pair<int,int>>deg(n);
	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		deg[i]=make_pair(x,i);
	}
	sort(deg.begin(),deg.end());
	vector<pair<int,pair<int,int>>>arr(n*(n-1)/2);
	int idx=0;
	for(int c=n-1;c>=0;c--) {
		int i=deg[c].second;
		for(int o=0;o<c;o++) {
			int j=deg[o].second;
			pair<int,pair<int,int>>zz;
			zz.first=-deg[c].first+deg[o].first;
			zz.second=make_pair(i, j);
			arr[idx++]=zz;
		}
	}
	sort(arr.begin(),arr.end());
	for(int c=0;c<arr.size();c++) {
		int i=arr[c].second.first,j=arr[c].second.second;
		cout << "? " << i+1 << " " << j+1 << endl;
		string s;
		cin >> s;
		if(s[0]=='Y') {
			cout << "! " << i+1 << " " << j+1 << endl;
			return;
		}

	}

	cout << "! 0 0" << endl;
}

int main() {
	import;
//	int tc = 1;
//	readInt(tc);
//	while (tc--)
		test_case();
	return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal to k is a palindrome. How many such strings exist? Your task is to find their quantity modulo 1000000007 (109 + 7). Be careful and don't miss a string or two!

Let us remind you that a string is a palindrome if it can be read the same way in either direction, from the left to the right and from the right to the left.

Input

The first and only line contains three integers: n, m and k (1 ≤ n, m, k ≤ 2000).

Output

Print a single integer — the number of strings of the described type modulo 1000000007 (109 + 7).

Examples

Input

1 1 1

Output

1

Input

5 2 4

Output

2

Note

In the first sample only one string is valid: "a" (let's denote the only letter of our alphabet as "a").

In the second sample (if we denote the alphabet letters as "a" and "b") the following strings are valid: "aaaaa" and "bbbbb".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b, long long int mod) {
  if (b == 1) return a % mod;
  if (b == 0) return 1;
  long long int z = power((a * a) % mod, b / 2, mod);
  if (b % 2) return (z * a) % mod;
  return z % mod;
}
int main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  long long int mod = 1000000007;
  if (k == 1 || k > n)
    cout << power(m, n, mod) << endl;
  else if (k == n)
    cout << power(m, (n + 1) / 2, mod) << endl;
  else if (k % 2 == 0)
    cout << m % mod << endl;
  else
    cout << (m * m) % mod << endl;
  return 0;
}

```


### Prompt

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

Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.

Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required. It is guaranteed that for each of four colors at least one light is working.

It is known that the garland contains light bulbs of four colors: red, blue, yellow and green. The garland is made as follows: if you take any four consecutive light bulbs then there will not be light bulbs with the same color among them. For example, the garland can look like "RYBGRYBGRY", "YBGRYBGRYBG", "BGRYB", but can not look like "BGRYG", "YBGRYBYGR" or "BGYBGY". Letters denote colors: 'R' — red, 'B' — blue, 'Y' — yellow, 'G' — green.

Using the information that for each color at least one light bulb still works count the number of dead light bulbs of each four colors.

Input

The first and the only line contains the string s (4 ≤ |s| ≤ 100), which describes the garland, the i-th symbol of which describes the color of the i-th light bulb in the order from the beginning of garland:

  * 'R' — the light bulb is red,
  * 'B' — the light bulb is blue,
  * 'Y' — the light bulb is yellow,
  * 'G' — the light bulb is green,
  * '!' — the light bulb is dead.

The string s can not contain other symbols except those five which were described.

It is guaranteed that in the given string at least once there is each of four letters 'R', 'B', 'Y' and 'G'.

It is guaranteed that the string s is correct garland with some blown light bulbs, it means that for example the line "GRBY!!!B" can not be in the input data.

Output

In the only line print four integers kr, kb, ky, kg — the number of dead light bulbs of red, blue, yellow and green colors accordingly.

Examples

Input

RYBGRYBGR

Output

0 0 0 0

Input

!RGYB

Output

0 1 0 0

Input

!!!!YGRB

Output

1 1 1 1

Input

!GB!RG!Y!

Output

2 1 1 0

Note

In the first example there are no dead light bulbs.

In the second example it is obvious that one blue bulb is blown, because it could not be light bulbs of other colors on its place according to the statements.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int sz = s.size();
  vector<int> cnt(4, 0);
  vector<char> c(4);
  int r, g, y, b;
  for (int a = 0; a < 4; a++)
    for (int i = a; i < sz; i = i + 4)
      if (s[i] != '!')
        c[a] = s[i];
      else
        cnt[a] += 1;
  for (int i = 0; i < 4; i++) {
    if (c[i] == 'R')
      r = cnt[i];
    else if (c[i] == 'B')
      b = cnt[i];
    else if (c[i] == 'Y')
      y = cnt[i];
    else
      g = cnt[i];
  }
  cout << r << " " << b << " " << y << " " << g;
}

```


### Prompt

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

Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)

Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.

If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.

Constraints

* 1 \leq A \leq B \leq 100
* A and B are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

If there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print `-1`.

Examples

Input

2 2

Output

25

Input

8 10

Output

100

Input

19 99

Output

-1

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	for(int i=1;i<=10000;i++)
	{
		if(i*2/25==a&&i/10==b)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}
```


### Prompt

Develop a solution in cpp to the problem described below:

It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.

Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws n sticks in a row. After that the players take turns crossing out exactly k sticks from left or right in each turn. Sasha moves first, because he is the inventor of the game. If there are less than k sticks on the paper before some turn, the game ends. Sasha wins if he makes strictly more moves than Lena. Sasha wants to know the result of the game before playing, you are to help him.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 1018, k ≤ n) — the number of sticks drawn by Sasha and the number k — the number of sticks to be crossed out on each turn.

Output

If Sasha wins, print "YES" (without quotes), otherwise print "NO" (without quotes).

You can print each letter in arbitrary case (upper of lower).

Examples

Input

1 1

Output

YES

Input

10 4

Output

NO

Note

In the first example Sasha crosses out 1 stick, and then there are no sticks. So Lena can't make a move, and Sasha wins.

In the second example Sasha crosses out 4 sticks, then Lena crosses out 4 sticks, and after that there are only 2 sticks left. Sasha can't make a move. The players make equal number of moves, so Sasha doesn't win.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int ans = (n / k);
  if (ans % 2 == 0) {
    cout << "NO"
         << "\n";
  } else
    cout << "YES"
         << "\n";
  return 0;
}

```


### Prompt

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

The annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2N teams participating in the tournament, numbered from 1 to 2N. The tournament lasts N rounds, with each round eliminating half the teams. The first round consists of 2N - 1 games, numbered starting from 1. In game i, team 2·i - 1 will play against team 2·i. The loser is eliminated and the winner advances to the next round (there are no ties). Each subsequent round has half as many games as the previous round, and in game i the winner of the previous round's game 2·i - 1 will play against the winner of the previous round's game 2·i.

Every year the office has a pool to see who can create the best bracket. A bracket is a set of winner predictions for every game. For games in the first round you may predict either team to win, but for games in later rounds the winner you predict must also be predicted as a winner in the previous round. Note that the bracket is fully constructed before any games are actually played. Correct predictions in the first round are worth 1 point, and correct predictions in each subsequent round are worth twice as many points as the previous, so correct predictions in the final game are worth 2N - 1 points.

For every pair of teams in the league, you have estimated the probability of each team winning if they play against each other. Now you want to construct a bracket with the maximum possible expected score.

Input

Input will begin with a line containing N (2 ≤ N ≤ 6).

2N lines follow, each with 2N integers. The j-th column of the i-th row indicates the percentage chance that team i will defeat team j, unless i = j, in which case the value will be 0. It is guaranteed that the i-th column of the j-th row plus the j-th column of the i-th row will add to exactly 100.

Output

Print the maximum possible expected score over all possible brackets. Your answer must be correct to within an absolute or relative error of 10 - 9.

Formally, let your answer be a, and the jury's answer be b. Your answer will be considered correct, if <image>.

Examples

Input

2
0 40 100 100
60 0 40 40
0 60 0 45
0 60 55 0

Output

1.75

Input

3
0 0 100 0 100 0 0 0
100 0 100 0 0 0 100 100
0 0 0 100 100 0 0 0
100 100 0 0 0 0 100 100
0 100 0 100 0 0 100 0
100 100 100 100 100 0 0 0
100 0 100 0 0 100 0 0
100 0 100 0 100 100 100 0

Output

12

Input

2
0 21 41 26
79 0 97 33
59 3 0 91
74 67 9 0

Output

3.141592

Note

In the first example, you should predict teams 1 and 4 to win in round 1, and team 1 to win in round 2. Recall that the winner you predict in round 2 must also be predicted as a winner in round 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
double p[100][100];
double w[10][100];
double s[10][100];
vector<int> opp[10][100];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int k = 1; k <= (1 << n); k += (1 << i)) {
      for (int j = k; j < k + (1 << (i - 1)); j++) {
        for (int m = k + (1 << (i - 1)); m < k + (1 << i); m++)
          opp[i][j].push_back(m);
      }
      for (int j = k + (1 << (i - 1)); j < k + (1 << i); j++) {
        for (int m = k; m < k + (1 << (i - 1)); m++) opp[i][j].push_back(m);
      }
    }
  }
  for (int i = 1; i <= (1 << n); i++) {
    for (int j = 1; j <= (1 << n); j++) {
      scanf("%lf", &p[i][j]);
      p[i][j] /= (double)100;
    }
  }
  for (int i = 1; i <= (1 << n); i++) {
    w[0][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= (1 << n); j++) {
      for (auto k : opp[i][j]) w[i][j] += w[i - 1][j] * w[i - 1][k] * p[j][k];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= (1 << n); j++) {
      for (auto k : opp[i][j])
        s[i][j] =
            max(s[i][j], s[i - 1][k] + s[i - 1][j] + (1 << (i - 1)) * w[i][j]);
    }
  }
  double ans = 0;
  for (int i = 1; i <= (1 << n); i++) {
    ans = max(ans, s[n][i]);
  }
  cout << fixed << setprecision(10) << ans << "\n";
  return 0;
}

```