### Prompt

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

Dima and Anya love playing different games. Now Dima has imagined a new game that he wants to play with Anya.

Dima writes n pairs of integers on a piece of paper (li, ri) (1 ≤ li < ri ≤ p). Then players take turns. On his turn the player can do the following actions:

  1. choose the number of the pair i (1 ≤ i ≤ n), such that ri - li > 2;
  2. replace pair number i by pair <image> or by pair <image>. Notation ⌊x⌋ means rounding down to the closest integer.

The player who can't make a move loses.

Of course, Dima wants Anya, who will move first, to win. That's why Dima should write out such n pairs of integers (li, ri) (1 ≤ li < ri ≤ p), that if both players play optimally well, the first one wins. Count the number of ways in which Dima can do it. Print the remainder after dividing the answer by number 1000000007 (109 + 7).

Two ways are considered distinct, if the ordered sequences of the written pairs are distinct.

Input

The first line contains two integers n, p (1 ≤ n ≤ 1000, 1 ≤ p ≤ 109). The numbers are separated by a single space.

Output

In a single line print the remainder after dividing the answer to the problem by number 1000000007 (109 + 7).

Examples

Input

2 2

Output

0

Input

4 4

Output

520

Input

100 1000

Output

269568947

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int gi() {
  int w = 0;
  bool q = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') q = 0, c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return q ? w : -w;
}
const int N = 1e5;
const int lim = 1e9;
int L[N], R[N], sg[N];
inline void init() {
  int m = 1, a = 1, b = 1;
  L[1] = 1, R[1] = 2;
  while (R[m] < lim) {
    while (R[a] * 3 + 2 <= R[m]) a++;
    while (R[b] / 2 * 3 + (R[b] & 1) <= R[m]) b++;
    L[m + 1] = R[m] + 1;
    R[++m] = min(R[a] * 3 + 2, R[b] / 2 * 3 + (R[b] & 1));
    if (!sg[a] || !sg[b]) sg[m] = 1 + (sg[a] == 1 || sg[b] == 1);
    if (sg[m] == sg[m - 1]) R[m - 1] = R[m], m--;
  }
  L[m + 1] = 1 << 30;
}
int main() {
  init();
  const int mod = 1e9 + 7;
  int n = gi(), p = gi(), i, t, s[3] = {}, f[4] = {}, g[4] = {};
  for (i = 1; L[i] < p; i++) {
    t = min(R[i], p - 1);
    s[sg[i]] = (s[sg[i]] + 1LL * (t - L[i] + 1) * (p - L[i] + p - t) / 2) % mod;
  }
  for (i = 0; i < 3; i++)
    if (s[i] < 0) s[i] += mod;
  f[0] = 1;
  while (n--) {
    for (i = 0; i < 4; i++) g[i] = f[i], f[i] = 0;
    for (i = 0; i < 4; i++)
      for (t = 0; t < 3; t++) f[i ^ t] = (f[i ^ t] + 1LL * g[i] * s[t]) % mod;
  }
  printf("%d\n", ((f[1] + f[2]) % mod + f[3]) % mod);
  return 0;
}

```


### Prompt

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

Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarpus has already accidentally removed the user IDs corresponding to the requests from the database. Thus, it is now impossible to determine whether any two requests are made by the same person or by different people.

But wait, something is still known, because that day a record was achieved — M simultaneous users online! In addition, Polycarpus believes that if a user made a request at second s, then he was online for T seconds after that, that is, at seconds s, s + 1, s + 2, ..., s + T - 1. So, the user's time online can be calculated as the union of time intervals of the form [s, s + T - 1] over all times s of requests from him.

Guided by these thoughts, Polycarpus wants to assign a user ID to each request so that:

  * the number of different users online did not exceed M at any moment,
  * at some second the number of distinct users online reached value M,
  * the total number of users (the number of distinct identifiers) was as much as possible.

Help Polycarpus cope with the test.

Input

The first line contains three integers n, M and T (1 ≤ n, M ≤ 20 000, 1 ≤ T ≤ 86400) — the number of queries, the record number of online users and the time when the user was online after a query was sent. Next n lines contain the times of the queries in the format "hh:mm:ss", where hh are hours, mm are minutes, ss are seconds. The times of the queries follow in the non-decreasing order, some of them can coincide. It is guaranteed that all the times and even all the segments of type [s, s + T - 1] are within one 24-hour range (from 00:00:00 to 23:59:59).

Output

In the first line print number R — the largest possible number of distinct users. The following n lines should contain the user IDs for requests in the same order in which the requests are given in the input. User IDs must be integers from 1 to R. The requests of the same user must correspond to the same identifiers, the requests of distinct users must correspond to distinct identifiers. If there are multiple solutions, print any of them. If there is no solution, print "No solution" (without the quotes).

Examples

Input

4 2 10
17:05:53
17:05:58
17:06:01
22:39:47

Output

3
1
2
2
3

Input

1 2 86400
00:00:00

Output

No solution

Note

Consider the first sample. The user who sent the first request was online from 17:05:53 to 17:06:02, the user who sent the second request was online from 17:05:58 to 17:06:07, the user who sent the third request, was online from 17:06:01 to 17:06:10. Thus, these IDs cannot belong to three distinct users, because in that case all these users would be online, for example, at 17:06:01. That is impossible, because M = 2. That means that some two of these queries belonged to the same user. One of the correct variants is given in the answer to the sample. For it user 1 was online from 17:05:53 to 17:06:02, user 2 — from 17:05:58 to 17:06:10 (he sent the second and third queries), user 3 — from 22:39:47 to 22:39:56.

In the second sample there is only one query. So, only one user visited the network within the 24-hour period and there couldn't be two users online on the network simultaneously. (The time the user spent online is the union of time intervals for requests, so users who didn't send requests could not be online in the network.)

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (int i = 0; i < v.size(); i++)
    os << v[i] << (i + 1 < v.size() ? ", " : "");
  os << "}";
  return os;
}
class range {
  struct Iterator {
    int val, inc;
    int operator*() { return val; }
    bool operator!=(Iterator& rhs) { return val < rhs.val; }
    void operator++() { val += inc; }
  };
  Iterator i, n;

 public:
  range(int e) : i({0, 1}), n({e, 1}) {}
  range(int b, int e) : i({b, 1}), n({e, 1}) {}
  range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {}
  Iterator& begin() { return i; }
  Iterator& end() { return n; }
};
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }
void iostream_init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(12);
}
int time(string s) {
  for (char& c : s)
    if (c == ':') c = ' ';
  stringstream ss(s);
  int h, m, c;
  ss >> h >> m >> c;
  return 60 * 60 * h + 60 * m + c;
}
int main() {
  iostream_init();
  int N, M, T;
  while (cin >> N >> M >> T) {
    vector<int> t(N);
    for (int i = 0; i < (int)(N); ++i) {
      string s;
      cin >> s;
      t[i] = time(s);
    }
    vector<int> b, e;
    {
      int last = 0;
      for (int i = 0; i < (int)(N); ++i) {
        bool update = false;
        while (last < N && t[last] < t[i] + T) {
          update = true;
          last++;
        }
        if (update) {
          b.push_back(i);
          e.push_back(last);
        }
      }
    }
    int L = b.size();
    bool exist = false;
    for (int i = 0; i < (int)(L); ++i)
      if (e[i] - b[i] >= M) exist = true;
    if (!exist) {
      cout << "No solution" << endl;
      continue;
    }
    vector<int> ans(N);
    int last = 0;
    int start = 0;
    vector<int> cnt(L);
    for (int i = 0; i < N; i++) {
      bool add_ok = true;
      while (start < L && e[start] <= i) start++;
      for (int j = start; j < L; j++) {
        if (i < b[j]) break;
        if (cnt[j] == M) add_ok = false;
      }
      if (add_ok) {
        ans[i] = ++last;
        for (int j = start; j < L; j++) {
          if (i < b[j]) break;
          cnt[j]++;
        }
      } else {
        ans[i] = last;
        for (int j = start; j < L; j++) {
          if (i < b[j]) break;
          if (b[j] == i) cnt[j]++;
        }
      }
    }
    cout << last << endl;
    for (int i = 0; i < (int)(N); ++i) cout << ans[i] << endl;
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.

An integer greater than 1 is composite, if it is not prime, i.e. if it has positive divisors not equal to 1 and the integer itself.

Input

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

q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.

Output

For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.

Examples

Input

1
12

Output

3

Input

2
6
8

Output

1
2

Input

3
1
2
3

Output

-1
-1
-1

Note

12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.

8 = 4 + 4, 6 can't be split into several composite summands.

1, 2, 3 are less than any composite number, so they do not have valid splittings.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 1, msiz = 2, mod = 1e9 + 7, inf = 1e18;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int x;
    cin >> x;
    if (x < 3)
      cout << -1;
    else if (x % 2 == 0)
      cout << x / 4;
    else if (x % 4 == 1) {
      if (x == 5)
        cout << -1;
      else
        cout << x / 4 - 1;
    } else {
      if (x < 12)
        cout << -1;
      else
        cout << x / 4 - 1;
    }
    cout << endl;
  }
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Anton likes to play chess, and so does his friend Danik.

Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.

Now Anton wonders, who won more games, he or Danik? Help him determine this.

Input

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

The second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.

Output

If Anton won more games than Danik, print "Anton" (without quotes) in the only line of the output.

If Danik won more games than Anton, print "Danik" (without quotes) in the only line of the output.

If Anton and Danik won the same number of games, print "Friendship" (without quotes).

Examples

Input

6
ADAAAA

Output

Anton

Input

7
DDDAADA

Output

Danik

Input

6
DADADA

Output

Friendship

Note

In the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is "Anton".

In the second sample, Anton won 3 games and Danik won 4 games, so the answer is "Danik".

In the third sample, both Anton and Danik won 3 games and the answer is "Friendship".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int game, a = 0, d = 0;
  cin >> game;
  string x;
  cin >> x;
  for (int i = 0; i < x.size(); i++) {
    x[i] == 'D' ? d++ : a++;
  }
  if (a > d)
    cout << "Anton";
  else if (d > a)
    cout << "Danik";
  else
    cout << "Friendship";
  return 0;
}

```


### Prompt

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

The GCD table G of size n × n for an array of positive integers a of length n is defined by formula

<image>

