### Prompt

Please create a solution in CPP to the following problem:

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

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

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

Input

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

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

Output

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

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

Examples

Input

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

Output

1.75

Input

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

Output

12

Input

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

Output

3.141592

Note

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double p[110][110], fp[110][110][110];
double f[110][110][110];
void solve(int le, int ri, int score) {
  if (le == ri) {
    fp[le][ri][le] = 1;
    return;
  }
  int mid = le + ri >> 1;
  solve(le, mid, score - 1);
  solve(mid + 1, ri, score - 1);
  for (int i = le; i <= mid; i++) {
    fp[le][ri][i] = 0;
    double ma = 0;
    for (int j = mid + 1; j <= ri; j++)
      fp[le][ri][i] += fp[le][mid][i] * fp[mid + 1][ri][j] * 0.01 * p[i][j],
          ma = max(ma, f[mid + 1][ri][j]);
    f[le][ri][i] = f[le][mid][i] + ma + fp[le][ri][i] * double(1 << score);
  }
  for (int i = mid + 1; i <= ri; i++) {
    fp[le][ri][i] = 0;
    double ma = 0;
    for (int j = le; j <= mid; j++)
      fp[le][ri][i] += fp[mid + 1][ri][i] * fp[le][mid][j] * 0.01 * p[i][j],
          ma = max(ma, f[le][mid][j]);
    f[le][ri][i] = f[mid + 1][ri][i] + ma + fp[le][ri][i] * (1 << score);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= 1 << n; i++)
    for (int j = 1; j <= 1 << n; j++) scanf("%lf", &p[i][j]);
  solve(1, 1 << n, n - 1);
  double ans = 0;
  for (int i = 1; i <= 1 << n; i++) ans = max(ans, f[1][1 << n][i]);
  printf("%.10lf", ans);
  return 0;
}

```


### Prompt

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

During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in peace.

The Word of Universe is a long word containing the lowercase English characters only. At each moment of time, each of the religion beliefs could be described by a word consisting of lowercase English characters.

The three religions can coexist in peace if their descriptions form disjoint subsequences of the Word of Universe. More formally, one can paint some of the characters of the Word of Universe in three colors: 1, 2, 3, so that each character is painted in at most one color, and the description of the i-th religion can be constructed from the Word of Universe by removing all characters that aren't painted in color i.

The religions however evolve. In the beginning, each religion description is empty. Every once in a while, either a character is appended to the end of the description of a single religion, or the last character is dropped from the description. After each change, determine if the religions could coexist in peace.

Input

The first line of the input contains two integers n, q (1 ≤ n ≤ 100 000, 1 ≤ q ≤ 1000) — the length of the Word of Universe and the number of religion evolutions, respectively. The following line contains the Word of Universe — a string of length n consisting of lowercase English characters.

Each of the following line describes a single evolution and is in one of the following formats:

  * + i c (i ∈ \{1, 2, 3\}, c ∈ \{a, b, ..., z\}: append the character c to the end of i-th religion description.
  * - i (i ∈ \{1, 2, 3\}) – remove the last character from the i-th religion description. You can assume that the pattern is non-empty.

You can assume that no religion will have description longer than 250 characters.

Output

Write q lines. The i-th of them should be YES if the religions could coexist in peace after the i-th evolution, or NO otherwise.

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

Examples

Input

6 8
abdabc
+ 1 a
+ 1 d
+ 2 b
+ 2 c
+ 3 a
+ 3 b
+ 1 c
- 2

Output

YES
YES
YES
YES
YES
YES
NO
YES

Input

6 8
abbaab
+ 1 a
+ 2 a
+ 3 a
+ 1 b
+ 2 b
+ 3 b
- 1
+ 2 z

Output

YES
YES
YES
YES
YES
NO
YES
NO

Note

In the first example, after the 6th evolution the religion descriptions are: ad, bc, and ab. The following figure shows how these descriptions form three disjoint subsequences of the Word of Universe:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
  for (Tp current = _begin; current != _end; ++current) {
    std::cout << *current << _delim;
  }
  std::cout << '\n';
}
using ll = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
string s;
int dp[255][255][255];
int nxt[100000][26];
int len[3];
string religions[3];
void Init() {
  memset(dp, INF, sizeof(dp));
  dp[0][0][0] = 0;
  for (char c = 'a'; c <= 'z'; ++c) {
    nxt[static_cast<int>((s).size()) - 1][c - 'a'] =
        s.back() == c ? static_cast<int>((s).size()) - 1
                      : static_cast<int>((s).size());
    for (int i = static_cast<int>((s).size()) - 2; i >= 0; --i) {
      nxt[i][c - 'a'] = s[i] == c ? i : nxt[i + 1][c - 'a'];
    }
  }
}
void Add(int i, char c) {
  int f = i == 0 ? 1 : 0;
  int ff = i == 2 ? 1 : 2;
  for (int a = 0; a <= len[f]; ++a) {
    for (int b = 0; b <= len[ff]; ++b) {
      if (i == 0) {
        int k = dp[len[i]][a][b];
        if (k < static_cast<int>((s).size()) &&
            nxt[k][c - 'a'] < static_cast<int>((s).size())) {
          dp[len[i] + 1][a][b] = min(dp[len[i] + 1][a][b], nxt[k][c - 'a'] + 1);
        }
      } else if (i == 1) {
        int k = dp[a][len[i]][b];
        if (k < static_cast<int>((s).size()) &&
            nxt[k][c - 'a'] < static_cast<int>((s).size())) {
          dp[a][len[i] + 1][b] = min(dp[a][len[i] + 1][b], nxt[k][c - 'a'] + 1);
        }
      } else {
        int k = dp[a][b][len[i]];
        if (k < static_cast<int>((s).size()) &&
            nxt[k][c - 'a'] < static_cast<int>((s).size())) {
          dp[a][b][len[i] + 1] = min(dp[a][b][len[i] + 1], nxt[k][c - 'a'] + 1);
        }
      }
    }
  }
  ++len[i];
  religions[i] += c;
  for (int a = 0; a <= len[f]; ++a) {
    for (int b = 0; b <= len[ff]; ++b) {
      if (i == 0) {
        int k = dp[len[i]][a][b];
        if (len[f] > 0 && a < len[f]) {
          char z = religions[f][a];
          if (k < static_cast<int>((s).size()) &&
              nxt[k][z - 'a'] < static_cast<int>((s).size())) {
            dp[len[i]][a + 1][b] =
                min(dp[len[i]][a + 1][b], nxt[k][z - 'a'] + 1);
          }
        }
        if (len[ff] > 0 && b < len[ff]) {
          char z = religions[ff][b];
          if (k < static_cast<int>((s).size()) &&
              nxt[k][z - 'a'] < static_cast<int>((s).size())) {
            dp[len[i]][a][b + 1] =
                min(dp[len[i]][a][b + 1], nxt[k][z - 'a'] + 1);
          }
        }
      } else if (i == 1) {
        int k = dp[a][len[i]][b];
        if (len[f] > 0 && a < len[f]) {
          char z = religions[f][a];
          if (k < static_cast<int>((s).size()) &&
              nxt[k][z - 'a'] < static_cast<int>((s).size())) {
            dp[a + 1][len[i]][b] =
                min(dp[a + 1][len[i]][b], nxt[k][z - 'a'] + 1);
          }
        }
        if (len[ff] > 0 && b < len[ff]) {
          char z = religions[ff][b];
          if (k < static_cast<int>((s).size()) &&
              nxt[k][z - 'a'] < static_cast<int>((s).size())) {
            dp[a][len[i]][b + 1] =
                min(dp[a][len[i]][b + 1], nxt[k][z - 'a'] + 1);
          }
        }
      } else {
        int k = dp[a][b][len[i]];
        if (len[f] > 0 && a < len[f]) {
          char z = religions[f][a];
          if (k < static_cast<int>((s).size()) &&
              nxt[k][z - 'a'] < static_cast<int>((s).size())) {
            dp[a + 1][b][len[i]] =
                min(dp[a + 1][b][len[i]], nxt[k][z - 'a'] + 1);
          }
        }
        if (len[ff] > 0 && b < len[ff]) {
          char z = religions[ff][b];
          if (k < static_cast<int>((s).size()) &&
              nxt[k][z - 'a'] < static_cast<int>((s).size())) {
            dp[a][b + 1][len[i]] =
                min(dp[a][b + 1][len[i]], nxt[k][z - 'a'] + 1);
          }
        }
      }
    }
  }
}
void Del(int i) {
  int f = i == 0 ? 1 : 0;
  int ff = i == 2 ? 1 : 2;
  for (int a = 0; a <= len[f]; ++a) {
    for (int b = 0; b <= len[ff]; ++b) {
      if (i == 0) {
        dp[len[i]][a][b] = INF;
      } else if (i == 1) {
        dp[a][len[i]][b] = INF;
      } else {
        dp[a][b][len[i]] = INF;
      }
    }
  }
  --len[i];
  religions[i].pop_back();
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, q;
  cin >> n >> q >> s;
  Init();
  while (q--) {
    char cmd;
    int i;
    cin >> cmd >> i;
    --i;
    if (cmd == '+') {
      char c;
      cin >> c;
      Add(i, c);
    } else {
      Del(i);
    }
    cout << (dp[len[0]][len[1]][len[2]] <= n ? "YES" : "NO") << "\n";
  }
  return 0;
}

```


### Prompt

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

There are n beacons located at distinct positions on a number line. The i-th beacon has position ai and power level bi. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance bi inclusive. The beacon itself is not destroyed however. Saitama will activate the beacons one at a time from right to left. If a beacon is destroyed, it cannot be activated.

Saitama wants Genos to add a beacon strictly to the right of all the existing beacons, with any position and any power level, such that the least possible number of beacons are destroyed. Note that Genos's placement of the beacon means it will be the first beacon activated. Help Genos by finding the minimum number of beacons that could be destroyed.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 100 000) — the initial number of beacons.

The i-th of next n lines contains two integers ai and bi (0 ≤ ai ≤ 1 000 000, 1 ≤ bi ≤ 1 000 000) — the position and power level of the i-th beacon respectively. No two beacons will have the same position, so ai ≠ aj if i ≠ j.

Output

Print a single integer — the minimum number of beacons that could be destroyed if exactly one beacon is added.

Examples

Input

4
1 9
3 1
6 1
7 4

Output

1

Input

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

Output

3

Note

For the first sample case, the minimum number of beacons destroyed is 1. One way to achieve this is to place a beacon at position 9 with power level 2.

