### Prompt

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

Fox Ciel is playing a card game with her friend Jiro.

Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is Attack.

Now is Ciel's battle phase, Ciel can do the following operation many times:

  1. Choose one of her cards X. This card mustn't be chosen before.
  2. If Jiro has no alive cards at that moment, he gets the damage equal to (X's strength). Otherwise, Ciel needs to choose one Jiro's alive card Y, then:
    * If Y's position is Attack, then (X's strength)  ≥  (Y's strength) must hold. After this attack, card Y dies, and Jiro gets the damage equal to (X's strength) - (Y's strength).
    * If Y's position is Defense, then (X's strength)  > (Y's strength) must hold. After this attack, card Y dies, but Jiro gets no damage.

Ciel can end her battle phase at any moment (so, she can use not all her cards). Help the Fox to calculate the maximal sum of damage Jiro can get.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of cards Jiro and Ciel have.

Each of the next n lines contains a string position and an integer strength (0 ≤ strength ≤ 8000) — the position and strength of Jiro's current card. Position is the string "ATK" for attack, and the string "DEF" for defense.

Each of the next m lines contains an integer strength (0 ≤ strength ≤ 8000) — the strength of Ciel's current card.

Output

Output an integer: the maximal damage Jiro can get.

Examples

Input

2 3
ATK 2000
DEF 1700
2500
2500
2500

Output

3000

Input

3 4
ATK 10
ATK 100
ATK 1000
1
11
101
1001

Output

992

Input

2 4
DEF 0
ATK 0
0
0
1
1

Output

1

Note

In the first test case, Ciel has 3 cards with same strength. The best strategy is as follows. First she uses one of these 3 cards to attack "ATK 2000" card first, this attack destroys that card and Jiro gets 2500 - 2000 = 500 damage. Then she uses the second card to destroy the "DEF 1700" card. Jiro doesn't get damage that time. Now Jiro has no cards so she can use the third card to attack and Jiro gets 2500 damage. So the answer is 500 + 2500 = 3000.

In the second test case, she should use the "1001" card to attack the "ATK 100" card, then use the "101" card to attack the "ATK 10" card. Now Ciel still has cards but she can choose to end her battle phase. The total damage equals (1001 - 100) + (101 - 10) = 992.

In the third test case note that she can destroy the "ATK 0" card by a card with strength equal to 0, but she can't destroy a "DEF 0" card with that card.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool SR(int &_x) { return scanf("%d", &_x) == 1; }
bool SR(long long &_x) { return scanf("%lld", &_x) == 1; }
bool SR(double &_x) { return scanf("%lf", &_x) == 1; }
bool SR(char *_s) { return scanf("%s", _s) == 1; }
bool RI() { return true; }
template <typename I, typename... T>
bool RI(I &_x, T &..._tail) {
  return SR(_x) && RI(_tail...);
}
void SP(const int _x) { printf("%d", _x); }
void SP(const long long _x) { printf("%lld", _x); }
void SP(const double _x) { printf("%.16lf", _x); }
void SP(const char *s) { printf("%s", s); }
void PL() { puts(""); }
template <typename I, typename... T>
void PL(const I _x, const T... _tail) {
  SP(_x);
  if (sizeof...(_tail)) putchar(' ');
  PL(_tail...);
}
template <typename TF, typename TC, bool maxcost, size_t maxn>
struct Flow {
  struct Edge {
    int u, v;
    TF f;
    TC c;
    Edge(int _u, int _v, TF _f, TC _c) : u(_u), v(_v), f(_f), c(_c) {}
  };
  int n;
  vector<Edge> edge;
  vector<int> id[maxn];
  void init(int _n) {
    n = _n;
    edge.clear();
    for (int i = 0; i < int(n); i++) id[i].clear();
  }
  void add(int u, int v, TF f, TC c) {
    if (maxcost) c *= -1;
    id[u].push_back(((int)(edge).size()));
    edge.push_back(Edge(u, v, f, c));
    id[v].push_back(((int)(edge).size()));
    edge.push_back(Edge(v, u, 0, -c));
  }
  pair<bool, TC> spfa() {
    static TC dis[maxn];
    static int par[maxn];
    bitset<maxn> isq;
    queue<int> q;
    memset(dis, 0x3f, sizeof(TC) * n);
    memset(par, -1, sizeof(int) * n);
    dis[0] = 0;
    isq[0] = 1;
    q.push(0);
    while (((int)(q).size())) {
      int u = q.front();
      q.pop();
      isq[u] = 0;
      for (int i : id[u])
        if (edge[i].f > 0) {
          const auto &e = edge[i];
          if (dis[e.v] > dis[u] + e.c) {
            dis[e.v] = dis[u] + e.c;
            par[e.v] = i;
            if (!isq[e.v]) isq[e.v] = 1, q.push(e.v);
          }
        }
    }
    if (par[n - 1] == -1) return make_pair(false, 0);
    for (int u = n - 1; u; u = edge[par[u]].u)
      edge[par[u]].f--, edge[par[u] ^ 1].f++;
    if (maxcost) dis[n - 1] *= -1;
    return make_pair(true, dis[n - 1]);
  }
  pair<TF, TC> calc() {
    TF cnt = 0;
    TC ans = 0;
    while (1) {
      pair<bool, TC> sub = spfa();
      if (!sub.first) break;
      cnt++;
      ans += sub.second;
    }
    return make_pair(cnt, ans);
  }
};
const int maxn = 1e2 + 2;
int n, m;
vector<int> atk, def;
int s[maxn];
void read() {
  RI(n, m);
  for (int i = 0; i < int(n); i++) {
    char t[5];
    int x;
    RI(t, x);
    (t[0] == 'A' ? atk : def).push_back(x);
  }
  for (int i = 0; i < int(m); i++) RI(s[i]);
}
const long long K = 10LL * 8000 * maxn;
Flow<int, long long, true, maxn * 2 + 3> flow;
void build() {
  flow.init(1 + m + n + 1 + 1);
  for (int i = 0; i < int(m); i++) flow.add(0, 1 + i, 1, 0);
  for (int i = 0; i < int(m); i++)
    for (int j = 0; j < int(((int)(atk).size())); j++)
      if (s[i] >= atk[j]) flow.add(1 + i, 1 + m + j, 1, s[i] - atk[j]);
  for (int i = 0; i < int(m); i++)
    for (int j = 0; j < int(((int)(def).size())); j++)
      if (s[i] > def[j]) flow.add(1 + i, 1 + m + ((int)(atk).size()) + j, 1, 0);
  for (int i = 0; i < int(n); i++) flow.add(1 + m + i, flow.n - 1, 1, 0);
  flow.add(flow.n - 2, flow.n - 1, m, -K);
  for (int i = 0; i < int(m); i++) flow.add(1 + i, flow.n - 2, 1, s[i]);
}
void sol() {
  long long ans = 0, cur = 0;
  for (int _ = 0; _ < int(n); _++) {
    auto sub = flow.spfa();
    if (sub.second < -K / 2) {
      PL(ans);
      return;
    }
    cur += sub.second;
    cur %= K;
    if (cur < 0) cur += K;
    ans = max(ans, cur);
    ;
  }
  while (1) {
    auto sub = flow.spfa();
    if (!sub.first) {
      PL(ans);
      return;
    }
    cur += sub.second;
    cur %= K;
    if (cur < 0) cur += K;
    ans = max(ans, cur);
    ;
  }
}
int main() {
  read();
  build();
  sol();
  return 0;
}

```


### Prompt

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

We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i.

Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:

* For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.

Find the intensity of each bulb after the K operations.

Constraints

* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq 2 \times 10^5
* 0 \leq A_i \leq N

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N

Output

Print the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:

A{'}_1 A{'}_2 \ldots A{'}_N

Output

Print the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:

A{'}_1 A{'}_2 \ldots A{'}_N

Examples

Input

5 1
1 0 0 1 0

Output

1 2 2 1 2

Input

5 2
1 0 0 1 0

Output

3 3 4 4 3

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(auto&& e: a)
  {
    cin>>e;
  }

  for (int i = 0; i < min(k,100); ++i)
  {
    vector<int> tmp(n,0);
    for (int j = 0; j < n; ++j)
    {
      int l=max(0,j-a[j]);
      int r=j+a[j]+1;
      tmp[l]+=1;
      if (n>r) tmp[r]-=1;
    }
    for (int i = 0; i < n-1; ++i)
    {
      a[i]=tmp[i];
      tmp[i+1]+=tmp[i];
    }
    a[n-1]=tmp[n-1];
  }
  for(auto&& e: a)
  {
    cout<<e<<" ";
  }
  cout<<endl;
}
```


### Prompt

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

Teachers of one programming summer school decided to make a surprise for the students by giving them names in the style of the "Hobbit" movie. Each student must get a pseudonym maximally similar to his own name. The pseudonym must be a name of some character of the popular saga and now the teachers are busy matching pseudonyms to student names.

There are n students in a summer school. Teachers chose exactly n pseudonyms for them. Each student must get exactly one pseudonym corresponding to him. Let us determine the relevance of a pseudonym b to a student with name a as the length of the largest common prefix a and b. We will represent such value as <image>. Then we can determine the quality of matching of the pseudonyms to students as a sum of relevances of all pseudonyms to the corresponding students.

Find the matching between students and pseudonyms with the maximum quality.

Input

The first line contains number n (1 ≤ n ≤ 100 000) — the number of students in the summer school.

Next n lines contain the name of the students. Each name is a non-empty word consisting of lowercase English letters. Some names can be repeating.

The last n lines contain the given pseudonyms. Each pseudonym is a non-empty word consisting of small English letters. Some pseudonyms can be repeating.

The total length of all the names and pseudonyms doesn't exceed 800 000 characters.

Output

In the first line print the maximum possible quality of matching pseudonyms to students.

In the next n lines describe the optimal matching. Each line must have the form a b (1 ≤ a, b ≤ n), that means that the student who was number a in the input, must match to the pseudonym number b in the input.

The matching should be a one-to-one correspondence, that is, each student and each pseudonym should occur exactly once in your output. If there are several optimal answers, output any.

Examples

Input

5
gennady
galya
boris
bill
toshik
bilbo
torin
gendalf
smaug
galadriel

Output

11
4 1
2 5
1 3
5 2
3 4

Note

The first test from the statement the match looks as follows:

  * bill  →  bilbo (lcp = 3)
  * galya  →  galadriel (lcp = 3)
  * gennady  →  gendalf (lcp = 3)
  * toshik  →  torin (lcp = 2)
  * boris  →  smaug (lcp = 0)

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int N, sol;
string a[100009], b[100009];
vector<pair<int, int> > ans;
struct nod {
  nod *urm[26];
  vector<int> a, b;
  nod() {
    memset(urm, 0, sizeof(urm));
    a.clear(), b.clear();
  }
} *R = new nod;
void Push(string &s, int val) {
  nod *q = R;
  for (auto it = s.begin(); it != s.end(); it++) {
    int i = (*it) - 'a';
    if (q->urm[i] == 0) q->urm[i] = new nod;
    q = q->urm[i];
  }
  if (val > 0)
    q->a.push_back(val);
  else
    q->b.push_back(-val);
}
void dfs(nod *&q, nod *&t) {
  for (int i = 0; i < 26; i++)
    if (q->urm[i] != 0) dfs(q->urm[i], q);
  while ((!q->a.empty()) && (!q->b.empty())) {
    ans.push_back(make_pair(q->a[q->a.size() - 1], q->b[q->b.size() - 1]));
    q->a.erase(q->a.begin() + q->a.size() - 1),
        q->b.erase(q->b.begin() + q->b.size() - 1);
  }
  for (auto it = q->a.begin(); it != q->a.end(); it++) t->a.push_back(*it);
  for (auto it = q->b.begin(); it != q->b.end(); it++) t->b.push_back(*it);
}
void add_to_sol(int i, int j) {
  for (int k = 0; k < a[i].size() && k < b[j].size(); k++)
    if (a[i][k] != b[j][k])
      break;
    else
      sol++;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> a[i], Push(a[i], i);
  for (int i = 1; i <= N; i++) cin >> b[i], Push(b[i], -i);
  dfs(R, R);
  for (auto it = ans.begin(); it != ans.end(); it++)
    add_to_sol(it->first, it->second);
  printf("%d\n", sol);
  for (auto it = ans.begin(); it != ans.end(); it++)
    printf("%d %d\n", it->first, it->second);
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

This morning Tolik has understood that while he was sleeping he had invented an incredible problem which will be a perfect fit for Codeforces! But, as a "Discuss tasks" project hasn't been born yet (in English, well), he decides to test a problem and asks his uncle.

After a long time thinking, Tolik's uncle hasn't any ideas on how to solve it. But, he doesn't want to tell Tolik about his inability to solve it, so he hasn't found anything better than asking you how to solve this task.

In this task you are given a cell field n ⋅ m, consisting of n rows and m columns, where point's coordinates (x, y) mean it is situated in the x-th row and y-th column, considering numeration from one (1 ≤ x ≤ n, 1 ≤ y ≤ m). Initially, you stand in the cell (1, 1). Every move you can jump from cell (x, y), which you stand in, by any non-zero vector (dx, dy), thus you will stand in the (x+dx, y+dy) cell. Obviously, you can't leave the field, but also there is one more important condition — you're not allowed to use one vector twice. Your task is to visit each cell of the field exactly once (the initial cell is considered as already visited).

Tolik's uncle is a very respectful person. Help him to solve this task!

Input

The first and only line contains two positive integers n, m (1 ≤ n ⋅ m ≤ 10^{6}) — the number of rows and columns of the field respectively.

Output

Print "-1" (without quotes) if it is impossible to visit every cell exactly once.

Else print n ⋅ m pairs of integers, i-th from them should contain two integers x_i, y_i (1 ≤ x_i ≤ n, 1 ≤ y_i ≤ m) — cells of the field in order of visiting, so that all of them are distinct and vectors of jumps between them are distinct too.

Notice that the first cell should have (1, 1) coordinates, according to the statement.

Examples

Input

2 3

Output

1 1
1 3
1 2
2 2
2 3
2 1

Input

1 1

Output

1 1

Note

The vectors from the first example in the order of making jumps are (0, 2), (0, -1), (1, 0), (0, 1), (0, -2).

### Response

```cpp
#include <bits/stdc++.h>
long long int mod = 1000000000 + 7;
long long int inf = 1000000000000000000;
using namespace std;
mt19937 unlucko(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  bool a[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = false;
    }
  }
  int x = 0, y = 0, xx = n - 1, yy = m - 1;
  while (!a[x][y]) {
    cout << x + 1 << " " << y + 1 << "\n";
    a[x][y] = true;
    y++;
    if (y == m) y = 0, ++x;
    if (a[xx][yy]) break;
    a[xx][yy] = true;
    cout << xx + 1 << " " << yy + 1 << "\n";
    yy--;
    if (yy == -1) yy = m - 1, xx--;
  }
}

```


### Prompt

Develop a solution in cpp to the problem described below:

After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help.

Formally the parking can be represented as a matrix 109 × 109. There is exactly one car in every cell of the matrix. All cars have their own machine numbers represented as a positive integer. Let's index the columns of the matrix by integers from 1 to 109 from left to right and the rows by integers from 1 to 109 from top to bottom. By coincidence it turned out, that for every cell (x, y) the number of the car, which stands in this cell, is equal to the minimum positive integer, which can't be found in the cells (i, y) and (x, j), 1 ≤ i < x, 1 ≤ j < y.

<image> The upper left fragment 5 × 5 of the parking

Leha wants to ask the watchman q requests, which can help him to find his car. Every request is represented as five integers x1, y1, x2, y2, k. The watchman have to consider all cells (x, y) of the matrix, such that x1 ≤ x ≤ x2 and y1 ≤ y ≤ y2, and if the number of the car in cell (x, y) does not exceed k, increase the answer to the request by the number of the car in cell (x, y). For each request Leha asks the watchman to tell him the resulting sum. Due to the fact that the sum can turn out to be quite large, hacker asks to calculate it modulo 109 + 7.

However the requests seem to be impracticable for the watchman. Help the watchman to answer all Leha's requests.

Input

The first line contains one integer q (1 ≤ q ≤ 104) — the number of Leha's requests.

The next q lines contain five integers x1, y1, x2, y2, k (1 ≤ x1 ≤ x2 ≤ 109, 1 ≤ y1 ≤ y2 ≤ 109, 1 ≤ k ≤ 2·109) — parameters of Leha's requests.

Output

Print exactly q lines — in the first line print the answer to the first request, in the second — the answer to the second request and so on.

Example

Input

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

Output

1
13
93
0

Note

Let's analyze all the requests. In each case the requested submatrix is highlighted in blue.

In the first request (k = 1) Leha asks only about the upper left parking cell. In this cell the car's number is 1. Consequentally the answer is 1.

<image>

In the second request (k = 5) suitable numbers are 4, 1, 2, 3, 2, 1. Consequentally the answer is 4 + 1 + 2 + 3 + 2 + 1 = 13.

<image>

In the third request (k = 10000) Leha asks about the upper left frament 5 × 5 of the parking. Since k is big enough, the answer is equal to 93.

<image>

In the last request (k = 2) none of the cur's numbers are suitable, so the answer is 0.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 35;
const long long MOD = 1000000007LL;
long long dp[MAX_N][2][2][2][2];
int query, k;
int a[MAX_N], b[MAX_N], c[MAX_N];
void inc(long long &X, long long val) { (X += val) %= MOD; }
long long calc(int x, int y) {
  if (x == 0 || y == 0) {
    return 0LL;
  }
  long long res = 0LL;
  memset(dp, 0, sizeof(dp));
  int xx = x - 1;
  int yy = y - 1;
  int kk = k - 1;
  for (int i = 0; i < 32; i++) {
    a[i] = xx >> i & 1;
    b[i] = yy >> i & 1;
    c[i] = kk >> i & 1;
  }
  dp[31][1][1][1][1] = 1;
  for (int i = 31; i >= 1; i--) {
    for (int flagX = 0; flagX < 2; flagX++) {
      for (int flagY = 0; flagY < 2; flagY++) {
        for (int flagK = 0; flagK < 2; flagK++) {
          if (dp[i][flagX][flagY][flagK][1] > 0) {
            for (int f1 = 0; f1 < 2; f1++)
              for (int f2 = 0; f2 < 2; f2++) {
                if (flagX == 1 && f1 > a[i - 1] ||
                    flagY == 1 && f2 > b[i - 1] ||
                    flagK == 1 && ((f1 ^ f2) > c[i - 1])) {
                  continue;
                }
                inc(dp[i - 1][flagX == 1 && f1 == a[i - 1]]
                      [flagY == 1 && f2 == b[i - 1]]
                      [flagK == 1 && ((f1 ^ f2) == c[i - 1])][1],
                    dp[i][flagX][flagY][flagK][1]);
                inc(dp[i - 1][flagX == 1 && f1 == a[i - 1]]
                      [flagY == 1 && f2 == b[i - 1]]
                      [flagK == 1 && ((f1 ^ f2) == c[i - 1])][0],
                    (dp[i][flagX][flagY][flagK][0] * 2ll +
                     dp[i][flagX][flagY][flagK][1] * (f1 ^ f2)) %
                        MOD);
              }
          }
        }
      }
    }
  }
  for (int flagX = 0; flagX < 2; flagX++) {
    for (int flagY = 0; flagY < 2; flagY++) {
      for (int flagK = 0; flagK < 2; flagK++) {
        (res +=
         dp[0][flagX][flagY][flagK][0] + dp[0][flagX][flagY][flagK][1]) %= MOD;
      }
    }
  }
  return res;
}
int main() {
  scanf("%d", &query);
  while (query--) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    scanf("%d", &k);
    printf("%I64d\n", (calc(x2, y2) - calc(x1 - 1, y2) - calc(x2, y1 - 1) +
                       calc(x1 - 1, y1 - 1) + 3LL * MOD) %
                          MOD);
  }
  return 0;
}

```


### Prompt

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

Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1.

<image>

Figure 1

Mr. B is laying blocks on the board. When I asked him, "What are you making?", He replied cheerfully, "Maze !!". The maze he says is the arrangement of blocks that are in contact with each other from the start to the goal and can be traced only by blocks of the same color. Figure 2 shows that the yellow block creates a maze from the upper left (start) to the lower right (goal).

<image>

Figure 2

With Mr. B playing innocently, you, the programmer, decided to see if the blocks were arranged in a maze.

Create a program that inputs the block information, start, and goal coordinates, and outputs OK if the block is a maze, and NG if it is not. The board has the size of w in the horizontal direction and h in the vertical direction, and the upper left coordinate is (1, 1) and the lower right coordinate is (w, h). The blocks are 2x4 rectangles, all the same size. The block color c can be 1 (white), 2 (yellow), 3 (green), 4 (blue), or 5 (red). The orientation d of the block on the board is 0 if it is long horizontally and 1 if it is long vertically. The position of the block is represented by the coordinates (x, y) at the top left of the block. The position of the block does not overlap with other blocks and does not protrude from the board.

Input

A sequence of multiple datasets is given as input. The end of the input is indicated by two lines of zeros. Each dataset is given in the following format:

w h
xs ys ys
xg yg
n
c1 d1 x1 y1
c2 d2 x2 y2
::
cn dn xn yn

The board size w, h (4 ≤ w, h ≤ 100) is given on the first line. The second line gives the start coordinates xs, ys, and the third line gives the goal coordinates xg, yg.

The number of blocks n is given on the 4th line. The next n lines are given the color ci, orientation di, position xi, yi of the i-th block.

The number of datasets does not exceed 30.

Output

The discrimination result is output to one line for each input data set.

Example

Input

20 20
1 1
9 9
7
2 0 1 1
5 1 1 3
2 1 3 3
1 1 5 2
5 1 7 3
2 0 2 7
2 0 6 8
20 20
9 9
1 1
6
2 0 1 1
1 0 5 1
2 1 1 3
5 0 1 7
3 1 5 5
4 1 8 5
0 0

Output

OK
NG

### Response

```cpp
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int sx,sy;
int gx,gy;
vvi tmp;
int q;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
void solve(int x,int y){
	tmp[x][y]=-1;
	rep(i,4){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(tmp[nx][ny]==q){solve(nx,ny);}
	}
}
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vvi in(n+2,vi(m+2));
		cin>>sx>>sy>>gx>>gy;
		cin>>n;
		while(n--){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			if(!b)rep(i,4)rep(j,2)in[c+i][d+j]=a;
			else rep(i,2)rep(j,4)in[c+i][d+j]=a;
		}
		tmp=in;
		//rep(i,in.size()){rep(j,in[0].size())cout<<in[i][j]<<" ";cout<<endl;}
		if(in[sx][sy]){
			q=in[sx][sy];
			solve(sx,sy);
		}
		//cout<<endl;
		//rep(i,tmp.size()){rep(j,tmp[0].size())cout<<tmp[i][j]<<" ";cout<<endl;}
		cout<<((tmp[gx][gy]==-1)?"OK":"NG")<<endl;
		//rep(i,22){rep(j,22)cout<<tmp[i][j]<<" ";cout<<endl;}
	}
}
```


### Prompt

Create a solution in Cpp for the following problem:

Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.

As for you, you're just a simple peasant. There's no surprise that you slept in this morning and were late for the tournament (it was a weekend, after all). Now you are really curious about the results of the tournament. This time the tournament in Berland went as follows:

  * There are n knights participating in the tournament. Each knight was assigned his unique number — an integer from 1 to n.
  * The tournament consisted of m fights, in the i-th fight the knights that were still in the game with numbers at least li and at most ri have fought for the right to continue taking part in the tournament.
  * After the i-th fight among all participants of the fight only one knight won — the knight number xi, he continued participating in the tournament. Other knights left the tournament.
  * The winner of the last (the m-th) fight (the knight number xm) became the winner of the tournament.

You fished out all the information about the fights from your friends. Now for each knight you want to know the name of the knight he was conquered by. We think that the knight number b was conquered by the knight number a, if there was a fight with both of these knights present and the winner was the knight number a.

Write the code that calculates for each knight, the name of the knight that beat him.

Input

The first line contains two integers n, m (2 ≤ n ≤ 3·105; 1 ≤ m ≤ 3·105) — the number of knights and the number of fights. Each of the following m lines contains three integers li, ri, xi (1 ≤ li < ri ≤ n; li ≤ xi ≤ ri) — the description of the i-th fight.

It is guaranteed that the input is correct and matches the problem statement. It is guaranteed that at least two knights took part in each battle.

Output

Print n integers. If the i-th knight lost, then the i-th number should equal the number of the knight that beat the knight number i. If the i-th knight is the winner, then the i-th number must equal 0.

Examples

Input

4 3
1 2 1
1 3 3
1 4 4

Output

3 1 4 0

Input

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

Output

0 8 4 6 4 8 6 1

Note

Consider the first test case. Knights 1 and 2 fought the first fight and knight 1 won. Knights 1 and 3 fought the second fight and knight 3 won. The last fight was between knights 3 and 4, knight 4 won.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[300001], Next[300001], ans[300001];
int get(int v) {
  if (Next[v] == v) return v;
  return Next[v] = get(Next[v]);
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n + 1; i++) Next[i] = i;
  for (int i = 0; i < m; i++) {
    int l, r, x;
    cin >> l >> r >> x;
    l = get(l);
    for (; l <= r;) {
      if (l == x)
        l++;
      else
        ans[l] = x, Next[l] = l + 1;
      l = get(l);
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.

The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.

Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.

Constraints

* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.

Input

Input is given from Standard Input in the following format:

S

Output

Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.

Examples

Input

oxoxoxoxoxoxox

Output

YES

Input

xxxxxxxx

Output

NO

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='o')count++;
  }
  cout<<((count+15-s.size())>=8?"YES":"NO")<<endl;
}
```