Let us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both x and y, it is denoted as <image>. For example, for array a = {4, 3, 6, 2} of length 4 the GCD table will look as follows:

<image>

Given all the numbers of the GCD table G, restore array a.

Input

The first line contains number n (1 ≤ n ≤ 500) — the length of array a. The second line contains n2 space-separated numbers — the elements of the GCD table of G for array a.

All the numbers in the table are positive integers, not exceeding 109. Note that the elements are given in an arbitrary order. It is guaranteed that the set of the input data corresponds to some array a.

Output

In the single line print n positive integers — the elements of array a. If there are multiple possible solutions, you are allowed to print any of them.

Examples

Input

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

Output

4 3 6 2

Input

1
42

Output

42

Input

2
1 1 1 1

Output

1 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int val[1000111];
map<int, int> f;
vector<int> luu;
int gcd(int x, int y) {
  while (y > 0) {
    x %= y;
    swap(x, y);
  }
  return x;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1), _b = (n * n); i <= _b; ++i) {
    scanf("%d", &val[i]);
    f[val[i]]++;
  }
  sort(val + 1, val + n * n + 1);
  int m = 0;
  for (int i = (n * n), _b = (1); i >= _b; --i) {
    if (f[val[i]] > 0) {
      f[val[i]]--;
      for (int j = 0, _b = (luu.size()); j < _b; ++j)
        f[gcd(val[i], luu[j])] -= 2;
      luu.push_back(val[i]);
    }
  }
  for (int i = 0, _b = (luu.size()); i < _b; ++i) printf("%d ", luu[i]);
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Consider the following process. You have a binary string (a string where each character is either 0 or 1) w of length n and an integer x. You build a new binary string s consisting of n characters. The i-th character of s is chosen as follows:

  * if the character w_{i-x} exists and is equal to 1, then s_i is 1 (formally, if i > x and w_{i-x} =  1, then s_i =  1);
  * if the character w_{i+x} exists and is equal to 1, then s_i is 1 (formally, if i + x ≤ n and w_{i+x} =  1, then s_i =  1);
  * if both of the aforementioned conditions are false, then s_i is 0.

You are given the integer x and the resulting string s. Reconstruct the original string w.

Input

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

Each test case consists of two lines. The first line contains the resulting string s (2 ≤ |s| ≤ 10^5, each character of s is either 0 or 1). The second line contains one integer x (1 ≤ x ≤ |s| - 1).

The total length of all strings s in the input does not exceed 10^5.

Output

For each test case, print the answer on a separate line as follows:

  * if no string w can produce the string s at the end of the process, print -1;
  * otherwise, print the binary string w consisting of |s| characters. If there are multiple answers, print any of them.

Example

Input

3
101110
2
01
1
110
1

Output

111011
10
-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238463;
const long long int MOD = 1000000007;
list<long long> ls;
vector<long long> v, v1, v2, vv;
set<long long> s;
map<long long, long long> mp;
stack<char> st;
stack<long long> sti;
inline long long fp(long long bs, long long pw) {
  long long res = 1;
  while (pw > 0) {
    if (pw % 2 == 1) {
      res = (res * bs) % MOD;
    }
    bs = (bs * bs) % MOD;
    pw = pw / 2;
  }
  return res;
}
long long pp(long long bs, unsigned long long pw) {
  long long ans = 1;
  while (pw > 0) {
    if (pw & 1) ans = ans * bs;
    pw = pw >> 1;
    bs = bs * bs;
  }
  return ans;
}
bool ff22(const pair<long long, long long> &a,
          const pair<long long, long long> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, n, m, k, h, p, i, j, a, b, c, x, V, ind, sz,
      ans = 0, ans2, mx, sum = 0, ct = 0, ti, q, temp, t2, mn, ptr, ct1, ct2,
      cc, ln, diff;
  double kh = 4;
  bool fl;
  string s, sub, sorted, anss;
  cin >> t;
  while (t--) {
    ct = 0;
    cin >> s;
    n = s.length();
    sub = "";
    for (i = 0; i < n; i++) sub.push_back('1');
    cin >> x;
    for (i = 0; i < n; i++) {
      long long ms = i - x;
      long long pl = i + x;
      if (s[i] == '0') {
        if (ms >= 0) {
          sub[ms] = '0';
        }
        if (pl < n) {
          sub[pl] = '0';
        }
      }
    }
    for (i = 0; i < n; i++) {
      long long ms = i - x;
      long long pl = i + x;
      if (s[i] == '1') {
        if ((ms >= 0 && sub[ms] == '1') || (pl < n && sub[pl] == '1'))
          continue;
        else {
          ct++;
          break;
        }
      } else {
        if ((ms >= 0 && sub[ms] == '1') || (pl < n && sub[pl] == '1')) {
          ct++;
          break;
        }
      }
    }
    if (ct > 0)
      cout << -1 << endl;
    else
      cout << sub << endl;
  }
  return 0;
}

```


### Prompt

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

You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations:

  * Write parity(a) to the end of a. For example, <image>.
  * Remove the first character of a. For example, <image>. You cannot perform this operation if a is empty.

You can use as many operations as you want. The problem is, is it possible to turn a into b?

The parity of a 01-string is 1 if there is an odd number of "1"s in the string, and 0 otherwise.

Input

The first line contains the string a and the second line contains the string b (1 ≤ |a|, |b| ≤ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.

Output

Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.

Examples

Input

01011
0110

Output

YES

Input

0011
1110

Output

NO

Note

In the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string a, b;
int ans[2];
void dfs(string s, int pos) {
  cout << s << " " << pos << endl;
  if (s == "0") {
    ans[pos] |= 1;
    return;
  }
  if (s == "1") {
    ans[pos] |= 2;
    return;
  }
  dfs(s.substr(1), pos);
  int ct = count(s.begin(), s.end(), '1');
  if (ct % 2 == 0) dfs(s.substr(0, s.length() - 1), pos);
}
int main() {
  cin >> a >> b;
  int ac = count(a.begin(), a.end(), '1');
  int bc = count(b.begin(), b.end(), '1');
  if (ac % 2) {
    ac++;
  }
  if (ac >= bc)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

```


### Prompt

Create a solution in cpp for the following problem:

A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular (shortly, RBS) if it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, "", "(())" and "()()" are RBS and ")(" and "(()" are not.

We can see that each opening bracket in RBS is paired with some closing bracket, and, using this fact, we can define nesting depth of the RBS as maximum number of bracket pairs, such that the 2-nd pair lies inside the 1-st one, the 3-rd one — inside the 2-nd one and so on. For example, nesting depth of "" is 0, "()()()" is 1 and "()((())())" is 3.

Now, you are given RBS s of even length n. You should color each bracket of s into one of two colors: red or blue. Bracket sequence r, consisting only of red brackets, should be RBS, and bracket sequence, consisting only of blue brackets b, should be RBS. Any of them can be empty. You are not allowed to reorder characters in s, r or b. No brackets can be left uncolored.

Among all possible variants you should choose one that minimizes maximum of r's and b's nesting depth. If there are multiple solutions you can print any of them.

Input

The first line contains an even integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the length of RBS s.

The second line contains regular bracket sequence s (|s| = n, s_i ∈ \{"(", ")"\}).

Output

Print single string t of length n consisting of "0"-s and "1"-s. If t_i is equal to 0 then character s_i belongs to RBS r, otherwise s_i belongs to b.

Examples

Input

2
()

Output

11

Input

4
(())

Output

0101

Input

10
((()())())

Output

0110001111

Note

In the first example one of optimal solutions is s =  "\color{blue}{()}". r is empty and b =  "()". The answer is max(0, 1) = 1.

In the second example it's optimal to make s =  "\color{red}{(}\color{blue}{(}\color{red}{)}\color{blue}{)}". r = b =  "()" and the answer is 1.

In the third example we can make s =  "\color{red}{(}\color{blue}{((}\color{red}{)()}\color{blue}{)())}". r =  "()()" and b =  "(()())" and the answer is 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, m, i, j;
  string str;
  cin >> n;
  cin >> str;
  stack<int> s;
  int arr[n];
  j = 0;
  for (i = 0; i < n; i++) {
    if (str[i] == '(') {
      if (s.empty()) {
        s.push(i);
        arr[i] = 0;
      } else {
        arr[i] = (arr[s.top()] + 1) % 2;
        s.push(i);
      }
    } else {
      arr[i] = arr[s.top()];
      s.pop();
    }
  }
  for (i = 0; i < n; i++) cout << arr[i];
}

