### Prompt

Please formulate a cpp solution to the following problem:

Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options:

  1. on this day the gym is closed and the contest is not carried out;
  2. on this day the gym is closed and the contest is carried out;
  3. on this day the gym is open and the contest is not carried out;
  4. on this day the gym is open and the contest is carried out.

On each of days Vasya can either have a rest or write the contest (if it is carried out on this day), or do sport (if the gym is open on this day).

Find the minimum number of days on which Vasya will have a rest (it means, he will not do sport and write the contest at the same time). The only limitation that Vasya has — he does not want to do the same activity on two consecutive days: it means, he will not do sport on two consecutive days, and write the contest on two consecutive days.

Input

The first line contains a positive integer n (1 ≤ n ≤ 100) — the number of days of Vasya's vacations.

The second line contains the sequence of integers a1, a2, ..., an (0 ≤ ai ≤ 3) separated by space, where:

  * ai equals 0, if on the i-th day of vacations the gym is closed and the contest is not carried out;
  * ai equals 1, if on the i-th day of vacations the gym is closed, but the contest is carried out;
  * ai equals 2, if on the i-th day of vacations the gym is open and the contest is not carried out;
  * ai equals 3, if on the i-th day of vacations the gym is open and the contest is carried out.

Output

Print the minimum possible number of days on which Vasya will have a rest. Remember that Vasya refuses:

  * to do sport on any two consecutive days,
  * to write the contest on any two consecutive days.

Examples

Input

4
1 3 2 0

Output

2

Input

7
1 3 3 2 1 2 3

Output

0

Input

2
2 2

Output

1

Note

In the first test Vasya can write the contest on the day number 1 and do sport on the day number 3. Thus, he will have a rest for only 2 days.

In the second test Vasya should write contests on days number 1, 3, 5 and 7, in other days do sport. Thus, he will not have a rest for a single day.

In the third test Vasya can do sport either on a day number 1 or number 2. He can not do sport in two days, because it will be contrary to the his limitation. Thus, he will have a rest for only one day.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int rest = 0;
int gym = 0;
int contest = 0;
int main() {
  int n;
  int type;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> type;
    if (type == 0) {
      gym = 0;
      contest = 0;
      rest++;
    } else if (type == 1) {
      if (contest == 0) {
        gym = 0;
        contest = 1;
      } else {
        gym = 0;
        contest = 0;
        rest++;
      }
    } else if (type == 2) {
      if (gym == 0) {
        gym = 1;
        contest = 0;
      } else {
        gym = 0;
        contest = 0;
        rest++;
      }
    } else if (type == 3) {
      if (gym == 1 && contest == 0) {
        gym = 0;
        contest = 1;
      } else if (gym == 0 && contest == 1) {
        gym = 1;
        contest = 0;
      } else {
        gym = 0;
        contest = 0;
      }
    }
  }
  cout << rest << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that <image>. In other words each wool sequence contains a subsequence of consecutive elements with xor equal to 0.

The expression <image> means applying the operation of a bitwise xor to numbers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is marked as "^", in Pascal — as "xor".

In this problem you are asked to compute the number of sequences made of n integers from 0 to 2m - 1 that are not a wool sequence. You should print this number modulo 1000000009 (109 + 9).

Input

The only line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 105).

Output

Print the required number of sequences modulo 1000000009 (109 + 9) on the only line of output.

Examples

Input

3 2

Output

6

Note

Sequences of length 3 made of integers 0, 1, 2 and 3 that are not a wool sequence are (1, 3, 1), (1, 2, 1), (2, 1, 2), (2, 3, 2), (3, 1, 3) and (3, 2, 3).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, m, q, r;
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) return a * pw(a, b - 1) % 1000000009;
  return pw(a * a % 1000000009, b / 2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  q = pw(2, m);
  q = q - 1 + 1000000009;
  q %= 1000000009;
  r = 1;
  for (int i = 1; i <= n; i++) {
    r = r * (q - i + 1000000009 + 1) % 1000000009;
  }
  cout << r << endl;
  cin.get();
  cin.get();
  return 0;
}

```


### Prompt

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

Petya recently found a game "Choose a Square". In this game, there are n points numbered from 1 to n on an infinite field. The i-th point has coordinates (x_i, y_i) and cost c_i.

You have to choose a square such that its sides are parallel to coordinate axes, the lower left and upper right corners belong to the line y = x, and all corners have integer coordinates.

The score you get is the sum of costs of the points covered by the selected square minus the length of the side of the square. Note that the length of the side can be zero.

Petya asks you to calculate the maximum possible score in the game that can be achieved by placing exactly one square.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the number of points on the field.

Each of the following n lines contains three integers x_i, y_i, c_i (0 ≤ x_i, y_i ≤ 10^9, -10^6 ≤ c_i ≤ 10^6) — coordinates of the i-th point and its cost, respectively.

Output

In the first line print the maximum score Petya can achieve.

In the second line print four integers x_1, y_1, x_2, y_2 (0 ≤ x_1, y_1, x_2, y_2 ≤ 2 ⋅ 10^9, x_1 = y_1, x_2 = y_2, x_1 ≤ x_2) separated by spaces — the coordinates of the lower left and upper right corners of the square which Petya has to select in order to achieve the maximum score.

Examples

Input

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

Output

4
1 1 3 3

Input

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

Output

0
1 1 1 1

Note

The field corresponding to the first example: <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
long long int c[N], lzy[6 * N], n, x[N], y[N], sz = 0, m2[N];
map<long long int, long long int> m1;
pair<long long int, long long int> tree[6 * N];
vector<pair<long long int, long long int> > v[N];
void build(int lo, int hi, int i) {
  if (lo == hi) {
    tree[i] = {0, lo};
    return;
  }
  int mid = (lo + hi) / 2;
  build(lo, mid, 2 * i);
  build(mid + 1, hi, 2 * i + 1);
  tree[i] = max(tree[2 * i], tree[2 * i + 1]);
}
void update(int lo, int hi, int l, int r, long long int cost, int i) {
  if (lo > r || hi < l) return;
  if (lzy[i]) {
    if (lo != hi) {
      tree[2 * i].first += lzy[i];
      tree[2 * i + 1].first += lzy[i];
      lzy[2 * i] += lzy[i];
      lzy[2 * i + 1] += lzy[i];
    }
    lzy[i] = 0;
  }
  if (lo >= l && hi <= r) {
    tree[i].first += cost;
    lzy[i] += cost;
    return;
  }
  int mid = (lo + hi) / 2;
  update(lo, mid, l, r, cost, 2 * i);
  update(mid + 1, hi, l, r, cost, 2 * i + 1);
  tree[i] = max(tree[2 * i], tree[2 * i + 1]);
}
pair<long long int, long long int> query(int lo, int hi, int l, int r, int i) {
  if (lo > r || hi < l) return {-1e18, 0};
  if (lzy[i]) {
    if (lo != hi) {
      tree[2 * i].first += lzy[i];
      tree[2 * i + 1].first += lzy[i];
      lzy[2 * i] += lzy[i];
      lzy[2 * i + 1] += lzy[i];
    }
    lzy[i] = 0;
  }
  if (lo >= l && hi <= r) {
    return tree[i];
  }
  int mid = (lo + hi) / 2;
  return max(query(lo, mid, l, r, 2 * i), query(mid + 1, hi, l, r, 2 * i + 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> x[i] >> y[i] >> c[i];
    if (x[i] > y[i]) swap(x[i], y[i]);
    m1[x[i]], m1[y[i]];
  }
  for (__typeof(m1.begin()) it = m1.begin(); it != m1.end(); it++) {
    sz++;
    m1[it->first] = sz;
    m2[sz] = it->first;
  }
  for (int i = 0; i <= n - 1; i++) {
    v[m1[x[i]]].push_back(make_pair(m1[y[i]], c[i]));
  }
  build(1, sz, 1);
  for (int i = 1; i <= sz; i++) {
    update(1, sz, i, i, -m2[i], 1);
  }
  long long int ans = 0;
  pair<long long int, long long int> p = {1e9 + 7, 1e9 + 7};
  for (int i = sz; i >= 1; i--) {
    for (__typeof(v[i].begin()) it = v[i].begin(); it != v[i].end(); it++) {
      long long int y = (it->first), cst = (it->second);
      update(1, sz, y, sz, cst, 1);
    }
    pair<long long int, long long int> q = query(1, sz, i, sz, 1);
    if (q.first + m2[i] > ans) {
      ans = q.first + m2[i];
      p.first = m2[i], p.second = m2[q.second];
    }
  }
  cout << ans;
  cout << "\n";
  cout << p.first << " " << p.first;
  cout << " ";
  cout << p.second << " " << p.second;
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin knows the ip and name of each server. For simplicity, we'll assume that an nginx command is of form "command ip;" where command is a string consisting of English lowercase letter only, and ip is the ip of one of school servers.

<image>

Each ip is of form "a.b.c.d" where a, b, c and d are non-negative integers less than or equal to 255 (with no leading zeros). The nginx configuration file Dustin has to add comments to has m commands. Nobody ever memorizes the ips of servers, so to understand the configuration better, Dustin has to comment the name of server that the ip belongs to at the end of each line (after each command). More formally, if a line is "command ip;" Dustin has to replace it with "command ip; #name" where name is the name of the server with ip equal to ip.

Dustin doesn't know anything about nginx, so he panicked again and his friends asked you to do his task for him.

Input

The first line of input contains two integers n and m (1 ≤ n, m ≤ 1000).

The next n lines contain the names and ips of the servers. Each line contains a string name, name of the server and a string ip, ip of the server, separated by space (1 ≤ |name| ≤ 10, name only consists of English lowercase letters). It is guaranteed that all ip are distinct.

The next m lines contain the commands in the configuration file. Each line is of form "command ip;" (1 ≤ |command| ≤ 10, command only consists of English lowercase letters). It is guaranteed that ip belongs to one of the n school servers.

Output

Print m lines, the commands in the configuration file after Dustin did his task.

Examples

Input

2 2
main 192.168.0.2
replica 192.168.0.1
block 192.168.0.1;
proxy 192.168.0.2;

Output

block 192.168.0.1; #replica
proxy 192.168.0.2; #main

Input

3 5
google 8.8.8.8
codeforces 212.193.33.27
server 138.197.64.57
redirect 138.197.64.57;
block 8.8.8.8;
cf 212.193.33.27;
unblock 8.8.8.8;
check 138.197.64.57;

Output

redirect 138.197.64.57; #server
block 8.8.8.8; #google
cf 212.193.33.27; #codeforces
unblock 8.8.8.8; #google
check 138.197.64.57; #server

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
map<string, string> mp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string x, y;
    cin >> x >> y;
    y += ";";
    mp[y] = x;
  }
  for (int i = 0; i < m; i++) {
    string x, y;
    cin >> x >> y;
    cout << x << " " << y << " #" << mp[y] << endl;
  }
  return 0;
}

```