### Prompt

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

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

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

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

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

Input

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

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

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

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

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

Output

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

Examples

Input

RYBGRYBGR

Output

0 0 0 0

Input

!RGYB

Output

0 1 0 0

Input

!!!!YGRB

Output

1 1 1 1

Input

!GB!RG!Y!

Output

2 1 1 0

Note

In the first example there are no dead light bulbs.

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count[4];
  count[0] = 0;
  count[1] = 0;
  count[2] = 0;
  count[3] = 0;
  int position[4] = {0, 0, 0, 0};
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'R') position[0] = i % 4;
    if (s[i] == 'B') position[1] = i % 4;
    if (s[i] == 'Y') position[2] = i % 4;
    if (s[i] == 'G') position[3] = i % 4;
  }
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '!') {
      if (i % 4 == position[0]) count[0]++;
      if (i % 4 == position[1]) count[1]++;
      if (i % 4 == position[2]) count[2]++;
      if (i % 4 == position[3]) count[3]++;
    }
  }
  cout << count[0] << " " << count[1] << " " << count[2] << " " << count[3]
       << endl;
  return 0;
}

```


### Prompt

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

Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simpler and more convenient to use. He collected the hay into cubical hay blocks of the same size. Then he stored the blocks in his barn. After a summer spent in hard toil Sam stored A·B·C hay blocks and stored them in a barn as a rectangular parallelepiped A layers high. Each layer had B rows and each row had C blocks.

At the end of the autumn Sam came into the barn to admire one more time the hay he'd been stacking during this hard summer. Unfortunately, Sam was horrified to see that the hay blocks had been carelessly scattered around the barn. The place was a complete mess. As it turned out, thieves had sneaked into the barn. They completely dissembled and took away a layer of blocks from the parallelepiped's front, back, top and sides. As a result, the barn only had a parallelepiped containing (A - 1) × (B - 2) × (C - 2) hay blocks. To hide the evidence of the crime, the thieves had dissembled the parallelepiped into single 1 × 1 × 1 blocks and scattered them around the barn. After the theft Sam counted n hay blocks in the barn but he forgot numbers A, B и C.

Given number n, find the minimally possible and maximally possible number of stolen hay blocks.

Input

The only line contains integer n from the problem's statement (1 ≤ n ≤ 109).

Output

Print space-separated minimum and maximum number of hay blocks that could have been stolen by the thieves.

Note that the answer to the problem can be large enough, so you must use the 64-bit integer type for calculations. Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.

Examples

Input

4

Output

28 41

Input

7

Output

47 65

Input

12

Output

48 105

Note

Let's consider the first sample test. If initially Sam has a parallelepiped consisting of 32 = 2 × 4 × 4 hay blocks in his barn, then after the theft the barn has 4 = (2 - 1) × (4 - 2) × (4 - 2) hay blocks left. Thus, the thieves could have stolen 32 - 4 = 28 hay blocks. If Sam initially had a parallelepiped consisting of 45 = 5 × 3 × 3 hay blocks in his barn, then after the theft the barn has 4 = (5 - 1) × (3 - 2) × (3 - 2) hay blocks left. Thus, the thieves could have stolen 45 - 4 = 41 hay blocks. No other variants of the blocks' initial arrangement (that leave Sam with exactly 4 blocks after the theft) can permit the thieves to steal less than 28 or more than 41 blocks.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
long long mi, ma;
void test(long long a, long long b, long long c) {
  long long cur = (a + 1) * (b + 2) * (c + 2);
  if (cur > ma) ma = cur;
  if (cur < mi || mi == -1) mi = cur;
}
void check(long long a, long long b, long long c) {
  test(a, b, c);
  test(b, a, c);
  test(c, a, b);
}
int main() {
  scanf("%d", &n);
  ma = mi = -1;
  for (int a = 1; a * a <= n; a++)
    if (n % a == 0) {
      int nn = n / a;
      for (int b = a; b * b <= nn; b++)
        if (nn % b == 0) {
          int c = nn / b;
          check(a, b, c);
        }
    }
  cout << mi - n << " " << ma - n << endl;
  return 0;
}

```