```


### Prompt

Please create a solution in CPP to the following problem:

Three planets X, Y and Z within the Alpha planetary system are inhabited with an advanced civilization. The spaceports of these planets are connected by interplanetary space shuttles. The flight scheduler should decide between 1, 2 and 3 return flights for every existing space shuttle connection. Since the residents of Alpha are strong opponents of the symmetry, there is a strict rule that any two of the spaceports connected by a shuttle must have a different number of flights.

For every pair of connected spaceports, your goal is to propose a number 1, 2 or 3 for each shuttle flight, so that for every two connected spaceports the overall number of flights differs.

You may assume that:

1) Every planet has at least one spaceport

2) There exist only shuttle flights between spaceports of different planets

3) For every two spaceports there is a series of shuttle flights enabling traveling between them

4) Spaceports are not connected by more than one shuttle

Input

The first row of the input is the integer number N (3 ≤ N ≤ 100 000), representing overall number of spaceports. The second row is the integer number M (2 ≤ M ≤ 100 000) representing number of shuttle flight connections.

Third row contains N characters from the set \\{X, Y, Z\}. Letter on I^{th} position indicates on which planet is situated spaceport I. For example, "XYYXZZ" indicates that the spaceports 0 and 3 are located at planet X, spaceports 1 and 2 are located at Y, and spaceports 4 and 5 are at Z.

Starting from the fourth row, every row contains two integer numbers separated by a whitespace. These numbers are natural numbers smaller than N and indicate the numbers of the spaceports that are connected. For example, "12\ 15" indicates that there is a shuttle flight between spaceports 12 and 15.

Output

The same representation of shuttle flights in separate rows as in the input, but also containing a third number from the set \{1, 2, 3\} standing for the number of shuttle flights between these spaceports.

Example

Input

10
15
XXXXYYYZZZ
0 4
0 5
0 6
4 1
4 8
1 7
1 9
7 2
7 5
5 3
6 2
6 9
8 2
8 3
9 3

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 100100;
int n, m;
int ed[N][3];
vector<int> g[N];
char t[N];
int h[N];
int par[N];
int col[N];
bool used[N];
void printAns() {
  for (int i = 0; i < m; i++) {
    int x = ed[i][2];
    x %= 3;
    while (x <= 0) x += 3;
    printf("%d %d %d\n", ed[i][0], ed[i][1], x);
  }
  exit(0);
}
int getOther(int id, int v) { return ed[id][0] ^ ed[id][1] ^ v; }
void dfsSolve(int v) {
  for (int id : g[v]) {
    int u = getOther(id, v);
    if (used[u]) continue;
    used[u] = true;
    dfsSolve(u);
    ed[id][2] = col[u];
    col[u] -= ed[id][2];
    col[v] -= ed[id][2];
    if (col[v] < 0) col[v] += 3;
  }
}
void solveOdd(int id) {
  int v = ed[id][0], u = ed[id][1];
  if (h[v] < h[u]) swap(v, u);
  vector<pair<int, int> > cyc;
  while (v != u) {
    cyc.push_back(make_pair(v, par[v]));
    v = getOther(par[v], v);
  }
  cyc.push_back(make_pair(u, id));
  int sz = (int)cyc.size();
  for (int i = 0; i < sz; i++) {
    42;
  }
  for (int i = 0; i < n; i++) col[i] = (int)(t[i] - 'X');
  for (int i = 0; i < sz; i++) used[cyc[i].first] = true;
  for (int i = 0; i < sz; i++) dfsSolve(cyc[i].first);
  int sum = 0;
  for (int i = 0; i < sz; i++) sum += col[cyc[i].first];
  if (sum & 1) sum += 3;
  sum /= 2;
  for (int i = 2; i < sz; i += 2) sum -= col[cyc[i].first];
  sum %= 3;
  if (sum < 0) sum += 3;
  ed[cyc[0].second][2] = sum;
  for (int i = 1; i < sz; i++) {
    int x = col[cyc[i].first] - ed[cyc[i - 1].second][2];
    if (x < 0) x += 3;
    ed[cyc[i].second][2] = x;
  }
  printAns();
}
void solveEven(int id) {
  int v = ed[id][0], u = ed[id][1];
  if (h[v] < h[u]) swap(v, u);
  vector<pair<int, int> > cyc;
  while (v != u) {
    cyc.push_back(make_pair(v, par[v]));
    v = getOther(par[v], v);
  }
  cyc.push_back(make_pair(u, id));
  int sz = (int)cyc.size();
  for (int i = 0; i < n; i++) col[i] = h[i] & 1;
  if (col[cyc[0].first] == 1) rotate(cyc.begin(), cyc.begin() + 1, cyc.end());
  for (int i = 0; i < sz; i++) used[cyc[i].first] = true;
  for (int i = 0; i < sz; i++) dfsSolve(cyc[i].first);
  int bal = 0;
  for (int i = 0; i < sz; i++) {
    int x = col[cyc[i].first];
    if (i % 2 == 0)
      bal += x;
    else
      bal -= x;
  }
  bal %= 3;
  if (bal < 0) bal += 3;
  if (bal == 1) {
    int v = cyc[0].first;
    col[v]--;
    if (col[v] < 0) col[v] += 3;
  } else if (bal == 2) {
    for (int i = 0; i < 3; i += 2) {
      int v = cyc[i].first;
      col[v]--;
      if (col[v] < 0) col[v] += 3;
    }
  }
  for (int i = 1; i < sz; i++) {
    int x = col[cyc[i].first] - ed[cyc[i - 1].second][2];
    if (x < 0) x += 3;
    ed[cyc[i].second][2] = x;
  }
  printAns();
}
void dfs1(int v) {
  for (int id : g[v]) {
    int u = getOther(id, v);
    if (h[u] == -1) {
      h[u] = h[v] + 1;
      par[u] = id;
      dfs1(u);
    } else if (h[v] % 2 == h[u] % 2) {
      solveOdd(id);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", t);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 2; j++) {
      scanf("%d", &ed[i][j]);
      g[ed[i][j]].push_back(i);
    }
  }
  for (int i = 0; i < n; i++) h[i] = -1;
  for (int i = 0; i < n; i++) {
    if ((int)g[i].size() == 1) {
      for (int j = 0; j < n; j++) col[j] = (int)(t[j] - 'X');
      dfsSolve(i);
      printAns();
    }
  }
  h[0] = 0;
  dfs1(0);
  for (int v = 0; v < n; v++) {
    for (int id : g[v]) {
      if (par[v] == id) continue;
      int u = getOther(id, v);
      if (h[u] < h[v]) solveEven(id);
    }
  }
  throw;
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.

The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination.

As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible.

Input

The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners.

Output

In the first line, print a single integer — the minimum number of problems the jury needs to prepare.

Examples

Input

1 10
7 2
1

Output

2

Input

2 2
2 1
2

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5, inf = 0x3f3f3f3f, mod = 1000000007;
void read() {}
template <typename T, typename... T2>
inline void read(T &x, T2 &...oth) {
  x = 0;
  int ch = getchar(), f = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  if (f) x = -x;
  read(oth...);
}
int dp[maxn];
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int c, d, n, m, k;
  cin >> c >> d >> n >> m >> k;
  for (int i = 1; i < n; i++) dp[i] = min(c, i * d);
  for (int i = n; i <= n * m - k; i++)
    dp[i] = min(dp[i - n] + c, dp[i - 1] + d);
  cout << dp[n * m - k] << endl;
  return 0;
}

```


### Prompt

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

Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m columns. For example, in a 3 × 5 table there are 15 squares with side one, 8 squares with side two and 3 squares with side three. The total number of distinct squares in a 3 × 5 table is 15 + 8 + 3 = 26.

Input

The first line of the input contains a single integer x (1 ≤ x ≤ 1018) — the number of squares inside the tables Spongebob is interested in.

Output

First print a single integer k — the number of tables with exactly x distinct squares inside.

Then print k pairs of integers describing the tables. Print the pairs in the order of increasing n, and in case of equality — in the order of increasing m.

Examples

Input

26

Output

6
1 26
2 9
3 5
5 3
9 2
26 1

Input

2

Output

2
1 2
2 1

Input

8

Output

4
1 8
2 3
3 2
8 1

Note

In a 1 × 2 table there are 2 1 × 1 squares. So, 2 distinct squares in total.

<image>