### Prompt

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

A monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care.

There is an n× m grid. Initially, you may place some north magnets and some south magnets into the cells. You are allowed to place as many magnets as you like, even multiple in the same cell.

An operation is performed as follows. Choose a north magnet and a south magnet to activate. If they are in the same row or the same column and they occupy different cells, then the north magnet moves one unit closer to the south magnet. Otherwise, if they occupy the same cell or do not share a row or column, then nothing changes. Note that the south magnets are immovable.

Each cell of the grid is colored black or white. Let's consider ways to place magnets in the cells so that the following conditions are met.

  1. There is at least one south magnet in every row and every column.
  2. If a cell is colored black, then it is possible for a north magnet to occupy this cell after some sequence of operations from the initial placement.
  3. If a cell is colored white, then it is impossible for a north magnet to occupy this cell after some sequence of operations from the initial placement.

Determine if it is possible to place magnets such that these conditions are met. If it is possible, find the minimum number of north magnets required (there are no requirements on the number of south magnets).

Input

The first line contains two integers n and m (1≤ n,m≤ 1000) — the number of rows and the number of columns, respectively.

The next n lines describe the coloring. The i-th of these lines contains a string of length m, where the j-th character denotes the color of the cell in row i and column j. The characters "#" and "." represent black and white, respectively. It is guaranteed, that the string will not contain any other characters.

Output

Output a single integer, the minimum possible number of north magnets required.

If there is no placement of magnets that satisfies all conditions, print a single integer -1.

Examples

Input

3 3
.#.
###
##.

Output

1

Input

4 2
##
.#
.#
##

Output

-1

Input

4 5
....#
####.
.###.
.#...

Output

2

Input

2 1
.
#

Output

-1

Input

3 5
.....
.....
.....

Output

0

Note

In the first test, here is an example placement of magnets:

<image>

In the second test, we can show that no required placement of magnets exists. Here are three example placements that fail to meet the requirements. The first example violates rule 3 since we can move the north magnet down onto a white square. The second example violates rule 2 since we cannot move the north magnet to the bottom-left black square by any sequence of operations. The third example violates rule 1 since there is no south magnet in the first column.

<image>

In the third test, here is an example placement of magnets. We can show that there is no required placement of magnets with fewer north magnets.

<image>

In the fourth test, we can show that no required placement of magnets exists. Here are two example placements that fail to meet the requirements. The first example violates rule 1 since there is no south magnet in the first row. The second example violates rules 1 and 3 since there is no south magnet in the second row and we can move the north magnet up one unit onto a white square.

<image>

In the fifth test, we can put the south magnet in each cell and no north magnets. Because there are no black cells, it will be a correct placement.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O2")
#pragma GCC optimization("unroll-loops")
using namespace std;
short n, m;
string s[1001];
vector<short> b_hor[1001], b_ver[1001];
vector<pair<short, short> > g[1001][1001];
bool used[1001][1001];
void dfs(pair<int, int> u) {
  used[u.first][u.second] = 1;
  for (auto v : g[u.first][u.second]) {
    if (!used[v.first][v.second]) dfs(v);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') {
        b_hor[i].push_back(j);
        b_ver[j].push_back(i);
        if (i && s[i - 1][j] == '#') {
          g[i][j].push_back(make_pair(i - 1, j));
          g[i - 1][j].push_back(make_pair(i, j));
        }
        if (j && s[i][j - 1] == '#') {
          g[i][j].push_back(make_pair(i, j - 1));
          g[i][j - 1].push_back(make_pair(i, j));
        }
      }
    }
  }
  bool fucked = 0, w_hor = 0, w_ver = 0;
  for (int i = 0; i < n; ++i) {
    if (b_hor[i].empty()) {
      w_hor = 1;
      continue;
    }
    for (int j = 0; j < int(b_hor[i].size()) - 1; ++j) {
      if (b_hor[i][j + 1] - b_hor[i][j] > 1) fucked = 1;
    }
  }
  for (int j = 0; j < m; ++j) {
    if (b_ver[j].empty()) {
      w_ver = 1;
      continue;
    }
    for (int i = 0; i < int(b_ver[j].size()) - 1; ++i) {
      if (b_ver[j][i + 1] - b_ver[j][i] > 1) fucked = 1;
    }
  }
  if (fucked || (w_hor ^ w_ver))
    cout << "-1\n";
  else {
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (s[i][j] == '#' && !used[i][j]) {
          dfs(make_pair(i, j));
          ++ans;
        }
      }
    }
    cout << ans << '\n';
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya has sequence a consisting of n integers.

The subsequence of the sequence a is such subsequence that can be obtained from a by removing zero or more of its elements.

Two sequences are considered different if index sets of numbers included in them are different. That is, the values of the elements do not matter in the comparison of subsequences. In particular, any sequence of length n has exactly 2n different subsequences (including an empty subsequence).

A subsequence is considered lucky if it has a length exactly k and does not contain two identical lucky numbers (unlucky numbers can be repeated any number of times).

Help Petya find the number of different lucky subsequences of the sequence a. As Petya's parents don't let him play with large numbers, you should print the result modulo prime number 1000000007 (109 + 7).

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 105). The next line contains n integers ai (1 ≤ ai ≤ 109) — the sequence a.

Output

On the single line print the single number — the answer to the problem modulo prime number 1000000007 (109 + 7).

Examples

Input

3 2
10 10 10

Output

3

Input

4 2
4 4 7 7

Output

4

Note

In the first sample all 3 subsequences of the needed length are considered lucky.