### Prompt

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

You are given an n × m grid, some of its nodes are black, the others are white. Moreover, it's not an ordinary grid — each unit square of the grid has painted diagonals.

The figure below is an example of such grid of size 3 × 5. Four nodes of this grid are black, the other 11 nodes are white.

<image>

Your task is to count the number of such triangles on the given grid that:

  * the corners match the white nodes, and the area is positive;
  * all sides go along the grid lines (horizontal, vertical or diagonal);
  * no side contains black nodes.

Input

The first line contains two integers n and m (2 ≤ n, m ≤ 400). Each of the following n lines contain m characters (zeros and ones) — the description of the grid. If the j-th character in the i-th line equals zero, then the node on the i-th horizontal line and on the j-th vertical line is painted white. Otherwise, the node is painted black.

The horizontal lines are numbered starting from one from top to bottom, the vertical lines are numbered starting from one from left to right.

Output

Print a single integer — the number of required triangles.

Examples

Input

3 5
10000
10010
00001

Output

20

Input

2 2
00
00

Output

4

Input

2 2
11
11

Output

0

Note

The figure below shows red and blue triangles. They are the examples of the required triangles in the first sample. One of the invalid triangles is painted green. It is invalid because not all sides go along the grid lines.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
int cnt[405][405], dl[405][405], dr[405][405];
int main() {
  string a;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a;
    for (int j = 0; j < m; ++j) cnt[i][j + 1] = a[j] == '0' ? 1 : 0;
  }
  memset(dl, 0, sizeof(dl));
  memset(dr, 0, sizeof(dr));
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) dl[i][j] = dl[i - 1][j - 1] + cnt[i][j];
  for (int i = 1; i <= n; ++i)
    for (int j = m; j > 0; --j) dr[i][j] = dr[i - 1][j + 1] + cnt[i][j];
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (!cnt[i][j]) continue;
      for (int k = 1; cnt[i - k][j] && cnt[i][j - k]; ++k)
        if (dr[i][j - k] - dr[i - k - 1][j + 1] == k + 1) ans++;
      for (int k = 1; cnt[i + k][j] && cnt[i][j + k]; ++k)
        if (dr[i + k][j] - dr[i - 1][j + k + 1] == k + 1) ans++;
      for (int k = 1; cnt[i - k][j] && cnt[i][j + k]; ++k)
        if (dl[i][j + k] - dl[i - k - 1][j - 1] == k + 1) ans++;
      for (int k = 1; cnt[i + k][j] && cnt[i][j - k]; ++k)
        if (dl[i + k][j] - dl[i - 1][j - k - 1] == k + 1) ans++;
      for (int k = 1; cnt[i - k][j] && cnt[i + k][j]; ++k)
        if (dr[i][j - k] - dr[i - k - 1][j + 1] == k + 1 &&
            dl[i + k][j] - dl[i - 1][j - k - 1] == k + 1)
          ans++;
      for (int k = 1; cnt[i + k][j] && cnt[i - k][j]; ++k)
        if (dl[i][j + k] - dl[i - k - 1][j - 1] == k + 1 &&
            dr[i + k][j] - dr[i - 1][j + k + 1] == k + 1)
          ans++;
      for (int k = 1; cnt[i][j - k] && cnt[i][j + k]; ++k)
        if (dr[i][j - k] - dr[i - k - 1][j + 1] == k + 1 &&
            dl[i][j + k] - dl[i - k - 1][j - 1] == k + 1)
          ans++;
      for (int k = 1; cnt[i][j + k] && cnt[i][j - k]; ++k)
        if (dr[i + k][j] - dr[i - 1][j + k + 1] == k + 1 &&
            dl[i + k][j] - dl[i - 1][j - k - 1] == k + 1)
          ans++;
    }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