For the second sample case, the minimum number of beacons destroyed is 3. One way to achieve this is to place a beacon at position 1337 with power level 42.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int const MAX_N = 1001000;
int const INT_INF = 1000000000;
long long const LL_INF = 1000000000000000000LL;
int s[MAX_N], dp[MAX_N], part_sum[MAX_N];
int find_part_sum(int a, int b) {
  if (a > b) return 0;
  a = max(a, 0);
  b = min(b, MAX_N - 1);
  int ans = part_sum[b];
  if (a > 0) ans -= part_sum[a - 1];
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, lev;
    scanf("%d%d", &x, &lev);
    s[x] = lev;
  }
  part_sum[0] = s[0] > 0;
  for (int i = 1; i < MAX_N; i++) part_sum[i] = part_sum[i - 1] + (s[i] > 0);
  for (int i = 0; i < MAX_N; i++) dp[i] = INT_INF;
  dp[0] = 0;
  for (int i = 1; i < MAX_N; i++)
    if (s[i] == 0)
      dp[i] = dp[i - 1];
    else {
      int prev = i - s[i] - 1;
      prev = max(prev, 0);
      dp[i] = min(dp[i], dp[prev] + find_part_sum(max(i - s[i], 0), i - 1));
    }
  int ans = INT_INF;
  for (int i = MAX_N - 1; i >= 0; i--)
    ans = min(ans, dp[i] + find_part_sum(i + 1, MAX_N - 1));
  cout << ans;
  return 0;
}

```


### Prompt

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

You are given two positive integers d and s. Find minimal positive integer n which is divisible by d and has sum of digits equal to s.

Input

The first line contains two positive integers d and s (1 ≤ d ≤ 500, 1 ≤ s ≤ 5000) separated by space.

Output

Print the required number or -1 if it doesn't exist.

Examples

Input

13 50

Output

699998

Input

61 2

Output

1000000000000000000000000000001

Input

15 50

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dig[505][5005];
int dist[505][5005];
pair<int, int> par[505][5005];
int main() {
  int d, s;
  scanf("%d %d", &d, &s);
  queue<pair<int, int> > Q;
  Q.push({0, s});
  memset(dist, -1, sizeof dist);
  dist[0][s] = 0;
  while (!Q.empty()) {
    auto top = Q.front();
    Q.pop();
    for (int i = 0; i <= 9; i++) {
      int mod = (top.first * 10 + i) % d;
      int sd = top.second - i;
      if (sd >= 0 && dist[mod][sd] == -1) {
        dist[mod][sd] = dist[top.first][top.second] + 1;
        par[mod][sd] = top;
        dig[mod][sd] = i;
        Q.push({mod, sd});
      }
    }
  }
  if (dist[0][0] == -1) {
    printf("-1\n");
    return 0;
  }
  int x = 0, y = 0;
  string st;
  while (1) {
    st += char(dig[x][y] + '0');
    auto nw = par[x][y];
    x = nw.first;
    y = nw.second;
    if (x == 0 && y == s) break;
  }
  reverse(st.begin(), st.end());
  printf("%s\n", st.c_str());
  return 0;
}

```


### Prompt

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

Rng has a connected undirected graph with N vertices. Currently, there are M edges in the graph, and the i-th edge connects Vertices A_i and B_i.

Rng will add new edges to the graph by repeating the following operation:

* Operation: Choose u and v (u \neq v) such that Vertex v can be reached by traversing exactly three edges from Vertex u, and add an edge connecting Vertices u and v. It is not allowed to add an edge if there is already an edge connecting Vertices u and v.

Find the maximum possible number of edges that can be added.

Constraints

* 2 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* 1 \leq A_i,B_i \leq N
* The graph has no self-loops or multiple edges.
* The graph is connected.

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
A_2 B_2
:
A_M B_M

Output

Find the maximum possible number of edges that can be added.

Examples

Input

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

Output

4

Input

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

Output

5

### Response

```cpp
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+10;
ll n,m,a,b,cnt;
ll head[N],bl[N];
struct Edge{ll nxt,to;}edge[N<<1];
inline void add(ll u,ll v){edge[++cnt]=(Edge){head[u],v};head[u]=cnt;}
void dfs(ll u,ll col){
	bl[u]=col;
	for(ll i=head[u];i;i=edge[i].nxt){
		ll v=edge[i].to;
		if(bl[v]==-1) dfs(v,!col);
		if(bl[v]!=!col){printf("%lld",n*(n-1)/2-m);exit(0);}
	}
}
int main(){
	scanf("%lld%lld",&n,&m);
	for(ll i=1;i<=m;i++) scanf("%lld%lld",&a,&b),add(a,b),add(b,a);
	memset(bl,-1,sizeof(bl));
	dfs(1,0);
	ll s1=0,s2=0;
	for(ll i=1;i<=n;i++) if(bl[i]==0) s1++; else if(bl[i]==1) s2++;
	printf("%lld",s1*s2-m);
}
```


### Prompt

Generate a CPP solution to the following problem:

Rick and Morty want to find MR. PBH and they can't do it alone. So they need of Mr. Meeseeks. They Have generated n Mr. Meeseeks, standing in a line numbered from 1 to n. Each of them has his own color. i-th Mr. Meeseeks' color is ai.

Rick and Morty are gathering their army and they want to divide Mr. Meeseeks into some squads. They don't want their squads to be too colorful, so each squad should have Mr. Meeseeks of at most k different colors. Also each squad should be a continuous subarray of Mr. Meeseeks in the line. Meaning that for each 1 ≤ i ≤ e ≤ j ≤ n, if Mr. Meeseeks number i and Mr. Meeseeks number j are in the same squad then Mr. Meeseeks number e should be in that same squad.

<image>

Also, each squad needs its own presidio, and building a presidio needs money, so they want the total number of squads to be minimized.

Rick and Morty haven't finalized the exact value of k, so in order to choose it, for each k between 1 and n (inclusive) need to know the minimum number of presidios needed.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 105) — number of Mr. Meeseeks.

The second line contains n integers a1, a2, ..., an separated by spaces (1 ≤ ai ≤ n) — colors of Mr. Meeseeks in order they standing in a line.

Output

In the first and only line of input print n integers separated by spaces. i-th integer should be the minimum number of presidios needed if the value of k is i.

Examples

Input

5
1 3 4 3 3

Output

4 2 1 1 1

Input

8
1 5 7 8 1 7 6 1

Output

8 4 3 2 1 1 1 1

Note

For the first sample testcase, some optimal ways of dividing army into squads for each k are:

  1. [1], [3], [4], [3, 3]
  2. [1], [3, 4, 3, 3]
  3. [1, 3, 4, 3, 3]
  4. [1, 3, 4, 3, 3]
  5. [1, 3, 4, 3, 3]