In a 2 × 3 table there are 6 1 × 1 squares and 2 2 × 2 squares. That is equal to 8 squares in total.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
int dxx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
int dyy[] = {0, +1, 0, -1, +1, -1, +1, -1};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
vector<pair<long long, long long> > ans;
int main() {
  long long x, i, sz = 0, l, y;
  scanf("%lld", &x);
  l = min(x, 10000000LL);
  for (i = 1; i <= l; i++) {
    y = x * 6LL;
    if (y % i) continue;
    y /= i;
    if (y % (i + 1)) continue;
    y /= (i + 1);
    y += (i - 1);
    if (y % 3) continue;
    y /= 3;
    if (y < i) continue;
    ans.push_back(make_pair(i, y));
    if (i == y)
      sz++;
    else
      sz += 2;
  }
  printf("%lld\n", sz);
  for (i = 0; i < ans.size(); i++)
    printf("%lld %lld\n", ans[i].first, ans[i].second);
  for (i = ans.size() - 1; ~i; i--)
    if (ans[i].first != ans[i].second)
      printf("%lld %lld\n", ans[i].second, ans[i].first);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

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

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

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

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

Input

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

Output

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

Examples

Input

1033

Output

33

Input

10

Output

0

Input

11

Output

-1

Note

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline long long ma(long long a, long long b) { return ((a - b > 0) ? a : b); }
inline long long mi(long long a, long long b) { return ((a - b > 0) ? b : a); }
long long dp[200005], ar[200005];
vector<long long> v;
inline long long solve(long long id, long long cnt, string &s, string &s2) {
  vector<long long> v;
  string s1;
  for (long long(i) = (s.size() - 1); (i) >= (0); (i)--) {
    if (v.size() >= cnt) break;
    if ((s[i] - '0') % 3 == id) v.push_back(i);
  }
  for (long long(i) = (0); (i) < (s.size()); (i)++) {
    long long flag = 0;
    for (long long(j) = (0); (j) < (v.size()); (j)++) {
      if (i == v[j]) flag = 1;
    }
    if (flag == 0) s1 += s[i];
  }
  long long flag = 0;
  id = -1;
  for (long long(i) = (0); (i) < (s1.size()); (i)++) {
    if ((s1[i] - '0') != 0) {
      id = i;
      flag = 1;
      break;
    }
  }
  if (v.size() != 0 && v.size() == cnt) {
    if (flag == 0) s1.size() != 0 ? s2 += '0' : s2;
    if (flag == 1)
      for (long long(i) = (id); (i) < (s1.size()); (i)++) s2 += s1[i];
  }
  return s2.size();
}
int main() {
  string s, s1, s2, s3;
  cin >> s;
  for (long long(i) = (0); (i) < (s.size()); (i)++) dp[(s[i] - '0') % 3]++;
  long long a = dp[1] % 3, b = dp[2] % 3;
  long long id, cnt;
  if (a == 0) {
    if (b == 0) cout << s << endl;
    if (b == 1) {
      long long ta1 = solve(2, 1, s, s1), ta2 = solve(1, 2, s, s2);
      (ta1 > ta2) ? s3 = s1 : s3 = s2;
      (s3.size() != 0) ? cout << s3 << "\n" : cout << -1 << "\n";
    }
    if (b == 2) {
      long long ta1 = solve(2, 2, s, s1), ta2 = solve(1, 1, s, s2);
      (ta1 > ta2) ? s3 = s1 : s3 = s2;
      (s3.size() != 0) ? cout << s3 << "\n" : cout << -1 << "\n";
    }
  }
  if (a == 1) {
    if (b == 1) cout << s << endl;
    if (b == 0) {
      long long ta1 = solve(1, 1, s, s1), ta2 = solve(2, 2, s, s2);
      (ta1 > ta2) ? s3 = s1 : s3 = s2;
      (s3.size() != 0) ? cout << s3 << "\n" : cout << -1 << "\n";
    }
    if (b == 2) {
      long long ta1 = solve(2, 1, s, s1), ta2 = solve(1, 2, s, s2);
      (ta1 > ta2) ? s3 = s1 : s3 = s2;
      (s3.size() != 0) ? cout << s3 << "\n" : cout << -1 << "\n";
    }
  }
  if (a == 2) {
    if (b == 0) {
      long long ta1 = solve(1, 2, s, s1), ta2 = solve(2, 1, s, s2);
      (ta1 > ta2) ? s3 = s1 : s3 = s2;
      (s3.size() != 0) ? cout << s3 << "\n" : cout << -1 << "\n";
    }
    if (b == 1) {
      long long ta1 = solve(1, 1, s, s1), ta2 = solve(2, 2, s, s2);
      (ta1 > ta2) ? s3 = s1 : s3 = s2;
      (s3.size() != 0) ? cout << s3 << "\n" : cout << -1 << "\n";
    }
    if (b == 2) cout << s << endl;
  }
  return 0;
}

```


### Prompt

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

A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.

Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number ti:

  * If Petya has visited this room before, he writes down the minute he was in this room last time;
  * Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i.

Initially, Petya was in one of the rooms at minute 0, he didn't write down number t0.

At some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — then number of notes in Petya's logbook.

The second line contains n non-negative integers t1, t2, ..., tn (0 ≤ ti < i) — notes in the logbook.

Output

In the only line print a single integer — the minimum possible number of rooms in Paris catacombs.

Examples

Input

2
0 0

Output

2

Input

5
0 1 0 1 3

Output

3

Note

In the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.

In the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 5;
long long a[N], s[N] = {0}, pos[N] = {0};
long long n, cnt = 1;
vector<long long> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = 0; i < (n); ++i) cin >> a[i + 1];
  for (int i = n; i > 0; i--) s[a[i]]++;
  pos[0] = 1;
  for (int i = 1; i <= n; i++) {
    s[a[i]]--;
    if (pos[a[i]]) {
      if (s[a[i]] == 0) {
        ans.push_back(pos[a[i]]);
        pos[i] = pos[a[i]];
        pos[a[i]] = 0;
        continue;
      }
    }
    cnt++;
    ans.push_back(cnt);
    pos[i] = cnt;
  }
  cout << cnt << endl;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

The pandemic is upon us, and the world is in shortage of the most important resource: toilet paper. As one of the best prepared nations for this crisis, BubbleLand promised to help all other world nations with this valuable resource. To do that, the country will send airplanes to other countries carrying toilet paper.

In BubbleLand, there are N toilet paper factories, and N airports. Because of how much it takes to build a road, and of course legal issues, every factory must send paper to only one airport, and every airport can only take toilet paper from one factory.

Also, a road can't be built between all airport-factory pairs, again because of legal issues. Every possible road has number d given, number of days it takes to build that road.

Your job is to choose N factory-airport pairs, such that if the country starts building all roads at the same time, it takes the least amount of days to complete them.

Input

The first line contains two integers N (1 ≤ N ≤ 10^4) - number of airports/factories, and M (1 ≤ M ≤ 10^5) - number of available pairs to build a road between.

On next M lines, there are three integers u, v (1 ≤ u,v ≤ N), d (1 ≤ d ≤ 10^9) - meaning that you can build a road between airport u and factory v for d days.

Output

If there are no solutions, output -1. If there exists a solution, output the minimal number of days to complete all roads, equal to maximal d among all chosen roads.

Example

Input

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

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
class BPGraph {
 public:
  long long n;
  long long m;
  vector<long long> *adj;
  long long *pair_left;
  long long *pair_right;
  long long *dis;
  BPGraph(long long n, long long m) {
    this->n = n;
    this->m = m;
    adj = new vector<long long>[n + 1];
  }
  void add_Edge(long long u, long long v) { adj[u].push_back(v); }
  bool bfs() {
    queue<long long> q;
    dis[0] = inf;
    for (long long i = 1; i <= n; i++) {
      if (pair_left[i] == 0) {
        dis[i] = 0;
        q.push(i);
      } else {
        dis[i] = inf;
      }
    }
    while (!q.empty()) {
      long long u = q.front();
      q.pop();
      if (dis[u] < dis[0]) {
        for (long long v : adj[u]) {
          long long pair = pair_right[v];
          if (dis[pair] == inf) {
            dis[pair] = dis[u] + 1;
            q.push(pair);
          }
        }
      }
    }
    return (dis[0] < inf);
  }
  bool dfs(long long u) {
    if (!u) return true;
    for (long long v : adj[u]) {
      long long pair = pair_right[v];
      if (dis[pair] == dis[u] + 1) {
        if (dfs(pair)) {
          pair_left[u] = v;
          pair_right[v] = u;
          return true;
        }
      }
    }
    return false;
  }
  long long hopcroft_karp() {
    pair_left = new long long[n + 1];
    pair_right = new long long[m + 1];
    dis = new long long[n + 1];
    for (long long i = 0; i <= n; i++) {
      pair_left[i] = 0;
    }
    for (long long i = 0; i <= m; i++) {
      pair_right[i] = 0;
    }
    long long ans = 0;
    while (bfs()) {
      for (long long u = 1; u <= n; u++) {
        if (!pair_left[u] && dfs(u)) {
          ans++;
        }
      }
    }
    return ans;
  }
};
int32_t main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, pair<long long, long long>>> edge;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    long long t;
    cin >> t;
    edge.push_back({t, {a, b}});
  }
  sort(edge.begin(), edge.end());
  long long low = 0, high = inf, ans = inf;
  while (low <= high) {
    long long mid = low + (high - low) / 2;
    BPGraph g(n, n);
    for (long long i = 0; i < m; i++) {
      if (edge[i].first > mid) break;
      g.add_Edge(edge[i].second.first, edge[i].second.second);
    }
    if (g.hopcroft_karp() == n) {
      ans = min(ans, mid);
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  if (ans < inf)
    cout << ans << endl;
  else
    cout << -1 << endl;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t.

Help George! Write a program that will, given time s and t, determine the time p when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see the second test sample).

Input

The first line contains current time s as a string in the format "hh:mm". The second line contains time t in the format "hh:mm" — the duration of George's sleep. It is guaranteed that the input contains the correct time in the 24-hour format, that is, 00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59.

Output

In the single line print time p — the time George went to bed in the format similar to the format of the time in the input.

Examples

Input

05:50
05:44

Output

00:06

Input

00:00
01:00

Output

23:00

Input

00:01
00:00

Output

00:01

Note

In the first sample George went to bed at "00:06". Note that you should print the time only in the format "00:06". That's why answers "0:06", "00:6" and others will be considered incorrect.

In the second sample, George went to bed yesterday.

In the third sample, George didn't do to bed at all.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h1, h2, m1, m2, h3, m3;
  char c;
  cin >> h1 >> c >> m1;
  cin >> h2 >> c >> m2;
  if (m1 - m2 < 0) {
    h1--;
    m3 = 60 - (m2 - m1);
  } else
    m3 = m1 - m2;
  if (h1 - h2 < 0)
    h3 = 24 - (h2 - h1);
  else
    h3 = h1 - h2;
  if (h3 / 10 == 0)
    cout << 0 << h3;
  else
    cout << h3;
  cout << ":";
  if (m3 / 10 == 0)
    cout << 0 << m3;
  else
    cout << m3;
  return 0;
}

```


### Prompt

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

One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm  ×  b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle, and cutting the excess part.

<image>

After making a paper ship from the square piece, Vasya looked on the remaining (a - b) mm  ×  b mm strip of paper. He got the idea to use this strip of paper in the same way to make an origami, and then use the remainder (if it exists) and so on. At the moment when he is left with a square piece of paper, he will make the last ship from it and stop.

Can you determine how many ships Vasya will make during the lesson?

Input

The first line of the input contains two integers a, b (1 ≤ b < a ≤ 1012) — the sizes of the original sheet of paper.

Output

Print a single integer — the number of ships that Vasya will make.

Examples

Input

2 1

Output

2

Input

10 7

Output

6

Input

1000000000000 1

Output

1000000000000

Note

Pictures to the first and second sample test.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long count = 0;
  while (a != 0 && b != 0) {
    if (a == b) {
      a = 0;
      b = 0;
      ++count;
      break;
    }
    if (a > b) {
      count += a / b;
      a = a % b;
    } else if (a < b) {
      count += b / a;
      b = b % a;
    }
  }
  cout << count;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Berland — is a huge country with diverse geography. One of the most famous natural attractions of Berland is the "Median mountain range". This mountain range is n mountain peaks, located on one straight line and numbered in order of 1 to n. The height of the i-th mountain top is a_i.

"Median mountain range" is famous for the so called alignment of mountain peaks happening to it every day. At the moment of alignment simultaneously for each mountain from 2 to n - 1 its height becomes equal to the median height among it and two neighboring mountains. Formally, if before the alignment the heights were equal b_i, then after the alignment new heights a_i are as follows: a_1 = b_1, a_n = b_n and for all i from 2 to n - 1 a_i = median(b_{i-1}, b_i, b_{i+1}). The median of three integers is the second largest number among them. For example, median(5,1,2) = 2, and median(4,2,4) = 4.

Recently, Berland scientists have proved that whatever are the current heights of the mountains, the alignment process will stabilize sooner or later, i.e. at some point the altitude of the mountains won't changing after the alignment any more. The government of Berland wants to understand how soon it will happen, i.e. to find the value of c — how many alignments will occur, which will change the height of at least one mountain. Also, the government of Berland needs to determine the heights of the mountains after c alignments, that is, find out what heights of the mountains stay forever. Help scientists solve this important problem!

Input

The first line contains integers n (1 ≤ n ≤ 500 000) — the number of mountains.

The second line contains integers a_1, a_2, a_3, …, a_n (1 ≤ a_i ≤ 10^9) — current heights of the mountains.

Output

In the first line print c — the number of alignments, which change the height of at least one mountain.

In the second line print n integers — the final heights of the mountains after c alignments.

Examples

Input

5
1 2 1 2 1

Output

2
1 1 1 1 1

Input

6
1 3 2 5 4 6

Output

1
1 2 3 4 5 6

Input

6
1 1 2 2 1 1

Output

0
1 1 2 2 1 1

Note

In the first example, the heights of the mountains at index 1 and 5 never change. Since the median of 1, 2, 1 is 1, the second and the fourth mountains will have height 1 after the first alignment, and since the median of 2, 1, 2 is 2, the third mountain will have height 2 after the first alignment. This way, after one alignment the heights are 1, 1, 2, 1, 1. After the second alignment the heights change into 1, 1, 1, 1, 1 and never change from now on, so there are only 2 alignments changing the mountain heights.

In the third examples the alignment doesn't change any mountain height, so the number of alignments changing any height is 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7;
const int INF = 1e9 + 7;
int n;
int a[N], g[N], h[N];
struct pir {
  int x, v;
} p[N];
bool cmp(pir x, pir y) { return x.v < y.v; }
bool t[N];
struct dat {
  int vl, vr, vm, gg, l;
};
dat mer(dat a, dat b) {
  dat c = (dat){0, 0, 0, 0, a.l + b.l};
  if (a.gg) {
    if (b.gg) return (dat){a.l + b.l, a.l + b.l, a.l + b.l, 1, a.l + b.l};
    c.vl = a.l + b.vl;
    c.vr = b.vr;
    c.vm = max(b.vm, c.vl);
    c.gg = 0;
    return c;
  }
  if (b.gg) {
    c.vr = a.vr + b.l;
    c.vl = a.vl;
    c.vm = max(a.vm, c.vr);
    c.gg = 0;
    return c;
  }
  c.gg = 0;
  c.vl = a.vl;
  c.vr = b.vr;
  c.vm = max(max(a.vm, b.vm), a.vr + b.vl);
  return c;
}
struct Tree {
  int l, r, mx, mi;
  dat q;
} tr[N * 4];
void upd(int p) {
  tr[p].q = mer(tr[p * 2].q, tr[p * 2 + 1].q);
  tr[p].mx = max(tr[p * 2].mx, tr[p * 2 + 1].mx);
  tr[p].mi = min(tr[p * 2].mi, tr[p * 2 + 1].mi);
}
void build(int l, int r, int p) {
  tr[p] = (Tree){l, r, r, l, (dat){0, 0, 0, 0, r - l + 1}};
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, p * 2);
  build(mid + 1, r, p * 2 + 1);
}
void ins(int x, int p) {
  int l = tr[p].l, r = tr[p].r;
  if (l == r) {
    if (tr[p].mx) {
      tr[p].q = (dat){1, 1, 1, 1, 1};
      tr[p].mx = 0;
      tr[p].mi = INF;
    } else {
      tr[p].q = (dat){0, 0, 0, 0, 1};
      tr[p].mx = tr[p].mi = x;
    }
    return;
  }
  int mid = (l + r) >> 1;
  ins(x, p * 2 + (x > mid));
  upd(p);
}
int ch1(int p, int L) {
  if (L <= tr[p].l) return tr[p].mi;
  int mid = (tr[p].l + tr[p].r) >> 1;
  if (L <= mid) return min(ch1(p * 2, L), tr[p * 2 + 1].mi);
  return ch1(p * 2 + 1, L);
}
int ch2(int p, int R) {
  if (R >= tr[p].r) return tr[p].mx;
  int mid = (tr[p].l + tr[p].r) >> 1;
  if (R > mid) return max(ch2(p * 2 + 1, R), tr[p * 2].mx);
  return ch2(p * 2, R);
}
bool ck(int x) {
  if (x <= 1 || x >= n) return 0;
  return (t[x - 1] ^ t[x]) & (t[x] ^ t[x + 1]);
}
set<int> S;
void calc(int l, int r, int k) {
  int cnt = 0;
  for (set<int>::iterator ss = S.lower_bound(l); ss != S.end(); ss++) {
    if ((*ss) > r) break;
    g[(*ss)] = k;
    h[++cnt] = (*ss);
  }
  for (int i = 1; i <= cnt; i++) S.erase(h[i]);
}
void modify(int x, int nw) {
  if (!ck(x)) {
    int pl = ch2(1, x - 1), pr = ch1(1, x + 1);
    calc((x + pl + 1) / 2, x, nw);
    calc(x, (x + pr) / 2, nw);
  } else {
    int pl = ch2(1, x - 1), pr = ch1(1, x + 1);
    if (t[pl]) calc(pl, (pl + pr) / 2, nw);
    if (t[pr]) calc((pl + pr + 1) / 2, pr, nw);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) p[i] = (pir){i, a[i]};
  for (int i = 1; i <= n; i++) S.insert(i);
  sort(p + 1, p + n + 1, cmp);
  memset(t, 0, sizeof(t));
  build(1, n, 1);
  int ans = 0;
  p[n + 1].v = -INF;
  for (int i = 1; i <= n; i++) {
    int e0 = ck(p[i].x - 1), e1 = ck(p[i].x), e2 = ck(p[i].x + 1);
    t[p[i].x] ^= 1;
    if (ck(p[i].x - 1) != e0) ins(p[i].x - 1, 1);
    if (ck(p[i].x) != e1) ins(p[i].x, 1);
    if (ck(p[i].x + 1) != e2) ins(p[i].x + 1, 1);
    if (ck(p[i].x - 1) != e0) modify(p[i].x - 1, p[i].v);
    if (ck(p[i].x) != e1) modify(p[i].x, p[i].v);
    if (ck(p[i].x + 1) != e2) modify(p[i].x + 1, p[i].v);
    if (ck(p[i].x) == e1) {
      g[p[i].x] = a[p[i].x];
      S.erase(p[i].x);
    }
    if (p[i + 1].v != p[i].v) ans = max(ans, tr[1].q.vm);
  }
  printf("%d\n", (ans + 1) / 2);
  g[1] = a[1];
  g[n] = a[n];
  for (int i = 1; i <= n; i++) printf("%d ", g[i]);
  puts("");
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Polycarp has just launched his new startup idea. The niche is pretty free and the key vector of development sounds really promising, so he easily found himself some investors ready to sponsor the company. However, he is yet to name the startup!

Actually, Polycarp has already came up with the name but some improvement to it will never hurt. So now he wants to swap letters at some positions in it to obtain the better name. It isn't necessary for letters to be adjacent.

In addition, each of the investors has chosen some index in the name and selected a set of letters that can go there. Indices chosen by different investors are pairwise distinct. If some indices aren't chosen by any investor then any letter can go there.

Finally, Polycarp is sure that the smallest lexicographically name is the best. (Like why do you think Google decided to become Alphabet?)

More formally, you are given a string consisting of lowercase Latin letters from "a" to "f". You can swap letters at any positions arbitrary number of times (zero swaps is also possible).

What is the smallest lexicographically name you can obtain such that the letter at every position is among the allowed letters?

If Polycarp can't produce any valid name then print "Impossible".

Input

The first line is the string s (1 ≤ |s| ≤ 10^5) — the name Polycarp has came up with. The string consists only of lowercase Latin letters from "a" to "f".

The second line contains a single integer m (0 ≤ m ≤ |s|) — the number of investors.

The i-th of the next m lines contain an integer number pos_i and a non-empty string of allowed characters for pos_i (1 ≤ pos_i ≤ |s|). Each string contains pairwise distinct letters from "a" to "f". pos_1, pos_2, ..., pos_m are pairwise distinct. If any position of the string doesn't appear in the investors demands then any letter can go in this position.

Output

If Polycarp can't produce any valid name then print "Impossible".

Otherwise print the smallest lexicographically name Polycarp can obtain by swapping letters in string s such that the letter at every position is among the allowed ones.

Examples

Input

bedefead
5
2 e
1 dc
5 b
7 ef
6 ef

Output

deadbeef

Input

abacaba
0

Output

aaaabbc

Input

fc
2
1 cfab
2 f

Output

cf

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int cntmask[1 << 6];
int cnt[6];
int dp[1 << 6];
int allow[100010];
string s;
string ans;
int main(int argc, char const *argv[]) {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    allow[i] = (1 << 6) - 1;
  }
  int emp;
  cin >> emp;
  for (int i = 0; i < emp; i++) {
    int x;
    string t;
    cin >> x >> t;
    --x;
    int m = 0;
    for (int j = 0; j < t.size(); j++) {
      m |= 1 << (t[j] - 'a');
    }
    allow[x] = m;
  }
  for (int i = 0; i < n; i++) {
    cntmask[allow[i]] += 1;
    cnt[s[i] - 'a'] += 1;
  }
  memset(dp, 0, sizeof dp);
  for (int i = 0; i < (1 << 6); i++) {
    dp[i] = cntmask[i];
  }
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < (1 << 6); j++) {
      if ((j >> i) & 1) {
        dp[j] += dp[j ^ (1 << i)];
      }
    }
  }
  bool good = true;
  for (int j = 0; j < (1 << 6); j++) {
    int sum = 0;
    for (int k = 0; k < 6; k++) {
      if ((j >> k) & 1) {
        sum += cnt[k];
      }
    }
    int right = n - dp[((1 << 6) - 1) ^ j];
    if (sum > right) {
      good = false;
      break;
    }
  }
  if (!good) {
    cout << "Impossible" << endl;
    exit(0);
  }
  ans = s;
  for (int x = 0; x < n; x++) {
    cntmask[allow[x]] -= 1;
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < (1 << 6); i++) {
      dp[i] = cntmask[i];
    }
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < (1 << 6); j++) {
        if ((j >> i) & 1) {
          dp[j] += dp[j ^ (1 << i)];
        }
      }
    }
    for (int i = 0; i < 6; i++) {
      if ((allow[x] >> i) & 1) {
        cnt[i] -= 1;
        bool good = (cnt[i] >= 0);
        for (int j = 0; j < (1 << 6); j++) {
          int sum = 0;
          for (int k = 0; k < 6; k++) {
            if ((j >> k) & 1) {
              sum += cnt[k];
            }
          }
          int right = (n - x - 1) - dp[((1 << 6) - 1) ^ j];
          if (sum > right) {
            good = false;
            break;
          }
        }
        if (good) {
          ans[x] = i + 'a';
          break;
        }
        cnt[i] += 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they share a side.

One example of a grid path is (0, 0) → (0, 1) → (0, 2) → (1, 2) → (1, 1) → (0, 1) → ( - 1, 1). Note that squares in this sequence might be repeated, i.e. path has self intersections.

Movement within a grid path is restricted to adjacent squares within the sequence. That is, from the i-th square, one can only move to the (i - 1)-th or (i + 1)-th squares of this path. Note that there is only a single valid move from the first and last squares of a grid path. Also note, that even if there is some j-th square of the path that coincides with the i-th square, only moves to (i - 1)-th and (i + 1)-th squares are available. For example, from the second square in the above sequence, one can only move to either the first or third squares.

To ensure that movement is not ambiguous, the two grid paths will not have an alternating sequence of three squares. For example, a contiguous subsequence (0, 0) → (0, 1) → (0, 0) cannot occur in a valid grid path.

One marble is placed on the first square of each grid path. Genos wants to get both marbles to the last square of each grid path. However, there is a catch. Whenever he moves one marble, the other marble will copy its movement if possible. For instance, if one marble moves east, then the other marble will try and move east as well. By try, we mean if moving east is a valid move, then the marble will move east.

Moving north increases the second coordinate by 1, while moving south decreases it by 1. Similarly, moving east increases first coordinate by 1, while moving west decreases it.

Given these two valid grid paths, Genos wants to know if it is possible to move both marbles to the ends of their respective paths. That is, if it is possible to move the marbles such that both marbles rest on the last square of their respective paths.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 1 000 000) — the length of the paths.

The second line of the input contains a string consisting of n - 1 characters (each of which is either 'N', 'E', 'S', or 'W') — the first grid path. The characters can be thought of as the sequence of moves needed to traverse the grid path. For example, the example path in the problem statement can be expressed by the string "NNESWW".

The third line of the input contains a string of n - 1 characters (each of which is either 'N', 'E', 'S', or 'W') — the second grid path.

Output

Print "YES" (without quotes) if it is possible for both marbles to be at the end position at the same time. Print "NO" (without quotes) otherwise. In both cases, the answer is case-insensitive.

Examples

Input

7
NNESWW
SWSWSW

Output

YES

Input

3
NN
SS

Output

NO

Note

In the first sample, the first grid path is the one described in the statement. Moreover, the following sequence of moves will get both marbles to the end: NNESWWSWSW.

In the second sample, no sequence of moves can get both marbles to the end.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1001000, P1 = 1000000007, P2 = 1000000009;
int i, j, k, n, m, t1, t2, o1, o2;
int tm1[N], tm2[N];
char s1[N], s2[N];
char get(char x) {
  if (x == 'W') return 'E';
  if (x == 'E') return 'W';
  if (x == 'S') return 'N';
  if (x == 'N') return 'S';
}
int main() {
  scanf("%d", &n);
  n--;
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  tm1[0] = tm2[0] = 1;
  for (i = 1; i <= n; i++)
    tm1[i] = 31ll * tm1[i - 1] % P1, tm2[i] = 31ll * tm2[i - 1] % P2;
  for (i = n; i; i--) {
    s2[i] = get(s2[i]);
    t1 = (31ll * t1 + s1[i]) % P1;
    t2 = (1ll * s2[i] * tm1[n - i] + t2) % P1;
    o1 = (31ll * o1 + s1[i]) % P2;
    o2 = (1ll * s2[i] * tm2[n - i] + o2) % P2;
    if (t1 == t2 && o1 == o2) return puts("NO"), 0;
  }
  puts("YES");
}

```


### Prompt

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

Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school which has k pupils. Santa decided to treat them with tangerines.

However, there can be too few tangerines to present at least one tangerine to each pupil. So Santa decided to divide tangerines into parts so that no one will be offended. In order to do this, he can divide a tangerine or any existing part into two smaller equal parts. If the number of slices in the part he wants to split is odd, then one of the resulting parts will have one slice more than the other. It's forbidden to divide a part consisting of only one slice.

Santa Claus wants to present to everyone either a whole tangerine or exactly one part of it (that also means that everyone must get a positive number of slices). One or several tangerines or their parts may stay with Santa.

Let bi be the number of slices the i-th pupil has in the end. Let Santa's joy be the minimum among all bi's.

Your task is to find the maximum possible joy Santa can have after he treats everyone with tangerines (or their parts).

Input

The first line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 2·109) denoting the number of tangerines and the number of pupils, respectively.

The second line consists of n positive integers a1, a2, ..., an (1 ≤ ai ≤ 107), where ai stands for the number of slices the i-th tangerine consists of.

Output

If there's no way to present a tangerine or a part of tangerine to everyone, print -1. Otherwise, print the maximum possible joy that Santa can have.

Examples

Input

3 2
5 9 3

Output

5

Input

2 4
12 14

Output

6

Input

2 3
1 1

Output

-1

Note

In the first example Santa should divide the second tangerine into two parts with 5 and 4 slices. After that he can present the part with 5 slices to the first pupil and the whole first tangerine (with 5 slices, too) to the second pupil.

In the second example Santa should divide both tangerines, so that he'll be able to present two parts with 6 slices and two parts with 7 slices.

In the third example Santa Claus can't present 2 slices to 3 pupils in such a way that everyone will have anything.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int n, k, a[1000000 + 10];
bool ok(int x) {
  LL sum = 0;
  for (int i = 0; i < int(n); ++i) {
    if (x > a[i]) break;
    LL t = 0;
    for (LL j = 1; a[i] / j + 1 >= x; j += j) {
      LL r = a[i] % j;
      LL tmp = a[i] / j >= x ? j : r;
      t = max(t, tmp);
      if (a[i] / j == 0) break;
    }
    if (sum + (n - i) * t < k) break;
    sum += t;
    if (sum >= k) break;
  }
  return sum >= k;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < int(n); ++i) scanf("%d", &a[i]);
  sort(a, a + n, greater<int>());
  int l = 1, r = 1e7 + 1, ans = -1;
  while (l <= r) {
    int m = (l + r) >> 1;
    if (ok(m)) {
      ans = m;
      l = m + 1;
    } else
      r = m - 1;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one from the first column and the other from the second column, such that their sum is divisible by 5.

Formally, Alyona wants to count the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and <image> equals 0.

As usual, Alyona has some troubles and asks you to help.

Input

The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1 000 000).

Output

Print the only integer — the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and (x + y) is divisible by 5.

Examples

Input

6 12

Output

14

Input

11 14

Output

31

Input

1 5

Output

1

Input

3 8

Output

5

Input

5 7

Output

7

Input

21 21

Output

88

Note

Following pairs are suitable in the first sample case:

  * for x = 1 fits y equal to 4 or 9;
  * for x = 2 fits y equal to 3 or 8;
  * for x = 3 fits y equal to 2, 7 or 12;
  * for x = 4 fits y equal to 1, 6 or 11;
  * for x = 5 fits y equal to 5 or 10;
  * for x = 6 fits y equal to 4 or 9.

Only the pair (1, 4) is suitable in the third sample case.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a = 0, b = 0, c = 0, d = 0, e = 0;
  cin >> n >> m;
  long long kalo1 = 0;
  if (m >= 4 && n >= 1) {
    kalo1 = 1 + (m - 4) / 5;
  }
  long long kalo2 = 0;
  if (m >= 3 && n >= 2) {
    kalo2 = 1 + (m - 3) / 5;
  }
  long long kalo3 = 0;
  if (m >= 2 && n >= 3) {
    kalo3 = 1 + (m - 2) / 5;
  }
  long long kalo4 = 0;
  if (m >= 1 && n >= 4) {
    kalo4 = 1 + (m - 1) / 5;
  }
  long long kalo5 = 0;
  if (m >= 5 && n >= 5) {
    kalo5 = 1 + (m - 5) / 5;
  }
  for (long long i = 1; i <= n; i++) {
    if (i % 5 == 1) {
      a++;
    } else if (i % 5 == 2) {
      b++;
    } else if (i % 5 == 3) {
      c++;
    } else if (i % 5 == 4) {
      d++;
    } else if (i % 5 == 0) {
      e++;
    }
  }
  cout << a * kalo1 + b * kalo2 + c * kalo3 + d * kalo4 + e * kalo5;
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

In this problem you will meet the simplified model of game Pudding Monsters.

An important process in developing any game is creating levels. A game field in Pudding Monsters is an n × n rectangular grid, n of its cells contain monsters and some other cells contain game objects. The gameplay is about moving the monsters around the field. When two monsters are touching each other, they glue together into a single big one (as they are from pudding, remember?).

<image>

Statistics showed that the most interesting maps appear if initially each row and each column contains exactly one monster and the rest of map specifics is set up by the correct positioning of the other game objects.

A technique that's widely used to make the development process more efficient is reusing the available resources. For example, if there is a large n × n map, you can choose in it a smaller k × k square part, containing exactly k monsters and suggest it as a simplified version of the original map.

You wonder how many ways there are to choose in the initial map a k × k (1 ≤ k ≤ n) square fragment, containing exactly k pudding monsters. Calculate this number.

Input

The first line contains a single integer n (1 ≤ n ≤ 3 × 105) — the size of the initial field.

Next n lines contain the coordinates of the cells initially containing monsters. The i-th of the next lines contains two numbers ri, ci (1 ≤ ri, ci ≤ n) — the row number and the column number of the cell that initially contains the i-th monster.

It is guaranteed that all ri are distinct numbers and all ci are distinct numbers.

Output

Print the number of distinct square fragments of the original field that can form a new map.

Examples

Input

5
1 1
4 3
3 2
2 4
5 5

Output

10

### Response

```cpp
#include <bits/stdc++.h>
long long ans = 0;
int n, a[300005];
int mx[300005], mi[300005];
std::map<int, int> mp;
inline void cdq(int l, int r) {
  if (l == r) return ++ans, void();
  int mid = l + r >> 1;
  cdq(l, mid), cdq(mid + 1, r);
  mx[mid] = mi[mid] = a[mid];
  mx[mid + 1] = mi[mid + 1] = a[mid + 1];
  for (int i = mid - 1, iend = l; i >= iend; --i) {
    mx[i] = std::max(a[i], mx[i + 1]);
    mi[i] = std::min(a[i], mi[i + 1]);
  }
  for (int i = mid + 2, iend = r; i <= iend; ++i) {
    mx[i] = std::max(a[i], mx[i - 1]);
    mi[i] = std::min(a[i], mi[i - 1]);
  }
  for (int i = mid, iend = l; i >= iend; --i) {
    int pos = mx[i] - mi[i] + i;
    if (!(pos > mid && pos <= r)) continue;
    if (mx[pos] < mx[i] && mi[pos] > mi[i]) ++ans;
  }
  for (int i = mid + 1, iend = r; i <= iend; ++i) {
    int pos = i - mx[i] + mi[i];
    if (!(pos <= mid && pos >= l)) continue;
    if (mx[pos] < mx[i] && mi[pos] > mi[i]) ++ans;
  }
  int x, y;
  x = mid + 1, y = mid + 1;
  mp.clear();
  for (int i = mid, iend = l; i >= iend; --i) {
    while (y <= r && mi[y] > mi[i]) {
      ++mp[mx[y] - y];
      ++y;
    }
    while (x < y && mx[x] < mx[i]) {
      --mp[mx[x] - x];
      ++x;
    }
    ans += mp[mi[i] - i];
  }
  x = mid, y = mid;
  mp.clear();
  for (int i = mid + 1, iend = r; i <= iend; ++i) {
    while (y >= l && mi[y] > mi[i]) {
      ++mp[mx[y] + y];
      --y;
    }
    while (x > y && mx[x] < mx[i]) {
      --mp[mx[x] + x];
      --x;
    }
    ans += mp[mi[i] + i];
  }
}
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
  std::cin >> n;
  for (int i = 1, iend = n; i <= iend; ++i) {
    int x, y;
    std::cin >> x >> y;
    a[x] = y;
  }
  cdq(1, n);
  std::cout << ans << '\n';
  return 0;
}