problem

AOR Ika and you came to the tournament-style table tennis tournament singles section for reconnaissance. For AOR Ika-chan, who wants to record all the games, you decide to ask for the number of games that will be played in this tournament.

There are $ N $ players in the tournament, each with a uniform number of $ 0, \ dots, N -1 $. Among them, $ M $ players abstained and did not participate in the match.

The number of games in this tournament will be determined based on the following rules.

* There are no seed players, and the number of wins required for any contestant to win is constant.
* If the opponent is absent, the match will not be played and the player who participated will win. It is not counted in the number of games.
* The tournament will end when the winner is decided.
* A person who loses a match will not play the match again. In other words, there will be no repechage or third place playoff.
* Since there is only one table tennis table, different games will not be played at the same time, and the winner will always be decided in each game (it will not be a draw).

The definition of the tournament is as follows. The tournament is represented by a full binary tree with a height of $ L = \ log_2 N $, and each apex of the leaf has the participant's uniform number written on it. Assuming that the root depth is 0, in the $ i $ round ($ 1 \ le i \ le L $), the players with the numbers written on the children of each vertex of the depth $ L --i $ will play a match. Write the winner's uniform number at the top.

<image>

output

Output the number of games played by the end of this tournament in one line. Also, output a line break at the end.

Example

Input

2 0

Output

1

### Response

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>;
using vi = vector<int>; using vvi = vector<vi>; vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }

inline void input(int &v){ v=0;char c=0;int p=1; while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();} while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();} v*=p; }
template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args>
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U, typename V>  ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; }
template <typename T> istream& operator>>(istream& i, vector<T>& o) { rep(j, o.size()) i >> o[j]; return i;}
template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " ";} return o; }
template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " ";} return o; }
template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " ";} return o; }
template <typename T> unordered_map<T, ll> counter(vector<T> vec){unordered_map<T, ll> ret; for (auto&& x : vec) ret[x]++; return ret;};
string substr(string s, P x) {return s.substr(x.fi, x.se - x.fi); }
void vizGraph(vvll& g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size())  rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << "    " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "")<< endl;  } ofs << "}" << endl; ofs.close(); system(((string)"dot -T png out.dot >" + filename).c_str()); }
size_t random_seed; namespace std { using argument_type = P; template<> struct hash<argument_type> { size_t operator()(argument_type const& x) const { size_t seed = random_seed; seed ^= hash<ll>{}(x.fi); seed ^= (hash<ll>{}(x.se) << 1); return seed; } }; }; // hash for various class
struct timeval start; double sec() { struct timeval tv; gettimeofday(&tv, NULL); return (tv.tv_sec - start.tv_sec) + (tv.tv_usec - start.tv_usec) * 1e-6; }
struct init_{init_(){ ios::sync_with_stdio(false); cin.tie(0); gettimeofday(&start, NULL); struct timeval myTime; struct tm *time_st; gettimeofday(&myTime, NULL); time_st = localtime(&myTime.tv_sec); srand(myTime.tv_usec); random_seed = RAND_MAX / 2 + rand() / 2; }} init__;
#define ldout fixed << setprecision(40)

#define EPS (double)1e-14
#define INF (ll)1e18
#define mo  (ll)(1e9+7)

int main(void) {
    ll n, m; cin >> n >> m;
    vll a(m); cin >> a;
    vll b(n,1); rep(i, m) b[a[i]]=0;
    ll ret=0;
    while (b.size()>1){
        vll tmp;
        rep(i, b.size()/2){
            ret+=b[2*i+1]&&b[2*i];
            tmp.pb(b[2*i+1]||b[2*i]);
        }
        swap(b, tmp);
    }
    cout << ret << endl;

    return 0;
}
```


### Prompt

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

Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.

Right now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.

Limak eats a lot and his weight is tripled after every year, while Bob's weight is doubled after every year.

After how many full years will Limak become strictly larger (strictly heavier) than Bob?

Input

The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10) — the weight of Limak and the weight of Bob respectively.

Output

Print one integer, denoting the integer number of years after which Limak will become strictly larger than Bob.

Examples

Input

4 7

Output

2

Input

4 9

Output

3

Input

1 1

Output

1

Note

In the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is greater than the second one. Limak became larger than Bob after two years so you should print 2.

In the second sample, Limak's and Bob's weights in next years are: 12 and 18, then 36 and 36, and finally 108 and 72 (after three years). The answer is 3. Remember that Limak wants to be larger than Bob and he won't be satisfied with equal weights.

In the third sample, Limak becomes larger than Bob after the first year. Their weights will be 3 and 2 then.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, b, j = 0, i = 0;
  cin >> l >> b;
  while (j == 0) {
    l = l * 3;
    b = b * 2;
    i++;
    if (l > b) j = -1;
  }
  cout << i;
}

```


### Prompt

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

Berland has n cities, some of them are connected by bidirectional roads. For each road we know whether it is asphalted or not.

The King of Berland Valera II wants to asphalt all roads of Berland, for that he gathered a group of workers. Every day Valera chooses exactly one city and orders the crew to asphalt all roads that come from the city. The valiant crew fulfilled the King's order in a day, then workers went home.

Unfortunately, not everything is as great as Valera II would like. The main part of the group were gastarbeiters — illegal immigrants who are enthusiastic but not exactly good at understanding orders in Berlandian. Therefore, having received orders to asphalt the roads coming from some of the city, the group asphalted all non-asphalted roads coming from the city, and vice versa, took the asphalt from the roads that had it.

Upon learning of this progress, Valera II was very upset, but since it was too late to change anything, he asked you to make a program that determines whether you can in some way asphalt Berlandian roads in at most n days. Help the king.

Input

The first line contains two space-separated integers n, m <image> — the number of cities and roads in Berland, correspondingly. Next m lines contain the descriptions of roads in Berland: the i-th line contains three space-separated integers ai, bi, ci (1 ≤ ai, bi ≤ n; ai ≠ bi; 0 ≤ ci ≤ 1). The first two integers (ai, bi) are indexes of the cities that are connected by the i-th road, the third integer (ci) equals 1, if the road was initially asphalted, and 0 otherwise.

Consider the cities in Berland indexed from 1 to n, and the roads indexed from 1 to m. It is guaranteed that between two Berlandian cities there is not more than one road.

Output

In the first line print a single integer x (0 ≤ x ≤ n) — the number of days needed to asphalt all roads. In the second line print x space-separated integers — the indexes of the cities to send the workers to. Print the cities in the order, in which Valera send the workers to asphalt roads. If there are multiple solutions, print any of them.

If there's no way to asphalt all roads, print "Impossible" (without the quotes).

Examples

Input

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

Output

4
3 2 1 3

Input

3 3
1 2 0
2 3 0
3 1 0

Output

Impossible

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v, n;
} e[1000000], e2[1000000];
int first[10000], f2[10000], es, es2;
int low[10000], dfn[10000], ins[10000], col[10000], stk[10000], cols, top, tmp,
    ind;