For the second testcase, some optimal ways of dividing army into squads for each k are:

  1. [1], [5], [7], [8], [1], [7], [6], [1]
  2. [1, 5], [7, 8], [1, 7], [6, 1]
  3. [1, 5, 7], [8], [1, 7, 6, 1]
  4. [1, 5, 7, 8], [1, 7, 6, 1]
  5. [1, 5, 7, 8, 1, 7, 6, 1]
  6. [1, 5, 7, 8, 1, 7, 6, 1]
  7. [1, 5, 7, 8, 1, 7, 6, 1]
  8. [1, 5, 7, 8, 1, 7, 6, 1]

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18 + 5;
const int MOD = (int)1e9 + 7;
const int LOG = 18;
const int INF = 1e9;
const int N = 1e5 + 5;
const int M = 12;
const int SQ = 350;
int n, c[N], ans[N], mark[N];
int naive(int k) {
  memset(mark, 0, sizeof mark);
  int gro = 1, cnt = 0, ret = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      ret++;
      cnt++;
      mark[c[i]] = gro;
      continue;
    }
    if (mark[c[i]] == gro) {
      continue;
    }
    if (cnt == k) {
      cnt = 0;
      ret++;
      gro++;
    }
    mark[c[i]] = gro;
    cnt++;
  }
  return ret;
}
void solve(int l, int r, int optl, int optr) {
  if (l > r) return;
  ans[(l + r) / 2] = (optl == optr ? optl : naive((l + r) / 2));
  solve(l, (l + r) / 2 - 1, ans[(l + r) / 2], optr);
  solve((l + r) / 2 + 1, r, optl, ans[(l + r) / 2]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  solve(1, n, 1, n);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}

```


### Prompt

Develop a solution in CPP to the problem described below:

You have been blessed as a child of Omkar. To express your gratitude, please solve this problem for Omkar!

An array a of length n is called complete if all elements are positive and don't exceed 1000, and for all indices x,y,z (1 ≤ x,y,z ≤ n), a_{x}+a_{y} ≠ a_{z} (not necessarily distinct).

You are given one integer n. Please find any complete array of length n. It is guaranteed that under given constraints such array exists.

Input

Each test contains multiple test cases. The first line contains t (1 ≤ t ≤ 1000) — the number of test cases. Description of the test cases follows.

The only line of each test case contains one integer n (1 ≤ n ≤ 1000).

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

Output

For each test case, print a complete array on a single line. All elements have to be integers between 1 and 1000 and for all indices x,y,z (1 ≤ x,y,z ≤ n) (not necessarily distinct), a_{x}+a_{y} ≠ a_{z} must hold.

If multiple solutions exist, you may print any.

Example

Input

2
5
4

Output

1 5 3 77 12
384 384 44 44

Note

It can be shown that the outputs above are valid for each test case. For example, 44+44 ≠ 384.

Below are some examples of arrays that are NOT complete for the 1st test case:

[1,2,3,4,5]

Notice that a_{1}+a_{2} = a_{3}.

[1,3000,1,300,1]

Notice that a_{2} = 3000 > 1000.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      if (i > 1) cout << " ";
      cout << 1;
    }
    cout << '\n';
  }
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.

Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array in such a way that his array becomes a permutation (i.e. each of the integers from 1 to n was encountered in his array exactly once). If there are multiple ways to do it he wants to find the lexicographically minimal permutation among them.

Thus minimizing the number of changes has the first priority, lexicographical minimizing has the second priority.

In order to determine which of the two permutations is lexicographically smaller, we compare their first elements. If they are equal — compare the second, and so on. If we have two permutations x and y, then x is lexicographically smaller if xi < yi, where i is the first index in which the permutations x and y differ.

Determine the array Ivan will obtain after performing all the changes.

Input

The first line contains an single integer n (2 ≤ n ≤ 200 000) — the number of elements in Ivan's array.

The second line contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ n) — the description of Ivan's array.

Output

In the first line print q — the minimum number of elements that need to be changed in Ivan's array in order to make his array a permutation. In the second line, print the lexicographically minimal permutation which can be obtained from array with q changes.

Examples

Input

4
3 2 2 3

Output

2
1 2 4 3

Input

6
4 5 6 3 2 1

Output

0
4 5 6 3 2 1

Input

10
6 8 4 6 7 1 6 3 4 5

Output

3
2 8 4 6 7 1 9 3 10 5

Note

In the first example Ivan needs to replace number three in position 1 with number one, and number two in position 3 with number four. Then he will get a permutation [1, 2, 4, 3] with only two changed numbers — this permutation is lexicographically minimal among all suitable.

In the second example Ivan does not need to change anything because his array already is a permutation.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int cnt[n + 1];
  bool placedBefore[n + 1];
  queue<int> q;
  int minMoves = 0;
  memset(cnt, 0, sizeof(cnt));
  memset(placedBefore, false, sizeof(placedBefore));
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    cnt[arr[i]] += 1;
  }
  for (int i = 1; i <= n; i++) {
    if (cnt[i] == 0) {
      minMoves += 1;
      q.push(i);
    }
  }
  for (int i = 0; i < n; i++) {
    if (cnt[arr[i]] >= 1) {
      if (!q.empty()) {
        if (q.front() < arr[i]) {
          if (placedBefore[arr[i]]) {
            cnt[arr[i]] -= 1;
            arr[i] = q.front();
            placedBefore[q.front()] = true;
            cnt[q.front()] += 1;
            q.pop();
          } else {
            if (cnt[arr[i]] > 1) {
              cnt[arr[i]] -= 1;
              arr[i] = q.front();
              placedBefore[q.front()] = true;
              cnt[q.front()] += 1;
              q.pop();
            } else {
              placedBefore[arr[i]] = true;
              cnt[arr[i]] -= 1;
            }
          }
        } else {
          if (placedBefore[arr[i]]) {
            arr[i] = q.front();
            cnt[q.front()] += 1;
            placedBefore[q.front()] = true;
            q.pop();
          } else {
            placedBefore[arr[i]] = true;
            cnt[arr[i]] -= 1;
          }
        }
      } else {
        placedBefore[arr[i]] = true;
      }
    } else {
      placedBefore[arr[i]] = true;
    }
  }
  cout << minMoves << endl;
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

You, the mighty Blackout, are standing in the upper-left (0,0) corner of NxM matrix. You must move either right or down each second.

There are K transformers jumping around the matrix in the following way. Each transformer starts jumping from position (x,y), at time t, and jumps to the next position each second. The x-axes grows downwards, and y-axes grows to the right. The order of jumping positions is defined as {(x,y),(x+d,y-d),(x+d,y),(x,y+d)}, and is periodic. Before time t transformer is not in the matrix.

You want to arrive to the bottom-right corner (N-1,M-1), while slaying transformers and losing the least possible amount of energy. When you meet the transformer (or more of them) in the matrix field, you must kill them all, and you lose the sum of the energy amounts required to kill each transformer.

After the transformer is killed, he of course stops jumping, falls into the abyss and leaves the matrix world. Output minimum possible amount of energy wasted.

Input

In the first line, integers N,M (1 ≤ N, M ≤ 500), representing size of the matrix, and K (0 ≤ K ≤ 5*10^5) , the number of jumping transformers.

In next K lines, for each transformer, numbers x, y, d (d ≥ 1), t (0 ≤ t ≤ N+M-2), and e (0 ≤ e ≤ 10^9), representing starting coordinates of transformer, jumping positions distance in pattern described above, time when transformer starts jumping, and energy required to kill it.

It is guaranteed that all 4 of jumping points of the transformers are within matrix coordinates

Output

Print single integer, the minimum possible amount of energy wasted, for Blackout to arrive at bottom-right corner.

Example

Input

3 3 5
0 1 1 0 7
1 1 1 0 10
1 1 1 1 2
1 1 1 2 2
0 1 1 2 3

Output

9

Note

If Blackout takes the path from (0, 0) to (2, 0), and then from (2, 0) to (2, 2) he will need to kill the first and third transformer for a total energy cost of 9. There exists no path with less energy value.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const long long oo = 1e18;
vector<pair<int, long long>> row[N][N], col[N][N];
long long dp[N][N];
long long a[N][N];
int n, m, k;
void mini(long long &a, long long b) {
  if (a > b) a = b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    int x, y, d, t, w;
    cin >> x >> y >> d >> t >> w;
    if (x + y >= t) {
      if ((x + y - t) % 4 == 0) {
        a[x][y] += w;
        if ((x + y + d - t) % 4 == 3)
          row[x][y + d].push_back(make_pair(-y, -w));
        if ((x + y + d - t) % 4 == 2)
          col[x + d][y].push_back(make_pair(-x, -w));
      }
      if ((x + y - t) % 4 == 1) {
        a[x + d][y - d] += w;
        if ((x + y + d - t) % 4 == 2)
          row[x + d][y].push_back(make_pair(-(y - d), -w));
      }
    }
    if (x + y + d >= t) {
      if ((x + y + d - t) % 4 == 2) a[x + d][y] += w;
      if ((x + y + d - t) % 4 == 3) a[x][y + d] += w;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      sort(row[i][j].begin(), row[i][j].end());
      for (int id = 1; id < (int)row[i][j].size(); id++)
        row[i][j][id].second += row[i][j][id - 1].second;
      sort(col[i][j].begin(), col[i][j].end());
      for (int id = 1; id < (int)col[i][j].size(); id++)
        col[i][j][id].second += col[i][j][id - 1].second;
      dp[i][j] = oo;
    }
  dp[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      long long sum;
      sum = dp[i][j];
      for (int k = j + 1; k < m; k++) {
        sum += a[i][k];
        auto it =
            upper_bound(row[i][k].begin(), row[i][k].end(), make_pair(-j, oo));
        if (it != row[i][k].begin()) sum += prev(it)->second;
        mini(dp[i][k], sum);
      }
      sum = dp[i][j];
      for (int k = i + 1; k < n; k++) {
        sum += a[k][j];
        auto it =
            upper_bound(col[k][j].begin(), col[k][j].end(), make_pair(-i, oo));
        if (it != col[k][j].begin()) sum += prev(it)->second;
        mini(dp[k][j], sum);
      }
    }
  cout << dp[n - 1][m - 1];
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

We will call a string that can be obtained by concatenating two equal strings an even string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.

For a non-empty string S, we will define f(S) as the shortest even string that can be obtained by appending one or more characters to the end of S. For example, f(`abaaba`)=`abaababaab`. It can be shown that f(S) is uniquely determined for a non-empty string S.

You are given an even string S consisting of lowercase English letters. For each letter in the lowercase English alphabet, find the number of its occurrences from the l-th character through the r-th character of f^{10^{100}} (S).

Here, f^{10^{100}} (S) is the string f(f(f( ... f(S) ... ))) obtained by applying f to S 10^{100} times.

Constraints

* 2 \leq |S| \leq 2\times 10^5
* 1 \leq l \leq r \leq 10^{18}
* S is an even string consisting of lowercase English letters.
* l and r are integers.

Input

Input is given from Standard Input in the following format:

S
l r

Output

Print 26 integers in a line with spaces in between. The i-th integer should be the number of the occurrences of the i-th letter in the lowercase English alphabet from the l-th character through the r-th character of f^{10^{100}} (S).

Examples

Input

abaaba
6 10

Output

3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Input

xx
1 1000000000000000000

Output

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1000000000000000000 0 0

Input

vgxgpuamkvgxgvgxgpuamkvgxg
1 1000000000000000000

Output

87167725689669676 0 0 0 0 0 282080685775825810 0 0 0 87167725689669676 0 87167725689669676 0 0 87167725689669676 0 0 0 0 87167725689669676 141040342887912905 0 141040342887912905 0 0

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
string s;
long long l,r;
int p;
int n;
long long num[200010][26];
vector<int>zfunc()
{
	vector<int>z(1000010);
	int l=0,r=0;
	int ln=s.size();
	for(int k=2;k<=ln;k++)
	{
		if(s[k-1]!=s[0])continue;
		if(k>r)
		{
			l=r=k;
			while(r<=ln&&s[r-1]==s[r-l])r++;
			r--;
			z[k]=r+1-l;
		}
		else
		{
			int tk=k+1-l;
			if(z[tk]<r+1-k)
				z[k]=z[tk];
			else
			{
				l=k;
				while(r<=ln&&s[r-1]==s[r-l])r++;
				r--;
				z[k]=r+1-l;
			}
		}
	}
	return z;
}
long long doit(long long x,int y)
{
	if(x<=n)return num[x][y];
	if(x<=2*n)return num[n][y]+num[x-n][y];
	long long x1=num[n][y]+num[p][y],x2=num[n][y];
	long long l1=n+p,l2=n;
	while(x>l1+l2)
	{
//		cout<<x1<<" "<<x2<<" "<<l1<<" "<<l2<<endl;
		long long t=x1;
		x1+=x2;
		x2=t;
		t=l1;
		l1+=l2;
		l2=t;
	}
	x1+=doit(x-l1,y);
//	cout<<x<<" "<<x1<<endl;
	return x1;
}
long long sol(long long x,int y)
{
	if(x<=n)return num[x][y];
//	if(x<=2*n)return num[n][y]+num[x-n][y];
	if(n%p==0)
	{
		long long xx=(x-n)/(long long)p*num[p][y]+num[n][y];
		x%=(long long)p;
		xx+=num[x][y];
		return xx;
	}
	return doit(x,y);
}
int main()
{
	cin>>s>>l>>r;
	n=s.size()/2;
	vector<int>z=zfunc();
	for(int i=n+2;i<=2*n;i++)
	{
		if(i+z[i]==2*n+1)
		{
			p=z[i];
			break;
		}
	}
	p=n-p;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<26;j++)num[i][j]+=num[i-1][j];
		num[i][s[i-1]-'a']++;
	}
	for(int i=0;i<26;i++)cout<<sol(r,i)-sol(l-1,i)<<" ";
	cout<<endl;
	return 0;
}
```


### Prompt

Generate a CPP solution to the following problem:

Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of d meters, and a throw is worth 3 points if the distance is larger than d meters, where d is some non-negative integer.

Vasya would like the advantage of the points scored by the first team (the points of the first team minus the points of the second team) to be maximum. For that he can mentally choose the value of d. Help him to do that.

Input

The first line contains integer n (1 ≤ n ≤ 2·105) — the number of throws of the first team. Then follow n integer numbers — the distances of throws ai (1 ≤ ai ≤ 2·109).

Then follows number m (1 ≤ m ≤ 2·105) — the number of the throws of the second team. Then follow m integer numbers — the distances of throws of bi (1 ≤ bi ≤ 2·109).

Output

Print two numbers in the format a:b — the score that is possible considering the problem conditions where the result of subtraction a - b is maximum. If there are several such scores, find the one in which number a is maximum.

Examples

Input

3
1 2 3
2
5 6

Output

9:6

Input

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

Output

15:10

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  vector<pair<int, int> > ar;
  cin >> n;
  for (int ctr1 = 0; ctr1 < n; ctr1++) {
    int a;
    cin >> a;
    ar.push_back(make_pair(a, 0));
  }
  cin >> m;
  for (int ctr1 = 0; ctr1 < m; ctr1++) {
    int a;
    cin >> a;
    ar.push_back(make_pair(a, 1));
  }
  sort(ar.begin(), ar.end());
  long long f = 0, s = 0;
  long long rf = 3 * n, rs = 3 * m;
  long long r = 3 * n - 3 * m;
  if (2 * n - 2 * m > r) {
    r = 2 * n - 2 * m;
    rf = 2 * n;
    rs = 2 * m;
  }
  for (int ctr1 = 0; ctr1 < ar.size() - 1; ctr1++) {
    if (ar[ctr1].second == 0)
      f++;
    else
      s++;
    if (ar[ctr1].first != ar[ctr1 + 1].first) {
      if (2 * f + 3 * (n - f) - 2 * s - 3 * (m - s) > r) {
        r = 2 * f + 3 * (n - f) - 2 * s - 3 * (m - s);
        rf = 2 * f + 3 * (n - f);
        rs = 2 * s + 3 * (m - s);
      }
      if (2 * f + 3 * (n - f) - 2 * s - 3 * (m - s) == r) {
        if (2 * f + 3 * (n - f) > rf) {
          rf = 2 * f + 3 * (n - f);
          rs = 2 * s + 3 * (m - s);
        }
      }
    }
  }
  cout << rf << ":" << rs << endl;
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

All-Berland programming contest comes to an end. In total, n teams participated in it. Like in ACM-ICPC, current results stopped refreshing one hour before the contest ends. So at the Award Ceremony, results are partially known. For each team the value ai is given — the number of points the i-th team has earned before the last hour of the contest. Besides that, the Jury has evaluated all submissions sent during the last hour and knows values di — the number of points earned by the i-th team during the last hour (these values can be negative, which means that a team can lose points).

Before the contest, each team got unique id from 1 to n. According to the contest rules, a team with more points takes a higher place. If two or more teams have equal number of points, the team with lower id will take the higher place. So no two teams can share the same place.

The Award Ceremony proceeds in the following way. At the beginning of the ceremony, a large screen shows the results for the time moment "one hour before the end", which means that the i-th team has ai points. Then the Jury unfreezes results of the teams one by one in some order. When result of the j-th team is unfrozen, its score changes from aj to aj + dj. At this time the table of results is modified and the place of the team can change. The unfreezing of the j-th team is followed by the applause from the audience with duration of |xj - yj| seconds, where xj is the place of the j-th team before unfreezing and yj is the place right after the unfreezing. For example, if the team does not change the place, there is no applause from the audience. As you can see, during the Award Ceremony, each team will be unfrozen exactly once.

Your task is to find such an order to unfreeze all the teams that the total duration of applause is maximum possible.

Input

The first line of the input file contains a single integer n (1 ≤ n ≤ 100) — the number of teams.

Each of the next n lines contains two integers ai and di (1 ≤ ai ≤ 100,  - 100 ≤ di ≤ 100) — the number of points the i-th team has earned before the last hour of the contest and the number of points earned by this team during the last hour. It is possible that after unfreezing a team will have a negative score.

Output

Print the only integer — maximal total applause duration in seconds if the Jury can choose any order of the teams to unfreeze.

Examples

Input

4
17 -14
52 -5
1 52
6 0

Output

4

Input

5
4 5
3 2
5 -3
6 -2
4 3

Output

14

Note

In the first example the initial standings are:

  1. Team 2, 52 points
  2. Team 1, 17 points
  3. Team 4, 6 points
  4. Team 3, 1 point

Here any order of unfreezing the teams leads to 4 seconds of applause in total. For example, let's unfreeze teams in their order from the Team 1 to the Team 4.

After the Team 1 became unfrozen the standings are:

  1. Team 2, 52 points
  2. Team 4, 6 points
  3. Team 1, 3 points
  4. Team 3, 1 point

So there is 1 second of applause, because the difference between old and new places |2 - 3| = 1.

After the Team 2 became unfrozen the standings are:

  1. Team 2, 47 points
  2. Team 4, 6 points
  3. Team 1, 3 points
  4. Team 3, 1 point

The place of the Team 2 has not changed, so no applause during unfreezing.

After the Team 3 became unfrozen the standings are:

  1. Team 3, 53 point
  2. Team 2, 47 points
  3. Team 4, 6 points
  4. Team 1, 3 points

The place of the Team 3 has changed from 4 to 1, so the duration of applause is |4 - 1| = 3.

The unfreezing of the Team 4 has not changed any place because d4 = 0.

Therefore, the total duration of applause is 1 + 0 + 3 + 0 = 4 seconds.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
pair<int, int> inc[1000], qwerqwer[1000];
int n, st[1000], asdfasdf[1000], delt, iut, dut;
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) {
    scanf("%d %d", st + i, &delt);
    asdfasdf[i] = st[i] + delt;
    st[i] = 1000 * st[i] - i;
    asdfasdf[i] = 1000 * asdfasdf[i] - i;
    if (delt >= 0)
      inc[iut++] = {st[i], asdfasdf[i]};
    else
      qwerqwer[dut++] = {st[i], asdfasdf[i]};
  }
  sort(inc, inc + iut);
  sort(qwerqwer, qwerqwer + dut);
  reverse(qwerqwer, qwerqwer + dut);
  int ans = 0;
  for (int i = (0); i < (iut); i++)
    for (int j = (0); j < (dut); j++)
      if (inc[i].first < qwerqwer[j].first &&
          inc[i].second > qwerqwer[j].second) {
        ans++;
      }
  for (int i = (0); i < (iut); i++)
    for (int j = (i + 1); j < (iut); j++) {
      if (inc[i].second > inc[j].first) {
        ans++;
        if (inc[j].second > inc[i].second) ans++;
      }
    }
  for (int i = (0); i < (dut); i++)
    for (int j = (i + 1); j < (dut); j++) {
      if (qwerqwer[i].second < qwerqwer[j].first) {
        ans++;
        if (qwerqwer[j].second < qwerqwer[i].second) ans++;
      }
    }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)