```


### Prompt

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

Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.

After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!

She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.

Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.

Input

The first line contains an integer n (1 ≤ n ≤ 100): number of names.

Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.

Output

If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).

Otherwise output a single word "Impossible" (without quotes).

Examples

Input

3
rivest
shamir
adleman

Output

bcdefghijklmnopqrsatuvwxyz

Input

10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer

Output

Impossible

Input

10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever

Output

aghjlnopefikdmbcqrstuvwxyz

Input

7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck

Output

acbdefhijklmnogpqrstuvwxyz

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long mod = 10e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long modularExp(long long x, long long n, long long mod) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % mod;
    x = ((x % mod) * (x % mod)) % mod;
    n = n / 2;
  }
  return (result) % mod;
}
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
vector<long long> v[26], visited(26, 0), indeg(26, 0), recstack(26, 0);
bool dfs(long long x) {
  visited[x] = 1;
  recstack[x] = 1;
  long long i;
  for (i = 0; i < v[x].size(); i++) {
    if (!visited[v[x][i]] && dfs(v[x][i]))
      return true;
    else if (recstack[v[x][i]])
      return true;
  }
  recstack[x] = 0;
  return false;
}
int main() {
  long long n;
  cin >> n;
  long long i, j, k;
  vector<string> list(n + 1);
  for (i = 1; i <= n; i++) cin >> list[i];
  for (i = 1; i <= n - 1; i++) {
    string s = list[i];
    string t = list[i + 1];
    j = 0, k = 0;
    long long flag = 0;
    while (j < s.length() && k < t.length()) {
      if (s[j] != t[k]) {
        long long c1 = s[j] - 'a';
        long long c2 = t[k] - 'a';
        indeg[c2] += 1;
        v[c1].push_back(c2);
        flag = 1;
        break;
      }
      j++;
      k++;
    }
    if (flag == 0 && s.length() > t.length()) {
      cout << "Impossible";
      return 0;
    }
  }
  for (i = 0; i < 26; i++) {
    if (!visited[i]) {
      if (dfs(i)) {
        cout << "Impossible\n";
        return 0;
      }
    }
  }
  for (i = 0; i < 26; i++) visited[i] = 0;
  queue<long long> q;
  for (i = 0; i < 26; i++)
    if (indeg[i] == 0) {
      q.push(i);
      visited[i] = 1;
    }
  vector<long long> ans;
  while (!q.empty()) {
    long long top = q.front();
    q.pop();
    ans.push_back(top);
    for (i = 0; i < v[top].size(); i++) {
      indeg[v[top][i]] -= 1;
      if (indeg[v[top][i]] == 0) {
        q.push(v[top][i]);
        visited[v[top][i]] = 1;
      }
    }
  }
  for (i = 0; i < ans.size(); i++) {
    char c = ans[i] + 'a';
    cout << c;
  }
}

```