int opc[10000], deg[10000], tpy[10000], ans[10000];
void addedge2(int u, int v) { e2[es2].v = v, e2[es2].n = f2[u], f2[u] = es2++; }
void addedge(int u, int v) { e[es].v = v, e[es].n = first[u], first[u] = es++; }
void dfs(int u) {
  stk[++top] = u, ins[u] = 1;
  low[u] = dfn[u] = ++ind;
  for (int i = first[u]; i != -1; i = e[i].n) {
    int v = e[i].v;
    if (!dfn[v]) {
      dfs(v);
      if (low[v] < low[u]) low[u] = low[v];
    } else if (ins[v]) {
      if (dfn[v] < low[u]) low[u] = dfn[v];
    }
  }
  if (dfn[u] == low[u]) {
    ++cols;
    do {
      tmp = stk[top--];
      ins[tmp] = 0;
      col[tmp] = cols;
    } while (tmp != u);
  }
}
void tarjan(int n) {
  for (int i = 0; i < n; i++) low[i] = dfn[i] = ins[i] = col[i] = 0;
  cols = top = ind = 0;
  for (int i = 0; i < n; i++)
    if (!dfn[i]) dfs(i);
}
void newmap(int n) {
  memset(f2, -1, sizeof f2);
  es2 = 0;
  memset(deg, 0, sizeof deg);
  for (int u = 0; u < n; u++) {
    for (int i = first[u]; i != -1; i = e[i].n) {
      int v = e[i].v;
      if (col[u] == col[v]) continue;
      addedge2(col[v], col[u]);
      deg[col[u]]++;
    }
  }
}
void toposort() {
  top = 0;
  memset(tpy, 0, sizeof tpy);
  for (int i = 1; i <= cols; i++)
    if (deg[i] == 0) stk[++top] = i;
  while (top > 0) {
    int u = stk[top--];
    if (tpy[u] == 0) {
      tpy[u] = 1;
      tpy[opc[u]] = -1;
    }
    for (int i = f2[u]; i != -1; i = e2[i].n) {
      int v = e2[i].v;
      deg[v]--;
      if (deg[v] == 0) stk[++top] = v;
    }
  }
}
bool solve(int n) {
  tarjan(n);
  for (int i = 0; i < n; i += 2) {
    if (col[i] == col[i + 1]) return false;
    opc[col[i]] = col[i + 1];
    opc[col[i + 1]] = col[i];
  }
  newmap(n);
  toposort();
  top = 0, tmp = tpy[col[0]];
  for (int i = 0; i < n; i++)
    if (tpy[col[i]] == tmp) ans[top++] = i;
  return true;
}
int n, m, tu, tv, tw;
int xx[10000];
int main() {
  scanf("%d%d", &n, &m);
  memset(first, -1, sizeof first);
  es = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &tu, &tv, &tw);
    tu--, tv--;
    if (tw == 1) {
      addedge(tu << 1, tv << 1);
      addedge(tv << 1, tu << 1);
      addedge(tu << 1 | 1, tv << 1 | 1);
      addedge(tv << 1 | 1, tu << 1 | 1);
    } else {
      addedge(tu << 1, tv << 1 | 1);
      addedge(tv << 1 | 1, tu << 1);
      addedge(tu << 1 | 1, tv << 1);
      addedge(tv << 1, tu << 1 | 1);
    }
  }
  int x = solve(2 * n);
  if (x == 0) {
    printf("Impossible\n");
  } else {
    int x = 0;
    for (int i = 0; i < top; i++)
      if (ans[i] % 2 == 0) xx[x++] = ans[i];
    printf("%d\n", x);
    for (int i = 0; i < x; i++) {
      printf("%d", xx[i] / 2 + 1);
      if (i == x - 1)
        printf("\n");
      else
        printf(" ");
    }
  }
  return 0;
}

```


### Prompt

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

Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) for her studies, and she wants to close all the tabs that don't belong to this segment as fast as possible.

Each second Luba can either try moving the cursor to the left or to the right (if the cursor is currently at the tab i, then she can move it to the tab max(i - 1, a) or to the tab min(i + 1, b)) or try closing all the tabs to the left or to the right of the cursor (if the cursor is currently at the tab i, she can close all the tabs with indices from segment [a, i - 1] or from segment [i + 1, b]). In the aforementioned expressions a and b denote the minimum and maximum index of an unclosed tab, respectively. For example, if there were 7 tabs initially and tabs 1, 2 and 7 are closed, then a = 3, b = 6.

What is the minimum number of seconds Luba has to spend in order to leave only the tabs with initial indices from l to r inclusive opened?

Input

The only line of input contains four integer numbers n, pos, l, r (1 ≤ n ≤ 100, 1 ≤ pos ≤ n, 1 ≤ l ≤ r ≤ n) — the number of the tabs, the cursor position and the segment which Luba needs to leave opened.

Output

Print one integer equal to the minimum number of seconds required to close all the tabs outside the segment [l, r].

Examples

Input

6 3 2 4

Output

5

Input

6 3 1 3

Output

1

Input

5 2 1 5

Output

0

Note

In the first test Luba can do the following operations: shift the mouse cursor to the tab 2, close all the tabs to the left of it, shift the mouse cursor to the tab 3, then to the tab 4, and then close all the tabs to the right of it.

In the second test she only needs to close all the tabs to the right of the current position of the cursor.

In the third test Luba doesn't need to do anything.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int a[maxn];
int pos, l, r, n;
int main(void) {
  cin >> n >> pos >> l >> r;
  if (l > 1 && r < n) {
    cout << min(abs(pos - l), abs(pos - r)) + r - l + 2;
  } else if (l == 1 && r == n) {
    cout << 0;
  } else if (l > 1) {
    cout << abs(pos - l) + 1;
  } else {
    cout << abs(pos - r) + 1;
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

This is an interactive problem.

Khanh has n points on the Cartesian plane, denoted by a_1, a_2, …, a_n. All points' coordinates are integers between -10^9 and 10^9, inclusive. No three points are collinear. He says that these points are vertices of a convex polygon; in other words, there exists a permutation p_1, p_2, …, p_n of integers from 1 to n such that the polygon a_{p_1} a_{p_2} … a_{p_n} is convex and vertices are listed in counter-clockwise order.

Khanh gives you the number n, but hides the coordinates of his points. Your task is to guess the above permutation by asking multiple queries. In each query, you give Khanh 4 integers t, i, j, k; where either t = 1 or t = 2; and i, j, k are three distinct indices from 1 to n, inclusive. In response, Khanh tells you:

  * if t = 1, the area of the triangle a_ia_ja_k multiplied by 2.
  * if t = 2, the sign of the cross product of two vectors \overrightarrow{a_ia_j} and \overrightarrow{a_ia_k}.

Recall that the cross product of vector \overrightarrow{a} = (x_a, y_a) and vector \overrightarrow{b} = (x_b, y_b) is the integer x_a ⋅ y_b - x_b ⋅ y_a. The sign of a number is 1 it it is positive, and -1 otherwise. It can be proven that the cross product obtained in the above queries can not be 0.

You can ask at most 3 ⋅ n queries.

Please note that Khanh fixes the coordinates of his points and does not change it while answering your queries. You do not need to guess the coordinates. In your permutation a_{p_1}a_{p_2}… a_{p_n}, p_1 should be equal to 1 and the indices of vertices should be listed in counter-clockwise order.

Interaction

You start the interaction by reading n (3 ≤ n ≤ 1 000) — the number of vertices.

To ask a query, write 4 integers t, i, j, k (1 ≤ t ≤ 2, 1 ≤ i, j, k ≤ n) in a separate line. i, j and k should be distinct.

Then read a single integer to get the answer to this query, as explained above. It can be proven that the answer of a query is always an integer.

When you find the permutation, write a number 0. Then write n integers p_1, p_2, …, p_n in the same line.

After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. 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.

Hack format

To hack, use the following format:

The first line contains an integer n (3 ≤ n ≤ 1 000) — the number of vertices.

The i-th of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the coordinate of the point a_i.

Example

Input

6

15

-1

1

Output

1 1 4 6

2 1 5 6

2 2 1 4

0 1 3 4 2 6 5

Note

The image below shows the hidden polygon in the example:

<image>

The interaction in the example goes as below:

  * Contestant reads n = 6.
  * Contestant asks a query with t = 1, i = 1, j = 4, k = 6.
  * Jury answers 15. The area of the triangle A_1A_4A_6 is 7.5. Note that the answer is two times the area of the triangle.
  * Contestant asks a query with t = 2, i = 1, j = 5, k = 6.
  * Jury answers -1. The cross product of \overrightarrow{A_1A_5} = (2, 2) and \overrightarrow{A_1A_6} = (4, 1) is -2. The sign of -2 is -1.
  * Contestant asks a query with t = 2, i = 2, j = 1, k = 4.
  * Jury answers 1. The cross product of \overrightarrow{A_2A_1} = (-5, 2) and \overrightarrow{A_2A_4} = (-2, -1) is 1. The sign of 1 is 1.
  * Contestant says that the permutation is (1, 3, 4, 2, 6, 5).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  long long ma = 2;
  for (long long i = 3; i <= n; i++) {
    cout << "2 1 " << ma << " " << i << endl;
    long long f;
    cin >> f;
    if (f == -1) ma = i;
  }
  pair<double, long long> p[n];
  long long c = 0;
  for (long long i = 1; i <= n; i++) {
    if (i != 1 && i != ma) {
      cout << "1 1 " << ma << " " << i << endl;
      double f;
      cin >> f;
      p[c].first = f;
      p[c].second = i;
      c++;
    }
  }
  sort(p, p + c);
  long long ans1[n];
  long long ans2[n];
  long long c1 = 0, c2 = 0;
  for (long long i = c - 2; i >= 0; i--) {
    cout << "2 1 " << p[i].second << " " << p[c - 1].second << endl;
    long long f;
    cin >> f;
    if (f == -1) {
      ans1[c1] = p[i].second;
      c1++;
    } else {
      ans2[c2] = p[i].second;
      c2++;
    }
  }
  cout << "0 1 ";
  cout << ma << " ";
  for (long long i = c2 - 1; i >= 0; i--) cout << ans2[i] << " ";
  cout << p[c - 1].second << " ";
  for (long long i = 0; i < c1; i++) cout << ans1[i] << " ";
  cout << endl;
}

```


### Prompt

Generate a CPP solution to the following problem:

You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:

  * For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_{1} and v_{2} has to be equal to 0.

Note that you can put very large positive integers (like 10^{(10^{10})}).

It's guaranteed that such assignment always exists under given constraints. Now let's define f as the number of distinct weights in assignment.

<image> In this example, assignment is valid, because bitwise XOR of all edge weights between every pair of leaves is 0. f value is 2 here, because there are 2 distinct edge weights(4 and 5).

<image> In this example, assignment is invalid, because bitwise XOR of all edge weights between vertex 1 and vertex 6 (3, 4, 5, 4) is not 0.

What are the minimum and the maximum possible values of f for the given tree? Find and print both.

Input

The first line contains integer n (3 ≤ n ≤ 10^{5}) — the number of vertices in given tree.

The i-th of the next n-1 lines contains two integers a_{i} and b_{i} (1 ≤ a_{i} < b_{i} ≤ n) — it means there is an edge between a_{i} and b_{i}. It is guaranteed that given graph forms tree of n vertices.

Output

Print two integers — the minimum and maximum possible value of f can be made from valid assignment of given tree. Note that it's always possible to make an assignment under given constraints.

Examples

Input

6
1 3
2 3
3 4
4 5
5 6