We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.

Constraints

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

Input

Input is given from Standard Input in the following format:

A B

Output

Print the total horizontal length of the uncovered parts of the window.

Examples

Input

12 4

Output

4

Input

20 15

Output

0

Input

20 30

Output

0

### Response

```cpp
#include <iostream>

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<(((a-2*b)>0)?(a-2*b):0);
  return 0;
}
```


### Prompt

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

For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $S$, find the smallest sub-array size (smallest window length) where the sum of the sub-array is greater than or equal to $S$. If there is not such sub-array, report 0.

Constraints

* $1 \leq N \leq 10^5$
* $1 \leq S \leq 10^9$
* $1 \leq a_i \leq 10^4$

Input

The input is given in the following format.

$N$ $S$
$a_1$ $a_2$ ... $a_N$

Output

Print the smallest sub-array size in a line.

Examples

Input

6 4
1 2 1 2 3 2

Output

2

Input

6 6
1 2 1 2 3 2

Output

3

Input

3 7
1 2 3

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;

int main(){
  int n,s; cin >> n >> s;
  int a[n];rep(i,n) cin >> a[i];
  bool frag = false;
  //smallest window length
  int ans = n;
  int r = 0;
  int sum = 0;
  rep(l,n){
    while(sum < s){
      if(r == n) break;
      else {
        sum += a[r];
        r++;
      }
    }
    if(sum < s) break; // r == n でもsに達しない場合
    // cout << l << " " << r << "\n";
    frag = true;
    ans = min(ans, r-l);
    sum -= a[l];
    if(r == l) r++;
  }
  if(frag) cout << ans << "\n";
  else cout << 0 << "\n";
}