In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long dp[2100][2100];
int use[3010], id[100010];
long long fac[100010];
map<int, int> ss;
const long long MOD = 1000000007LL;
bool lucky(int num) {
  while (num != 0) {
    if (num % 10 != 4 && num % 10 != 7) return false;
    num /= 10;
  }
  return true;
}
long long exp(int a, int b) {
  long long ans = 1, num = a;
  while (b != 0) {
    if (b % 2 == 1) ans = (ans * num) % MOD;
    num = (num * num) % MOD;
    b = b / 2;
  }
  return ans;
}
long long c(int a, int b) {
  if (a < b) return 0;
  long long ans = fac[a];
  ans = (ans * exp(fac[b], MOD - 2)) % MOD;
  ans = (ans * exp(fac[a - b], MOD - 2)) % MOD;
  return ans;
}
int a[100010];
int main() {
  fac[0] = 1;
  for (int i = 1; i <= 100000; i++) {
    fac[i] = (fac[i - 1] * i) % MOD;
  }
  int n, k;
  while (scanf("%d%d", &n, &k) == 2) {
    int cnt = 0, others = 0;
    ss.clear();
    memset(use, 0, sizeof(use));
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      if (lucky(a[i])) {
        if (ss.find(a[i]) == ss.end()) {
          cnt++;
          ss[a[i]] = cnt - 1;
          id[i] = cnt - 1;
          use[cnt - 1]++;
        } else {
          id[i] = ss[a[i]];
          use[ss[a[i]]]++;
        }
      } else
        others++;
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 1; i <= cnt; i++) {
      for (int j = 0; j <= i; j++) {
        dp[i][j] = dp[i - 1][j];
        if (j != 0) dp[i][j] += (dp[i - 1][j - 1] * use[i - 1]) % MOD;
        dp[i][j] %= MOD;
      }
    }
    long long ans = 0;
    for (int i = 0; i <= k && i <= cnt; i++) {
      long long tnum = dp[cnt][i];
      tnum = (tnum * c(others, k - i)) % MOD;
      ans = (ans + tnum) % MOD;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}

```


### Prompt

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

There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.

Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.

How many good observatories are there?

Constraints

* 2 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* 1 \leq H_i \leq 10^9
* 1 \leq A_i,B_i \leq N
* A_i \neq B_i
* Multiple roads may connect the same pair of observatories.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
H_1 H_2 ... H_N
A_1 B_1
A_2 B_2
:
A_M B_M

Output

Print the number of good observatories.

Examples

Input

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

Output

2

Input

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

Output

3

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int n,m,h[100010],a,b,f[100010],ans;
vector<int> v[100010];
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>h[i];
	for (int i=0;i<m;i++){
		cin>>a>>b;
		if (h[a]>=h[b]) f[b]=1;
		if (h[a]<=h[b]) f[a]=1;
	}
	for (int i=1;i<=n;i++) if (f[i]==0) ans++;
	cout<<ans<<endl;
	return 0;
}
```


### Prompt

Develop a solution in cpp to the problem described below:

A Martian boy is named s — he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys looking for his name everywhere. If he sees that he can obtain his name from some string by removing zero or more letters (at that, the remaining letters remain in the same order), he gets happy. For example, if s=«aba», then strings «baobab», «aabbaa», «helloabahello» make him very happy and strings «aab», «baaa» and «helloabhello» do not.

However rather than being happy once, he loves twice as much being happy twice! So, when he got string t as a present, he wanted to cut it in two parts (the left part and the right part) so that each part made him happy.

Help s determine the number of distinct ways to cut the given string t into two parts in the required manner.

Input

The first line contains string s, consisting of lowercase English letters. The length of string s is from 1 to 1000 letters.

The second line contains string t, that also consists of lowercase English letters. The length of string t is from 1 to 106 letters.

Output

Print the sought number of ways to cut string t in two so that each part made s happy.

Examples

Input

aba
baobababbah

Output

2

Input

mars
sunvenusearthmarsjupitersaturnuranusneptune

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int rposs = 0, r = 0;
  int lposs = 0, l = s1.size() - 1;
  for (int i = 0; i < s2.size(); ++i) {
    if (r < s1.size() && s2[i] == s1[r]) {
      ++r;
      rposs = i;
    }
    if (l >= 0 && s2[s2.size() - 1 - i] == s1[l]) {
      --l;
      lposs = s2.size() - 1 - i;
    }
  }
  if (r == s1.size() && l == -1 && rposs <= lposs) {
    cout << lposs - rposs;
    return 0;
  }
  cout << 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Constraints

* 1 \leq S \leq 2000
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

S

Output

Print the answer.

Examples

Input

7

Output

3

Input

2

Output

0

Input

1729

Output

294867501

### Response

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

int main() {
  int s;
  cin >> s;
  vector<long long> dp(2001,0);
  dp[0]=1;
  for(int i=3;i<2001;i++){
    for(int j=0;j<=i-3;j++){
      dp[i]=(dp[i]+dp[j])%1000000007;
    }
  }
  cout << dp[s] << endl;
  return 0;
}
```


### Prompt

Please create a solution in CPP to the following problem:

You're given an array a of length 2n. Is it possible to reorder it in such way so that the sum of the first n elements isn't equal to the sum of the last n elements?

Input

The first line contains an integer n (1 ≤ n ≤ 1000), where 2n is the number of elements in the array a.

The second line contains 2n space-separated integers a_1, a_2, …, a_{2n} (1 ≤ a_i ≤ 10^6) — the elements of the array a.

Output

If there's no solution, print "-1" (without quotes). Otherwise, print a single line containing 2n space-separated integers. They must form a reordering of a. You are allowed to not change the order.

Examples

Input

3
1 2 2 1 3 1

Output

2 1 3 1 1 2

Input

1
1 1

Output

-1

Note

In the first example, the first n elements have sum 2+1+3=6 while the last n elements have sum 1+1+2=4. The sums aren't equal.

In the second example, there's no solution.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1000, M = 50, MOD = 1e9 + 9, Sqrt = 500;
const int OO = 1e5 + 1;
int a[N];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= 2 * n; ++i) cin >> a[i];
  sort(a + 1, a + 1 + 2 * n, greater<int>());
  long long sum = 0;
  for (int i = 1; i <= n; ++i) sum += a[i];
  for (int i = n + 1; i <= 2 * n; ++i) sum -= a[i];
  if (sum == 0) {
    return cout << "-1" << endl, 0;
  }
  for (int i = 1; i <= 2 * n; ++i) cout << a[i] << " ";
  cout << endl;
}

```


### Prompt

Create a solution in CPP for the following problem:

Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.

Arithmetic progression is a sequence a1, a1 + d, a1 + 2d, ..., a1 + (n - 1)d, where a1 and d are any numbers.

Geometric progression is a sequence b1, b2 = b1q, ..., bn = bn - 1q, where b1 ≠ 0, q ≠ 0, q ≠ 1.

Help Petya and write a program to determine if the given sequence is arithmetic or geometric. Also it should found the next number. If the sequence is neither arithmetic nor geometric, print 42 (he thinks it is impossible to find better answer). You should also print 42 if the next element of progression is not integer. So answer is always integer.

Input

The first line contains exactly four integer numbers between 1 and 1000, inclusively.

Output

Print the required number. If the given sequence is arithmetic progression, print the next progression element. Similarly, if the given sequence is geometric progression, print the next progression element.

Print 42 if the given sequence is not an arithmetic or geometric progression.

Examples

Input

836 624 412 200

Output

-12

Input

1 334 667 1000

Output

1333

Note

This problem contains very weak pretests!

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  double nums[4];
  double d, q;
  for (int i = 0; i < 4; i++) cin >> nums[i];
  d = nums[1] - nums[0];
  q = nums[1] / nums[0];
  if (nums[2] == nums[1] + d && nums[3] == nums[2] + d) {
    if (static_cast<int>(nums[3] + d) == (nums[3] + d))
      cout << nums[3] + d << endl;
    else
      cout << 42 << endl;
  } else if (nums[2] == nums[1] * q && nums[3] == nums[2] * q) {
    if (static_cast<int>(nums[3] * q) == (nums[3] * q))
      cout << nums[3] * q << endl;
    else
      cout << 42 << endl;
  } else {
    cout << 42 << endl;
  }
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

To learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme a community member, who is the first to learn the news, calls some other member, the latter, in his turn, calls some third member, and so on; i.e. a person with index i got a person with index fi, to whom he has to call, if he learns the news. With time BolgenOS community members understood that their scheme doesn't work sometimes — there were cases when some members didn't learn the news at all. Now they want to supplement the scheme: they add into the scheme some instructions of type (xi, yi), which mean that person xi has to call person yi as well. What is the minimum amount of instructions that they need to add so, that at the end everyone learns the news, no matter who is the first to learn it?

Input

The first input line contains number n (2 ≤ n ≤ 105) — amount of BolgenOS community members. The second line contains n space-separated integer numbers fi (1 ≤ fi ≤ n, i ≠ fi) — index of a person, to whom calls a person with index i.

Output

In the first line output one number — the minimum amount of instructions to add. Then output one of the possible variants to add these instructions into the scheme, one instruction in each line. If the solution is not unique, output any.

Examples

Input

3
3 3 2

Output

1
3 1

Input

7
2 3 1 3 4 4 1

Output

3
2 5
2 6
3 7

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> f(n), cnt(n, 0);
  vector<bool> vis(n, false);
  vector<int> head, tail;
  for (int& e : f) {
    cin >> e, e--;
    cnt[e]++;
  }
  for (int i = 0; i < n; i++) {
    if (cnt[i] || vis[i]) continue;
    int j = i;
    while (!vis[j]) {
      vis[j] = true;
      j = f[j];
    }
    head.emplace_back(i + 1), tail.emplace_back(j + 1);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    int j = i;
    while (!vis[j]) {
      vis[j] = true;
      j = f[j];
    }
    head.emplace_back(i + 1), tail.emplace_back(j + 1);
  };
  int m = head.size();
  if (m == 1 && head[0] == tail[0]) {
    cout << "0\n";
    return 0;
  }
  cout << m << '\n';
  for (int i = 0; i < m; i++)
    cout << tail[i] << ' ' << head[(i + 1) % m] << '\n';
}

```


### Prompt

Develop a solution in cpp to the problem described below:

During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesting is that these years are in the range (1, 10^9)! Therefore, the planet was named Longlifer.

In order to learn more about Longlifer's previous population, scientists need to determine the year with maximum number of individuals that were alive, as well as the number of alive individuals in that year. Your task is to help scientists solve this problem!

Input

The first line contains an integer n (1 ≤ n ≤ 10^5) — the number of people.

Each of the following n lines contain two integers b and d (1 ≤ b < d ≤ 10^9) representing birth and death year (respectively) of each individual.

Output

Print two integer numbers separated by blank character, y — the year with a maximum number of people alive and k — the number of people alive in year y.

In the case of multiple possible solutions, print the solution with minimum year.

Examples

Input

3
1 5
2 4
5 6

Output

2 2

Input

4
3 4
4 5
4 6
8 10

Output

4 2

Note

You can assume that an individual living from b to d has been born at the beginning of b and died at the beginning of d, and therefore living for d - b years.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int n = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = n * 10 + ch - '0';
    ch = getchar();
  }
  return n * f;
}
struct sth {
  int t, j;
} a[800004];
bool bi(struct sth x, struct sth y) {
  if (x.t != y.t)
    return x.t < y.t;
  else
    return x.j < y.j;
}
int main() {
  int n, maxn = 0, now = 0, mpos = 0;
  n = read();
  for (int i = 1; i <= n; i++) {
    a[2 * i - 1].t = read();
    a[2 * i - 1].j = 1;
    a[2 * i].t = read();
    a[2 * i].j = -1;
  }
  sort(a + 1, a + 2 * n + 1, bi);
  for (int i = 1; i <= 2 * n; i++) {
    now += a[i].j;
    if (now > maxn) {
      maxn = now;
      mpos = a[i].t;
    }
  }
  printf("%d %d\n", mpos, maxn);
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels!

There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle...

Everybody was upset. The beautiful Belle was upset, so was the Beast, so was Lumiere the candlestick. But the worst thing was that Cogsworth was upset. Cogsworth is not a human, but is the mantel clock, which was often used as an alarm clock.

Due to Cogsworth's frustration all the inhabitants of the castle were in trouble: now they could not determine when it was time to drink morning tea, and when it was time for an evening stroll.

Fortunately, deep in the basement are lying digital clock showing the time in the format HH:MM. Now the residents of the castle face a difficult task. They should turn Cogsworth's hour and minute mustache hands in such a way, that Cogsworth began to show the correct time. Moreover they need to find turn angles in degrees for each mustache hands. The initial time showed by Cogsworth is 12:00.

You can only rotate the hands forward, that is, as is shown in the picture:

<image>

As since there are many ways too select such angles because of full rotations, choose the smallest angles in the right (non-negative) direction.

Note that Cogsworth's hour and minute mustache hands move evenly and continuously. Hands are moving independently, so when turning one hand the other hand remains standing still.

Input

The only line of input contains current time according to the digital clock, formatted as HH:MM (00 ≤ HH ≤ 23, 00 ≤ MM ≤ 59). The mantel clock initially shows 12:00.

Pretests contain times of the beginning of some morning TV programs of the Channel One Russia.

Output

Print two numbers x and y — the angles of turning the hour and minute hands, respectively (0 ≤ x, y < 360). The absolute or relative error in the answer should not exceed 10 - 9.

Examples

Input

12:00

Output

0 0

Input

04:30

Output

135 180

Input

08:17

Output

248.5 102

Note

A note to the second example: the hour hand will be positioned exactly in the middle, between 4 and 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, m, p;
  double x, y;
  scanf("%d:%d", &h, &m);
  if (h > 11) h = h % 12;
  p = h * 30;
  x = p + (double)m / 2;
  y = 6.0 * m;
  printf("%lf %lf", x, y);
}

```


### Prompt

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

Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.

When they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %. Find the expected number of games that will be played, and print it as follows.

We can represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R \times Q \equiv P\pmod {10^9+7}. (Such an integer R always uniquely exists under the constraints of this problem.)

Constraints