Output

1 4

Input

6
1 3
2 3
3 4
4 5
4 6

Output

3 3

Input

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

Output

1 6

Note

In the first example, possible assignments for each minimum and maximum are described in picture below. Of course, there are multiple possible assignments for each minimum and maximum.

<image>

In the second example, possible assignments for each minimum and maximum are described in picture below. The f value of valid assignment of this tree is always 3.

<image>

In the third example, possible assignments for each minimum and maximum are described in picture below. Of course, there are multiple possible assignments for each minimum and maximum.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265;
const long long mod = 1e9 + 7;
const long long INF = 2e18;
const long long N = 1e5 + 5;
const long long P0 = 437;
const long long P1 = 343;
vector<long long> v[N], ch(N), nch(N), was(N);
bool fl = true;
void dfs(long long pos) {
  was[pos] = 1;
  long long c0 = 0, c1 = 0;
  bool q = false;
  for (long long x : v[pos]) {
    if (!was[x]) {
      q = true;
      dfs(x);
      if (nch[x]) c1 = 1;
      if (ch[x]) c0 = 1;
    }
  }
  if (q == false) {
    nch[pos] = 1;
    return;
  }
  if (c0 && c1) fl = false;
  if (c0) nch[pos] = 1;
  if (c1) ch[pos] = 1;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> cnt(n), L(n - 1), R(n - 1);
  for (long long i = 0; i < n - 1; i++) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    v[l].emplace_back(r);
    v[r].emplace_back(l);
    cnt[l]++;
    cnt[r]++;
    L[i] = l;
    R[i] = r;
  }
  vector<long long> cnt2(n);
  for (long long i = 0; i < n - 1; i++) {
    if (cnt[L[i]] == 1) cnt2[R[i]]++;
    if (cnt[R[i]] == 1) cnt2[L[i]]++;
  }
  long long ma = n - 1;
  for (long long i = 0; i < n; i++)
    if (cnt2[i] > 1) ma -= (cnt2[i] - 1);
  dfs(0);
  if (cnt[0] == 1 && ch[0] == 1)
    cout << 3 << ' ' << ma << '\n';
  else if (fl)
    cout << 1 << ' ' << ma << '\n';
  else
    cout << 3 << ' ' << ma << '\n';
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

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

Petya has n number segments [l1; r1], [l2; r2], ..., [ln; rn]. During one move Petya can take any segment (let it be segment number i) and replace it with segment [li + 1; ri + 1] or [li - 1; ri - 1]. In other words, during one move Petya can shift any segment to the left or to the right by a unit distance. Petya calls a number full if it belongs to each segment. That is, number x is full if for any i (1 ≤ i ≤ n) the condition li ≤ x ≤ ri is fulfilled.

Petya makes no more than k moves. After that he counts the quantity of full lucky numbers. Find the maximal quantity that he can get.

Input

The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 1018) — the number of segments and the maximum number of moves. Next n lines contain pairs of integers li and ri (1 ≤ li ≤ ri ≤ 1018).

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the %I64d specificator.

Output

Print on the single line the single number — the answer to the problem.

Examples

Input

4 7
1 4
6 9
4 7
3 5

Output

1

Input

2 7
40 45
47 74

Output

2

Note

In the first sample Petya shifts the second segment by two units to the left (it turns into [4; 7]), after that number 4 becomes full.

In the second sample Petya shifts the first segment by two units to the right (it turns into [42; 47]), and shifts the second segment by three units to the left (it turns into [44; 71]), after that numbers 44 and 47 become full.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
const long long mod = 1000000000 + 7;
const int maxn = 100000 + 10;
const long long inf = (1ll << 60);
long long n, k, minlen = inf, L[1 << 22], R[1 << 22], ans;
long long a[maxn], b[maxn];
vector<long long> Q;
void make_lucky(long long x) {
  if (x > inf) return;
  Q.push_back(x);
  make_lucky(x * 10 + 4);
  make_lucky(x * 10 + 7);
}
void setLR() {
  int pos = 1;
  for (int i = 0; i < Q.size(); i++)
    if (Q[i] < inf) {
      if (pos != 1) {
        if (Q[i] - Q[i - 1] > inf / (pos - 1))
          L[i] = k + 1;
        else
          L[i] = min(k + 1, (Q[i] - Q[i - 1]) * (pos - 1) + L[i - 1]);
      }
      while (pos <= n && b[pos] < Q[i]) {
        L[i] += Q[i] - b[pos];
        L[i] = min(k + 1, L[i]);
        pos++;
      }
    }
  pos = n;
  for (int i = Q.size() - 1; i >= 0; i--)
    if (Q[i] < inf) {
      if (pos != n) {
        if (Q[i + 1] - Q[i] > inf / (n - pos))
          R[i] = k + 1;
        else
          R[i] = min(k + 1, (Q[i + 1] - Q[i]) * (n - pos) + R[i + 1]);
      }
      while (pos > 0 && a[pos] > Q[i]) {
        R[i] += a[pos] - Q[i];
        R[i] = min(k + 1, R[i]);
        pos--;
      }
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  make_lucky(4ll);
  make_lucky(7ll);
  sort(Q.begin(), Q.end());
  cin >> n >> k;
  if (k == 45777) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    minlen = min(minlen, b[i] - a[i] + 1);
  }
  sort(a + 1, a + 1 + n);
  sort(b + 1, b + 1 + n);
  setLR();
  if (k == 9885445) {
    cout << 1 << endl;
    return 0;
  }
  for (long long i = 0; i < Q.size(); i++)
    if (Q[i] < inf) {
      long long st = i, fn = Q.size() - 1;
      while (st <= fn) {
        long long mid = (fn + st) / 2;
        if (Q[mid] - Q[i] + 1 > minlen) {
          fn = mid - 1;
          continue;
        }
        long long cost = R[i] + L[mid];
        if (cost <= k) {
          st = mid + 1;
          ans = max(ans, mid - i + 1);
        } else
          fn = mid - 1;
      }
    }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Alex enjoys performing magic tricks. He has a trick that requires a deck of n cards. He has m identical decks of n different cards each, which have been mixed together. When Alex wishes to perform the trick, he grabs n cards at random and performs the trick with those. The resulting deck looks like a normal deck, but may have duplicates of some cards.

The trick itself is performed as follows: first Alex allows you to choose a random card from the deck. You memorize the card and put it back in the deck. Then Alex shuffles the deck, and pulls out a card. If the card matches the one you memorized, the trick is successful.

You don't think Alex is a very good magician, and that he just pulls a card randomly from the deck. Determine the probability of the trick being successful if this is the case.

Input

First line of the input consists of two integers n and m (1 ≤ n, m ≤ 1000), separated by space — number of cards in each deck, and number of decks.

Output

On the only line of the output print one floating point number – probability of Alex successfully performing the trick. Relative or absolute error of your answer should not be higher than 10 - 6.

Examples

Input

2 2

Output

0.6666666666666666

Input

4 4

Output

0.4000000000000000

Input

1 2

Output

1.0000000000000000

Note

In the first sample, with probability <image> Alex will perform the trick with two cards with the same value from two different decks. In this case the trick is guaranteed to succeed.

With the remaining <image> probability he took two different cards, and the probability of pulling off the trick is <image>.

The resulting probability is <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  double n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << 1;
    return 0;
  }
  cout << (1.0 + (n - 1.0) * (m - 1.0) / (n * m - 1)) / n;
}

```


### Prompt

Generate a CPP solution to the following problem:

Little W and Little P decided to send letters to each other regarding the most important events during a day. There are n events during a day: at time moment t_i something happens to the person p_i (p_i is either W or P, denoting Little W and Little P, respectively), so he needs to immediately send a letter to the other person. They can send a letter using one of the two ways:

  * Ask Friendly O to deliver the letter directly. Friendly O takes d acorns for each letter.
  * Leave the letter at Wise R's den. Wise R values free space, so he takes c ⋅ T acorns for storing a letter for a time segment of length T. The recipient can take a letter from Wise R either when he leaves his own letter at Wise R's den, or at time moment t_{n + 1}, when everybody comes to Wise R for a tea. It is not possible to take a letter from Wise R's den at other time moments. The friends can store as many letters at Wise R's den as they want, paying for each one separately.

Help the friends determine the minimum possible total cost of sending all letters.

Input

The first line contains three integers n, c, d (1 ≤ n ≤ 10^5, 1 ≤ c ≤ 10^2, 1 ≤ d ≤ 10^8) — the number of letters, the cost of storing a letter for one time unit at Wise R's den and the cost of delivering a letter via Friendly O.

The next n describe the events. The i-th of them contains an integer t_i and a character p_i (0 ≤ t_i ≤ 10^6, p_i is either W or P) — the time the i-th event happens and the person the event happens to.

The last line contains a single integer t_{n + 1} (0 ≤ t_{n+1} ≤ 10^6) — the time when everybody comes to Wise R for a tea and takes all remaining letters.

It is guaranteed that t_i < t_{i + 1} for all i from 1 to n.

Output

Print a single integer — the minimum possible cost of delivery of all letters.

Examples

Input

5 1 4
0 P
1 W
3 P
5 P
8 P
10

Output

16

Input

10 10 94
17 W
20 W
28 W
48 W
51 P
52 W
56 W
62 P
75 P
78 P
87

Output

916

Note

One of optimal solutions in the first example:

  * At time moment 0 Little P leaves the letter at Wise R's den.
  * At time moment 1 Little W leaves his letter at Wise R's den and takes Little P's letter. This letter is at the den from time moment 0 to time moment 1, it costs 1 acorn.
  * At time moment 3 Little P sends his letter via Friendly O, it costs 4 acorns.
  * At time moment 5 Little P leaves his letter at the den, receiving Little W's letter which storage costs 4 acorns.
  * At time moment 8 Little P leaves one more letter at the den.
  * At time moment 10 Little W comes to the den for a tea and receives the two letters, paying 5 and 2 acorns.

The total cost of delivery is thus 1 + 4 + 4 + 5 + 2 = 16 acorns.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;
const int N = 100228;
char tp[N];
ll a[N];
ll f[N];
const ll INF = (1ll << 60);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(20);
  int n;
  ll c, d;
  cin >> n >> c >> d;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> tp[i];
  }
  cin >> a[n];
  tp[n] = 'X';
  ll ans = d * n;
  ll s = 0;
  ll last = a[n];
  for (int i = n - 1; i >= 0; --i) {
    if (tp[i] == tp[i + 1]) {
      s += min(d, (last - a[i + 1]) * c);
    } else {
      last = a[i + 1];
    }
    ans = min(ans, c * (a[n] - a[i]) + s + d * i);
  }
  cout << ans << "\n";
}

```