```


### Prompt

Please create a solution in cpp to the following problem:

You have an array a consisting of n integers. Each integer from 1 to n appears exactly once in this array.

For some indices i (1 ≤ i ≤ n - 1) it is possible to swap i-th element with (i + 1)-th, for other indices it is not possible. You may perform any number of swapping operations any order. There is no limit on the number of times you swap i-th element with (i + 1)-th (if the position is not forbidden).

Can you make this array sorted in ascending order performing some sequence of swapping operations?

Input

The first line contains one integer n (2 ≤ n ≤ 200000) — the number of elements in the array.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 200000) — the elements of the array. Each integer from 1 to n appears exactly once.

The third line contains a string of n - 1 characters, each character is either 0 or 1. If i-th character is 1, then you can swap i-th element with (i + 1)-th any number of times, otherwise it is forbidden to swap i-th element with (i + 1)-th.

Output

If it is possible to sort the array in ascending order using any sequence of swaps you are allowed to make, print YES. Otherwise, print NO.

Examples

Input

6
1 2 5 3 4 6
01110

Output

YES

Input

6
1 2 5 3 4 6
01010

Output

NO

Note

In the first example you may swap a3 and a4, and then swap a4 and a5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int arr[300000];
int coun[300000];
string s;
int main() {
  int n, j;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  cin >> s;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == '1')
      coun[i] = 1;
    else
      coun[i] = 0;
  }
  for (int i = 0; i < n - 1; i++) {
    if (coun[i] == 1) {
      for (j = i; j < n - 1; j++) {
        if (coun[j] != 1) break;
      }
      sort(arr + i, arr + j + 1);
      i = j;
    }
  }
  bool f = true;
  for (int i = 0; i < n; i++)
    if (arr[i] != (i + 1)) f = false;
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

One day Maria Ivanovna found a Sasha's piece of paper with a message dedicated to Olya. Maria Ivanovna wants to know what is there in a message, but unfortunately the message is ciphered. Maria Ivanovna knows that her students usually cipher their messages by replacing each letter of an original message by some another letter. Replacement works in such way that same letters are always replaced with some fixed letter, and different letters are always replaced by different letters.

Maria Ivanovna supposed that the message contains answers to the final exam (since its length is equal to the number of final exam questions). On the other hand she knows that Sasha's answer are not necessary correct. There are K possible answers for each questions. Of course, Maria Ivanovna knows correct answers.

Maria Ivanovna decided to decipher message in such way that the number of Sasha's correct answers is maximum possible. She is very busy now, so your task is to help her.

Input

First line contains length of both strings N (1 ≤ N ≤ 2 000 000) and an integer K — number of possible answers for each of the questions (1 ≤ K ≤ 52). Answers to the questions are denoted as Latin letters abcde...xyzABCDE...XYZ in the order. For example for K = 6, possible answers are abcdef and for K = 30 possible answers are abcde...xyzABCD.

Second line contains a ciphered message string consisting of Latin letters.

Third line contains a correct answers string consisting of Latin letters.

Output

In the first line output maximum possible number of correct Sasha's answers.

In the second line output cipher rule as the string of length K where for each letter from the students' cipher (starting from 'a' as mentioned above) there is specified which answer does it correspond to.

If there are several ways to produce maximum answer, output any of them.

Examples

Input

10 2
aaabbbaaab
bbbbabbbbb

Output

7
ba

Input

10 2
aaaaaaabbb
bbbbaaabbb

Output

6
ab

Input

9 4
dacbdacbd
acbdacbda

Output

9
cdba

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int EPS = 1e-9;
const int INF = 1e14;
int cost[502][502], lx[502], ly[502], slack[502];
int n, max_match, xy[502], yx[502], slackx[502], prev2[502];
bool S[502], T[502];
void add_to_tree(int x, int prevx) {
  S[x] = true, prev2[x] = prevx;
  for (int y = 0; y < int(n); y++)
    if (lx[x] + ly[y] - cost[x][y] < slack[y] - EPS)
      slack[y] = lx[x] + ly[y] - cost[x][y], slackx[y] = x;
}
void update_labels() {
  int delta = INF;
  for (int y = 0; y < int(n); y++)
    if (!T[y]) delta = min(delta, slack[y]);
  for (int x = 0; x < int(n); x++)
    if (S[x]) lx[x] -= delta;
  for (int y = 0; y < int(n); y++)
    if (T[y])
      ly[y] += delta;
    else
      slack[y] -= delta;
}
void init_labels() {
  memset(lx, 0, sizeof(lx)), memset(ly, 0, sizeof(ly));
  for (int x = 0; x < int(n); x++)
    for (int y = 0; y < int(n); y++) lx[x] = max(lx[x], cost[x][y]);
}
void augment() {
  if (max_match == n) return;
  int x, y, root, q[502], wr = 0, rd = 0;
  memset(S, false, sizeof(S)), memset(T, false, sizeof(T));
  memset(prev2, -1, sizeof(prev2));
  for (int x = 0; x < int(n); x++)
    if (xy[x] == -1) {
      q[wr++] = root = x, prev2[x] = -2;
      S[x] = true;
      break;
    }
  for (int y = 0; y < int(n); y++)
    slack[y] = lx[root] + ly[y] - cost[root][y], slackx[y] = root;
  while (true) {
    while (rd < wr) {
      x = q[rd++];
      for (y = 0; y < n; y++)
        if (cost[x][y] == lx[x] + ly[y] && !T[y]) {
          if (yx[y] == -1) break;
          T[y] = true;
          q[wr++] = yx[y], add_to_tree(yx[y], x);
        }
      if (y < n) break;
    }
    if (y < n) break;
    update_labels(), wr = rd = 0;
    for (y = 0; y < n; y++)
      if (!T[y] && slack[y] == 0) {
        if (yx[y] == -1) {
          x = slackx[y];
          break;
        } else {
          T[y] = true;
          if (!S[yx[y]]) q[wr++] = yx[y], add_to_tree(yx[y], slackx[y]);
        }
      }
    if (y < n) break;
  }
  if (y < n) {
    max_match++;
    for (int cx = x, cy = y, ty; cx != -2; cx = prev2[cx], cy = ty)
      ty = xy[cx], yx[cy] = cx, xy[cx] = cy;
    augment();
  }
}
int hungarian() {
  int ret = 0;
  max_match = 0, memset(xy, -1, sizeof(xy));
  memset(yx, -1, sizeof(yx)), init_labels(), augment();
  for (int x = 0; x < int(n); x++) ret += cost[x][xy[x]];
  return ret;
}
char dic[100];
int inv[1000];
void init() {
  int cnt = 0;
  for (char c = 'a'; c <= 'z'; c++) {
    inv[c] = cnt;
    dic[cnt++] = c;
  }
  for (char c = 'A'; c <= 'Z'; c++) {
    inv[c] = cnt;
    dic[cnt++] = c;
  }
}
char A[2002000], B[2002000];
int main() {
  init();
  int len;
  scanf("%d %d", &len, &n);
  scanf("%s", A);
  scanf("%s", B);
  for (int i = 0; i < int(len); i++) cost[inv[A[i]]][inv[B[i]]]++;
  printf("%d\n", hungarian());
  for (int i = 0; i < int(n); i++) printf("%c", dic[xy[i]]);
  printf("\n");
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

After returning to shore, uncle Bogdan usually visits the computer club "The Rock", to solve tasks in a pleasant company. One day, uncle Bogdan met his good old friend who told him one unusual task...

There are n non-intersecting horizontal segments with ends in integers points on the plane with the standard cartesian coordinate system. All segments are strictly above the OX axis. You can choose an arbitrary vector (a, b), where b < 0 and coordinates are real numbers, and project all segments to OX axis along this vector. The projections shouldn't intersect but may touch each other.

Find the minimum possible difference between x coordinate of the right end of the rightmost projection and x coordinate of the left end of the leftmost projection.

Input

The first line contains the single integer n (1 ≤ n ≤ 2000) — the number of segments.

The i-th of the next n lines contains three integers xl_i, xr_i and y_i (-10^6 ≤ xl_i < xr_i ≤ 10^6; 1 ≤ y_i ≤ 10^6) — coordinates of the corresponding segment.

It's guaranteed that the segments don't intersect or touch.

Output

Print the minimum possible difference you can get.

Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.

Formally, if your answer is a and jury's answer is b then your answer will be considered correct if \frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.

Examples

Input

3
1 6 2
4 6 4
4 6 6

Output

9.000000000

Input

3
2 5 1
4 6 4
7 8 2

Output

6.333333333

Input

2
1 3 1
4 7 1

Output

6.000000000

Note

In the first example if we project segments along the vector (1, -1) then we get an answer 12-3=9 and (it can be proven) it is impossible to get less.

<image>

It is optimal to project along the vector (1, -3) in the second example. The answer is 82/3-21/3=61/3

<image>

### Response

```cpp
#include <bits/stdc++.h>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
long long A1, B1, A2, B2;
int mtksz, stksz;
inline bool intersect(pair<long long, long long> p1,
                      pair<long long, long long> p2,
                      pair<long long, long long> p3) {
  A1 = p1.second - p2.second;
  B1 = p2.first - p1.first;
  if (B1 < 0) {
    A1 *= -1;
    B1 *= -1;
  }
  A2 = p1.second - p3.second;
  B2 = p3.first - p1.first;
  if (B2 < 0) {
    A2 *= -1;
    B2 *= -1;
  }
  return A1 * B2 > A2 * B1;
}
vector<pair<long double, long double> > stk(4005), mtk(4005);
int L, R, mid;
long double mini, cur, next, maxi;
int cnt = 0;
inline long double convex_min(long double z) {
  L = 0;
  R = stksz;
  mini = LLONG_MAX;
  while (L < R) {
    mid = (L + R) / 2;
    mini = min(mini, z * stk[mid].first + stk[mid].second);
    if (z * stk[mid].first + stk[mid].second <
        z * stk[mid + 1].first + stk[mid + 1].second) {
      mini = min(mini, z * stk[mid].first + stk[mid].second);
      R = mid;
    } else {
      mini = min(mini, z * stk[mid + 1].first + stk[mid + 1].second);
      L = mid + 1;
    }
  }
  return mini;
}
inline long double convex_max(long double z) {
  L = 0;
  R = mtksz;
  maxi = LLONG_MIN;
  while (L < R) {
    mid = (L + R) / 2;
    maxi = max(mini, z * mtk[mid].first + mtk[mid].second);
    if (z * mtk[mid].first + mtk[mid].second >
        z * mtk[mid + 1].first + mtk[mid + 1].second) {
      maxi = max(mini, z * mtk[mid].first + mtk[mid].second);
      R = mid;
    } else {
      maxi = max(mini, z * mtk[mid + 1].first + mtk[mid + 1].second);
      L = mid + 1;
    }
  }
  return maxi;
}
inline vector<pair<long double, long double> > merge_Intervals(
    vector<pair<long double, long double> > &forbid) {
  sort(forbid.begin(), forbid.end());
  vector<pair<long double, long double> > ss;
  if (forbid.size() == 0) return ss;
  ss.push_back(forbid[0]);
  for (int i = 0; i < forbid.size(); i++) {
    if (ss.back().second <= forbid[i].first)
      ss.push_back(forbid[i]);
    else if (ss.back().second < forbid[i].second) {
      ss.back().second = forbid[i].second;
    }
  }
  return ss;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<pair<pair<long double, long double>, long double> > v;
    long double x, y, z;
    for (long long i = 0; i < n; i++) {
      cin >> x >> y >> z;
      v.push_back({{x, y}, z});
    }
    sort(v.begin(), v.end());
    long double ans = LLONG_MAX;
    vector<long double> xx;
    vector<pair<long double, long double> > forbid;
    long double z1, z2, den1, den2, pos = LLONG_MAX, neg = LLONG_MIN;
    vector<pair<long long, long long> > lines;
    for (long long gg = 0; gg < n; gg++) {
      lines.push_back({v[gg].second, v[gg].first.first});
      lines.push_back({v[gg].second, v[gg].first.second});
      for (long long i = gg + 1; i < n; i++) {
        if (v[i].second == v[gg].second) {
          continue;
        }
        z1 = (v[i].second - v[gg].second) /
             (v[i].first.first - v[gg].first.second);
        z2 = (v[gg].second - v[i].second) /
             (v[gg].first.first - v[i].first.second);
        den1 = (v[i].first.first - v[gg].first.second);
        den2 = (v[gg].first.first - v[i].first.second);
        if (z1 > 0 and z2 > 0 and den1 != 0 and den2 != 0)
          forbid.push_back({min(z1, z2), max(z1, z2)});
        else if (z1 < 0 and z2 < 0 and den2 != 0 and den1 != 0)
          forbid.push_back({min(z1, z2), max(z1, z2)});
        else if (den1 == 0.0 and den2 != 0) {
          if (z2 > 0)
            forbid.push_back({z2, pos});
          else
            forbid.push_back({neg, z2});
        } else if (den2 == 0.0 and den1 != 0) {
          if (z1 > 0)
            forbid.push_back({z1, pos});
          else
            forbid.push_back({neg, z1});
        } else {
          forbid.push_back({neg, min(z1, z2)});
          forbid.push_back({max(z1, z2), pos});
        }
      }
    }
    sort(lines.begin(), lines.end());
    reverse(lines.begin(), lines.end());
    stk[stksz] = lines[0];
    for (long long i = 1; i < lines.size(); i++) {
      while (stksz != -1 and stk[stksz].first == lines[i].first and
             stk[stksz].second > lines[i].second)
        stksz--;
      while (stksz >= 1 and intersect(stk[stksz - 1], stk[stksz], lines[i]))
        stksz--;
      if (stksz == -1) {
        stksz++;
        stk[stksz] = lines[i];
        continue;
      }
      if (stk[stksz].first != lines[i].first) {
        stksz++;
        stk[stksz] = lines[i];
      }
    }
    mtk[mtksz] = lines[0];
    for (long long i = 1; i < lines.size(); i++) {
      while (mtksz != -1 and mtk[mtksz].first == lines[i].first and
             mtk[mtksz].second < lines[i].second)
        mtksz--;
      while (mtksz >= 1 and !intersect(mtk[mtksz - 1], mtk[mtksz], lines[i]))
        mtksz--;
      if (mtksz == -1) {
        mtksz++;
        mtk[mtksz] = lines[i];
        continue;
      }
      if (mtk[mtksz].first != lines[i].first) {
        mtksz++;
        mtk[mtksz] = lines[i];
      }
    }
    vector<pair<long double, long double> > interval = merge_Intervals(forbid);
    for (int i = 0; i < interval.size(); i++) {
      xx.push_back(interval[i].first);
      xx.push_back(interval[i].second);
    }
    vector<long double>::iterator low, up;
    long long sz1, sz2;
    for (long long i = 0; i < xx.size(); i++) {
      if (xx[i] == pos or xx[i] == neg) continue;
      x = convex_min(-1 / xx[i]);
      y = convex_max(-1 / xx[i]);
      ans = min(ans, y - x);
    }
    long long rr = 1;
    for (long long i = 1; i < n; i++)
      if (v[i - 1].first.second > v[i].first.first) rr = 0;
    if (rr) {
      ans = min(ans, v[n - 1].first.second - v[0].first.first);
    }
    cout << setprecision(15) << ans;
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?

Constraints

* 1 \leq a \leq 9
* 1 \leq b \leq 9
* a and b are integers.

Input

Input is given from Standard Input in the following format:

a b

Output

Print the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)