### Prompt

Your task is to create 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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N;
vector<int> adj[100001];
bool odd = false;
bool e[100001], o[100001];
void dfs(int node, int par) {
  for (int x : adj[node]) {
    if (x != par) {
      dfs(x, node);
      if (o[x]) e[node] = true;
      if (e[x]) o[node] = true;
    }
  }
  if (adj[node].size() == 1) e[node] = true;
  if (e[node] && o[node]) odd = true;
}
int main() {
  cin >> N;
  for (int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 1);
  int sub = 0;
  for (int i = 1; i <= N; i++) {
    int cnt = 0;
    for (int x : adj[i])
      if (adj[x].size() == 1) cnt++;
    if (cnt >= 2) sub += cnt - 1;
  }
  if (odd)
    cout << 3 << ' ' << N - 1 - sub << endl;
  else
    cout << 1 << ' ' << N - 1 - sub << endl;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S zero or more times:

* Remove the two characters at the beginning of S, erase one of them, and reinsert the other somewhere in S. This operation can be applied only when S has two or more characters.

Constraints

* 1 \leq |S| \leq 300
* S consists of `0` and `1`.

Input

Input is given from Standard Input in the following format:

S

Output

Print the number of strings, modulo 998244353, that can result from applying the operation on S zero or more times.

Examples

Input

0001

Output

8

Input

110001

Output

24

Input

11101111011111000000000110000001111100011111000000001111111110000000111111111

Output

697354558

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
char s[333];
int n,suf0[333],suf1[333],arr[333],mx[333][333],num[333][333][333],ans;
bool dp[333][333][333];
void upd(int &x,int y)
{
	if (x<y) x=y;
}
void add(int &x,int y)
{
	x+=y;
	if (x>=mod) x-=mod;
}
int main()
{
	scanf("%s",s);n=strlen(s);
	for (int i=1;i<=n;i++) arr[i]=s[i-1]-'0';
	for (int i=n;i>=1;i--)
	{
		suf0[i]=suf0[i+1]+(arr[i]==0);
		suf1[i]=suf1[i+1]+(arr[i]==1);
	}
	dp[0][0][1]=1;
	for (int k=1;k<=n+1;k++)
	{
		for (int i=n;i>=0;i--)
		{
			for (int j=n;j>=0;j--)
			{
				if (!dp[i][j][k]) continue;
				if (arr[k]==1 || arr[k+1]==1) dp[i][j+1][k+2]=1;
				if (arr[k]==0 || arr[k+1]==0) dp[i+1][j][k+2]=1;
				dp[i][j][k+1]=1;
				if (arr[k]==1 && i) dp[i-1][j+1][k+1]=1;
				if (arr[k]==0 && j) dp[i+1][j-1][k+1]=1;
				if (i) dp[i-1][j][k]=1;
				if (j) dp[i][j-1][k]=1;
			}
		}
	}
	memset(mx,-1,sizeof(mx));
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			for (int k=1;k<=n+1;k++)
			{
				if (dp[i][j][k])
				{
					upd(mx[i+suf0[k]][j+suf1[k]],k);
				}
			}
		}
	}
	num[0][0][n]=1;
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			add(num[i+1][j][0],num[i][j][0]);
			add(num[i][j+1][0],num[i][j][0]);
			for (int k=1;k<=n;k++)
			{
				if (arr[k])
				{
					add(num[i+1][j][k],num[i][j][k]);
					add(num[i][j+1][k-1],num[i][j][k]);
				}
				else
				{
					add(num[i+1][j][k-1],num[i][j][k]);
					add(num[i][j+1][k],num[i][j][k]);
				}
			}
		}
	}
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			if (!i && !j) continue;
			for (int k=0;k<=n;k++)
			{
				if (k<mx[i][j])
				{
					if (num[i][j][k])
					{
						add(ans,num[i][j][k]);
					}
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}
```


### Prompt

Please create a solution in CPP to the following problem:

A median in an array with the length of n is an element which occupies position number <image> after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is the number 2, and a median of array (0, 96, 17, 23) — the number 17.

We define an expression <image> as the integer part of dividing number a by number b.

One day Vasya showed Petya an array consisting of n integers and suggested finding the array's median. Petya didn't even look at the array and said that it equals x. Petya is a very honest boy, so he decided to add several numbers to the given array so that the median of the resulting array would be equal to x.

Petya can add any integers from 1 to 105 to the array, including the same numbers. Of course, he can add nothing to the array. If a number is added multiple times, then we should consider it the number of times it occurs. It is not allowed to delete of change initial numbers of the array.

While Petya is busy distracting Vasya, your task is to find the minimum number of elements he will need.

Input

The first input line contains two space-separated integers n and x (1 ≤ n ≤ 500, 1 ≤ x ≤ 105) — the initial array's length and the required median's value. The second line contains n space-separated numbers — the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily different.

Output

Print the only integer — the minimum number of elements Petya needs to add to the array so that its median equals x.

Examples

Input

3 10
10 20 30

Output

1

Input

3 4
1 2 3

Output

4

Note

In the first sample we can add number 9 to array (10, 20, 30). The resulting array (9, 10, 20, 30) will have a median in position <image>, that is, 10.

In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void init() { freopen("input.txt", "r", stdin); }
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  int ans = 0;
  while (arr[(n - 1) / 2] != x) {
    arr.push_back(x);
    sort(arr.begin(), arr.end());
    ++ans;
    ++n;
  }
  cout << ans;
  return 0;
}

```


### Prompt

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

Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.

Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the resulting word must be prefix of at least one string from the group. A player loses if he cannot move.

Andrew and Alex decided to play this game k times. The player who is the loser of the i-th game makes the first move in the (i + 1)-th game. Guys decided that the winner of all games is the player who wins the last (k-th) game. Andrew and Alex already started the game. Fedor wants to know who wins the game if both players will play optimally. Help him.

Input

The first line contains two integers, n and k (1 ≤ n ≤ 105; 1 ≤ k ≤ 109).

Each of the next n lines contains a single non-empty string from the given group. The total length of all strings from the group doesn't exceed 105. Each string of the group consists only of lowercase English letters.

Output

If the player who moves first wins, print "First", otherwise print "Second" (without the quotes).

Examples

Input

2 3
a
b

Output

First

Input

3 1
a
b
c

Output

First

Input

1 2
ab

Output

Second

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
std::vector<std::string> alph;
class IAlphabet {
 public:
  virtual int encode(char symbol) = 0;
  virtual char decode(int code) = 0;
  virtual int size() = 0;
};
class alphabet_eng : public IAlphabet {
 public:
  virtual int encode(char symbol);
  virtual char decode(int code);
  virtual int size() { return 26; };
};
int alphabet_eng::encode(char symbol) {
  if ((symbol < 97) || (symbol >= 123))
    return -1;
  else
    return (symbol - 97);
}
char alphabet_eng::decode(int code) {
  if ((code < 0) || (code >= 26))
    return 0;
  else
    return (code + 97);
}
class VocabularyTrie {
 public:
  VocabularyTrie(IAlphabet& alphabet);
  VocabularyTrie(VocabularyTrie& parent);
  void Fill();
  int GetSize();
  bool m_end_of_word;
  IAlphabet& m_alphabet;
  int winner;
  int loser;
  std::vector<std::unique_ptr<VocabularyTrie>> m_children;
  VocabularyTrie* m_parent;
};
std::set<std::pair<int, VocabularyTrie*>> proce;
VocabularyTrie::VocabularyTrie(IAlphabet& alphabet)
    : m_end_of_word(false),
      m_children(alphabet.size()),
      m_parent(nullptr),
      m_alphabet(alphabet) {
  winner = 2;
}
VocabularyTrie::VocabularyTrie(VocabularyTrie& parent)
    : m_end_of_word(false),
      m_children(parent.GetSize()),
      m_parent(&parent),
      m_alphabet(parent.m_alphabet) {}
int VocabularyTrie::GetSize() { return m_alphabet.size(); }
void VocabularyTrie::Fill() {
  for (int i = 0; i < alph.size(); i++) {
    std::string word;
    word = alph[i];
    VocabularyTrie* trie_ptr = this;
    for (int letter = 0; letter < word.length(); letter++) {
      int curr_letter_code = m_alphabet.encode(word[letter]);
      if (trie_ptr->m_children[curr_letter_code] == nullptr) {
        trie_ptr->m_children[curr_letter_code].reset(
            new VocabularyTrie(*trie_ptr));
      }
      trie_ptr = trie_ptr->m_children[curr_letter_code].get();
    }
    trie_ptr->m_end_of_word = true;
    proce.insert(std::make_pair(word.length(), trie_ptr));
  }
}
int main() {
  int m, n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    std::string x;
    cin >> x;
    alph.push_back(x);
  }
  alphabet_eng alphabet;
  VocabularyTrie nn(alphabet);
  nn.Fill();
  while (proce.size() >= 1) {
    auto h = proce.end();
    h--;
    int x = h->first;
    VocabularyTrie* y = h->second;
    proce.erase(std::make_pair(x, y));
    int winner = 2;
    int loser = 1;
    for (int i = 0; i < 26; i++) {
      if (y->m_children[i] != nullptr) loser = 2;
    }
    if (y == nullptr) continue;
    for (int i = 0; i < 26; i++) {
      if ((y->m_children[i] != nullptr) && (y->m_children[i]->winner == 2))
        winner = 1;
      if ((y->m_children[i] != nullptr) && (y->m_children[i]->loser == 2))
        loser = 1;
    }
    y->winner = winner;
    y->loser = loser;
    if (x > 0) proce.insert(std::make_pair(x - 1, y->m_parent));
  }
  int whowins = 1;
  int u = nn.winner;
  int v = nn.loser;
  if (u == 2)
    whowins = 2;
  else {
    if (v == 1)
      whowins = 1;
    else
      whowins = 2 - (k % 2);
  }
  if (whowins == 2)
    cout << "Second";
  else
    cout << "First";
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

A great king of a certain country suddenly decided to visit the land of a friendly country. The country is famous for trains, and the king visits various stations.

There are 52 train stations, each with a single uppercase or lowercase alphabetic name (no overlapping names). The line of this train is circular, with station a next to station b, station b next to station c, then station z next to station A, then station B, and so on. Proceed in order, and after Z station, it becomes a station and returns to the original. It is a single track, and there are no trains running in the opposite direction.

One day, a newspaper reporter got a list of the stations the King would visit.

"DcdkIlkP ..."

It is said that they will visit d station first, then c station, then d station, and so on. With this, when I thought that I could follow up on the king of a great country, I discovered something unexpected. The list was encrypted for counter-terrorism! A fellow reporter reportedly obtained the key to break the code. The reporter immediately gave him the key and started to modify the list. The key consists of a sequence of numbers.

"3 1 4 5 3"

This number means that the first station you visit is the one three stations before the one on the list. The station you visit second is the station in front of the second station on the list, which indicates how many stations you actually visit are in front of the stations on the list. The reporter started to fix it, but when I asked my friends what to do because the number of keys was smaller than the number of stations to visit, if you use the last key, use the first key again. It seems to be good. And the reporter was finally able to revise the list.

"AbZfFijL ..."

With this, there would be nothing scary anymore, and as soon as I thought so, an unexpected situation was discovered. The Great King stayed for days, and there was a list and keys for each date. The reporter was instructed by his boss to decrypt the entire list, but the amount was not enough for him alone. Your job is to help him and create a program that will automatically decrypt this list.

Input

The input consists of multiple datasets. The format of each data set is as follows.

n
k1 k2 ... kn
s

n is an integer representing the number of keys and can be assumed to be between 1 and 100. The following line contains a list of keys. ki indicates the i-th key. It can be assumed that it is 1 or more and 52 or less. s is a character string consisting of uppercase and lowercase letters, and indicates a list of stations to visit. It may be assumed that it is 1 or more and 100 or less. n = 0 indicates the end of input. This is not included in the dataset.

Output

Print the decrypted list for each dataset on one line each.

Sample Input

2
1 2
bdd
3
3 2 1
DDDA
Five
3 1 4 5 3
dcdkIlkP
0

Output for Sample Input

abc
ABCx
abZfFijL

Example

Input

2
1 2
bdd
3
3 2 1
DDDA
5
3 1 4 5 3
dcdkIlkP
0

Output

abc
ABCx
abZfFijL

### Response

```cpp
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int char_int(char c){
	if(c >= 'a' && c <= 'z') return c - 'a';
	if(c >= 'A' && c <= 'Z') return c - 'A' + 26;
}

char int_char(int i){
	if(i < 0) i += 52;
	if(i > 51) i -= 52;
	if(i >= 0 && i <= 25) return i + 'a';
	if(i >= 26 && i <= 51) return i + 'A' - 26;
}

int main(){
	int i, j, n, k[100];
	string s;
	while(1){
		cin >> n;
		if(!n)break;
		for(i=0;i<n;i++) cin >> k[i];
		for(i=n;i<100;i++) k[i] = k[i-n];
		cin >> s;
		for(i=0;i<s.size();i++){
			cout << int_char(char_int(s[i]) - k[i]);
		}
		cout << endl;
	}

	return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.

Input

The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.

Output

Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.

Examples

Input

6
549871

Output

54-98-71

Input

7
1198733

Output

11-987-33

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long INF = 1e18L;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const double pi = 2.0 * acos(0.0);
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  string s;
  cin >> s;
  if (n == 3) {
    cout << s << "\n";
    return 0;
  }
  if (n % 3 == 1) {
    for (long long i = 0; i < n - 4; i += 3) {
      cout << s.substr(i, 3) << "-";
    }
    cout << s.substr(n - 4, 2) << "-";
    cout << s.substr(n - 2, 2) << "\n";
    return 0;
  }
  if (n % 3 == 0) {
    long long i;
    for (i = 0; i < (n / 3 - 1) * 3; i += 3) {
      cout << s.substr(i, 3) << "-";
    }
    cout << s.substr(i, 3) << "\n";
    return 0;
  }
  long long i;
  for (i = 0; i < n / 3 * 3; i += 3) {
    cout << s.substr(i, 3) << "-";
  }
  cout << s.substr(i, 3) << "\n";
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

There is a new attraction in Singapore Zoo: The Infinite Zoo.

The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled 1,2,3,…. There is a directed edge from vertex u to vertex u+v if and only if u\&v=v, where \& denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND). There are no other edges in the graph.

Zookeeper has q queries. In the i-th query she will ask you if she can travel from vertex u_i to vertex v_i by going through directed edges.

Input

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

The i-th of the next q lines will contain two integers u_i, v_i (1 ≤ u_i, v_i < 2^{30}) — a query made by Zookeeper.

Output

For the i-th of the q queries, output "YES" in a single line if Zookeeper can travel from vertex u_i to vertex v_i. Otherwise, output "NO".

You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer.

Example

Input

5
1 4
3 6
1 6
6 2
5 5

Output

YES
YES
NO
NO
YES

Note

The subgraph on vertices 1,2,3,4,5,6 is shown below.

<image>

### Response

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

int main() {
	int T; scanf("%d", &T);
	while(T--) {
		int u, v; scanf("%d%d", &u, &v);
		if(u > v) {
			puts("NO"); continue;
		}
		vector<int> bits[2];
		auto Gao = [&](int x) {
			vector<int> res;
			for(int i = 0; i < 30; i++)
				if(x & (1 << i)) res.push_back(i);
			return res;
		};

		bits[0] = Gao(u), bits[1] = Gao(v);
		if(bits[0].size() < bits[1].size()) {
			puts("NO"); continue;
		}
		bool flag = 1;
		for(int i = 0; i < bits[1].size(); i++) {
			if(bits[1][i] < bits[0][i]) {
				flag = 0; continue;
			}
		}
		puts(flag ? "YES" : "NO");
	}
	return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.

In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.

When activated, each type of robot will operate as follows.

* When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.

* When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.

Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.

Constraints

* 1 \leq N \leq 100
* 1 \leq K \leq 100
* 0 < x_i < K
* All input values are integers.

Inputs

Input is given from Standard Input in the following format:

N
K
x_1 x_2 ... x_N

Outputs

Print the minimum possible total distance covered by robots.

Examples

Input

1
10
2

Output

4

Input

2
9
3 6

Output

12

Input

5
20
11 12 9 17 12

Output

74

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,k,cnt;
	cin>>n>>k;
	for(int i=1;i<=n;i++){cin>>x;cnt+=2*min(x,k-x);}
	cout<<cnt<<endl;
}

```