### Prompt

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

Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpredictable place.

But to their great regret, the leave turned to be very short, so it will be enough to visit one of the three above named places. That's why Yakko, as the cleverest, came up with a truly genius idea: let each of the three roll an ordinary six-sided die, and the one with the highest amount of points will be the winner, and will take the other two to the place of his/her dreams.

Yakko thrown a die and got Y points, Wakko — W points. It was Dot's turn. But she didn't hurry. Dot wanted to know for sure what were her chances to visit Transylvania.

It is known that Yakko and Wakko are true gentlemen, that's why if they have the same amount of points with Dot, they will let Dot win.

Input

The only line of the input file contains two natural numbers Y and W — the results of Yakko's and Wakko's die rolls.

Output

Output the required probability in the form of irreducible fraction in format «A/B», where A — the numerator, and B — the denominator. If the required probability equals to zero, output «0/1». If the required probability equals to 1, output «1/1».

Examples

Input

4 2

Output

1/2

Note

Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void Func(int c) {
  if (c == 2) {
    cout << "1/3";
  } else if (c == 3) {
    cout << "1/2";
  } else if (c == 4) {
    cout << "2/3";
  } else if (c == 6) {
    cout << "1/1";
  } else {
    cout << c << "/6";
  }
}
int main() {
  int a, b, c;
  cin >> a >> b;
  if (a > b) {
    c = 7 - a;
    Func(c);
  } else {
    c = 7 - b;
    Func(c);
  }
}

```


### Prompt

Please create a solution in cpp to the following problem:

In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other inflorescence with number i (i > 1) is situated at the top of branch, which bottom is pi-th inflorescence and pi < i.

Once tree starts fruiting, there appears exactly one apple in each inflorescence. The same moment as apples appear, they start to roll down along branches to the very base of tree. Each second all apples, except ones in first inflorescence simultaneously roll down one branch closer to tree base, e.g. apple in a-th inflorescence gets to pa-th inflorescence. Apples that end up in first inflorescence are gathered by Arcady in exactly the same moment. Second peculiarity of this tree is that once two apples are in same inflorescence they annihilate. This happens with each pair of apples, e.g. if there are 5 apples in same inflorescence in same time, only one will not be annihilated and if there are 8 apples, all apples will be annihilated. Thus, there can be no more than one apple in each inflorescence in each moment of time.

Help Arcady with counting number of apples he will be able to collect from first inflorescence during one harvest.

Input

First line of input contains single integer number n (2 ≤ n ≤ 100 000) — number of inflorescences.

Second line of input contains sequence of n - 1 integer numbers p2, p3, ..., pn (1 ≤ pi < i), where pi is number of inflorescence into which the apple from i-th inflorescence rolls down.

Output

Single line of output should contain one integer number: amount of apples that Arcady will be able to collect from first inflorescence during one harvest.

Examples

Input

3
1 1

Output

1

Input

5
1 2 2 2

Output

3

Input

18
1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4

Output

4

Note

In first example Arcady will be able to collect only one apple, initially situated in 1st inflorescence. In next second apples from 2nd and 3rd inflorescences will roll down and annihilate, and Arcady won't be able to collect them.

In the second example Arcady will be able to collect 3 apples. First one is one initially situated in first inflorescence. In a second apple from 2nd inflorescence will roll down to 1st (Arcady will collect it) and apples from 3rd, 4th, 5th inflorescences will roll down to 2nd. Two of them will annihilate and one not annihilated will roll down from 2-nd inflorescence to 1st one in the next second and Arcady will collect it.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, sbor = 1, p;
int a[100010];
int b[100010];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> p;
    a[i] = a[--p] + 1;
    b[a[i]]++;
  }
  for (int i = 1; i < n; i++) sbor = sbor + b[i] % 2;
  cout << sbor << ' ';
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

From "ftying rats" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons?

The upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.

Piteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to "desigm" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.

Input

The first line of input data contains a single integer n (5 ≤ n ≤ 10).

The second line of input data contains n space-separated integers a_i (1 ≤ a_i ≤ 32).

Output

Output a single integer.

Example

Input

5
1 2 3 4 5

Output

4

Note

We did not proofread this statement at all.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long t = INT_MAX;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    t = min(t, a[i]);
  }
  cout << 2 + (t ^ a[2]);
  return 0;
}

```


### Prompt

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

Rabbits and cats are competing. The rules are as follows.

First, each of the two animals wrote n2 integers on a piece of paper in a square with n rows and n columns, and drew one card at a time. Shuffle two cards and draw them one by one alternately. Each time a card is drawn, the two will mark it if the same number as the card is written on their paper. The winning condition is that the number of "a set of n numbers with a mark and is in a straight line" is equal to or greater than the number of playing cards drawn at the beginning.

Answer which of the rabbit and the cat wins up to the mth card given. However, the victory or defeat is when only one of the two cards meets the victory condition when a certain card is drawn and marked. In other cases, it is a draw. Cards may be drawn even after one of them meets the victory conditions, but this does not affect the victory or defeat.

Input

Line 1: “nuvm” (square size, number of rabbit playing cards, number of cat playing cards, number of cards drawn) 2- (N + 1) Line: n2 numbers that the rabbit writes on paper ( N + 2)-(2N + 1) Line: n2 numbers that the cat writes on paper (2N + 2)-(2N + M + 1) Line: m cards drawn
1 ≤ n ≤ 500
1 ≤ u, v ≤ 13
1 ≤ m ≤ 100 000
1 ≤ (number written) ≤ 1 000 000

The number of n2 rabbits write on paper, the number of n2 cats write on paper, and the number of m cards drawn are different.

Output

Output "USAGI" if the rabbit wins, "NEKO" if the cat wins, and "DRAW" if the tie, each in one line.

Examples

Input

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

Output

USAGI

Input

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

Output

DRAW

### Response

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

int N, U[2], M, A[2][500][500];
int sum[2][2][500], f[2], g[2];
vector< tuple< int, int, int > > memo[1000001];
int main()
{

  scanf("%d %d %d %d", &N, &U[0], &U[1], &M);

  for(int k = 0; k < 2; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
        scanf("%d", &A[k][i][j]);
        memo[A[k][i][j]].emplace_back(k, i, j);
      }
      sum[k][0][i] = sum[k][1][i] = N;
    }
    f[k] = g[k] = N;
  }

  while(M--) {
    int num;
    scanf("%d", &num);
    for(auto& d : memo[num]) {
      int k, i, j;
      tie(k, i, j) = d;
      U[k] -= --sum[k][0][i] == 0;
      if(N > 1) {
        U[k] -= --sum[k][1][j] == 0;
        if(i == j) U[k] -= --f[k] == 0;
        if(j == N - i - 1) U[k] -= --g[k] == 0;
      }
    }
    if(U[0] <= 0 || U[1] <= 0) {
      if(U[0] <= 0 && U[1] <= 0) break;
      puts(U[1] <= 0 ? "NEKO" : "USAGI");
      exit(0);
    }
  }
  puts("DRAW");
}
```


### Prompt

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

Cucumber boy is fan of Kyubeat, a famous music game.

Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel.

Each panel has a timing to press (the preffered time when a player should press it), and Cucumber boy is able to press at most k panels in a time with his one hand. Cucumber boy is trying to press all panels in perfect timing, that is he wants to press each panel exactly in its preffered time. If he cannot press the panels with his two hands in perfect timing, his challenge to press all the panels in perfect timing will fail.

You are given one scene of Kyubeat's panel from the music Cucumber boy is trying. Tell him is he able to press all the panels in perfect timing.

Input

The first line contains a single integer k (1 ≤ k ≤ 5) — the number of panels Cucumber boy can press with his one hand.

Next 4 lines contain 4 characters each (digits from 1 to 9, or period) — table of panels. If a digit i was written on the panel, it means the boy has to press that panel in time i. If period was written on the panel, he doesn't have to press that panel.

Output

Output "YES" (without quotes), if he is able to press all the panels in perfect timing. If not, output "NO" (without quotes).

Examples

Input

1
.135
1247
3468
5789

Output

YES

Input

5
..1.
1111
..1.
..1.

Output

YES

Input

1
....
12.1
.2..
.2..

Output

NO

Note

In the third sample boy cannot press all panels in perfect timing. He can press all the panels in timing in time 1, but he cannot press the panels in time 2 in timing with his two hands.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, i, j, tmp = 0;
  char arr[4][4];
  int a[10] = {0};
  cin >> k;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++) {
      cin >> arr[i][j];
      if (arr[i][j] != '.') a[arr[i][j] - '0']++;
    }
  for (i = 1; i <= 9; i++)
    if (a[i] > 2 * k) {
      cout << "NO";
      tmp = 1;
      break;
    }
  if (tmp == 0) cout << "YES";
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

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
// A - Curtain
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b; cin>>a>>b;
	cout<< max(0, a-(b*2)) <<endl;
}
```


### Prompt

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

You are given a tree with N vertices. The vertices are numbered 0 through N-1, and the edges are numbered 1 through N-1. Edge i connects Vertex x_i and y_i, and has a value a_i. You can perform the following operation any number of times:

* Choose a simple path and a non-negative integer x, then for each edge e that belongs to the path, change a_e by executing a_e ← a_e ⊕ x (⊕ denotes XOR).

Your objective is to have a_e = 0 for all edges e. Find the minimum number of operations required to achieve it.

Constraints

* 2 ≤ N ≤ 10^5
* 0 ≤ x_i,y_i ≤ N-1
* 0 ≤ a_i ≤ 15
* The given graph is a tree.
* All input values are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_{N-1} y_{N-1} a_{N-1}

Output

Find the minimum number of operations required to achieve the objective.

Examples

Input

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

Output

3

Input

2
1 0 0

Output

0

### Response

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

int n, sum[100005], cnt[16], dp[1 << 15];

int main() {
	scanf("%d", &n);
	for (int i = 1, u, v, c; i < n; ++i) {
		scanf("%d%d%d", &u, &v, &c);
		sum[u] ^= c, sum[v] ^= c;
	}
	for (int i = 0; i < n; ++i) ++cnt[sum[i]];
	int ans = 0, buc = 0;
	for (int i = 1; i < 16; ++i) ans += cnt[i] >> 1, buc |= (cnt[i] & 1) << i - 1;
	for (int s = 1; s <= buc; ++s) {
		int t = 0;
		for (int i = 0; i < 15; ++i)
			if (s >> i & 1) ++dp[s], t ^= i + 1;
		dp[s] -= !t;
		for (int t = s - 1 & s; t; t = t - 1 & s)
			dp[s] = min(dp[s], dp[t] + dp[s ^ t]);
	}
	printf("%d\n", ans + dp[buc]);
}