* 1 \leq N \leq 100000
* 0 \leq A,B,C \leq 100
* 1 \leq A+B
* A+B+C=100
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B C

Output

Print the expected number of games that will be played, in the manner specified in the statement.

Examples

Input

1 25 25 50

Output

2

Input

4 50 50 0

Output

312500008

Input

1 100 0 0

Output

1

Input

100000 31 41 28

Output

104136146

### Response

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

constexpr long long MOD = 1e9 + 7;
constexpr int MAX_N = 200000 + 1;
long long fact[MAX_N];
void init_fact() {
    fact[0] = 1;
    for(auto i = 1; i < MAX_N; ++i)
        fact[i] = fact[i-1] * i % MOD;
}

long long pow_mod(long long x, long long y, long long mod) {
    auto ret=1ll;
    while (y) {
            if (y % 2)
                ret = ret * x % mod;
            x =  x * x % mod;
            y /= 2;
        }
    return ret;
}

long long nCr(int n, int r) {
    return fact[n] * pow_mod(fact[n-r], MOD - 2, MOD) % MOD * pow_mod(fact[r], MOD - 2, MOD) % MOD;
}

void solve()
{
    init_fact();
    int N, A, B, C;
    cin >> N >> A >> B >> C;

    long long ans = 0;
    long long dab = pow_mod(A + B, MOD - 2, MOD);
    for(auto i = N; i < 2 * N; ++i)
    {
        ans += nCr(i - 1, N - 1)
            * (pow_mod(A, N, MOD) * pow_mod(B, i - N, MOD) % MOD + pow_mod(A, i - N, MOD) * pow_mod(B, N, MOD) % MOD) % MOD
            * i % MOD
            * 100 % MOD
            * pow_mod(dab, i, MOD) % MOD
            * pow_mod(100 - C, MOD - 2, MOD) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

int main()
{
    cin.sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.

Input

The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.

This problem doesn't have subproblems. You will get 3 points for the correct submission.

Output

Output "First" if the first player wins and "Second" otherwise.

Examples

Input

2 2 1 2

Output

Second

Input

2 1 1 1

Output

First

Note

Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, i, j, x, y, k, m, n;
  while (cin >> a >> b >> c >> d) {
    while (1) {
      a = a - 1;
      if (a < 0) {
        cout << "Second" << endl;
        break;
      }
      b = b - 1;
      if (b < 0) {
        cout << "First" << endl;
        break;
      }
    }
  }
  return 0;
}

```


### Prompt

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

Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:

  * deletes all the vowels,
  * inserts a character "." before each consonant,
  * replaces all uppercase consonants with corresponding lowercase ones.

Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.

Help Petya cope with this easy task.

Input

The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.

Output

Print the resulting string. It is guaranteed that this string is not empty.

Examples

Input

tour

Output

.t.r

Input

Codeforces

Output

.c.d.f.r.c.s

Input

aBAcAba

Output

.b.c.b

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  int i;
  for (i = 0; i < n; ++i) {
    if (s[i] == 'A' || s[i] == 'a' || s[i] == 'E' || s[i] == 'e' ||
        s[i] == 'I' || s[i] == 'i' || s[i] == 'O' || s[i] == 'o' ||
        s[i] == 'U' || s[i] == 'u' || s[i] == 'Y' || s[i] == 'y')
      continue;
    else if (s[i] >= 65 && s[i] <= 90) {
      s[i] += 32;
      cout << "." << s[i];
    } else
      cout << "." << s[i];
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

The country Treeland consists of n cities connected with n - 1 bidirectional roads in such a way that it's possible to reach every city starting from any other city using these roads. There will be a soccer championship next year, and all participants are Santa Clauses. There are exactly 2k teams from 2k different cities.

During the first stage all teams are divided into k pairs. Teams of each pair play two games against each other: one in the hometown of the first team, and the other in the hometown of the other team. Thus, each of the 2k cities holds exactly one soccer game. However, it's not decided yet how to divide teams into pairs.

It's also necessary to choose several cities to settle players in. Organizers tend to use as few cities as possible to settle the teams.

Nobody wants to travel too much during the championship, so if a team plays in cities u and v, it wants to live in one of the cities on the shortest path between u and v (maybe, in u or in v). There is another constraint also: the teams from one pair must live in the same city.

Summarizing, the organizers want to divide 2k teams into pairs and settle them in the minimum possible number of cities m in such a way that teams from each pair live in the same city which lies between their hometowns.

Input

The first line of input contains two integers n and k (2 ≤ n ≤ 2·105, 2 ≤ 2k ≤ n) — the number of cities in Treeland and the number of pairs of teams, respectively.

The following n - 1 lines describe roads in Treeland: each of these lines contains two integers a and b (1 ≤ a, b ≤ n, a ≠ b) which mean that there is a road between cities a and b. It's guaranteed that there is a path between any two cities.

The last line contains 2k distinct integers c1, c2, ..., c2k (1 ≤ ci ≤ n), where ci is the hometown of the i-th team. All these numbers are distinct.

Output

The first line of output must contain the only positive integer m which should be equal to the minimum possible number of cities the teams can be settled in.

The second line should contain m distinct numbers d1, d2, ..., dm (1 ≤ di ≤ n) denoting the indices of the cities where the teams should be settled.

The k lines should follow, the j-th of them should contain 3 integers uj, vj and xj, where uj and vj are the hometowns of the j-th pair's teams, and xj is the city they should live in during the tournament. Each of the numbers c1, c2, ..., c2k should occur in all uj's and vj's exactly once. Each of the numbers xj should belong to {d1, d2, ..., dm}.

If there are several possible answers, print any of them.

Example

Input

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

Output

1
2
5 4 2
6 2 2

Note

In the first test the orginizers can settle all the teams in the city number 2. The way to divide all teams into pairs is not important, since all requirements are satisfied anyway, because the city 2 lies on the shortest path between every two cities from {2, 4, 5, 6}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> Edge[200001];
vector<int> Party[200001];
priority_queue<pair<int, int> > Q;
int N, K, C[200001], Visit[200001], Center, Size, Num;
int findCenter(int now) {
  int i, j = Edge[now].size(), sum = 0, temp, ok = 1;
  for (i = 0; i < j; i++) {
    if (!Visit[Edge[now][i]]) {
      Visit[Edge[now][i]] = 1;
      temp = findCenter(Edge[now][i]);
      sum += temp;
      if (temp > K) ok = 0;
    }
  }
  if (C[now]) sum++;
  if (sum < K) ok = 0;
  if (ok) Center = now;
  return sum;
}
void makeParty(int now) {
  int i, j = Edge[now].size();
  for (i = 0; i < j; i++)
    if (!Visit[Edge[now][i]]) {
      Visit[Edge[now][i]] = 1;
      if (C[Edge[now][i]]) Party[Num].push_back(Edge[now][i]);
      makeParty(Edge[now][i]);
    }
}
int main(void) {
  int i, x, y;
  scanf("%d %d", &N, &K);
  for (i = 1; i < N; i++) {
    scanf("%d %d", &x, &y);
    Edge[x].push_back(y);
    Edge[y].push_back(x);
  }
  for (i = 1; i <= 2 * K; i++) {
    scanf("%d", &x);
    C[x] = 1;
  }
  Visit[1] = 1;
  x = findCenter(1);
  for (i = 1; i <= N; i++) Visit[i] = 0;
  printf("1\n%d\n", Center);
  Visit[Center] = 1;
  Size = Edge[Center].size();
  for (i = 0; i < Size; i++) {
    Num = i + 1;
    Visit[Edge[Center][i]] = 1;
    if (C[Edge[Center][i]]) Party[Num].push_back(Edge[Center][i]);
    makeParty(Edge[Center][i]);
  }
  if (C[Center]) {
    for (i = 1; i <= Size; i++) {
      if (Party[i].size() < K) {
        Party[i].push_back(Center);
        break;
      }
    }
    if (i == Size + 1) Party[++Size].push_back(Center);
  }
  for (i = 1; i <= Size; i++)
    if (Party[i].size()) Q.push(make_pair(Party[i].size(), i));
  while (!Q.empty()) {
    x = Q.top().second;
    Q.pop();
    y = Q.top().second;
    Q.pop();
    printf("%d %d %d\n", Party[x].back(), Party[y].back(), Center);
    Party[x].pop_back();
    Party[y].pop_back();
    if (Party[x].size()) Q.push(make_pair(Party[x].size(), x));
    if (Party[y].size()) Q.push(make_pair(Party[y].size(), y));
  }
  return 0;
}

```


### Prompt

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

Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on this counter increases by 1. If the player answers a question incorrectly, the counter is reset, that is, the number on it reduces to 0. If after an answer the counter reaches the number k, then it is reset, and the player's score is doubled. Note that in this case, first 1 point is added to the player's score, and then the total score is doubled. At the beginning of the game, both the player's score and the counter of consecutive correct answers are set to zero.

Manao remembers that he has answered exactly m questions correctly. But he does not remember the order in which the questions came. He's trying to figure out what his minimum score may be. Help him and compute the remainder of the corresponding number after division by 1000000009 (109 + 9).

Input

The single line contains three space-separated integers n, m and k (2 ≤ k ≤ n ≤ 109; 0 ≤ m ≤ n).

Output

Print a single integer — the remainder from division of Manao's minimum possible score in the quiz by 1000000009 (109 + 9).

Examples

Input

5 3 2

Output

3

Input

5 4 2

Output

6

Note

Sample 1. Manao answered 3 questions out of 5, and his score would double for each two consecutive correct answers. If Manao had answered the first, third and fifth questions, he would have scored as much as 3 points.

Sample 2. Now Manao answered 4 questions. The minimum possible score is obtained when the only wrong answer is to the question 4.

Also note that you are asked to minimize the score and not the remainder of the score modulo 1000000009. For example, if Manao could obtain either 2000000000 or 2000000020 points, the answer is 2000000000 mod 1000000009, even though 2000000020 mod 1000000009 is a smaller number.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T Abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T sqr(T a) {
  return a * a;
}
template <typename T>
inline void relaxMin(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
inline void relaxMax(T &a, T b) {
  if (b > a) a = b;
}
const int INF = (int)1E9;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const int mod = 1000000009;
const int N2 = 2 * 2;
vector<long long> mult(vector<long long> a, vector<long long> b) {
  vector<long long> c(N2);
  c[0] = (a[0] * b[0] + a[1] * b[2]) % mod;
  c[1] = (a[0] * b[1] + a[1] * b[3]) % mod;
  c[2] = (a[2] * b[0] + a[3] * b[2]) % mod;
  c[3] = (a[2] * b[1] + a[3] * b[3]) % mod;
  return c;
}
vector<long long> pow(vector<long long> a, long long p) {
  vector<long long> ans(N2);
  ans[0] = ans[3] = 1;
  ans[1] = ans[2] = 0;
  while (p) {
    if (p & 1) {
      ans = mult(ans, a);
    }
    a = mult(a, a);
    p >>= 1;
  }
  return ans;
}
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  long long w = n - m;
  long long e = n / k;
  long long e2 = max(0LL, e - w);
  vector<long long> mm(4);
  mm[0] = 2;
  mm[1] = 2 * k;
  mm[2] = 0;
  mm[3] = 1;
  vector<long long> ans = pow(mm, e2);
  long long ans2 = ans[1];
  n -= e2 * k;
  ans2 += n - w;
  ans2 %= mod;
  cout << ans2 << endl;
}
int main() {
  srand(time(0));
  solve();
  return 0;
}

```


### Prompt

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

The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.

His plan is as follows:

1. Get out of the nest with N acorns in his hands.
2. Go to Exchange A and do some trades.
3. Go to Exchange B and do some trades.
4. Go to Exchange A and do some trades.
5. Go back to the nest.

In Exchange X (X = A, B), he can perform the following operations any integer number of times (possibly zero) in any order:

* Lose g_{X} acorns and gain 1 gram of gold.
* Gain g_{X} acorns and lose 1 gram of gold.
* Lose s_{X} acorns and gain 1 gram of silver.
* Gain s_{X} acorns and lose 1 gram of silver.
* Lose b_{X} acorns and gain 1 gram of bronze.
* Gain b_{X} acorns and lose 1 gram of bronze.

Naturally, he cannot perform an operation that would leave him with a negative amount of acorns, gold, silver, or bronze.

What is the maximum number of acorns that he can bring to the nest? Note that gold, silver, or bronze brought to the nest would be worthless because he is just a squirrel.

Constraints

* 1 \leq N \leq 5000
* 1 \leq g_{X} \leq 5000
* 1 \leq s_{X} \leq 5000
* 1 \leq b_{X} \leq 5000
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
g_A s_A b_A
g_B s_B b_B

Output

Print the maximum number of acorns that Chokudai can bring to the nest.

Example

Input

23
1 1 1
2 1 1

Output

46

### Response

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

using namespace std;

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

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

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

	ll n;
	cin >> n;

	ll a[3];
	rep(i, 3) cin >> a[i];

	ll b[3];
	rep(i, 3) cin >> b[i];

	ll dp[n+1];
	rep(i, 4) rep(j, n+1) dp[j] = 0;
	dp[0] = n;

	rep(i, 3){
		rep(j, n+1) {
			if(j-a[i] >= 0) chmax(dp[j], dp[j-a[i]] + b[i] - a[i]);
		}
	}

	ll m = 0;
	rep(j, n+1) chmax(m, dp[j]);

	vector<ll> dp2(m+1, 0);
	dp2[0] = m;

	rep(i, 3){
		rep(j, m+1){
			if(j-b[i] >= 0) chmax(dp2[j], dp2[j-b[i]] + a[i] - b[i]);
		}
	}

	ll ans = 0;
	rep(j, m+1) chmax(ans, dp2[j]);
	cout << ans << endl;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the vertical line, that is, the right part of the image moves to the left, and vice versa) and zooming on the image. He is sure that that there is a large number of transformations that can be expressed through these three.

He has recently stopped implementing all three transformations for monochrome images. To test this feature, he asked you to write a code that will consecutively perform three actions with a monochrome image: first it will rotate the image 90 degrees clockwise, then it will flip the image horizontally and finally, it will zoom in twice on the image (that is, it will double all the linear sizes).

Implement this feature to help Polycarp test his editor.

Input

The first line contains two integers, w and h (1 ≤ w, h ≤ 100) — the width and height of an image in pixels. The picture is given in h lines, each line contains w characters — each character encodes the color of the corresponding pixel of the image. The line consists only of characters "." and "*", as the image is monochrome.

Output

Print 2w lines, each containing 2h characters — the result of consecutive implementing of the three transformations, described above.

Examples

Input

3 2
.*.
.*.

Output

....
....
****
****
....
....

Input

9 20
**.......
****.....
******...
*******..
..******.
....****.
......***
*.....***
*********
*********
*********
*********
....**...
...****..
..******.
.********
****..***
***...***
**.....**
*.......*

Output

********......**********........********
********......**********........********
********........********......********..
********........********......********..
..********......********....********....
..********......********....********....
..********......********..********......
..********......********..********......
....********....****************........
....********....****************........
....********....****************........
....********....****************........
......******************..**********....
......******************..**********....
........****************....**********..
........****************....**********..
............************......**********
............************......**********

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long A = 100000000000000LL, N = 1000;
string st;
char a[N][N], c, b[N][N];
long long i, j, n, m;
int main() {
  cin >> n >> m;
  swap(n, m);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> a[i][j];
  for (j = 0; j < m; j++)
    for (i = n - 1; i >= 0; i--) b[j][n - i - 1] = a[i][j];
  swap(n, m);
  for (i = 0; i < n; i++) reverse(b[i], b[i] + m);
  for (i = 0; i < n; i++) {
    st = "";
    for (j = 0; j < m; j++)
      cout << b[i][j] << b[i][j], st += b[i][j], st += b[i][j];
    cout << "\n" << st << "\n";
  }
}

```


### Prompt

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

Example

Input

5
1 2
1 3
1 4
1 5

Output

6

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int b = 1007, mo = 1e9+7;
VI g[100010];
map<int,int> v;
// 部分木xのハッシュを返す
int func(int x, int p) {
  int ret = b;
  for(int e: g[x]) {
    if(e == p) continue;
    (ret += func(e, x) * b % mo) %= mo;
  }
  v[ret]++;
  return ret;
}

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

  int n;
  cin >> n;
  REP(i, n-1) {
    int a, b;
    cin >> a >> b; a--, b--;
    g[a].PB(b);
    g[b].PB(a);
  }

  mo = 1e9+7;
  b = rand() % mo;
  v.clear();
  func(0, -1);

  int ret = 0;
  for(auto i: v) ret += i.second*(i.second-1)/2;
  cout << ret << endl;

  return 0;
}

```


### Prompt

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

Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something.

Dima and Seryozha have n fruits in the fridge. Each fruit has two parameters: the taste and the number of calories. Inna decided to make a fruit salad, so she wants to take some fruits from the fridge for it. Inna follows a certain principle as she chooses the fruits: the total taste to the total calories ratio of the chosen fruits must equal k. In other words, <image> , where aj is the taste of the j-th chosen fruit and bj is its calories.

Inna hasn't chosen the fruits yet, she is thinking: what is the maximum taste of the chosen fruits if she strictly follows her principle? Help Inna solve this culinary problem — now the happiness of a young couple is in your hands!

Inna loves Dima very much so she wants to make the salad from at least one fruit.

Input

The first line of the input contains two integers n, k (1 ≤ n ≤ 100, 1 ≤ k ≤ 10). The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the fruits' tastes. The third line of the input contains n integers b1, b2, ..., bn (1 ≤ bi ≤ 100) — the fruits' calories. Fruit number i has taste ai and calories bi.

Output

If there is no way Inna can choose the fruits for the salad, print in the single line number -1. Otherwise, print a single integer — the maximum possible sum of the taste values of the chosen fruits.

Examples

Input

3 2
10 8 1
2 7 1

Output

18

Input

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

Output

-1

Note

In the first test sample we can get the total taste of the fruits equal to 18 if we choose fruit number 1 and fruit number 2, then the total calories will equal 9. The condition <image> fulfills, that's exactly what Inna wants.

In the second test sample we cannot choose the fruits so as to follow Inna's principle.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[110], b[110], n, k;
int mem[110][2 * 110 * 100 * 10];
const int med = 100000;
int dfs(int rec, int sum) {
  if (mem[rec][sum] != -1) return mem[rec][sum];
  if (rec >= n) {
    if (sum == med)
      return 0;
    else
      return -1 << 29;
  }
  return mem[rec][sum] = max(dfs(rec + 1, sum),
                             dfs(rec + 1, sum - a[rec] + k * b[rec]) + a[rec]);
}
int main() {
  memset(mem, -1, sizeof(mem));
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  dfs(0, med);
  for (int i = n; i >= 0; i--) {
    for (int j = -40; j <= 40; j++) {
    }
  }
  if (mem[0][med] > 0)
    cout << mem[0][med] << endl;
  else
    cout << -1 << endl;
  return 0;
}

```


### Prompt

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

You are given an array a_1, a_2, ... , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, ... , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the length of this subarray (∑_{i=l}^{r} a_i = r - l + 1).

For example, if a = [1, 2, 0], then there are 3 good subarrays: a_{1 ... 1} = [1], a_{2 ... 3} = [2, 0] and a_{1 ... 3} = [1, 2, 0].

Calculate the number of good subarrays of the array a.

Input

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

The first line of each test case contains one integer n (1 ≤ n ≤ 10^5) — the length of the array a.

The second line of each test case contains a string consisting of n decimal digits, where the i-th digit is equal to the value of a_i.

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

Output

For each test case print one integer — the number of good subarrays of the array a.

Example

Input

3
3
120
5
11011
6
600005

Output

3
6
1

Note

The first test case is considered in the statement.

In the second test case, there are 6 good subarrays: a_{1 ... 1}, a_{2 ... 2}, a_{1 ... 2}, a_{4 ... 4}, a_{5 ... 5} and a_{4 ... 5}.

In the third test case there is only one good subarray: a_{2 ... 6}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 2e9;
const long long MOD = 998244353;
const int MAX = 2e8 + 1;
const long long int N = 1000000;
using namespace std;
void solve() {
  int n;
  string s;
  cin >> n >> s;
  long long ans = 0, prefixSum = 0;
  map<int, int> map;
  map[prefixSum]++;
  for (int i = 0; i < n; ++i) {
    prefixSum += s[i] - '0';
    ans += map[prefixSum - i - 1];
    map[prefixSum - i - 1]++;
  }
  cout << ans << endl;
}
int main() {
  int tc;
  cin >> tc;
  while (tc--) solve();
  return 0;
}

```


### Prompt

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

You are given an integer n (n ≥ 0) represented with k digits in base (radix) b. So,

$$$n = a_1 ⋅ b^{k-1} + a_2 ⋅ b^{k-2} + … a_{k-1} ⋅ b + a_k.$$$

For example, if b=17, k=3 and a=[11, 15, 7] then n=11⋅17^2+15⋅17+7=3179+255+7=3441.

Determine whether n is even or odd.

Input

The first line contains two integers b and k (2≤ b≤ 100, 1≤ k≤ 10^5) — the base of the number and the number of digits.

The second line contains k integers a_1, a_2, …, a_k (0≤ a_i < b) — the digits of n.

The representation of n contains no unnecessary leading zero. That is, a_1 can be equal to 0 only if k = 1.

Output

Print "even" if n is even, otherwise print "odd".

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

Examples

Input

13 3
3 2 7

Output

even

Input

10 9
1 2 3 4 5 6 7 8 9

Output

odd

Input

99 5
32 92 85 74 4

Output

odd

Input

2 2
1 0

Output

even

Note

In the first example, n = 3 ⋅ 13^2 + 2 ⋅ 13 + 7 = 540, which is even.

In the second example, n = 123456789 is odd.

In the third example, n = 32 ⋅ 99^4 + 92 ⋅ 99^3 + 85 ⋅ 99^2 + 74 ⋅ 99 + 4 = 3164015155 is odd.

In the fourth example n = 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int b, n, k, r;
int a[100005];
int main() {
  cin >> b >> n;
  if (b % 2 == 0)
    k = 0;
  else
    k = 1;
  r = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i == n) {
      if (a[i] % 2 != 0) r++;
    } else if ((a[i] % 2 == 1) && (k == 1))
      r++;
  }
  if (r % 2 == 0)
    cout << "even";
  else
    cout << "odd";
}

```


### Prompt

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

Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each room of each apartment has exactly one window. In other words, a three-room apartment has three windows, a five-room — five windows, and a seven-room — seven windows.

Monocarp went around the building and counted n windows. Now he is wondering, how many apartments of each type the building may have.

Unfortunately, Monocarp only recently has learned to count, so he is asking you to help him to calculate the possible quantities of three-room, five-room, and seven-room apartments in the building that has n windows. If there are multiple answers, you can print any of them.

Here are some examples:

  * if Monocarp has counted 30 windows, there could have been 2 three-room apartments, 2 five-room apartments and 2 seven-room apartments, since 2 ⋅ 3 + 2 ⋅ 5 + 2 ⋅ 7 = 30;
  * if Monocarp has counted 67 windows, there could have been 7 three-room apartments, 5 five-room apartments and 3 seven-room apartments, since 7 ⋅ 3 + 5 ⋅ 5 + 3 ⋅ 7 = 67;
  * if Monocarp has counted 4 windows, he should have mistaken since no building with the aforementioned layout can have 4 windows.

Input

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

The only line of each test case contains one integer n (1 ≤ n ≤ 1000) — the number of windows in the building.

Output

For each test case, if a building with the new layout and the given number of windows just can't exist, print -1.

Otherwise, print three non-negative integers — the possible number of three-room, five-room, and seven-room apartments. If there are multiple answers, print any of them.

Example

Input

4
30
67
4
14

Output

2 2 2
7 5 3
-1
0 0 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  t = 1;
  cin >> t;
  while (t-- > 0) {
    long long int n;
    cin >> n;
    if (n == 1 || n == 2 || n == 4) {
      cout << "-1";
      cout << "\n";
      continue;
    }
    if (!(n % 3))
      cout << n / 3 << " "
           << "0"
           << " "
           << "0";
    if (n % 3 == 1)
      cout << (n - 7) / 3 << " "
           << "0"
           << " "
           << "1";
    if (n % 3 == 2)
      cout << (n - 5) / 3 << " "
           << "1"
           << " "
           << "0";
    cout << "\n";
  }
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Consider the following problem: given an array a containing n integers (indexed from 0 to n-1), find max_{0 ≤ l ≤ r ≤ n-1} ∑_{l ≤ i ≤ r} (r-l+1) ⋅ a_i. In this problem, 1 ≤ n ≤ 2 000 and |a_i| ≤ 10^6.

In an attempt to solve the problem described, Alice quickly came up with a blazing-fast greedy algorithm and coded it. Her implementation in pseudocode is as follows:

    function find_answer(n, a)
        # Assumes n is an integer between 1 and 2000, inclusive
        # Assumes a is a list containing n integers: a[0], a[1], ..., a[n-1]
        res = 0
        cur = 0
        k = -1
        for i = 0 to i = n-1
            cur = cur + a[i]
            if cur < 0
                cur = 0
                k = i
            res = max(res, (i-k)*cur)
        return res

Also, as you can see, Alice's idea is not entirely correct. For example, suppose n = 4 and a = [6, -8, 7, -42]. Then, find_answer(n, a) would return 7, but the correct answer is 3 ⋅ (6-8+7) = 15.

You told Alice that her solution is incorrect, but she did not believe what you said.

Given an integer k, you are to find any sequence a of n integers such that the correct answer and the answer produced by Alice's algorithm differ by exactly k. Note that although the choice of n and the content of the sequence is yours, you must still follow the constraints earlier given: that 1 ≤ n ≤ 2 000 and that the absolute value of each element does not exceed 10^6. If there is no such sequence, determine so.

Input

The first and only line contains one integer k (1 ≤ k ≤ 10^9).

Output

If there is no sought sequence, print "-1".

Otherwise, in the first line, print one integer n (1 ≤ n ≤ 2 000), denoting the number of elements in the sequence.

Then, in the second line, print n space-separated integers: a_0, a_1, …, a_{n-1} (|a_i| ≤ 10^6).

Examples

Input

8

Output

4
6 -8 7 -42

Input

612

Output

7
30 -12 -99 123 -2 245 -300

Note

The first sample corresponds to the example given in the problem statement.

In the second sample, one answer is n = 7 with a = [30, -12, -99, 123, -2, 245, -300], in which case find_answer(n, a) returns 1098, while the correct answer is 1710.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long k, l = 2000;
  cin >> k;
  if (k > 2000 * 1000000) {
    cout << -1 << '\n';
    return;
  }
  cout << "2000\n";
  long long sum = k + 2000;
  cout << "-1 ";
  for (int i = 1; i <= 1999; i++) {
    if (sum > 1000000) {
      cout << "1000000"
           << " \n"[i == 2000];
      sum -= 1000000;
    } else {
      cout << sum << " \n"[i == 2000];
      sum = 0;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.

A game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.

When a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.

At the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.

In the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i. For Kizahashi, write a program that determines whether each of the N players survived this game.

Constraints

* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq K \leq 10^9
* 1 \leq Q \leq 10^5
* 1 \leq A_i \leq N\ (1 \leq i \leq Q)

Input

Input is given from Standard Input in the following format:

N K Q
A_1
A_2
.
.
.
A_Q

Output

Print N lines. The i-th line should contain `Yes` if Player i survived the game, and `No` otherwise.

Examples

Input

6 3 4
3
1
3
2

Output

No
No
Yes
No
No
No

Input

6 5 4
3
1
3
2

Output

Yes
Yes
Yes
Yes
Yes
Yes

Input

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

Output

No
No
No
No
Yes
No
No
No
Yes
No

### Response

```cpp
#include<iostream>
using namespace std;
int main(){
	int N,K,Q,An,A[100000]={0};
	cin>>N>>K>>Q;
	for(int i=0;i<Q;i++){
		cin>>An;
		A[An-1]++;
	}
	for(int i=0;i<N;i++){
		if(A[i]-Q+K<=0)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}
```


### Prompt

Develop a solution in CPP to the problem described below:

You will be given a contest schedule for D days. For each d=1,2,\ldots,D, calculate the satisfaction at the end of day d.

Input

Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.

D
c_1 c_2 \cdots c_{26}
s_{1,1} s_{1,2} \cdots s_{1,26}
\vdots
s_{D,1} s_{D,2} \cdots s_{D,26}
t_1
t_2
\vdots
t_D

* The constraints and generation methods for the input part are the same as those for Problem A.
* For each d, t_d is an integer satisfying 1\leq t_d \leq 26, and your program is expected to work correctly for any value that meets the constraints.

Output

Let v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:

v_1
v_2
\vdots
v_D

Output

Let v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:

v_1
v_2
\vdots
v_D

Example

Input

5
86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82
19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424
6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570
6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256
8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452
19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192
1
17
13
14
13

Output

18398
35037
51140
65837
79325

### Response

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

int main() {
  int D,N,x;
  N=0;
  x=0;
  cin >> D;
  vector<int> c(26);
  vector<int> last(26);
  for (int i=0;i<26;i++) {
    cin >> c.at(i);
  }
  vector<vector<int>> s(D,vector<int>(26));
  for (int i=0;i<D;i++) {
    for (int j=0;j<26;j++) {
      cin >> s.at(i).at(j);
    }
  }
  vector<int> t(D);
  for (int i=0;i<D;i++) {
    cin >> t.at(i);
  }
  for (int i=0;i<D;i++) {
    N=t.at(i)-1;
    x+=s.at(i).at(N);
    last.at(N)=i+1;
    for (int j=0;j<26;j++) {
      x-=c.at(j)*(i+1-last.at(j));
    }
    cout << x << endl;
  }
}
```


### Prompt

Generate a CPP solution to the following problem:

You have a long fence which consists of n sections. Unfortunately, it is not painted, so you decided to hire q painters to paint it. i-th painter will paint all sections x such that l_i ≤ x ≤ r_i.

Unfortunately, you are on a tight budget, so you may hire only q - 2 painters. Obviously, only painters you hire will do their work.

You want to maximize the number of painted sections if you choose q - 2 painters optimally. A section is considered painted if at least one painter paints it.

Input

The first line contains two integers n and q (3 ≤ n, q ≤ 5000) — the number of sections and the number of painters availible for hire, respectively.

Then q lines follow, each describing one of the painters: i-th line contains two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n).

Output

Print one integer — maximum number of painted sections if you hire q - 2 painters.

Examples

Input

7 5
1 4
4 5
5 6
6 7
3 5

Output

7

Input

4 3
1 1
2 2
3 4

Output

2

Input

4 4
1 1
2 2
2 3
3 4

Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, q, i, j, l, r;
  cin >> n >> q;
  int auxi[n + 2], sum[n + 2];
  memset(auxi, 0, sizeof(auxi));
  memset(sum, 0, sizeof(sum));
  vector<pair<int, int> > v;
  for (i = 0; i < q; i++) {
    cin >> l >> r;
    v.push_back({l, r});
    auxi[r + 1] -= 1;
    auxi[l] += 1;
  }
  int net = 0;
  for (i = 0; i <= n + 1; i++) {
    net += auxi[i];
    sum[i] += net;
  }
  int ans = 0;
  for (i = 0; i < q; i++) {
    for (j = 0; j <= n; j++) {
      auxi[j] = sum[j];
    }
    int count = 0;
    for (j = v[i].first; j <= v[i].second; j++) {
      auxi[j]--;
    }
    int prefix[n + 1];
    prefix[0] = 0;
    for (j = 1; j <= n; j++) {
      prefix[j] = prefix[j - 1] + (auxi[j] == 1);
      if (auxi[j]) count++;
    }
    for (j = i + 1; j < q; j++) {
      ans = max(ans, count - prefix[v[j].second] + prefix[v[j].first - 1]);
    }
  }
  cout << ans << "\n";
}

```


### Prompt

Please create a solution in CPP to the following problem:

Vasya had a strictly increasing sequence of positive integers a1, ..., an. Vasya used it to build a new sequence b1, ..., bn, where bi is the sum of digits of ai's decimal representation. Then sequence ai got lost and all that remained is sequence bi.

Vasya wonders what the numbers ai could be like. Of all the possible options he likes the one sequence with the minimum possible last number an. Help Vasya restore the initial sequence.

It is guaranteed that such a sequence always exists.

Input

The first line contains a single integer number n (1 ≤ n ≤ 300).

Next n lines contain integer numbers b1, ..., bn — the required sums of digits. All bi belong to the range 1 ≤ bi ≤ 300.

Output

Print n integer numbers, one per line — the correct option for numbers ai, in order of following in sequence. The sequence should be strictly increasing. The sum of digits of the i-th number should be equal to bi.

If there are multiple sequences with least possible number an, print any of them. Print the numbers without leading zeroes.

Examples

Input

3
1
2
3

Output

1
2
3

Input

3
3
2
1

Output

3
11
100

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
int b[3100];
int a[3100];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
    int bb = b[i] - b[i - 1], l;
    if (bb > 0) {
    orzprwang:
      l = 1;
      while (bb) {
        while (a[l] == 9) l++;
        a[l]++;
        --bb;
      }
    } else if (bb < 0) {
      while (bb) {
        if (bb > 0) goto orzprwang;
        l = 0;
        while (a[++l] == 0)
          ;
        do {
          bb += a[l] - 1;
          a[l] = 0;
          ++a[++l];
        } while (a[l] >= 10);
      }
    } else {
      l = 0;
      while (a[++l] == 0)
        ;
      do {
        bb += a[l] - 1;
        a[l] = 0;
        ++a[++l];
      } while (a[l] >= 10);
      goto orzprwang;
    }
    int len = 3010;
    while (a[len] == 0) --len;
    for (int j = len; j >= 1; --j) printf("%d", a[j]);
    printf("\n");
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Soon there will be held the world's largest programming contest, but the testing system still has m bugs. The contest organizer, a well-known university, has no choice but to attract university students to fix all the bugs. The university has n students able to perform such work. The students realize that they are the only hope of the organizers, so they don't want to work for free: the i-th student wants to get ci 'passes' in his subjects (regardless of the volume of his work).

Bugs, like students, are not the same: every bug is characterized by complexity aj, and every student has the level of his abilities bi. Student i can fix a bug j only if the level of his abilities is not less than the complexity of the bug: bi ≥ aj, and he does it in one day. Otherwise, the bug will have to be fixed by another student. Of course, no student can work on a few bugs in one day. All bugs are not dependent on each other, so they can be corrected in any order, and different students can work simultaneously.

The university wants to fix all the bugs as quickly as possible, but giving the students the total of not more than s passes. Determine which students to use for that and come up with the schedule of work saying which student should fix which bug.

Input

The first line contains three space-separated integers: n, m and s (1 ≤ n, m ≤ 105, 0 ≤ s ≤ 109) — the number of students, the number of bugs in the system and the maximum number of passes the university is ready to give the students.

The next line contains m space-separated integers a1, a2, ..., am (1 ≤ ai ≤ 109) — the bugs' complexities.

The next line contains n space-separated integers b1, b2, ..., bn (1 ≤ bi ≤ 109) — the levels of the students' abilities.

The next line contains n space-separated integers c1, c2, ..., cn (0 ≤ ci ≤ 109) — the numbers of the passes the students want to get for their help.

Output

If the university can't correct all bugs print "NO".

Otherwise, on the first line print "YES", and on the next line print m space-separated integers: the i-th of these numbers should equal the number of the student who corrects the i-th bug in the optimal answer. The bugs should be corrected as quickly as possible (you must spend the minimum number of days), and the total given passes mustn't exceed s. If there are multiple optimal answers, you can output any of them.

Examples

Input

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

Output

YES
2 3 2 3

Input

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

Output

YES
1 3 1 3

Input

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

Output

YES
3 3 2 3

Input

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

Output

NO

Note

Consider the first sample.

The third student (with level 3) must fix the 2nd and 4th bugs (complexities 3 and 2 correspondingly) and the second student (with level 1) must fix the 1st and 3rd bugs (their complexity also equals 1). Fixing each bug takes one day for each student, so it takes 2 days to fix all bugs (the students can work in parallel).

The second student wants 3 passes for his assistance, the third student wants 6 passes. It meets the university's capabilities as it is ready to give at most 9 passes.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, s, p[N];
struct student {
  int idx, level, money;
  bool operator<(const student &str) const { return level > str.level; }
};
student st[N];
priority_queue<pair<int, int> > rem, have;
int ans[N];
int final[N];
int main() {
  scanf("%d%d%d", &n, &m, &s);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &p[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &st[i].level);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &st[i].money);
    st[i].idx = i + 1;
  }
  sort(st, st + n);
  int lo = 0, hi = N;
  bool there = false;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    int idx = 0;
    long long total = 0;
    while (!have.empty()) have.pop();
    while (!rem.empty()) rem.pop();
    for (int i = 0; i < m; ++i) rem.push(make_pair(p[i], i));
    bool can = true;
    while (!rem.empty()) {
      int mx = rem.top().first;
      while (mx <= st[idx].level) {
        have.push(make_pair(-st[idx].money, st[idx].idx));
        idx++;
      }
      if (have.empty()) {
        can = false;
        break;
      }
      int lft = mid;
      total += 1LL * -have.top().first;
      int res = have.top().second;
      have.pop();
      while (lft > 0 && !rem.empty()) {
        ans[rem.top().second] = res;
        rem.pop();
        lft--;
      }
    }
    if (total > s) can = false;
    if (can) {
      there = true;
      for (int i = 0; i < m; ++i) {
        final[i] = ans[i];
      }
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  if (!there) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 0; i < m; ++i) {
    if (i) printf(" ");
    printf("%d", final[i]);
  }
  puts("");
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Nauuo is a girl who loves traveling.

One day she went to a tree, Old Driver Tree, literally, a tree with an old driver on it.

The tree is a connected graph consisting of n nodes and n-1 edges. Each node has a color, and Nauuo will visit the ODT through a simple path on the tree in the old driver's car.

Nauuo wants to visit see more different colors in her journey, but she doesn't know which simple path she will be traveling on. So, she wants to calculate the sum of the numbers of different colors on all different paths. Can you help her?

What's more, the ODT is being redecorated, so there will be m modifications, each modification will change a single node's color. Nauuo wants to know the answer after each modification too.

Note that in this problem, we consider the simple path from u to v and the simple path from v to u as two different simple paths if and only if u≠ v.

Input

The first line contains two integers n and m (2≤ n≤ 4⋅ 10^5, 1≤ m≤ 4⋅ 10^5) — the number of nodes and the number of modifications.

The second line contains n integers c_1,c_2,…,c_n (1≤ c_i≤ n), where c_i is the initial color of node i.

Each of the next n-1 lines contains two integers u and v (1≤ u,v≤ n), denoting there is an edge between u and v. It is guaranteed that the given edges form a tree.

Each of the next m lines contains two integers u and x (1≤ u,x≤ n), which means a modification that changes the color of node u into x.

Output

The output contains m+1 integers — the first integer is the answer at the beginning, the rest integers are the answers after every modification in the given order.

Examples

Input

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

Output

47
51
49
45

Input

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

Output

36
46

Note

Example 1

<image>

The number of colors on each simple path at the beginning:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class node>
struct link_cut_tree {
  bool connected(node* u, node* v) { return lca(u, v) != NULL; }
  int depth(node* u) {
    access(u);
    return get_sz(u->ch[0]);
  }
  node* get_root(node* u) {
    access(u);
    while (u->ch[0]) u = u->ch[0], u->push();
    return access(u), u;
  }
  node* ancestor(node* u, int k) {
    k = depth(u) - k;
    for (;; u->push()) {
      int sz = get_sz(u->ch[0]);
      if (sz == k) return access(u), u;
      if (sz < k)
        k -= sz + 1, u = u->ch[1];
      else
        u = u->ch[0];
    }
  }
  node* lca(node* u, node* v) {
    if (u == v) return u;
    access(u);
    access(v);
    if (!u->p) return NULL;
    u->splay();
    return u->p ?: u;
  }
  void link(node* u, node* v) {
    make_root(v);
    access(u);
    set_link(v, u, 0);
    v->update();
  }
  void cut(node* u) {
    access(u);
    u->ch[0]->p = NULL;
    u->ch[0] = NULL;
    u->update();
  }
  void cut(node* u, node* v) { cut(depth(u) > depth(v) ? u : v); }
  void make_root(node* u) {
    access(u);
    u->rev ^= 1;
    access(u);
  }
  void access(node* u) {
    for (node *v = u, *pre = NULL; v; v = v->p) {
      v->splay();
      if (pre) v->update_vsub(pre, false);
      if (v->ch[1]) v->update_vsub(v->ch[1], true);
      v->ch[1] = pre;
      v->update();
      pre = v;
    }
    u->splay();
  }
  node* operator[](int i) { return &data[i]; }
  int operator[](node* i) { return i - &data[0]; }
  vector<node> data;
  link_cut_tree(int n) : data(n) {}
};
template <typename pnode>
struct splay_tree {
  pnode ch[2], p;
  bool rev;
  int sz;
  splay_tree() {
    ch[0] = ch[1] = p = NULL;
    rev = 0;
    sz = 1;
  }
  friend int get_sz(pnode u) { return u ? u->sz : 0; }
  virtual void update() {
    if (ch[0]) ch[0]->push();
    if (ch[1]) ch[1]->push();
    sz = 1 + get_sz(ch[0]) + get_sz(ch[1]);
  }
  virtual void push() {
    if (rev) {
      if (ch[0]) ch[0]->rev ^= 1;
      if (ch[1]) ch[1]->rev ^= 1;
      swap(ch[0], ch[1]);
      rev = 0;
    }
  }
  int dir() {
    if (!p) return -2;
    if (p->ch[0] == this) return 0;
    if (p->ch[1] == this) return 1;
    return -1;
  }
  bool is_root() { return dir() < 0; }
  friend void set_link(pnode u, pnode v, int d) {
    if (v) v->p = u;
    if (d >= 0) u->ch[d] = v;
  }
  void rotate() {
    int x = dir();
    pnode g = p;
    set_link(g->p, static_cast<pnode>(this), g->dir());
    set_link(g, ch[x ^ 1], x);
    set_link(static_cast<pnode>(this), g, x ^ 1);
    g->update();
  }
  void splay() {
    while (!is_root() && !p->is_root()) {
      p->p->push(), p->push(), push();
      dir() == p->dir() ? p->rotate() : rotate();
      rotate();
    }
    if (!is_root()) p->push(), push(), rotate();
    push(), update();
  }
};
struct node : splay_tree<node*> {
  using splay_tree::ch;
  int rsz, vrsz;
  long long chsz2, vchsz2;
  node() : splay_tree() {
    rsz = 1;
    vrsz = chsz2 = vchsz2 = 0;
  }
  void update() override {
    splay_tree::update();
    rsz = 1 + (ch[0] ? ch[0]->rsz : 0) + (ch[1] ? ch[1]->rsz : 0) + vrsz;
    chsz2 = (ch[0] ? ((long long)ch[0]->rsz * ch[0]->rsz) : 0) +
            (ch[1] ? ((long long)ch[1]->rsz * ch[1]->rsz) : 0) + vchsz2;
  }
  void update_vsub(node* v, bool add) {
    vrsz += (add ? +1 : -1) * v->rsz;
    vchsz2 += (add ? +1 : -1) * (long long)v->rsz * v->rsz;
  }
  void push() override { splay_tree::push(); }
};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> col(n);
  vector<vector<pair<int, int>>> e(n);
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
    --x;
    e[x].push_back({0, i});
    col[i] = x;
  }
  vector<vector<int>> adj(n + 1);
  for (int i = 1, u, v; i < n; ++i) {
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  adj[n].push_back(0);
  link_cut_tree<node> lct(n + 1);
  vector<int> parent(n + 1, -1);
  function<void(int)> dfs = [&](int u) {
    for (auto v : adj[u])
      if (v != parent[u]) {
        lct.link(lct[u], lct[v]);
        parent[v] = u;
        dfs(v);
      }
  };
  dfs(n);
  for (int i = 1, u, x; i <= q; ++i) {
    cin >> u >> x;
    --u, --x;
    if (col[u] == x) continue;
    e[col[u]].push_back({i, ~u});
    e[x].push_back({i, u});
    col[u] = x;
  }
  vector<long long> ans(q + 1);
  vector<bool> nodes(n);
  for (auto& c : e) {
    long long last = 0, sz2 = (long long)n * n;
    for (auto& i : c) {
      int ru = max(i.second, ~i.second);
      auto u = lct[ru], pu = lct[parent[ru]], r = lct.get_root(pu);
      if (i.second < 0) {
        nodes[ru] = false;
        sz2 -= r->chsz2;
        lct.access(u);
        sz2 -= u->chsz2;
        lct.link(pu, u);
        lct.access(r);
        sz2 += r->chsz2;
      } else {
        nodes[ru] = true;
        sz2 -= r->chsz2;
        lct.cut(u);
        sz2 += u->chsz2;
        lct.access(r);
        sz2 += r->chsz2;
      }
      if (i.first > 0 || &i == &c.back() || c[&i - &c[0] + 1].first > 0) {
        ans[i.first] += -last;
        ans[i.first] += (last = (long long)n * n - sz2);
      }
    }
    for (auto& i : c) {
      int ru = max(i.second, ~i.second);
      if (nodes[ru]) {
        nodes[ru] = false;
        lct.link(lct[parent[ru]], lct[ru]);
      }
    }
  }
  partial_sum(ans.begin(), ans.end(), ans.begin());
  for (auto& i : ans) cout << i << "\n";
  return 0;
}

```


### Prompt

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

AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this integer a multiple of 4?

Constraints

* 1 ≤ r, g, b ≤ 9

Input

Input is given from Standard Input in the following format:

r g b

Output

If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`.

Examples

Input

4 3 2

Output

YES

Input

2 3 4

Output

NO

### Response

```cpp
#include<stdio.h>

int main(){
  int r,g,b;
  scanf("%d%d%d",&r,&g,&b);

  if((r*100+g*10+b)%4==0) printf("YES");
  else printf("NO");

}
```


### Prompt

Please formulate a Cpp solution to the following problem:

In the Isle of Guernsey there are n different types of coins. For each i (1 ≤ i ≤ n), coin of type i is worth ai cents. It is possible that ai = aj for some i and j (i ≠ j).

Bessie has some set of these coins totaling t cents. She tells Jessie q pairs of integers. For each i (1 ≤ i ≤ q), the pair bi, ci tells Jessie that Bessie has a strictly greater number of coins of type bi than coins of type ci. It is known that all bi are distinct and all ci are distinct.

Help Jessie find the number of possible combinations of coins Bessie could have. Two combinations are considered different if there is some i (1 ≤ i ≤ n), such that the number of coins Bessie has of type i is different in the two combinations. Since the answer can be very large, output it modulo 1000000007 (109 + 7).

If there are no possible combinations of coins totaling t cents that satisfy Bessie's conditions, output 0.

Input

The first line contains three space-separated integers, n, q and t (1 ≤ n ≤ 300; 0 ≤ q ≤ n; 1 ≤ t ≤ 105). The second line contains n space separated integers, a1, a2, ..., an (1 ≤ ai ≤ 105). The next q lines each contain two distinct space-separated integers, bi and ci (1 ≤ bi, ci ≤ n; bi ≠ ci).

It's guaranteed that all bi are distinct and all ci are distinct.

Output

A single integer, the number of valid coin combinations that Bessie could have, modulo 1000000007 (109 + 7).

Examples

Input

4 2 17
3 1 2 5
4 2
3 4

Output

3

Input

3 2 6
3 1 1
1 2
2 3

Output

0

Input

3 2 10
1 2 3
1 2
2 1

Output

0

Note

For the first sample, the following 3 combinations give a total of 17 cents and satisfy the given conditions: {0 of type 1, 1 of type 2, 3 of type 3, 2 of type 4}, {0, 0, 6, 1}, {2, 0, 3, 1}.

No other combinations exist. Note that even though 4 occurs in both bi and ci,  the problem conditions are still satisfied because all bi are distinct and all ci are distinct.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX = 305;
const int MAX_COST = 100005;
const int MOD = 1000000007;
long long regSum[MAX], espSum[MAX];
int a[MAX], in[MAX], out[MAX], dp[2][MAX_COST][2], n;
bool mark[MAX];
vector<int> tps;
void error() {
  cout << 0 << endl;
  exit(0);
}
void insertPath(int v) {
  if (v == -1) return;
  if (mark[v] == true) error();
  mark[v] = true;
  tps.push_back(v);
  insertPath(out[v]);
}
void sort() {
  for (int j = 1; j <= n; j++)
    if (in[j] == -1) insertPath(j);
  if (tps.size() != n) error();
}
int main() {
  int q, t;
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    in[i] = out[i] = -1;
  }
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    in[c] = b;
    out[b] = c;
  }
  sort();
  for (int i = 0; i < n; i++) {
    int v = tps[i], u = in[v];
    long long rs = 0, es = 0;
    if (u != -1) {
      rs = regSum[u];
      es = espSum[u];
    }
    regSum[v] = rs + a[v];
    espSum[v] = es + regSum[v];
  }
  dp[0][0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= t; j++)
      for (int k = 0; k <= 1; k++) {
        int v = tps[i - 1], u = in[v];
        long long cost1, cost2;
        int newK = 1;
        if (k == 0) {
          cost1 = j - espSum[v];
          cost2 = j - (u == -1 ? 0 : espSum[u]);
        } else {
          cost1 = j - regSum[v];
          cost2 = j;
        }
        if (u == -1) newK = 0;
        dp[i % 2][j][k] = ((cost1 < 0 ? 0 : dp[i % 2][cost1][1]) +
                           (cost2 < 0 ? 0 : dp[(i - 1) % 2][cost2][newK])) %
                          MOD;
      }
  cout << dp[n % 2][t][0] << endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.

Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.

This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.

Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n".

You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.

Input

The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.

Output

Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.

Examples

Input

4
word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis

Output

word
l10n
i18n
p43s

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int t;
  cin >> t;
  while (t--) {
    string word;
    cin >> word;
    if (word.length() > 10) {
      cout << word[0] << word.length() - 2 << word[word.length() - 1] << endl;
    } else {
      cout << word << endl;
    }
  }
  return 0;
}

```