Examples

Input

4 3

Output

3333

Input

7 7

Output

7777777

### Response

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

int main(){
  int n,m;cin>>n>>m;
  for(int i=0; i<max(n,m); i++)cout<<min(n,m);
}

```


### Prompt

Create a solution in Cpp for the following problem:

AtCoDeer the deer found N rectangle lying on the table, each with height 1. If we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≤i≤N) covers the vertical range of [i-1,i] and the horizontal range of [l_i,r_i], as shown in the following figure:

<image>

AtCoDeer will move these rectangles horizontally so that all the rectangles are connected. For each rectangle, the cost to move it horizontally by a distance of x, is x. Find the minimum cost to achieve connectivity. It can be proved that this value is always an integer under the constraints of the problem.

Constraints

* All input values are integers.
* 1≤N≤10^5
* 1≤l_i<r_i≤10^9

Input

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

N
l_1 r_1
l_2 r_2
:
l_N r_N

Output

Print the minimum cost to achieve connectivity.

Examples

Input

3
1 3
5 7
1 3

Output

2

Input

3
2 5
4 6
1 4

Output

0

Input

5
999999999 1000000000
1 2
314 315
500000 500001
999999999 1000000000

Output

1999999680

Input

5
123456 789012
123 456
12 345678901
123456 789012
1 23

Output

246433

Input

1
1 400

Output

0

### Response

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

struct SL {
	priority_queue<ll> L;
	priority_queue<ll, vector<ll>, greater<ll>> R;
	ll ans, rBase, lBase;
	SL() : ans(0ll), rBase(0ll), lBase(0ll) {}
	void addR(int v) {
		rBase += v;
	}
	void addL(int v) {
		lBase += v;
	}
	void addSL(int x) {
		L.push(x-lBase); R.push(x-rBase);
		while(R.top()+rBase < L.top()+lBase) {
			ll l = L.top()+lBase, r = R.top()+rBase;
			ans += l-r;
			L.pop(); R.pop();
			L.push(r-lBase); R.push(l-rBase);
		}
	}
};
int N, Nr[MAX_N][2];
int main() {
	cin >> N;
	REP(i, N) REP(j, 2) scanf("%d", &Nr[i][j]);
	SL sl;
	REP(i, N) {
		sl.addR(Nr[i][1] - Nr[i][0]);
		sl.addSL(Nr[i][1]);
		sl.addL(-(Nr[i][1] - Nr[i][0]));
	}
	printf("%lld\n", sl.ans);
	return 0;
}
```


### Prompt

Create a solution in Cpp for the following problem:

Karlsson has visited Lillebror again. They found a box of chocolates and a big whipped cream cake at Lillebror's place. Karlsson immediately suggested to divide the sweets fairly between Lillebror and himself. Specifically, to play together a game he has just invented with the chocolates. The winner will get the cake as a reward.

The box of chocolates has the form of a hexagon. It contains 19 cells for the chocolates, some of which contain a chocolate. The players move in turns. During one move it is allowed to eat one or several chocolates that lay in the neighboring cells on one line, parallel to one of the box's sides. The picture below shows the examples of allowed moves and of an unacceptable one. The player who cannot make a move loses.

<image>

Karlsson makes the first move as he is Lillebror's guest and not vice versa. The players play optimally. Determine who will get the cake.

Input

The input data contains 5 lines, containing 19 words consisting of one symbol. The word "O" means that the cell contains a chocolate and a "." stands for an empty cell. It is guaranteed that the box contains at least one chocolate. See the examples for better understanding.

Output

If Karlsson gets the cake, print "Karlsson" (without the quotes), otherwise print "Lillebror" (yet again without the quotes).

Examples

Input

  . . .
 . . O .
. . O O .
 . . . .
  . . .

Output

Lillebror

Input

  . . .
 . . . O
. . . O .
 O . O .
  . O .

Output

Karlsson

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxN = 19;
int sas[maxN][maxN], p[32];
vector<int> masks;
int mem[1 << maxN];
int main() {
  for (int i = 0; i < (32); ++i) p[i] = 1 << i;
  pair<int, int> pos[] = {
      make_pair(0, 2), make_pair(0, 4), make_pair(0, 6), make_pair(1, 1),
      make_pair(1, 3), make_pair(1, 5), make_pair(1, 7), make_pair(2, 0),
      make_pair(2, 2), make_pair(2, 4), make_pair(2, 6), make_pair(2, 8),
      make_pair(3, 1), make_pair(3, 3), make_pair(3, 5), make_pair(3, 7),
      make_pair(4, 2), make_pair(4, 4), make_pair(4, 6)};
  sas[0][1] = sas[1][2] = 1;
  sas[3][0] = sas[3][4] = sas[4][0] = sas[4][1] = sas[4][5] = sas[5][1] =
      sas[5][2] = sas[5][6] = sas[6][2] = 1;
  sas[7][3] = sas[7][8] = sas[8][3] = sas[8][4] = sas[8][9] = sas[9][4] =
      sas[9][5] = sas[9][10] = sas[10][5] = sas[10][6] = sas[10][11] =
          sas[11][6] = 1;
  sas[12][7] = sas[12][8] = sas[12][13] = sas[13][8] = sas[13][9] =
      sas[13][14] = sas[14][9] = sas[14][10] = sas[14][15] = sas[15][10] =
          sas[15][11] = 1;
  sas[16][12] = sas[16][13] = sas[16][17] = sas[17][13] = sas[17][14] =
      sas[17][18] = sas[18][14] = sas[18][15] = 1;
  for (int i = 0; i < (maxN); ++i)
    for (int j = 0; j < (maxN); ++j)
      if (sas[i][j]) sas[j][i] = 1;
  for (int mask = (1); mask <= (p[maxN] - 1); ++mask) {
    pair<int, int> diff = make_pair(INT_MAX, INT_MAX);
    int last = -1;
    for (int i = 0; i < (maxN); ++i)
      if (mask & p[i]) {
        if (last != -1) {
          if (!sas[i][last]) goto C;
          if (diff.first == INT_MAX)
            diff = make_pair(pos[i].first - pos[last].first,
                             pos[i].second - pos[last].second);
          else if (pos[i].first - pos[last].first != diff.first ||
                   pos[i].second - pos[last].second != diff.second)
            goto C;
        }
        last = i;
      }
    masks.push_back(mask);
  C:;
  }
  string aux, res[] = {"Lillebror", "Karlsson"};
  int m = 0;
  for (int i = 0; i < (maxN); ++i) {
    cin >> aux;
    if (aux[0] == 'O') m |= p[i];
  }
  mem[0] = 0;
  for (int mask = (1); mask <= (m); ++mask) {
    for (__typeof((masks).begin()) i = ((masks).begin()); i != (masks).end();
         ++i)
      if ((mask & *i) == *i && !mem[mask ^ *i]) {
        mem[mask] = 1;
        break;
      }
  }
  cout << res[mem[m]] << endl;
  return 0;
}

```


### Prompt

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

problem

If you write a positive integer in decimal notation (without leading 0) and look at the digit numbers in order, when the number increases and decreases alternately, the number is "zigza". Let's call it. For example, 2947 is a zigzag number because the digit numbers are in the order of 2 → 9 → 4 → 7 and increase → decrease → increase. In addition, 71946 is a zigzag number because it is in the order of decrease → increase → decrease → increase. On the other hand, 123, 71446, 71442 and 88 are not zigzag numbers. A one-digit positive integer is considered to be a zigzag number.

Create a program that finds the remainder of the number of zigzags divided by 10000 out of multiples of M between A and B.

input

The input consists of three lines, with one positive integer written on each line.

The integer on the first line represents A, the integer on the second line represents B, and the integer on the third line represents M. These satisfy 1 ≤ A ≤ B ≤ 10500 and 1 ≤ M ≤ 500.

* Note that the values of A and B may not fit in the data types that represent ordinary integers.

output

Output the remainder of the number of zigzag numbers divided by 10000 out of multiples of M between A and B in one line.

Input / output example

Input example 1

100
200
Five

Output example 1

13

In I / O example 1, the number of zigzags that are multiples of 5 from 100 to 200 is 13 of 105, 120, 130, 140, 150, 160, 165, 170, 175, 180, 185, 190, 195. ..

Input example 2

6
1234567
3

Output example 2

246

In I / O example 2, there are 50246 zigzag numbers that are multiples of 3 from 6 to 1234567, so 246, which is the remainder of dividing it by 10000, is output.

The question text and the data used for the automatic referee are the question text and the test data for scoring, which are created and published by the Japan Committee for Information Olympics.

Example

Input

100
200
5

Output

13

### Response

```cpp
#include<string>
#include<cstdio>
#include<cstring>
#define rep(i,a) for(int i=0;i<(a);++i)
#define repd(i,a) for(int i=(a);i>=0;--i)
#define clr(a,v) memset((a),(v),sizeof(a))

char A[502], B[502];
int M;

int dp[501][2][10][3][501];

int rec( const std::string &br, int i, bool smaller, int prv, short up, int mod )
{
	if( i == br.size() )
		return !mod;

	int &ret = dp[i][smaller][prv][up][mod];
	if( ~ret )
		return ret;

	ret = 0;
	rep( d, smaller?10:br[i]-'0'+1 ) if( !d||d!=prv )
		if( up==2 || up==1&&d<prv || !up&&d>prv )
			ret = (ret + rec( br, i+1, smaller|d!=br[i]-'0', d, up==2&&!prv?2:d>prv, (mod*10+d)%M )) % 10000;

	return ret;
}