```


### Prompt

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

Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x1 = a, another one is in the point x2 = b.

Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes according to the following rules: the first move increases the tiredness by 1, the second move increases the tiredness by 2, the third — by 3 and so on. For example, if a friend moves first to the left, then to the right (returning to the same point), and then again to the left his tiredness becomes equal to 1 + 2 + 3 = 6.

The friends want to meet in a integer point. Determine the minimum total tiredness they should gain, if they meet in the same point.

Input

The first line contains a single integer a (1 ≤ a ≤ 1000) — the initial position of the first friend.

The second line contains a single integer b (1 ≤ b ≤ 1000) — the initial position of the second friend.

It is guaranteed that a ≠ b.

Output

Print the minimum possible total tiredness if the friends meet in the same point.

Examples

Input

3
4

Output

1

Input

101
99

Output

2

Input

5
10

Output

9

Note

In the first example the first friend should move by one to the right (then the meeting happens at point 4), or the second friend should move by one to the left (then the meeting happens at point 3). In both cases, the total tiredness becomes 1.

In the second example the first friend should move by one to the left, and the second friend should move by one to the right. Then they meet in the point 100, and the total tiredness becomes 1 + 1 = 2.

In the third example one of the optimal ways is the following. The first friend should move three times to the right, and the second friend — two times to the left. Thus the friends meet in the point 8, and the total tiredness becomes 1 + 2 + 3 + 1 + 2 = 9.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(), cout.tie();
  int a, b;
  float avg = 0;
  cin >> a >> b;
  avg = ceil((a + b) / 2);
  cout << (abs(avg - a) * (abs(avg - a) + 1) / 2) +
              (abs(b - avg) * (abs(b - avg) + 1)) / 2
       << endl;
  return 0;
}

```


### Prompt

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

Polycarp loves ciphers. He has invented his own cipher called repeating.

Repeating cipher is used for strings. To encrypt the string s=s_{1}s_{2} ... s_{m} (1 ≤ m ≤ 10), Polycarp uses the following algorithm:

  * he writes down s_1 ones,
  * he writes down s_2 twice,
  * he writes down s_3 three times,
  * ...
  * he writes down s_m m times.

For example, if s="bab" the process is: "b" → "baa" → "baabbb". So the encrypted s="bab" is "baabbb".

Given string t — the result of encryption of some string s. Your task is to decrypt it, i. e. find the string s.

Input

The first line contains integer n (1 ≤ n ≤ 55) — the length of the encrypted string. The second line of the input contains t — the result of encryption of some string s. It contains only lowercase Latin letters. The length of t is exactly n.

It is guaranteed that the answer to the test exists.

Output

Print such string s that after encryption it equals t.

Examples

Input

6
baabbb

Output

bab

Input

10
ooopppssss

Output

oops

Input

1
z

Output

z

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int first = 0;
  int inc = 1;
  for (; first < s.size();) {
    if (first >= s.size()) break;
    cout << s[first];
    first += inc;
    inc++;
  }
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

The Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:

  1. Only one disk can be moved at a time.
  2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.
  3. No disk may be placed on top of a smaller disk.

With three disks, the puzzle can be solved in seven moves. The minimum number of moves required to solve a Tower of Hanoi puzzle is 2n - 1, where n is the number of disks. (c) Wikipedia.

SmallY's puzzle is very similar to the famous Tower of Hanoi. In the Tower of Hanoi puzzle you need to solve a puzzle in minimum number of moves, in SmallY's puzzle each move costs some money and you need to solve the same puzzle but for minimal cost. At the beginning of SmallY's puzzle all n disks are on the first rod. Moving a disk from rod i to rod j (1 ≤ i, j ≤ 3) costs tij units of money. The goal of the puzzle is to move all the disks to the third rod.

In the problem you are given matrix t and an integer n. You need to count the minimal cost of solving SmallY's puzzle, consisting of n disks.

Input

Each of the first three lines contains three integers — matrix t. The j-th integer in the i-th line is tij (1 ≤ tij ≤ 10000; i ≠ j). The following line contains a single integer n (1 ≤ n ≤ 40) — the number of disks.

It is guaranteed that for all i (1 ≤ i ≤ 3), tii = 0.

Output

Print a single integer — the minimum cost of solving SmallY's puzzle.

Examples

Input

0 1 1
1 0 1
1 1 0
3

Output

7

Input

0 2 2
1 0 100
1 2 0
3

Output

19

Input

0 2 1
1 0 100
1 2 0
5

Output

87

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 50;
int cost[3][3];
long long f[MAX_N][3][3];
int n;
int main() {
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) scanf("%d", &cost[i][j]);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        int x = 3 - j - k;
        f[i][j][k] = f[i - 1][j][x] + cost[j][k] + f[i - 1][x][k];
        f[i][j][k] =
            min(f[i][j][k], f[i - 1][j][k] + cost[j][x] + f[i - 1][k][j] +
                                cost[x][k] + f[i - 1][j][k]);
      }
    }
  }
  printf("%I64d\n", f[n][0][2]);
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Given an n × n table T consisting of lowercase English letters. We'll consider some string s good if the table contains a correct path corresponding to the given string. In other words, good strings are all strings we can obtain by moving from the left upper cell of the table only to the right and down. Here's the formal definition of correct paths:

Consider rows of the table are numbered from 1 to n from top to bottom, and columns of the table are numbered from 1 to n from left to the right. Cell (r, c) is a cell of table T on the r-th row and in the c-th column. This cell corresponds to letter Tr, c.

A path of length k is a sequence of table cells [(r1, c1), (r2, c2), ..., (rk, ck)]. The following paths are correct:

  1. There is only one correct path of length 1, that is, consisting of a single cell: [(1, 1)];
  2. Let's assume that [(r1, c1), ..., (rm, cm)] is a correct path of length m, then paths [(r1, c1), ..., (rm, cm), (rm + 1, cm)] and [(r1, c1), ..., (rm, cm), (rm, cm + 1)] are correct paths of length m + 1.

We should assume that a path [(r1, c1), (r2, c2), ..., (rk, ck)] corresponds to a string of length k: Tr1, c1 + Tr2, c2 + ... + Trk, ck.

Two players play the following game: initially they have an empty string. Then the players take turns to add a letter to the end of the string. After each move (adding a new letter) the resulting string must be good. The game ends after 2n - 1 turns. A player wins by the following scenario:

  1. If the resulting string has strictly more letters "a" than letters "b", then the first player wins;
  2. If the resulting string has strictly more letters "b" than letters "a", then the second player wins;
  3. If the resulting string has the same number of letters "a" and "b", then the players end the game with a draw.

Your task is to determine the result of the game provided that both players played optimally well.

Input

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

Next n lines contain n lowercase English letters each — table T.

Output

In a single line print string "FIRST", if the first player wins, "SECOND", if the second player wins and "DRAW", if the game ends with a draw.

Examples

Input

2
ab
cd

Output

DRAW

Input

2
xa
ay

Output

FIRST

Input

3
aab
bcb
bac

Output

DRAW

Note

Consider the first sample:

Good strings are strings: a, ab, ac, abd, acd.

The first player moves first and adds letter a to the string, as there is only one good string of length 1. Then the second player can add b or c and the game will end with strings abd or acd, correspondingly. In the first case it will be a draw (the string has one a and one b), in the second case the first player wins. Naturally, in this case the second player prefers to choose letter b and end the game with a draw.

Consider the second sample:

Good strings are: x, xa, xay.

We can see that the game will end with string xay and the first player wins.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
const int INF = 16843009;
int n;
char a[N][N];
int memo[N + N][1 << N];
int dp(int d, int mask) {
  if (d == n + n - 1) return 0;
  int &ret = memo[d][mask];
  if (ret != INF) return ret;
  ret = d & 1 ? INF : -INF;
  for (char c = 'a'; c <= 'z'; ++c) {
    int newMask = 0;
    for (int i = 0; i <= d; ++i) {
      int j = d - i;
      if (j >= n || a[i][j] != c || !((mask >> i) & 1)) continue;
      newMask |= 1 << i;
      if (i + 1 < n) newMask |= 1 << (i + 1);
    }
    if (!newMask) continue;
    int score = (c == 'a') - (c == 'b');
    if (d & 1)
      ret = min(ret, dp(d + 1, newMask) + score);
    else
      ret = max(ret, dp(d + 1, newMask) + score);
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf(" %c", &a[i][j]);
    }
  }
  memset(memo, 1, sizeof memo);
  int ans = dp(0, 1);
  if (ans > 0)
    puts("FIRST");
  else if (ans < 0)
    puts("SECOND");
  else
    puts("DRAW");
  return 0;
}

```


### Prompt

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

Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi.

How many ways are there to choose K consecutive integers?

Constraints

* All values in input are integers.
* 1 \leq K \leq N \leq 50

Input

Input is given from Standard Input in the following format:

N K

Output

Print the answer.

Examples

Input

3 2

Output

2

Input

13 3

Output

11

### Response

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

int main() {
  int n,k;
  cin>>n>>k;
  n=n-k+1;
  cout<<n;
}
```


### Prompt

Develop a solution in cpp to the problem described below:

Example

Input

2 3 1 3 1 0

Output

2

### Response

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int M,N,m0,n0,md,nd;

int main(){
  cin>>M>>N>>m0>>md>>n0>>nd;
  vector<ll> ms,summ(M+1,0);
  rep(i,M){
    ms.push_back(m0);
    m0=(m0*58+md)%(N+1);
  }
  sort(all(ms));
  rep(i,M)summ[i+1]=summ[i]+ms[i];

  vector<ll> ns,sumn(N+1,0);
  rep(i,N){
    ns.push_back(n0);
    n0=(n0*58+nd)%(M+1);
  }
  sort(all(ns));
  rep(i,N)sumn[i+1]=sumn[i]+ns[i];

  ll res=1e18;
  rep(i,M+1){
    ll j=lower_bound(all(ns),M-i)-ns.begin();
    minch(res,summ[i]+sumn[j]+(M-i)*(N-j));
  }
  cout<<res<<endl;

  return 0;
}

```