int main()
{
	scanf( "%s%s%d", A, B, &M );

	int c = 1, e = strlen(A)-1;
	repd( i, e )
	{
		A[i]-=c;
		c=0;

		if( A[i]-'0' < 0 )
			A[i]+=10, c=1;
	}

	clr( dp, -1 ); int upr = rec( B, 0, false, 0, 2, 0 );
	clr( dp, -1 ); int lwr = rec( A, 0, false, 0, 2, 0 );
	printf( "%d\n", (upr-lwr+10000)%10000 );

	return 0;
}
```


### Prompt

Generate a CPP solution to the following problem:

You are visiting a large electronics store to buy a refrigerator and a microwave.

The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen.

You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.

You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.

Constraints

* All values in input are integers.
* 1 \le A \le 10^5
* 1 \le B \le 10^5
* 1 \le M \le 10^5
* 1 \le a_i , b_i , c_i \le 10^5
* 1 \le x_i \le A
* 1 \le y_i \le B
* c_i \le a_{x_i} + b_{y_i}

Input

Input is given from Standard Input in the following format:

A B M
a_1 a_2 ... a_A
b_1 b_2 ... b_B
x_1 y_1 c_1
\vdots
x_M y_M c_M

Output

Print the answer.

Examples

Input

2 3 1
3 3
3 3 3
1 2 1

Output

5

Input

1 1 2
10
10
1 1 5
1 1 10

Output

10

Input

2 2 1
3 5
3 5
2 2 2

Output

6

### Response

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

int main (){
  int A,B,M;
  cin >> A>>B>>M;
  vector<int> a(A),b(B),sum(M);

  for (int i=0;i<A;i++){
    cin >> a[i];
  }
  for (int i=0;i<B;i++){
    cin >> b[i];
  }

  for (int i=0;i<M;i++){
    int x,y,c;
    cin >> x >> y >> c;
    sum[i] = a[x-1]+b[y-1]-c;
  }

  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(sum.begin(),sum.end());

  cout << min(a[0]+b[0],sum[0]) << endl;
}
```


### Prompt

Create a solution in Cpp for the following problem:

I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.

Input

The input is given in the following format:

n
v1
v2
::
vn

The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.

Output

Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.

Example

Input

6
12300
5600
33800
0
26495
52000

Output

21699

### Response

```cpp
#include<stdio.h>
int main(void)
{
	int n;
	int kin[100000];
	long long int sum,avg;
	int i;
	sum=0;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&kin[i]);
		sum=sum+kin[i];
	}
	avg=sum/n;
	printf("%d\n",avg);
	return 0;
}
```


### Prompt

Generate a cpp solution to the following problem:

Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.

Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!

Input

The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.

Output

If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1.

Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.

Examples

Input

527

Output

572

Input

4573

Output

3574

Input

1357997531

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, m, k, a[100100], cnt, i, j;
bool ch;
string s, s1, s2, arrS[100100];
template <typename T>
string NumberToString(T Number) {
  ostringstream ss;
  ss << Number;
  return ss.str();
}
int main() {
  cin >> s;
  long long maxx = -1;
  for (i = 0; i < s.size(); i++) {
    if ((s[i] - '0') % 2 == 0 && (s[i] - '0') < (s[s.size() - 1] - '0')) {
      swap(s[i], s[s.size() - 1]);
      cout << s;
      return 0;
    }
  }
  for (i = s.size() - 2; i >= 0; i--) {
    if ((s[i] - '0') % 2 == 0) {
      swap(s[i], s[s.size() - 1]);
      cout << s;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity.

Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2i - 1 liters and costs ci roubles. The number of bottles of each type in the store can be considered infinite.

You want to buy at least L liters of lemonade. How many roubles do you have to spend?

Input

The first line contains two integers n and L (1 ≤ n ≤ 30; 1 ≤ L ≤ 109) — the number of types of bottles in the store and the required amount of lemonade in liters, respectively.

The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 109) — the costs of bottles of different types.

Output

Output a single integer — the smallest number of roubles you have to pay in order to buy at least L liters of lemonade.

Examples

Input

4 12
20 30 70 90

Output

150

Input

4 3
10000 1000 100 10

Output

10

Input

4 3
10 100 1000 10000

Output

30

Input

5 787787787
123456789 234567890 345678901 456789012 987654321

Output

44981600785557577

Note

In the first example you should buy one 8-liter bottle for 90 roubles and two 2-liter bottles for 30 roubles each. In total you'll get 12 liters of lemonade for just 150 roubles.

In the second example, even though you need only 3 liters, it's cheaper to buy a single 8-liter bottle for 10 roubles.

In the third example it's best to buy three 1-liter bottles for 10 roubles each, getting three liters for 30 roubles.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) {
    return b;
  }
  gcd(b % a, a);
}
int main() {
  long long int t, m, o, e, a, k, b, l, r, c;
  long long int n;
  cin >> n >> l;
  std::vector<long long int> v2;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    v2.push_back(x);
  }
  for (long long int i = 0; i < n - 1; i++) {
    v2[i + 1] = min(v2[i + 1], 2 * v2[i]);
  }
  long long int ans = 9223372036854775801;
  long long int sum = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    long long int need = l / (1 << i);
    sum += need * v2[i];
    l -= need << i;
    ans = min(ans, sum + (l > 0) * v2[i]);
  }
  cout << ans;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

A string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:

* S is a palindrome.
* Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.
* The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.

Determine whether S is a strong palindrome.

Constraints

* S consists of lowercase English letters.
* The length of S is an odd number between 3 and 99 (inclusive).

Input

Input is given from Standard Input in the following format:

S

Output

If S is a strong palindrome, print `Yes`; otherwise, print `No`.

Examples

Input

akasaka

Output

Yes

Input

level

Output

No

Input

atcoder

Output

No

### Response

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  auto f = [&](string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
  };
  cout << ((f(S) && f(S.substr((N + 3) / 2 - 1))) ? "Yes" : "No") << "\n";
}
```


### Prompt

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

There are n cities in Berland. Some pairs of them are connected with m directed roads. One can use only these roads to move from one city to another. There are no roads that connect a city to itself. For each pair of cities (x, y) there is at most one road from x to y.

A path from city s to city t is a sequence of cities p1, p2, ... , pk, where p1 = s, pk = t, and there is a road from city pi to city pi + 1 for each i from 1 to k - 1. The path can pass multiple times through each city except t. It can't pass through t more than once.

A path p from s to t is ideal if it is the lexicographically minimal such path. In other words, p is ideal path from s to t if for any other path q from s to t pi < qi, where i is the minimum integer such that pi ≠ qi.

There is a tourist agency in the country that offers q unusual excursions: the j-th excursion starts at city sj and ends in city tj.

For each pair sj, tj help the agency to study the ideal path from sj to tj. Note that it is possible that there is no ideal path from sj to tj. This is possible due to two reasons:

  * there is no path from sj to tj;
  * there are paths from sj to tj, but for every such path p there is another path q from sj to tj, such that pi > qi, where i is the minimum integer for which pi ≠ qi.

The agency would like to know for the ideal path from sj to tj the kj-th city in that path (on the way from sj to tj).

For each triple sj, tj, kj (1 ≤ j ≤ q) find if there is an ideal path from sj to tj and print the kj-th city in that path, if there is any.

Input

The first line contains three integers n, m and q (2 ≤ n ≤ 3000,0 ≤ m ≤ 3000, 1 ≤ q ≤ 4·105) — the number of cities, the number of roads and the number of excursions.

Each of the next m lines contains two integers xi and yi (1 ≤ xi, yi ≤ n, xi ≠ yi), denoting that the i-th road goes from city xi to city yi. All roads are one-directional. There can't be more than one road in each direction between two cities.

Each of the next q lines contains three integers sj, tj and kj (1 ≤ sj, tj ≤ n, sj ≠ tj, 1 ≤ kj ≤ 3000).

Output

In the j-th line print the city that is the kj-th in the ideal path from sj to tj. If there is no ideal path from sj to tj, or the integer kj is greater than the length of this path, print the string '-1' (without quotes) in the j-th line.

Example

Input

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

Output

2
-1
-1
2
-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<vector<short>> g;
const int L = 12;
short lc[3005][3005][L];
void dfs(int v, vector<bool>& was) {
  if (was[v]) return;
  was[v] = 1;
  for (int nv : g[v]) {
    dfs(nv, was);
  }
}
short depth[3001][3001];
short pr[3001][3001];
vector<bool> vis;
void dfs3(int v) {
  if (vis[v]) return;
  vis[v] = 1;
  for (int nv : g[v]) dfs3(nv);
}
void dfs2(int v0, int v, int p, vector<bool>& was,
          const vector<vector<bool>>& r) {
  if (was[v]) return;
  was[v] = 1;
  pr[v0][v] = p;
  if (v != p) depth[v0][v] = depth[v0][p] + 1;
  for (int i = 0; i < g[v].size(); ++i) {
    int nv = g[v][i];
    if (!vis[nv]) dfs2(v0, nv, v, was, r);
    dfs3(nv);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
  }
  for (int i = 0; i < n; ++i) sort(g[i].begin(), g[i].end());
  vector<vector<bool>> r(n, vector<bool>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) pr[i][j] = -1;
    dfs(i, r[i]);
  }
  vector<bool> was(n);
  for (int i = 0; i < n; ++i) {
    was.assign(n, 0);
    vis.assign(n, 0);
    dfs2(i, i, i, was, r);
    for (int j = 0; j < n; ++j) {
      lc[i][j][0] = pr[i][j];
    }
    for (int l = 1; l < L; ++l) {
      for (int j = 0; j < n; ++j)
        if (pr[i][j] != -1) {
          lc[i][j][l] = lc[i][lc[i][j][l - 1]][l - 1];
        }
    }
  }
  for (int test = 0; test < q; ++test) {
    int s, t, k;
    cin >> s >> t >> k;
    --s;
    --t;
    --k;
    if (pr[s][t] == -1 || depth[s][t] < k)
      cout << -1 << endl;
    else {
      int l = depth[s][t] - k;
      int cur = t;
      for (int b = 0; b < L; ++b)
        if (l & (1 << b)) cur = lc[s][cur][b];
      cout << cur + 1 << endl;
    }
  }
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You are given the strings a and b, consisting of lowercase Latin letters. You can do any number of the following operations in any order:

  * if |a| > 0 (the length of the string a is greater than zero), delete the first character of the string a, that is, replace a with a_2 a_3 … a_n;
  * if |a| > 0, delete the last character of the string a, that is, replace a with a_1 a_2 … a_{n-1};
  * if |b| > 0 (the length of the string b is greater than zero), delete the first character of the string b, that is, replace b with b_2 b_3 … b_n;
  * if |b| > 0, delete the last character of the string b, that is, replace b with b_1 b_2 … b_{n-1}.

Note that after each of the operations, the string a or b may become empty.

For example, if a="hello" and b="icpc", then you can apply the following sequence of operations:

  * delete the first character of the string a ⇒ a="ello" and b="icpc";
  * delete the first character of the string b ⇒ a="ello" and b="cpc";
  * delete the first character of the string b ⇒ a="ello" and b="pc";
  * delete the last character of the string a ⇒ a="ell" and b="pc";
  * delete the last character of the string b ⇒ a="ell" and b="p".

For the given strings a and b, find the minimum number of operations for which you can make the strings a and b equal. Note that empty strings are also equal.

Input

The first line contains a single integer t (1 ≤ t ≤ 100). Then t test cases follow.

The first line of each test case contains the string a (1 ≤ |a| ≤ 20), consisting of lowercase Latin letters.

The second line of each test case contains the string b (1 ≤ |b| ≤ 20), consisting of lowercase Latin letters.

Output

For each test case, output the minimum number of operations that can make the strings a and b equal.

Example

Input

5
a
a
abcd
bc
hello
codeforces
hello
helo
dhjakjsnasjhfksafasd
adjsnasjhfksvdafdser

Output

0
2
13
3
20

### Response

```cpp
#include <bits/stdc++.h>
typedef long long ll;
#define fo(i,j,n) for(ll i=j;i<n;++i)
using namespace std;
#define endl "\n"
using Graph = vector<vector<int>>;
const int inf = 1e9 +5;
const ll ll_inf = 1e13 ;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt", "w" , stdout);
#endif
	ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;cin>>t;
    while(t--){
        string s1,s2;
        cin>>s1;
        cin>>s2;
        int dp[s1.size()+1][s2.size()+1];
        memset(dp,0,sizeof(dp));
        fo(i,0,s2.size()) dp[0][i]=0;
        fo(i,0,s1.size()) dp[i][0]=0;
        fo(i,1,s1.size()+1){
            fo(j,1,s2.size()+1){
                if(s1[i-1]==s2[j-1]) dp[i][j] = dp[i-1][j-1] +1;
                else dp[i][j] =0;
            }
        }
        int ans = -1;
        fo(i,0,s1.size()+1){
            fo(j,0,s2.size()+1){
                ans = max(ans,dp[i][j]);
            }
        }
        cout<<(s1.size()+s2.size()-2*ans)<<endl;
    }
    return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

C: Mod! Mod!

story

That's right! I'm looking for eyewitness testimony! A phantom thief has appeared in Aizu! Everyone's horse stick was stolen! Who is the culprit! ?? Unravel! Mod! Mod!

Problem statement

"Eyes" ... it's a miracle bud that swells in the hearts of the chosen ones ... You can steal anything with the special ability "Eyes".

Aizu Maru, the biggest phantom thief in Aizu, decides to steal a "horse stick" from n detectives in order to fill the world with a mystery. Umauma sticks are just sweets that Maru loves, and each of the n detectives has several horse sticks. Also, because Aizumaru is greedy, when he steals a horse stick from each detective, he steals all the horse sticks that the detective has.

Aizumaru, who is addicted to eating three horse sticks at the same time, when he has three or more horse sticks at hand, he keeps three horse sticks until he loses the temptation and has less than three horse sticks. I will eat it. However, Aizumaru loses his eyes in shock if he does not have a horse stick at hand, and he cannot steal any more horse sticks. In other words, in order to steal a horse horse stick, it is necessary to have one or more horse horse sticks on hand, and when it reaches 0, it becomes impossible to steal any more horse horse sticks.

Aizuma, who wants to steal horse sticks from as many detectives as possible, noticed that the number of detectives who can steal horse sticks depends on which detective steals the horse sticks in order. However, I don't know how difficult it is to get together. "Hate?" Aizumaru's excellent subordinate, you decided to write a program to ask how many detectives you can steal a horse stick instead of Aizumaru.

Since the number of detectives n and how many horse sticks to steal from each of n detectives are given, when stealing horse sticks from detectives in the optimum order, it is possible to steal horse sticks from up to how many detectives. Create a program that outputs what you can do. However, although the number of horse sticks on hand at the beginning is 0, it is assumed that the horse sticks can be stolen even if the number of horse sticks on hand is 0 only at the beginning.

Input format

The input consists of two lines and is given in the following format.

n
a_1 a_2… a_n

The first line is given the integer n, which is the number of detectives stealing horse sticks. On the second line, n number of horse sticks to steal from each detective are given, separated by blanks.

Constraint

* 1 ≤ n ≤ 500 {,} 000
* 1 ≤ a_i ≤ 9 (1 ≤ i ≤ n)

Output format

When you steal a horse stick from a detective in the optimal order, print out in one line how many detectives you can steal a horse stick from.

Input example 1

6
2 5 2 5 2 1

Output example 1

Five

If you steal in the order of 2 5 1 2 5, you can steal from 5 people. No matter what order you steal, you cannot steal from six people.

Input example 2

3
3 6 9

Output example 2

1

No matter which one you steal from, the number of horse sticks you have will be 0 and you will lose your eyes.

Input example 3

6
1 2 3 4 5 6

Output example 3

6

Example

Input

6
2 5 2 5 2 1

Output

5

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(3,0);
    rep(i,n){
        cnt[a[i]%3]++;
    }
    if(cnt[1]==0 and cnt[2]==0){
        cout << 1 << "\n";
    }else{
        int ans = cnt[0];
        ans += min(cnt[1],cnt[2]) * 2;
        ans += min(3,max(cnt[1],cnt[2])-min(cnt[1],cnt[2]));
        cout << ans << "\n";
    }
    return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to scroll d pages forwards or backwards (but he cannot scroll outside the book). For example, if the book consists of 10 pages, and d = 3, then from the first page Vasya can scroll to the first or to the fourth page by pressing one of the buttons; from the second page — to the first or to the fifth; from the sixth page — to the third or to the ninth; from the eighth — to the fifth or to the tenth.

Help Vasya to calculate the minimum number of times he needs to press a button to move to page y.

Input

The first line contains one integer t (1 ≤ t ≤ 10^3) — the number of testcases.

Each testcase is denoted by a line containing four integers n, x, y, d (1≤ n, d ≤ 10^9, 1 ≤ x, y ≤ n) — the number of pages, the starting page, the desired page, and the number of pages scrolled by pressing one button, respectively.

Output

Print one line for each test.

If Vasya can move from page x to page y, print the minimum number of times he needs to press a button to do it. Otherwise print -1.

Example

Input

3
10 4 5 2
5 1 3 4
20 4 19 3

Output

4
-1
5

Note

In the first test case the optimal sequence is: 4 → 2 → 1 → 3 → 5.

In the second test case it is possible to get to pages 1 and 5.

In the third test case the optimal sequence is: 4 → 7 → 10 → 13 → 16 → 19.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, d, x, y;
void solve() {
  cin >> n >> x >> y >> d;
  x--, y--;
  if (abs(y - x) % d == 0) {
    cout << abs(y - x) / d << endl;
    return;
  }
  int res = 2e9;
  if (y % d == 0) {
    res = min(res, (x - 1) / d + 1 + y / d);
  }
  if ((n - 1 - y) % d == 0) {
    res = min(res, ((n - 1 - x - 1) / d + 1 + (n - 1 - y) / d));
  }
  if (res == 2e9)
    cout << "-1\n";
  else
    cout << res << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

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

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

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

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

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

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

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

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

See the Interaction section below for more details.

Input

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

Interaction

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

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

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

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

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

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

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

Examples

Input

3
1 1 1
Yes

Output

? 1 2
! 1 2

Input

4
1 2 0 3
No
No
No
No
No
No

Output

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

Note

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

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

### Response

```cpp
//Author:MatrixCascade

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define clr(f, n) memset(f, 0, sizeof(int) * (n))
#define cpy(f, g, n) memcpy(f, g, sizeof(int) * (n))
#define rev(f, n) reverse(f, f + n)
#define pir pair<int, int>
#define mkp make_pair
#define fst it->first
#define sec it->second
#define int long long
#define up(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define down(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
using namespace std;
int n, m;
int read()
{
    int s = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * f;
}
inline void print(int *f, int len)
{
    for (int i = 0; i < len; i++)
        printf("%lld ", f[i]);
    puts("");
}
int T;
int k[5050];
struct node{
	int x,y,t;
}w[606060];
int tot=0;
bool cmp(node a,node b)
{
	return a.t>b.t;
}
signed main()
{
	n=read();
	up(i,1,n)k[i]=read();
	up(i,1,n)
	{
		up(j,i+1,n)
		{
			if(i==j)continue;
			if(k[i]>=k[j])w[++tot]=(node){i,j,k[i]-k[j]};
			else w[++tot]=(node){j,i,k[j]-k[i]};
		}
	}
	sort(w+1,w+tot+1,cmp);
	up(i,1,tot)
	{
		string s;
		cout<<"? "<<w[i].x<<" "<<w[i].y<<endl;
		cin>>s;
		if(s=="Yes")
		{
			cout<<"! "<<w[i].x<<" "<<w[i].y<<endl;
			return 0;
		}
	}
	cout<<"! 0 0"<<endl;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

problem

Taro often shop at JOI general stores. At JOI general stores, there are enough coins of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen, and we always pay the change so that the number of coins is the smallest. Create a program to find the number of coins included in the change you receive when Taro goes shopping at the JOI general store and puts out one 1000 yen bill at the cash register.

For example, in the case of input example 1, 4 must be output as shown in the figure below.

<image>

input

The input consists of multiple datasets. Each dataset consists of one line, and only one amount (an integer of 1 or more and less than 1000) paid by Taro is written. The input data ends with one zero line.

The number of datasets does not exceed 5.

output

Output the number of coins included in the change for each dataset on one line.

Examples

Input

380
1
0

Output

4
15

Input

None

Output

None

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  while(cin>>n,n){
    n=1000-n;
    int a[]={500,100,50,10,5,1};
    int ans=0;
    for(int i=0;i<6;i++){
      while(n>=a[i]) n-=a[i],ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}
```


### Prompt

Create a solution in CPP for the following problem:

A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.

You will be given three integers A, B, and C. If this triple is poor, print `Yes`; otherwise, print `No`.

Constraints

* A, B, and C are all integers between 1 and 9 (inclusive).

Input

Input is given from Standard Input in the following format:

A B C

Output

If the given triple is poor, print `Yes`; otherwise, print `No`.

Examples

Input

5 7 5

Output

Yes

Input

4 4 4

Output

No

Input

4 9 6

Output

No

Input

3 3 4

Output

Yes

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
    cin >> a >> b >> c;
    cout << (a==b && a!=c || a==c && a!=b || c==b && b!=a ? "Yes": "No");
    }
```