### Prompt

Generate a Cpp solution to the following problem:

The Kingdom of Neva is home to two ethnic groups, the Totata and the Tutete. The biggest feature of the Totata tribe is that they eat sweet and sour pork with pineapple. However, the Tutete tribe eats vinegared pork in pineapple. These two peoples couldn't get along with each other, and the Totata and Tutete have been in conflict for hundreds of years.

One day, a petition arrived from two ethnic groups under King Neva. According to it, the Totata tribe wants to build a road connecting the town A and the town B where they live. On the other hand, the Tutete tribe also wants to build a road connecting the town C and the town D where they live.

To prevent the two races from clashing, the roads of the Totata and Tutete cannot be crossed. Also, due to technical restrictions, it is only possible to build a road that connects the two cities in a straight line. In other words, if necessary, instead of connecting city A and city B directly with a road, it would indirectly connect city A and city B via some Totata towns (of course, of the Tutete tribe). Do not go through the city). At that time, the roads connecting the towns of the Totata tribe may intersect. The same applies to town C and town D.

Building a road costs proportional to its length. Therefore, I would like to make the total length of the roads to be constructed as short as possible while satisfying the conditions. Now, what is the minimum length?

Input

NA NB
xA, 1 yA, 1
xA, 2 yA, 2
..
..
..
xA, NA yA, NA
xB, 1 yB, 1
xB, 2 yB, 2
..
..
..
xB, NB yB, NB

The integer NA (2 ≤ NA ≤ 1,000) and the integer NB (2 ≤ NB ≤ 1,000) are written on the first line of the input, separated by blanks. This means that there are NA towns where the Totata tribe lives and NB towns where the Tutete tribe lives in the Kingdom of Neva. In the initial state, no road has been built anywhere.

The following NA line contains the integers xA, i (-10,000 ≤ xA, i ≤ 10,000) and the integers yA, i (-10,000 ≤ yA, i ≤ 10,000), separated by blanks. The geography of the Kingdom of Neva is represented by a two-dimensional Cartesian coordinate plane, and the integers xA, i and yA, i written on the 1 + i line are the position coordinates of the i-th city where the Totata tribe lives (xA, i, yA). , I). (xA, 1, yA, 1) and (xA, 2, yA, 2) are the coordinates of the two cities to be connected.

On the following NB line, the integers xB, i (-10,000 ≤ xB, i ≤ 10,000) and the integers yB, i (-10,000 ≤ yB, i ≤ 10,000) are written separated by blanks. The integers xB, i and yB, i written on the 1 + NA + i line indicate that the position coordinates of the i-th city where the Ytterbium live are (xB, i, yB, i). (xB, 1, yB, 1) and (xB, 2, yB, 2) are the coordinates of the two cities to be connected.

It can be assumed that the coordinates of the two cities are different and that none of the three cities are on the same straight line.

Output

When the road is constructed so as to meet the conditions of the problem statement, output the minimum value of the total length of the road. The "length" here is the Euclidean distance. However, if you cannot build a road that meets the conditions, output -1 instead. The output may contain errors, but the relative error to the true value must be less than 10-9.

Examples

Input

2 2
0 0
1 1
2 0
2 -1

Output

2.414213562373

Input

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

Output

-1

Input

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

Output

12.359173603117

### Response

```cpp
#include <iostream>
#include <queue>
#include <cstring>
#include <cmath>
#include <complex>
#include <vector>
#include <iomanip>
using namespace std;

double x[2][1001], y[2][1001];
double dist[1001];
int seen[1001];

double d(int idx, int s, int t) {
  return sqrt((x[idx][s] - x[idx][t])*(x[idx][s] - x[idx][t])
              + (y[idx][s] - y[idx][t])*(y[idx][s] - y[idx][t]));
}

typedef complex<double> P; // point
struct L : public vector<P> { // line
    L (P a, P b) {
        push_back(a);
        push_back(b);
    }
};
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
      ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

bool ok(int idx, int p, int q) {
  L l1 = L(P(x[idx][p], y[idx][p]), P(x[idx][q], y[idx][q]));
  L l2 = L(P(x[idx^1][0], y[idx^1][0]), P(x[idx^1][1], y[idx^1][1]));
  return !intersectSS(l1, l2);
}

int n[2];

double shortest_path(int idx, int s, int t) {
  memset(seen, 0, sizeof(seen));
  for (int i = 0; i < 1001; ++i) dist[i] = -1;
  dist[s] = 0;

  while(true) {
    int p = -1;
    double td = 1e13;
    for (int i = 0; i < n[idx]; ++i) {
      if (dist[i] != -1 && seen[i] == 0 && dist[i] < td) {
        p = i;
        td = dist[i];
      }
    }
    if (p == -1) break;
    if (p == t) return dist[t];
    seen[p] = 1;
    for (int next = 0; next < n[idx]; ++next) {
      if (seen[next] != 0) continue;
      if (!ok(idx, p, next)) continue;
      if (dist[next] == -1 || dist[p] + d(idx, p, next) < dist[next]) {
        dist[next] = dist[p] + d(idx, p, next);
      }
    }
  }

  return dist[t];
}

int main() {
  for (int i = 0; i < 1001; ++i) {
    x[0][i] = x[1][i] = y[0][i] = y[1][i] = -1;
  }
  cin>>n[0]>>n[1];
  for (int k = 0; k < 2; ++k)
    for (int i = 0; i < n[k]; ++i)
      cin>>x[k][i]>>y[k][i];

  // A
  double ans = d(0, 0, 1);
  double d1 = shortest_path(1, 0, 1);

  // B
  double ans2 = d(1, 0, 1);
  double d2 = shortest_path(0, 0, 1);

  cout << setprecision(15);
  if (d1 == -1 && d2 == -1) cout << -1 << endl;
  else if (d1 == -1) cout << ans2 + d2 << endl;
  else if (d2 == -1) cout << ans + d1 << endl;
  else cout << min(ans2 + d2, ans + d1) << endl;
}
```


### Prompt

Please formulate a CPP solution to the following problem:

It is never too late to play the fancy "Binary Cards" game!

There is an infinite amount of cards of positive and negative ranks that are used in the game. The absolute value of any card rank is a power of two, i.e. each card has a rank of either 2k or  - 2k for some integer k ≥ 0. There is an infinite amount of cards of any valid rank.

At the beginning of the game player forms his deck that is some multiset (possibly empty) of cards. It is allowed to pick any number of cards of any rank but the small deck is considered to be a skill indicator. Game consists of n rounds. In the i-th round jury tells the player an integer ai. After that the player is obligated to draw such a subset of his deck that the sum of ranks of the chosen cards is equal to ai (it is allowed to not draw any cards, in which case the sum is considered to be equal to zero). If player fails to do so, he loses and the game is over. Otherwise, player takes back all of his cards into his deck and the game proceeds to the next round. Player is considered a winner if he is able to draw the suitable set of cards in each of the rounds.

Somebody told you which numbers ai the jury is going to tell you in each round. Now you want to pick a deck consisting of the minimum number of cards that allows you to win the "Binary Cards" game.

Input

The first line of input contains an integer n (1 ≤ n ≤ 100 000), the number of rounds in the game.

The second line of input contains n integers a1, a2, ..., an ( - 100 000 ≤ ai ≤ 100 000), the numbers that jury is going to tell in each round.

Output

In the first line print the integer k (0 ≤ k ≤ 100 000), the minimum number of cards you have to pick in your deck in ordered to win the "Binary Cards".

In the second line print k integers b1, b2, ..., bk ( - 220 ≤ bi ≤ 220, |bi| is a power of two), the ranks of the cards in your deck. You may output ranks in any order. If there are several optimum decks, you are allowed to print any of them.

It is guaranteed that there exists a deck of minimum size satisfying all the requirements above.

Examples

Input

1
9

Output

2
1 8

Input

5
-1 3 0 4 7

Output

3
4 -1 4

Input

4
2 -2 14 18

Output

3
-2 2 16

Note

In the first sample there is the only round in the game, in which you may simply draw both your cards. Note that this sample test is the only one satisfying the first test group constraints.

In the second sample you may draw the only card  - 1 in the first round, cards 4 and  - 1 in the second round, nothing in the third round, the only card 4 in the fourth round and the whole deck in the fifth round.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int ans, flag, a[20][300010], n, i, x, anx[20], as[20];
void dfs(int x, int y) {
  if (y >= ans) return;
  if (x < 2) {
    anx[1] = 0;
    if (a[x][0]) {
      y++;
      anx[1] = -1;
    }
    if (a[x][2]) {
      y++;
      anx[1] = 1;
    }
    if (y < ans) {
      ans = y;
      for (int i = 1; i <= 18; i++) as[i] = anx[i];
    }
    return;
  }
  int flag = 0;
  for (int i = 0; i <= 1 << x - 1; i++) a[x - 1][i] = 0;
  for (int i = 0; i <= 1 << x; i++)
    if (a[x][i]) {
      if (i & 1) flag = 1;
      a[x - 1][i >> 1] = 1;
    }
  anx[x] = flag;
  dfs(x - 1, y + flag);
  if (flag) {
    for (int i = 0; i <= 1 << x - 1; i++) a[x - 1][i] = 0;
    for (int i = 0; i <= 1 << x; i++)
      if (a[x][i]) a[x - 1][i + 1 >> 1] = 1;
    anx[x] = -flag;
    dfs(x - 1, y + flag);
  }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &x), a[18][x + (1 << 17)] = 1;
  ans = 20;
  dfs(18, 0);
  printf("%d\n", ans);
  for (i = 18; i >= 1; i--)
    if (as[i]) printf("%d ", as[i] * (1 << 18 - i));
}

```


### Prompt

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

Berland is facing dark times again. The army of evil lord Van de Mart is going to conquer the whole kingdom. To the council of war called by the Berland's king Valery the Severe came n knights. After long discussions it became clear that the kingdom has exactly n control points (if the enemy conquers at least one of these points, the war is lost) and each knight will occupy one of these points.

Berland is divided into m + 1 regions with m fences, and the only way to get from one region to another is to climb over the fence. Each fence is a circle on a plane, no two fences have common points, and no control point is on the fence. You are given k pairs of numbers ai, bi. For each pair you have to find out: how many fences a knight from control point with index ai has to climb over to reach control point bi (in case when Van de Mart attacks control point bi first). As each knight rides a horse (it is very difficult to throw a horse over a fence), you are to find out for each pair the minimum amount of fences to climb over.

Input

The first input line contains three integers n, m, k (1 ≤ n, m ≤ 1000, 0 ≤ k ≤ 100000). Then follow n lines, each containing two integers Kxi, Kyi ( - 109 ≤ Kxi, Kyi ≤ 109) — coordinates of control point with index i. Control points can coincide.

Each of the following m lines describes fence with index i with three integers ri, Cxi, Cyi (1 ≤ ri ≤ 109,  - 109 ≤ Cxi, Cyi ≤ 109) — radius and center of the circle where the corresponding fence is situated.

Then follow k pairs of integers ai, bi (1 ≤ ai, bi ≤ n), each in a separate line — requests that you have to answer. ai and bi can coincide.

Output

Output exactly k lines, each containing one integer — the answer to the corresponding request.

Examples

Input

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

Output

1

Input

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

Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int x[1000], y[1000];
bool ins[1000][1000];
double sqr(double x) { return x * x; }
double dist(double x1, double y1, double x2, double y2) {
  return sqrt(sqr(x2 - x1) + sqr(y2 - y1));
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  for (int i = 0; i < m; i++) {
    int r, cx, cy;
    cin >> r >> cx >> cy;
    for (int j = 0; j < n; j++) {
      ins[j][i] = (dist(x[j], y[j], cx, cy) - r < -1e-6);
    }
  }
  for (int i = 0; i < k; i++) {
    int a, b, c = 0;
    cin >> a >> b;
    a--, b--;
    for (int j = 0; j < m; j++) {
      c += (ins[a][j] ^ ins[b][j]);
    }
    cout << c << endl;
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov told her about the construction of a time machine.

During the demonstration of the time machine performance Alisa noticed that the machine does not have high speed and the girl got interested in the reason for such disadvantage. As it turns out on closer examination, one of the problems that should be solved for the time machine isn't solved by an optimal algorithm. If you find a way to solve this problem optimally, the time machine will run faster and use less energy.

A task that none of the staff can solve optimally is as follows. There exists a matrix a, which is filled by the following rule:

The cells are consecutive positive integers, starting with one. Besides, ai, j < at, k (i, j, t, k ≥ 1), if:

  1. max(i, j) < max(t, k);
  2. max(i, j) = max(t, k) and j < k;
  3. max(i, j) = max(t, k), j = k and i > t.

So, after the first 36 numbers are inserted, matrix a will look as follows:

<image>

To solve the problem, you should learn to find rather quickly for the given values of x1, y1, x2 and y2 (x1 ≤ x2, y1 ≤ y2) the meaning of expression:

<image>

As the meaning of this expression can be large enough, it is sufficient to know only the last 10 digits of the sought value.

So, no one in MTI can solve the given task. Alice was brave enough to use the time machine and travel the past to help you.

Your task is to write a program that uses the given values x1, y1, x2 and y2 finds the last 10 digits of the given expression.

Input

The first input line contains a single integer t (1 ≤ t ≤ 105) — the number of test sets for which you should solve the problem.

Each of the next t lines contains the description of a test — four positive integers x1, y1, x2 and y2 (1 ≤ x1 ≤ x2 ≤ 109, 1 ≤ y1 ≤ y2 ≤ 109), separated by spaces.

Output

For each query print the meaning of the expression if it contains at most 10 characters. Otherwise, print three characters "." (without the quotes), and then ten last digits of the time expression. Print the answer to each query on a single line. Follow the format, given in the sample as closely as possible.

Examples

Input

5
1 1 1 1
2 2 3 3
2 3 5 6
100 87 288 2002
4 2 5 4

Output

1
24
300
...5679392764
111

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long mod, mmod = 2e10, val = 1e16;
long long ksc(long long a, long long b) {
  long long r = a * b - (long long)((long double)a * b / mod + 0.5) * mod;
  return r < 0 ? r + mod : r;
}
long long qwq(long long x, long long y) {
  if (x == 0 || y == 0) return 0;
  long long s, x2 = ksc(x, x), qaq;
  if (x == y) {
    if (x2 % 2 == 0)
      s = ksc(x2 / 2, x2 + 1);
    else
      s = ksc(x2, (x2 + 1) / 2);
    return s;
  }
  if (x < y) {
    if (x2 % 2 == 0)
      s = ksc(x2 / 2, x2 + 1);
    else
      s = ksc(x2, (x2 + 1) / 2);
    qaq = ksc(x + 3, y - x) - ksc(x + y + 1, 2 * y - 2 * x);
    if (y % 3 == 0) qaq += ksc(ksc(y + 1, y * 2 + 1), y / 3);
    if (y % 3 == 1) qaq += ksc(ksc(y + 1, (y * 2 + 1) / 3), y);
    if (y % 3 == 2) qaq += ksc(ksc((y + 1) / 3, y * 2 + 1), y);
    if (x % 3 == 0) qaq -= ksc(ksc(x + 1, x * 2 + 1), x / 3);
    if (x % 3 == 1) qaq -= ksc(ksc(x + 1, (x * 2 + 1) / 3), x);
    if (x % 3 == 2) qaq -= ksc(ksc((x + 1) / 3, x * 2 + 1), x);
    qaq = (qaq % mod + mod) % mod;
    if (qaq % 2 == 0)
      s = (s + ksc(x, qaq / 2)) % mod;
    else {
      if (mod % 2)
        s = (s + ksc(x, (qaq + mod) / 2)) % mod;
      else
        s = (s + ksc(x / 2, qaq)) % mod;
    }
  }
  if (x > y) {
    swap(x, y);
    x2 = ksc(x, x);
    if (x2 % 2 == 0)
      s = ksc(x2 / 2, x2 + 1);
    else
      s = ksc(x2, (x2 + 1) / 2);
    qaq = -ksc(x - 1, y - x);
    if (y % 3 == 0) qaq += ksc(ksc(y + 1, y * 2 + 1), y / 3);
    if (y % 3 == 1) qaq += ksc(ksc(y + 1, (y * 2 + 1) / 3), y);
    if (y % 3 == 2) qaq += ksc(ksc((y + 1) / 3, y * 2 + 1), y);
    if (x % 3 == 0) qaq -= ksc(ksc(x + 1, x * 2 + 1), x / 3);
    if (x % 3 == 1) qaq -= ksc(ksc(x + 1, (x * 2 + 1) / 3), x);
    if (x % 3 == 2) qaq -= ksc(ksc((x + 1) / 3, x * 2 + 1), x);
    qaq = (qaq % mod + mod) % mod;
    if (qaq % 2 == 0)
      s = (s + ksc(x, qaq / 2)) % mod;
    else {
      if (mod % 2)
        s = (s + ksc(x, (qaq + mod) / 2)) % mod;
      else
        s = (s + ksc(x / 2, qaq)) % mod;
    }
  }
  return s;
}
signed main() {
  long long T, x1, y1, x2, y2;
  scanf("%lld", &T);
  while (T--) {
    scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
    mod = mmod / 2 + 9;
    long long k1 = (qwq(x2, y2) + qwq(x1 - 1, y1 - 1) - qwq(x1 - 1, y2) -
                    qwq(x2, y1 - 1) + mod * 10) %
                   mod;
    mod = mmod;
    long long k2 = (qwq(x2, y2) + qwq(x1 - 1, y1 - 1) - qwq(x1 - 1, y2) -
                    qwq(x2, y1 - 1) + mod * 10) %
                   mod;
    if (k1 == k2)
      printf("%lld\n", k2);
    else
      printf("...%010lld\n", k2 % (mmod / 2));
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:

  1. They are equal.
  2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct:
    1. a1 is equivalent to b1, and a2 is equivalent to b2
    2. a1 is equivalent to b2, and a2 is equivalent to b1

As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent.

Gerald has already completed this home task. Now it's your turn!

Input

The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length.

Output

Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise.

Examples

Input

aaba
abaa

Output

YES

Input

aabb
abab

Output

NO

Note

In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a".

In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;
const long long mod = (int)1e8 + 7;
const long long p = 1993;
const int N = (int)3e5;
int n;
char a[N], b[N];
long long ha[N], hb[N], pw[N];
void end(bool yes) {
  puts(yes ? "YES" : "NO");
  exit(0);
}
void precalc() {
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * p;
  for (int i = 0; i < n; i++) {
    ha[i + 1] = ha[i] + pw[i] * (a[i] - 'a' + 1);
    hb[i + 1] = hb[i] + pw[i] * (b[i] - 'a' + 1);
  }
}
bool match(int pa, int push_back, int n) {
  return pw[max(0, push_back - pa)] * (ha[pa + n] - ha[pa]) ==
         (hb[push_back + n] - hb[push_back]) * pw[max(0, pa - push_back)];
}
bool check(int pa, int push_back, int n) {
  if (n & 1) return match(pa, push_back, n);
  n >>= 1;
  int t = rand() & 1;
  if (check(pa + t * n, push_back, n))
    return check(pa + (t ^ 1) * n, push_back + n, n);
  if (check(pa + (t ^ 1) * n, push_back, n))
    return check(pa + t * n, push_back + n, n);
  return false;
}
int main() {
  scanf("%s", a);
  scanf("%s", b);
  n = strlen(a);
  if (strlen(b) != n) end(0);
  precalc();
  end(check(0, 0, n));
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns are numbered 1 through n from left to right. At the far side of the room lies a door locked with evil magical forces. The following inscriptions are written on the door:

The cleaning of all evil will awaken the door!

Being a very senior adventurer, you immediately realize what this means. You notice that every single cell in the grid are initially evil. You should purify all of these cells.

The only method of tile purification known to you is by casting the "Purification" spell. You cast this spell on a single tile — then, all cells that are located in the same row and all cells that are located in the same column as the selected tile become purified (including the selected tile)! It is allowed to purify a cell more than once.

You would like to purify all n × n cells while minimizing the number of times you cast the "Purification" spell. This sounds very easy, but you just noticed that some tiles are particularly more evil than the other tiles. You cannot cast the "Purification" spell on those particularly more evil tiles, not even after they have been purified. They can still be purified if a cell sharing the same row or the same column gets selected by the "Purification" spell.

Please find some way to purify all the cells with the minimum number of spells cast. Print -1 if there is no such way.

Input

The first line will contain a single integer n (1 ≤ n ≤ 100). Then, n lines follows, each contains n characters. The j-th character in the i-th row represents the cell located at row i and column j. It will be the character 'E' if it is a particularly more evil cell, and '.' otherwise.

Output

If there exists no way to purify all the cells, output -1. Otherwise, if your solution casts x "Purification" spells (where x is the minimum possible number of spells), output x lines. Each line should consist of two integers denoting the row and column numbers of the cell on which you should cast the "Purification" spell.

Examples

Input

3
.E.
E.E
.E.

Output

1 1
2 2
3 3

Input

3
EEE
E..
E.E

Output

-1

Input

5
EE.EE
E.EE.
E...E
.EE.E
EE.EE

Output

3 3
1 3
2 2
4 4
5 3

Note

The first example is illustrated as follows. Purple tiles are evil tiles that have not yet been purified. Red tile is the tile on which "Purification" is cast. Yellow tiles are the tiles being purified as a result of the current "Purification" spell. Green tiles are tiles that have been purified previously.

<image>

In the second example, it is impossible to purify the cell located at row 1 and column 1.

For the third example:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string s[100000];
vector<vector<int> > v1(100000);
vector<vector<int> > v2(100000);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (s[i][j] == '.') {
        v1[i].push_back(j);
        v2[j].push_back(i);
      }
  bool ans = true;
  for (int i = 0; i < n && ans; i++)
    if (!v1[i].size()) ans = false;
  if (ans) {
    for (int i = 0; i < n; i++) cout << i + 1 << " " << v1[i][0] + 1 << "\n";
    return 0;
  }
  ans = true;
  for (int i = 0; i < n && ans; i++)
    if (!v2[i].size()) ans = false;
  if (ans) {
    for (int i = 0; i < n; i++) cout << v2[i][0] + 1 << " " << i + 1 << "\n";
  } else
    cout << "-1\n";
  return 0;
}

```


### Prompt

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

There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of course, the variants that only differ in the composition of the troupe are considered different.

Perform all calculations in the 64-bit type: long long for С/С++, int64 for Delphi and long for Java.

Input

The only line of the input data contains three integers n, m, t (4 ≤ n ≤ 30, 1 ≤ m ≤ 30, 5 ≤ t ≤ n + m).

Output

Find the required number of ways.

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

Examples

Input

5 2 5

Output

10

Input

4 3 5

Output

3

### Response

```cpp
#include <bits/stdc++.h>
const double pi = 3.1415926535897;
using namespace std;
int n, m, t;
int binCoff(int nn, int k) {
  int C[nn + 1][k + 1];
  int i, j;
  for (i = 0; i <= nn; i++) {
    for (j = 0; j <= min(i, k); j++) {
      if (j == 0 || j == i)
        C[i][j] = 1;
      else
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
    }
  }
  return C[nn][k];
}
long long int fact(long long int n) {
  long long int ans = 1;
  for (long long int i = 2; i <= n; i++) {
    ans *= i;
  }
  return ans;
}
long long int comb(int rG, int rB) {
  long long int ans = binCoff(n, rB);
  ans *= binCoff(m, rG);
  return ans;
}
int main() {
  cin >> n >> m >> t;
  long long int ans = 0;
  for (long long int nStart = 4; nStart <= n; nStart++) {
    for (long long int mStart = 1; mStart <= m; mStart++) {
      if (nStart + mStart != t) continue;
      ans += comb(mStart, nStart);
    }
  }
  cout << ans;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Vasya bought the collected works of a well-known Berland poet Petya in n volumes. The volumes are numbered from 1 to n. He thinks that it does not do to arrange the book simply according to their order. Vasya wants to minimize the number of the disposition’s divisors — the positive integers i such that for at least one j (1 ≤ j ≤ n) is true both: j mod i = 0 and at the same time p(j) mod i = 0, where p(j) is the number of the tome that stands on the j-th place and mod is the operation of taking the division remainder. Naturally, one volume can occupy exactly one place and in one place can stand exactly one volume.

Help Vasya — find the volume disposition with the minimum number of divisors.

Input

The first line contains number n (1 ≤ n ≤ 100000) which represents the number of volumes and free places.

Output

Print n numbers — the sought disposition with the minimum divisor number. The j-th number (1 ≤ j ≤ n) should be equal to p(j) — the number of tome that stands on the j-th place. If there are several solutions, print any of them.

Examples

Input

2

Output

2 1

Input

3

Output

1 3 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  for (i = 2; i <= n; i++) cout << i << " ";
  cout << "1";
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Finally Fox Ciel arrived in front of her castle!

She have to type a password to enter her castle. An input device attached to her castle is a bit unusual.

The input device is a 1 × n rectangle divided into n square panels. They are numbered 1 to n from left to right. Each panel has a state either ON or OFF. Initially all panels are in the OFF state. She can enter her castle if and only if x1-th, x2-th, ..., xk-th panels are in the ON state and other panels are in the OFF state.

She is given an array a1, ..., al. In each move, she can perform the following operation: choose an index i (1 ≤ i ≤ l), choose consecutive ai panels, and flip the states of those panels (i.e. ON → OFF, OFF → ON).

Unfortunately she forgets how to type the password with only above operations. Determine the minimal number of operations required to enter her castle.

Input

The first line contains three integers n, k and l (1 ≤ n ≤ 10000, 1 ≤ k ≤ 10, 1 ≤ l ≤ 100), separated by single spaces.

The second line contains k integers x1, ..., xk (1 ≤ x1 < x2 < ... < xk ≤ n), separated by single spaces.

The third line contains l integers a1, ..., al (1 ≤ ai ≤ n), separated by single spaces. It is possible that some elements of the array ai are equal value.

Output

Print the minimal number of moves required to type the password. If it's impossible, print -1.

Examples

Input

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

Output

2

Input

3 2 1
1 2
3

Output

-1

Note

One possible way to type the password in the first example is following: In the first move, choose 1st, 2nd, 3rd panels and flip those panels. In the second move, choose 5th, 6th, 7th, 8th, 9th panels and flip those panels.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
int n, k, l, x[23], a[111], m;
int d[10011], c[23][10011];
bool y[10011];
queue<int> q;
void init() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> l;
  for (int i = 0; i < k; ++i) cin >> x[i], y[x[i]] = 1;
  for (int i = 0; i < l; ++i) cin >> a[i];
  for (int j = 0; j <= n; ++j) {
    if (y[j] == y[j + 1]) continue;
    memset(d, 0, sizeof(d));
    d[j] = 1;
    q.push(j);
    for (int u; q.size() && (u = q.front(), 1); q.pop())
      for (int i = 0, v1, v2; i < l; ++i) {
        v1 = u + a[i], v2 = u - a[i];
        if (v1 <= n && !d[v1]) d[v1] = d[u] + 1, q.push(v1);
        if (v2 >= 0 && !d[v2]) d[v2] = d[u] + 1, q.push(v2);
      }
    for (int i = 0; i <= n; ++i) c[m][i] = d[i] ? d[i] - 1 : INF;
    x[m++] = j;
  }
}
int f[9999999];
void work() {
  fill(f, f + ((1 << (m - 1 + 1)) - 1) + 1, INF);
  f[0] = 0;
  for (int i = 1; i <= ((1 << (m - 1 + 1)) - 1); ++i) {
    int a = __builtin_ctz(i);
    for (int j = i & ~(1 << a); j; j &= j - 1) {
      int b = __builtin_ctz(j);
      f[i] = min(f[i], f[i & ~(1 << a) & ~(1 << b)] + c[a][x[b]]);
    }
  }
  cout << (f[((1 << (m - 1 + 1)) - 1)] == INF ? -1
                                              : f[((1 << (m - 1 + 1)) - 1)])
       << endl;
}
int main() {
  init();
  work();
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Takahashi has decided to give a string to his mother.

The value of a string T is the length of the longest common subsequence of T and T', where T' is the string obtained by reversing T. That is, the value is the longest length of the following two strings that are equal: a subsequence of T (possibly non-contiguous), and a subsequence of T' (possibly non-contiguous).

Takahashi has a string S. He wants to give her mother a string of the highest possible value, so he would like to change at most K characters in S to any other characters in order to obtain a string of the highest possible value. Find the highest possible value achievable.

Constraints

* 1 \leq |S| \leq 300
* 0 \leq K \leq |S|
* S consists of lowercase English letters.
* K is an integer.

Input

Input is given from Standard Input in the following format:

S
K

Output

Print the highest possible value achievable.

Examples

Input

abcabcabc
1

Output

7

Input

atcodergrandcontest
3

Output

15

### Response

```cpp
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[333];
int dp[333][333][333];
int calc(int S,int E,int left){
	if(S >= E)return 0;
	int&ret = dp[S][E][left];
	if(ret != -1)return ret;
	ret = min(calc(S+1, E, left), calc(S, E-1, left)) + 1;
	if(s[S] == s[E])
		ret = min(ret, calc(S+1, E-1, left));
	else
	if(left > 0)
		ret = min(ret, calc(S+1, E-1, left-1));
	return ret;
}
int main(){
	int k,n;
	scanf("%s%d",s,&k);
	n = strlen(s);
	memset(dp,-1,sizeof(dp));
	printf("%d\n", n - calc(0, n-1, k));
	return 0;
}
```


### Prompt

Develop a solution in CPP to the problem described below:

We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. Additionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.

For each k=1, 2, ..., N, solve the following problem:

* Find the number of simple paths that visit a vertex painted in the color k one or more times.

Note: The simple paths from Vertex u to v and from v to u are not distinguished.

Constraints

* 1 \leq N \leq 2 \times 10^5
* 1 \leq c_i \leq N
* 1 \leq a_i,b_i \leq N
* The given graph is a tree.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
c_1 c_2 ... c_N
a_1 b_1
:
a_{N-1} b_{N-1}

Output

Print the answers for k = 1, 2, ..., N in order, each in its own line.

Examples

Input

3
1 2 1
1 2
2 3

Output

5
4
0

Input

1
1

Output

1

Input

2
1 2
1 2

Output

2
2

Input

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

Output

5
8
10
5
5

Input

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

Output

18
15
0
14
23
0
23
0

### Response

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

constexpr int MAX = 200010;

ll subcalc(ll x) { return x * (x + 1) / 2; }

int n;
int c[MAX];
vector<int> G[MAX];

int sz[MAX];
vector<int> last[MAX];
ll ans[MAX];

// 部分木のサイズを求める
void dfs1(int v, int p) {
    sz[v] = 1;
    for(int u : G[v]) {
        if(u != p) {
            dfs1(u, v);
            sz[v] += sz[u];
        }
    }
}

// 答えの計算
void dfs2(int v, int p) {
    if(v == 0) {
        for(int i = 1; i <= n; i++)
            last[i].push_back(n);
        dfs2(1, 0);
        for(int i = 1; i <= n; i++)
            ans[i] += subcalc(last[i].back());
    } else {
        last[c[v]].back() -= sz[v];

        for(int u : G[v]) {
            if(u != p) {
                last[c[v]].push_back(sz[u]);
                dfs2(u, v);
                ans[c[v]] += subcalc(last[c[v]].back());
                last[c[v]].pop_back();
            }
        }
    }
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
        last[i].push_back(n);
    }
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs1(1, 0);
    dfs2(0, 0);

    for(int i = 1; i <= n; i++)
        cout << subcalc(n) - ans[i] << endl;

    return 0;
}
```


### Prompt

Construct a cpp code solution to the problem outlined:

In some country live wizards. They love to ride trolleybuses.

A city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The final station is at a distance of d meters from the depot. We know for the i-th trolleybus that it leaves at the moment of time ti seconds, can go at a speed of no greater than vi meters per second, and accelerate with an acceleration no greater than a meters per second squared. A trolleybus can decelerate as quickly as you want (magic!). It can change its acceleration as fast as you want, as well. Note that the maximum acceleration is the same for all trolleys.

Despite the magic the trolleys are still powered by an electric circuit and cannot overtake each other (the wires are to blame, of course). If a trolleybus catches up with another one, they go together one right after the other until they arrive at the final station. Also, the drivers are driving so as to arrive at the final station as quickly as possible.

You, as head of the trolleybuses' fans' club, are to determine for each trolley the minimum time by which it can reach the final station. At the time of arrival at the destination station the trolleybus does not necessarily have zero speed. When a trolley is leaving the depot, its speed is considered equal to zero. From the point of view of physics, the trolleybuses can be considered as material points, and also we should ignore the impact on the speed of a trolley bus by everything, except for the acceleration and deceleration provided by the engine.

Input

The first input line contains three space-separated integers n, a, d (1 ≤ n ≤ 105, 1 ≤ a, d ≤ 106) — the number of trolleybuses, their maximum acceleration and the distance from the depot to the final station, correspondingly.

Next n lines contain pairs of integers ti vi (0 ≤ t1 < t2... < tn - 1 < tn ≤ 106, 1 ≤ vi ≤ 106) — the time when the i-th trolleybus leaves the depot and its maximum speed, correspondingly. The numbers in the lines are separated by spaces.

Output

For each trolleybus print a single line the time it arrives to the final station. Print the times for the trolleybuses in the order in which the trolleybuses are given in the input. The answer will be accepted if the absolute or relative error doesn't exceed 10 - 4.

Examples

Input

3 10 10000
0 10
5 11
1000 1

Output

1000.5000000000
1000.5000000000
11000.0500000000

Input

1 2 26
28 29

Output

33.0990195136

Note

In the first sample the second trolleybus will catch up with the first one, that will happen at distance 510.5 meters from the depot. The trolleybuses will go the remaining 9489.5 meters together at speed 10 meters per second. As a result, both trolleybuses will arrive to the final station by the moment of time 1000.5 seconds. The third trolleybus will not catch up with them. It will arrive to the final station by the moment of time 11000.05 seconds.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long linf = 1LL << 60;
const int maxn = 100 * 1000 + 5;
long double res[maxn];
int a, d;
inline long double func(long double v) {
  long double dist_up = (long double)v * v / (2 * a);
  if (dist_up <= d) {
    return (long double)v / a + ((long double)d - dist_up) / v;
  } else {
    return sqrt((long double)2 * d / a);
  }
}
int main() {
  int n;
  scanf("%d%d%d", &n, &a, &d);
  for (int i = 0; i < n; ++i) {
    int t, v;
    scanf("%d%d", &t, &v);
    res[i] = t + func(v);
    if (i && res[i - 1] > res[i]) {
      res[i] = res[i - 1];
    }
  }
  cout.setf(ios::fixed);
  cout.precision(7);
  for (int i = 0; i < n; ++i) {
    cout << res[i] << "\n";
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Bashar was practicing for the national programming contest. Because of sitting too much in front of the computer without doing physical movements and eating a lot Bashar became much fatter. Bashar is going to quit programming after the national contest and he is going to become an actor (just like his father), so he should lose weight.

In order to lose weight, Bashar is going to run for k kilometers. Bashar is going to run in a place that looks like a grid of n rows and m columns. In this grid there are two one-way roads of one-kilometer length between each pair of adjacent by side cells, one road is going from the first cell to the second one, and the other road is going from the second cell to the first one. So, there are exactly (4 n m - 2n - 2m) roads.

Let's take, for example, n = 3 and m = 4. In this case, there are 34 roads. It is the picture of this case (arrows describe roads):

<image>

Bashar wants to run by these rules:

  * He starts at the top-left cell in the grid;
  * In one move Bashar may go up (the symbol 'U'), down (the symbol 'D'), left (the symbol 'L') or right (the symbol 'R'). More formally, if he stands in the cell in the row i and in the column j, i.e. in the cell (i, j) he will move to:
    * in the case 'U' to the cell (i-1, j);
    * in the case 'D' to the cell (i+1, j);
    * in the case 'L' to the cell (i, j-1);
    * in the case 'R' to the cell (i, j+1);
  * He wants to run exactly k kilometers, so he wants to make exactly k moves;
  * Bashar can finish in any cell of the grid;
  * He can't go out of the grid so at any moment of the time he should be on some cell;
  * Bashar doesn't want to get bored while running so he must not visit the same road twice. But he can visit the same cell any number of times.

Bashar asks you if it is possible to run by such rules. If it is possible, you should tell him how should he run.

You should give him a steps to do and since Bashar can't remember too many steps, a should not exceed 3000. In every step, you should give him an integer f and a string of moves s of length at most 4 which means that he should repeat the moves in the string s for f times. He will perform the steps in the order you print them.

For example, if the steps are 2 RUD, 3 UUL then the moves he is going to move are RUD + RUD + UUL + UUL + UUL = RUDRUDUULUULUUL.

Can you help him and give him a correct sequence of moves such that the total distance he will run is equal to k kilometers or say, that it is impossible?

Input

The only line contains three integers n, m and k (1 ≤ n, m ≤ 500, 1 ≤ k ≤ 10 ^{9}), which are the number of rows and the number of columns in the grid and the total distance Bashar wants to run.

Output

If there is no possible way to run k kilometers, print "NO" (without quotes), otherwise print "YES" (without quotes) in the first line.

If the answer is "YES", on the second line print an integer a (1 ≤ a ≤ 3000) — the number of steps, then print a lines describing the steps.

To describe a step, print an integer f (1 ≤ f ≤ 10^{9}) and a string of moves s of length at most 4. Every character in s should be 'U', 'D', 'L' or 'R'.

Bashar will start from the top-left cell. Make sure to move exactly k moves without visiting the same road twice and without going outside the grid. He can finish at any cell.

We can show that if it is possible to run exactly k kilometers, then it is possible to describe the path under such output constraints.

Examples

Input

3 3 4

Output

YES
2
2 R
2 L

Input

3 3 1000000000

Output

NO

Input

3 3 8

Output

YES
3
2 R
2 D
1 LLRR

Input

4 4 9

Output

YES
1
3 RLD

Input

3 4 16

Output

YES
8
3 R
3 L
1 D
3 R
1 D
1 U
3 L
1 D

Note

The moves Bashar is going to move in the first example are: "RRLL".

It is not possible to run 1000000000 kilometers in the second example because the total length of the roads is smaller and Bashar can't run the same road twice.

The moves Bashar is going to move in the third example are: "RRDDLLRR".

The moves Bashar is going to move in the fifth example are: "RRRLLLDRRRDULLLD". It is the picture of his run (the roads on this way are marked with red and numbered in the order of his running):

<image>

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int left = 4 * n * m - 2 * n - 2 * m - k;
  if (left < 0) {
    puts("NO");
    return 0;
  }
  std::vector<std::pair<int, std::string>> ops;
  auto add_op = [&](int cnt, std::string s) {
    if (cnt > 0) {
      ops.emplace_back(cnt, s);
    }
  };
  add_op(m - 1, "R");
  for (int i = 0; i < n - 1; ++i) {
    add_op(1, "D");
    add_op(m - 1, "LUD");
    add_op(m - 1, "R");
  }
  add_op(n - 1, "U");
  add_op(m - 1, "L");
  while (left > 0) {
    (!ops.empty());
    int cnt = ops.back().first;
    int len = ops.back().second.length();
    if (cnt * len <= left) {
      left -= cnt * len;
      ops.pop_back();
    } else {
      std::string s = ops.back().second;
      int c2 = (left + len - 1) / len;
      ops.back().first -= c2;
      if (ops.back().first == 0) ops.pop_back();
      int preserved = c2 * len - left;
      left = 0;
      if (preserved != 0) {
        (preserved < s.length());
        s.resize(preserved);
        add_op(1, s);
      }
    }
  }
  puts("YES");
  printf("%d\n", ops.size());
  for (auto t : ops) printf("%d %s\n", t.first, t.second.c_str());
}

```


### Prompt

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

Snuke received an integer sequence a of length 2N-1.

He arbitrarily permuted the elements in a, then used it to construct a new integer sequence b of length N, as follows:

* b_1 = the median of (a_1)
* b_2 = the median of (a_1, a_2, a_3)
* b_3 = the median of (a_1, a_2, a_3, a_4, a_5)
* :
* b_N = the median of (a_1, a_2, a_3, ..., a_{2N-1})

How many different sequences can be obtained as b? Find the count modulo 10^{9} + 7.

Constraints

* 1 ≤ N ≤ 50
* 1 ≤ a_i ≤ 2N-1
* a_i are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_{2N-1}

Output

Print the answer.

Examples

Input

2
1 3 2

Output

3

Input

4
1 3 2 3 2 4 3

Output

16

Input

15
1 5 9 11 1 19 17 18 20 1 14 3 3 8 19 15 16 29 10 2 4 13 6 12 7 15 16 1 1

Output

911828634

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define N 105
const int mod=1e9+7;
int dp[55][N][N];
int a[N],n,m;
int main(){
    scanf("%d",&n);m=n*2-1;
    for(int i=1;i<=m;i++) scanf("%d",&a[i]);
    sort(a+1,a+m+1);
    dp[n][1][1]=1;
    for(int i=n;i>=1;i--){
        int ml=a[m-i+1]!=a[m-i+2],mr=a[i]!=a[i-1];
        for(int j=1;j<=m;j++)
            for(int k=1,v;k<=m;k++)
                if(v=dp[i][j][k]){
                    (dp[i-1][j+ml][k+mr]+=v)%=mod;
                    for(int t=1;t<j+ml;t++) (dp[i-1][t][k+mr+1]+=v)%=mod;
                    for(int t=1;t<k+mr;t++) (dp[i-1][j+ml+1][t]+=v)%=mod;
                }
    }
    long long ans=0;
    for(int i=1;i<=m;i++)
        for(int j=1;j<=m;j++)
            ans+=dp[1][i][j];
    cout<<ans%mod<<endl;
    return 0;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 ≤ w2 ≤ ... ≤ wk holds.

Polar bears Alice and Bob each have caught some fish, and they are guessing who has the larger sum of weight of the fish he/she's caught. Given the type of the fish they've caught, determine whether it is possible that the fish caught by Alice has a strictly larger total weight than Bob's. In other words, does there exist a sequence of weights wi (not necessary integers), such that the fish caught by Alice has a strictly larger total weight?

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 105, 1 ≤ k ≤ 109) — the number of fish caught by Alice and Bob respectively, and the number of fish species.

The second line contains n integers each from 1 to k, the list of fish type caught by Alice. The third line contains m integers each from 1 to k, the list of fish type caught by Bob.

Note that one may have caught more than one fish for a same species.

Output

Output "YES" (without quotes) if it is possible, and "NO" (without quotes) otherwise.

Examples

Input

3 3 3
2 2 2
1 1 3

Output

YES

Input

4 7 9
5 2 7 3
3 5 2 7 3 8 7

Output

NO

Note

In the first sample, if w1 = 1, w2 = 2, w3 = 2.5, then Alice has a total of 2 + 2 + 2 = 6 weight units, while Bob only has 1 + 1 + 2.5 = 4.5.

In the second sample, the fish that Alice caught is a subset of Bob's. Therefore, the total weight of Bob’s fish is always not less than the total weight of Alice’s fish.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[100005], b[100005];
bool cmp(int x, int y) { return x > y; }
int main() {
  while (scanf("%d%d%d", &n, &m, &k) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int j = 1; j <= m; j++) scanf("%d", &b[j]);
    sort(a + 1, a + 1 + n, cmp);
    sort(b + 1, b + 1 + m, cmp);
    int qa = 1, qb = 1;
    int num1 = 0, num2 = 0;
    int cur1, cur2;
    int flag = 0;
    while (qa <= n) {
      num1++;
      cur1 = a[qa];
      while (qa < n && (a[qa] == a[qa + 1])) {
        qa++;
        num1++;
      }
      while (qb <= m && b[qb] >= cur1) {
        num2++;
        qb++;
      }
      if (num1 > num2) {
        flag = 1;
        break;
      }
      qa++;
    }
    if (flag)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

In the Bus of Characters there are n rows of seat, each having 2 seats. The width of both seats in the i-th row is w_i centimeters. All integers w_i are distinct.

Initially the bus is empty. On each of 2n stops one passenger enters the bus. There are two types of passengers:

  * an introvert always chooses a row where both seats are empty. Among these rows he chooses the one with the smallest seats width and takes one of the seats in it;
  * an extrovert always chooses a row where exactly one seat is occupied (by an introvert). Among these rows he chooses the one with the largest seats width and takes the vacant place in it.

You are given the seats width in each row and the order the passengers enter the bus. Determine which row each passenger will take.

Input

The first line contains a single integer n (1 ≤ n ≤ 200 000) — the number of rows in the bus.

The second line contains the sequence of integers w_1, w_2, ..., w_n (1 ≤ w_i ≤ 10^{9}), where w_i is the width of each of the seats in the i-th row. It is guaranteed that all w_i are distinct.

The third line contains a string of length 2n, consisting of digits '0' and '1' — the description of the order the passengers enter the bus. If the j-th character is '0', then the passenger that enters the bus on the j-th stop is an introvert. If the j-th character is '1', the the passenger that enters the bus on the j-th stop is an extrovert. It is guaranteed that the number of extroverts equals the number of introverts (i. e. both numbers equal n), and for each extrovert there always is a suitable row.

Output

Print 2n integers — the rows the passengers will take. The order of passengers should be the same as in input.

Examples

Input

2
3 1
0011

Output

2 1 1 2

Input

6
10 8 9 11 13 5
010010011101

Output

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

Note

In the first example the first passenger (introvert) chooses the row 2, because it has the seats with smallest width. The second passenger (introvert) chooses the row 1, because it is the only empty row now. The third passenger (extrovert) chooses the row 1, because it has exactly one occupied seat and the seat width is the largest among such rows. The fourth passenger (extrovert) chooses the row 2, because it is the only row with an empty place.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
struct T1 {
  int w, idx;
  bool operator<(const T1& other) const { return w > other.w; }
};
priority_queue<T1> PQ1;
struct T2 {
  int w, idx;
  bool operator<(const T2& other) const { return w < other.w; }
};
priority_queue<T2> PQ2;
void ReadInput() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int w;
    cin >> w;
    PQ1.push({w, i});
  }
  cin >> s;
}
void Solve() {
  for (int i = 0; i < 2 * n; i++)
    if (s[i] == '0') {
      T1 tp = PQ1.top();
      PQ1.pop();
      cout << tp.idx << ' ';
      PQ2.push({tp.w, tp.idx});
    } else {
      T2 tp = PQ2.top();
      PQ2.pop();
      cout << tp.idx << ' ';
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ReadInput();
  Solve();
}

```


### Prompt

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

Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.

Neko has two integers a and b. His goal is to find a non-negative integer k such that the least common multiple of a+k and b+k is the smallest possible. If there are multiple optimal integers k, he needs to choose the smallest one.

Given his mathematical talent, Neko had no trouble getting Wrong Answer on this problem. Can you help him solve it?

Input

The only line contains two integers a and b (1 ≤ a, b ≤ 10^9).

Output

Print the smallest non-negative integer k (k ≥ 0) such that the lowest common multiple of a+k and b+k is the smallest possible.

If there are many possible integers k giving the same value of the least common multiple, print the smallest one.

Examples

Input

6 10

Output

2

Input

21 31

Output

9

Input

5 10

Output

0

Note

In the first test, one should choose k = 2, as the least common multiple of 6 + 2 and 10 + 2 is 24, which is the smallest least common multiple possible.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long a, b, k;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
vector<long long> divs;
int main() {
  cin >> a >> b;
  if (a > b) swap(a, b);
  if (a == b) {
    cout << 0;
    return 0;
  }
  long long diff = b - a;
  long long res = 1e18;
  long long resK = 1e18;
  for (long long i = 1; i * i <= diff; i++) {
    if (diff % i == 0) {
      long long d1 = i;
      long long d2 = diff / d1;
      divs.push_back(d1);
      divs.push_back(d2);
    }
  }
  for (int i = 0; i < divs.size(); i++) {
    k = (divs[i] - a % divs[i]) % divs[i];
    long long cur = (a + k) * (b + k) / gcd(a + k, b + k);
    if (cur == res) {
      resK = min(resK, k);
    } else if (cur < res) {
      res = cur;
      resK = k;
    }
  }
  cout << resK;
}

```


### Prompt

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

For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique.

* insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$.
* get($key$): Print the value with the specified $key$. Print 0 if there is no such element.
* delete($key$): Delete the element with the specified $key$.
* dump($L$, $R$): Print all elements formed by a pair of the key and the value such that the key is greater than or equal to $L$ and less than or equal to $R$ in lexicographic order.

Constraints

* $1 \leq q \leq 200,000$
* $1 \leq x \leq 1,000,000,000$
* $1 \leq $ length of $key$ $ \leq 20$
* $key$ consists of lower-case letters
* $L \leq R$ in lexicographic order
* The total number of elements printed by dump operations does not exceed $1,000,000$

Input

The input is given in the following format.

$q$
$query_1$
$query_2$
:
$query_q$

Each query $query_i$ is given by

0 $key$ $x$

or

1 $key$

or

2 $key$

or

3 $L$ $R$

where the first digits 0, 1, 2 and 3 represent insert, get, delete and dump operations.

Output

For each get operation, print the corresponding value.
For each dump operation, print the corresponding elements formed by a pair of the key and the value. For the dump operation, print the elements (a pair of key and value separated by a space character) in ascending order of the keys.

Example

Input

9
0 blue 4
0 red 1
0 white 5
1 red
1 blue
2 red
1 black
1 red
3 w z

Output

1
4
0
0
white 5

### Response

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

using namespace std;

int main() {
    map<string, int> mp;

    int q;
    cin >> q;
    while (q--) {
        int op;
        string s;
        cin >> op;
        if (op == 0) {
            int x;
            cin >> s >> x;
            mp[s] = x;
        } else if (op == 1) {
            cin >> s;
            if (!mp.count(s)) {
                cout << 0 << endl;
            } else {
                cout << mp[s] << endl;
            }
        } else if (op == 2) {
            cin >> s;
            mp.erase(s);
        } else {
            string l, r;
            cin >> l >> r;
            for (auto it = mp.lower_bound(l); it != mp.upper_bound(r); it++) {
                cout << it->first << " " << it->second << endl;
            }
        }
    }
    return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

You are planning to build housing on a street. There are n spots available on the street on which you can build a house. The spots are labeled from 1 to n from left to right. In each spot, you can build a house with an integer height between 0 and h.

In each spot, if a house has height a, you will gain a^2 dollars from it.

The city has m zoning restrictions. The i-th restriction says that the tallest house from spots l_i to r_i (inclusive) must be at most x_i.

You would like to build houses to maximize your profit. Determine the maximum profit possible.

Input

The first line contains three integers n, h, and m (1 ≤ n,h,m ≤ 50) — the number of spots, the maximum height, and the number of restrictions.

Each of the next m lines contains three integers l_i, r_i, and x_i (1 ≤ l_i ≤ r_i ≤ n, 0 ≤ x_i ≤ h) — left and right limits (inclusive) of the i-th restriction and the maximum possible height in that range.

Output

Print a single integer, the maximum profit you can make.

Examples

Input

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

Output

14

Input

4 10 2
2 3 8
3 4 7

Output

262

Note

In the first example, there are 3 houses, the maximum height of a house is 3, and there are 3 restrictions. The first restriction says the tallest house between 1 and 1 must be at most 1. The second restriction says the tallest house between 2 and 2 must be at most 3. The third restriction says the tallest house between 3 and 3 must be at most 2.

In this case, it is optimal to build houses with heights [1, 3, 2]. This fits within all the restrictions. The total profit in this case is 1^2 + 3^2 + 2^2 = 14.

In the second example, there are 4 houses, the maximum height of a house is 10, and there are 2 restrictions. The first restriction says the tallest house from 2 to 3 must be at most 8. The second restriction says the tallest house from 3 to 4 must be at most 7.

In this case, it's optimal to build houses with heights [10, 8, 7, 7]. We get a profit of 10^2+8^2+7^2+7^2 = 262. Note that there are two restrictions on house 3 and both of them must be satisfied. Also, note that even though there isn't any explicit restrictions on house 1, we must still limit its height to be at most 10 (h=10).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, h, m, i, j, k, l, x, y, ans, head[N], adj[N], nxt[N], flow[N], cap[N],
    d[N], cur[N], q[N], bg, ed, cnt;
void addedge(int u, int v, int w) {
  adj[++l] = v;
  nxt[l] = head[u];
  head[u] = l;
  flow[l] = 0;
  cap[l] = w;
  adj[++l] = u;
  nxt[l] = head[v];
  head[v] = l;
  flow[l] = 0;
  cap[l] = 0;
}
bool bfs() {
  int i;
  for (i = 1; i <= cnt; ++i) d[i] = 1 << 30;
  d[cnt - 1] = 0;
  q[bg = ed = 1] = cnt - 1;
  while (bg <= ed) {
    for (i = head[q[bg]]; i; i = nxt[i])
      if (flow[i] < cap[i] && d[adj[i]] == (1 << 30)) {
        d[adj[i]] = d[q[bg]] + 1;
        q[++ed] = adj[i];
      }
    ++bg;
  }
  return d[cnt] < (1 << 30);
}
int dfs(int x, int a) {
  if (x == cnt || a <= 0) return a;
  int g, h = 0;
  for (; cur[x]; cur[x] = nxt[cur[x]])
    if (d[adj[cur[x]]] == d[x] + 1 &&
        (g = dfs(adj[cur[x]], min(a, cap[cur[x]] - flow[cur[x]]))) > 0) {
      flow[cur[x]] += g;
      flow[cur[x] & 1 ? cur[x] + 1 : cur[x] - 1] -= g;
      a -= g;
      h += g;
      if (a <= 0) break;
    }
  return h;
}
int main() {
  scanf("%d%d%d", &n, &h, &m);
  ans = n * h * h;
  cnt = h * n + m + 2;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j < h; ++j)
      addedge((i - 1) * h + j, (i - 1) * h + j + 1, h * h - j * j);
    addedge(cnt - 1, (i - 1) * h + 1, h * h);
    addedge(i * h, cnt, 0);
  }
  for (i = 1; i <= m; ++i) {
    scanf("%d%d%d%d", &j, &k, &x, &y);
    if (x + 1 > h) continue;
    for (; j <= k; ++j) addedge((j - 1) * h + x + 1, n * h + i, 1 << 30);
    addedge(n * h + i, cnt, y);
  }
  while (bfs()) {
    for (i = 1; i <= cnt; ++i) cur[i] = head[i];
    ans -= dfs(cnt - 1, 1 << 30);
  }
  printf("%d", ans);
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya.

Looking at her coins, a question came to her mind: after giving the coins to Arya, what values does Arya can make with them? She is jealous and she doesn't want Arya to make a lot of values. So she wants to know all the values x, such that Arya will be able to make x using some subset of coins with the sum k.

Formally, Pari wants to know the values x such that there exists a subset of coins with the sum k such that some subset of this subset has the sum x, i.e. there is exists some way to pay for the chocolate, such that Arya will be able to make the sum x using these coins.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 500) — the number of coins and the price of the chocolate, respectively.

Next line will contain n integers c1, c2, ..., cn (1 ≤ ci ≤ 500) — the values of Pari's coins.

It's guaranteed that one can make value k using these coins.

Output

First line of the output must contain a single integer q— the number of suitable values x. Then print q integers in ascending order — the values that Arya can make for some subset of coins of Pari that pays for the chocolate.

Examples

Input

6 18
5 6 1 10 12 2

Output

16
0 1 2 3 5 6 7 8 10 11 12 13 15 16 17 18

Input

3 50
25 25 50

Output

3
0 25 50

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> c(n + 1, 0);
  c[0] = 0;
  for (int i = 1; i <= n; i++) cin >> c[i];
  sort(c.begin(), c.end());
  bool dp[n + 1][k + 1][k + 1];
  memset(dp, 0, sizeof dp);
  for (int i = 0; i <= n; i++) {
    dp[i][0][0] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      for (int t = j; t <= k; t++) {
        if (c[i] > j && c[i] > t) dp[i][j][t] = dp[i - 1][j][t];
        if (c[i] > j && c[i] <= t)
          dp[i][j][t] = dp[i - 1][j][t - c[i]] || dp[i - 1][j][t];
        if (c[i] <= j && c[i] <= t)
          dp[i][j][t] = dp[i - 1][j - c[i]][t - c[i]] || dp[i - 1][j][t] ||
                        dp[i - 1][j][t - c[i]];
      }
    }
  }
  set<int> ans;
  ans.insert(0);
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (dp[i][j][k] == 1) ans.insert(j);
    }
  }
  cout << ans.size() << endl;
  for (set<int>::iterator it = ans.begin(); it != ans.end(); ++it)
    cout << *it << " ";
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Radewoosh is playing a computer game. There are n levels, numbered 1 through n. Levels are divided into k regions (groups). Each region contains some positive number of consecutive levels.

The game repeats the the following process:

  1. If all regions are beaten then the game ends immediately. Otherwise, the system finds the first region with at least one non-beaten level. Let X denote this region.
  2. The system creates an empty bag for tokens. Each token will represent one level and there may be many tokens representing the same level.
    * For each already beaten level i in the region X, the system adds ti tokens to the bag (tokens representing the i-th level).
    * Let j denote the first non-beaten level in the region X. The system adds tj tokens to the bag.
  3. Finally, the system takes a uniformly random token from the bag and a player starts the level represented by the token. A player spends one hour and beats the level, even if he has already beaten it in the past.

Given n, k and values t1, t2, ..., tn, your task is to split levels into regions. Each level must belong to exactly one region, and each region must contain non-empty consecutive set of levels. What is the minimum possible expected number of hours required to finish the game?

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 200 000, 1 ≤ k ≤ min(50, n)) — the number of levels and the number of regions, respectively.

The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 100 000).

Output

Print one real number — the minimum possible expected value of the number of hours spent to finish the game if levels are distributed between regions in the optimal way. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct if <image>.

Examples

Input

4 2
100 3 5 7

Output

5.7428571429

Input

6 2
1 2 4 8 16 32

Output

8.5000000000

Note

In the first sample, we are supposed to split 4 levels into 2 regions. It's optimal to create the first region with only one level (it must be the first level). Then, the second region must contain other three levels.

In the second sample, it's optimal to split levels into two regions with 3 levels each.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)2e5 + 5;
int n, m, t[maxn], dq[maxn], front, back;
long long s[maxn];
double a[maxn], b[maxn], f[maxn][51];
double get(int i, int j, int k) {
  return -s[j] * b[i] + f[j][k - 1] + b[j] * s[j] - a[j];
}
long long A(int x, int k) { return -s[x]; }
double B(int x, int k) { return f[x][k - 1] + b[x] * s[x] - a[x]; }
bool better(int x, int y, int z, int k) {
  return (B(y, k) - B(z, k)) * (A(x, k) - A(z, k)) >=
         (B(x, k) - B(z, k)) * (A(y, k) - A(z, k));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> t[i];
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + t[i];
    a[i] = a[i - 1] + 1.0 * s[i] / t[i];
    b[i] = b[i - 1] + 1.0 / t[i];
  }
  for (int i = 1; i <= n; i++) f[i][0] = 1e18;
  for (int k = 1; k <= m; k++) {
    front = back = 0;
    dq[0] = k - 1;
    for (int i = k; i <= n; i++) {
      while (front < back && get(i, dq[front], k) >= get(i, dq[front + 1], k))
        front++;
      f[i][k] = get(i, dq[front], k) + a[i];
      while (front < back && better(dq[back - 1], dq[back], i, k)) back--;
      dq[++back] = i;
    }
  }
  cout << fixed << setprecision(10) << f[n][m] << endl;
}

```


### Prompt

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

The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates fairly and to make those born under the lucky star the mayor. I did. It is a lottery later called Amidakuji.

The election is held as follows. The same number of long vertical lines as the number of candidates will be drawn, and some horizontal lines will be drawn there. Horizontal lines are drawn so as to connect the middle of adjacent vertical lines. Below one of the vertical lines is written "Winning". Which vertical line is the winner is hidden from the candidates. Each candidate selects one vertical line. Once all candidates have been selected, each candidate follows the line from top to bottom. However, if a horizontal line is found during the movement, it moves to the vertical line on the opposite side to which the horizontal line is connected, and then traces downward. When you reach the bottom of the vertical line, the person who says "winning" will be elected and become the next mayor.

This method worked. Under the lucky mayor, a peaceful era with few conflicts and disasters continued. However, in recent years, due to population growth, the limits of this method have become apparent. As the number of candidates increased, the Amidakuji became large-scale, and manual tabulation took a lot of time. Therefore, the city asked you, the programmer of the city hall, to computerize the Midakuji.

Your job is to write a program that finds the structure of the Amidakuji and which vertical line you will eventually reach given the position of the selected vertical line.

The figure below shows the contents of the input and output given as a sample.

<image>

Input

The input consists of multiple datasets. One dataset is given as follows.

> n m a
> Horizontal line 1
> Horizontal line 2
> Horizontal line 3
> ...
> Horizontal line m
>

n, m, and a are integers that satisfy 2 <= n <= 100, 0 <= m <= 1000, 1 <= a <= n, respectively. Represents a number.

The horizontal line data is given as follows.

> h p q

h, p, and q are integers that satisfy 1 <= h <= 1000, 1 <= p <q <= n, respectively, h is the height of the horizontal line, and p and q are connected to the horizontal line 2 Represents the number of the vertical line of the book.

No two or more different horizontal lines are attached to the same height of one vertical line.

At the end of the input, there is a line consisting of only three zeros separated by blanks.

Output

Output one line for each dataset, the number of the vertical line at the bottom of the vertical line a when traced from the top.

Sample Input

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

Output for the Sample Input

Four

Example

Input

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

Output

4

### Response

```cpp

#include<iostream>

using namespace std;

int line[100][1000];

int main()
{
loop:
  for(int i = 0; i < 100; i++)
    for(int j  = 0; j < 1000; j++)
      line[i][j] = -1;
  int n, m, a;
  cin >> n >> m >> a;
  if(!n)
    return 0;
  a--;
  for(int i = 0; i < m; i++)
  {
    int h, p, q;
    cin >> h >> p >> q;
    p--; q--;
    line[p][h] = q;
    line[q][h] = p;
  }
  for(int i = 1000; i > 0; i--)
  {
    if(line[a][i] != -1)
      a = line[a][i];
  }
  cout << a + 1 << endl;
  goto loop;
}
```


### Prompt

Develop a solution in CPP to the problem described below:

Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed that in this way it's impossible to get from some snow drifts to some other by any sequence of moves. He now wants to heap up some additional snow drifts, so that he can get from any snow drift to any other one. He asked you to find the minimal number of snow drifts that need to be created.

We assume that Bajtek can only heap up snow drifts at integer coordinates.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 100) — the number of snow drifts. Each of the following n lines contains two integers xi and yi (1 ≤ xi, yi ≤ 1000) — the coordinates of the i-th snow drift.

Note that the north direction coinсides with the direction of Oy axis, so the east direction coinсides with the direction of the Ox axis. All snow drift's locations are distinct.

Output

Output the minimal number of snow drifts that need to be created in order for Bajtek to be able to reach any snow drift from any other one.

Examples

Input

2
2 1
1 2

Output

1

Input

2
2 1
4 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int x, y;
} NODE;
NODE node[101];
int father[101];
void make_set(int n) {
  int i;
  for (i = 1; i <= n; i++) father[i] = i;
}
int Find(int i) {
  if (father[i] != i) father[i] = Find(father[i]);
  return father[i];
}
void Merge(int ai, int bj) {
  int fa, fb;
  fa = Find(ai);
  fb = Find(bj);
  if (fa == fb) return;
  father[fa] = fb;
}
int main() {
  int n, cnt = 0, s = 0, s1;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d%d", &node[i].x, &node[i].y);
  make_set(n);
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++)
      if (node[i].x == node[j].x || node[i].y == node[j].y) Merge(i, j);
  for (int i = 1; i <= n; ++i)
    if (father[i] == i) ++cnt;
  cout << cnt - 1 << endl;
  return 0;
}

```


### Prompt

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

Maxim loves to fill in a matrix in a special manner. Here is a pseudocode of filling in a matrix of size (m + 1) × (m + 1):

<image>

Maxim asks you to count, how many numbers m (1 ≤ m ≤ n) are there, such that the sum of values in the cells in the row number m + 1 of the resulting matrix equals t.

Expression (x xor y) means applying the operation of bitwise excluding "OR" to numbers x and y. The given operation exists in all modern programming languages. For example, in languages C++ and Java it is represented by character "^", in Pascal — by "xor".

Input

A single line contains two integers n and t (1 ≤ n, t ≤ 1012, t ≤ n + 1).

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

Output

In a single line print a single integer — the answer to the problem.

Examples

Input

1 1

Output

1

Input

3 2

Output

1

Input

3 3

Output

0

Input

1000000000000 1048576

Output

118606527258

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 10;
const int maxv = 1e3 + 10;
const double eps = 1e-9;
long long a[67];
long long dp[67][67];
long long n, ju, t, res, base;
long long Count(long long k, long long tmp) {
  if (k < tmp) return dp[k][tmp] = 0;
  if (!tmp || k == tmp) {
    return dp[k][tmp] = 1;
  }
  if (dp[k][tmp] != -1) return dp[k][tmp];
  return dp[k][tmp] = Count(k - 1, tmp - 1) + Count(k - 1, tmp);
}
void init() {
  ju = n;
  for (long long i = 0, j = 1; j <= ju; j <<= 1, i++) {
    res += Count(i, base);
    ju -= j;
  }
  long long tp = 0;
  for (long long i = 63; i >= 0; i--) {
    if ((ju >> i) & 1) {
      res += Count(i, base - tp);
      tp++;
      if (tp > base) break;
    }
  }
}
int main() {
  memset(dp, -1, sizeof dp);
  while (cin >> n >> t) {
    memset(a, 0, sizeof a);
    n++;
    res = 0;
    base = 0;
    while (t > 1) {
      base++;
      if (t & 1) {
        puts("0");
        return 0;
      }
      t /= 2;
    }
    init();
    if (base == 0) res--;
    cout << res << endl;
  }
  return 0;
}

```


### Prompt

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

Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.

Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer divisors — 1 and k.

Input

The only line of the input contains a single integer n (2 ≤ n ≤ 100 000).

Output

The first line of the output contains a single integer k — maximum possible number of primes in representation.

The second line should contain k primes with their sum equal to n. You can print them in any order. If there are several optimal solution, print any of them.

Examples

Input

5

Output

2
2 3

Input

6

Output

3
2 2 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = 100005;
long long int mod = 1000000007;
long long TES = 1000007;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
void solve() {
  int n;
  scanf("%d", &n);
  if (n % 2 == 1) {
    int t = n / 2;
    cout << "\n" << t << "\n";
    for (int(i) = (0); (i) < (t - 1); ++(i)) cout << "2 ";
    cout << "3\n";
  } else {
    int t = n / 2;
    cout << "\n" << t << "\n";
    for (int(i) = (0); (i) < (t); ++(i)) cout << "2 ";
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cout << fixed;
  cout << setprecision(9);
  solve();
}

```


### Prompt

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

You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.

The building consists of n towers, h floors each, where the towers are labeled from 1 to n, the floors are labeled from 1 to h. There is a passage between any two adjacent towers (two towers i and i + 1 for all i: 1 ≤ i ≤ n - 1) on every floor x, where a ≤ x ≤ b. It takes exactly one minute to walk between any two adjacent floors of a tower, as well as between any two adjacent towers, provided that there is a passage on that floor. It is not permitted to leave the building.

<image>

The picture illustrates the first example.

You have given k pairs of locations (ta, fa), (tb, fb): floor fa of tower ta and floor fb of tower tb. For each pair you need to determine the minimum walking time between these locations.

Input

The first line of the input contains following integers:

  * n: the number of towers in the building (1 ≤ n ≤ 108),
  * h: the number of floors in each tower (1 ≤ h ≤ 108),
  * a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h),
  * k: total number of queries (1 ≤ k ≤ 104).

Next k lines contain description of the queries. Each description consists of four integers ta, fa, tb, fb (1 ≤ ta, tb ≤ n, 1 ≤ fa, fb ≤ h). This corresponds to a query to find the minimum travel time between fa-th floor of the ta-th tower and fb-th floor of the tb-th tower.

Output

For each query print a single integer: the minimum walking time between the locations in minutes.

Example

Input

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

Output

1
4
2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int abs(int a) {
  if (a < 0) {
    return -a;
  } else {
    return a;
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, h, a, b, k, ta, fa, tb, fb, ans;
  cin >> n >> h >> a >> b >> k;
  for (int i = 1; i <= k; i++) {
    cin >> ta >> fa >> tb >> fb;
    ans = 0;
    if (ta == tb) {
      ans = abs(fa - fb);
    } else if (fa > a && fa > b && fb > a && fb > b) {
      ans = abs(ta - tb) + abs(fa - fb) + min(fa - b, fb - b) * 2;
    } else if (fa < a && fa < b && fb < a && fb < b) {
      ans = abs(ta - tb) + abs(fa - fb) + min(a - fa, a - fb) * 2;
    } else {
      ans = abs(ta - tb) + abs(fa - fb);
    }
    cout << ans << endl;
  }
  return 0;
}

```


### Prompt

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

Rng is going to a festival.

The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer.

Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.

Constraints

* 9 \leq |S| \leq 50
* S consists of uppercase English letters.
* S ends with `FESTIVAL`.

Input

Input is given from Standard Input in the following format:

S

Output

Print the answer to the question: "Rng is going to a festival of what?"

Examples

Input

CODEFESTIVAL

Output

CODE

Input

CODEFESTIVALFESTIVAL

Output

CODEFESTIVAL

Input

YAKINIKUFESTIVAL

Output

YAKINIKU

### Response

```cpp
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size()-8;i++)
	{
		cout<<s[i];
	}
	return 0;
}
```


### Prompt

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

Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm.

His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain rice, others are empty. k chickens are living on his farm. The number of chickens is not greater than the number of cells with rice on the farm.

Long wants to give his chicken playgrounds by assigning these farm cells to his chickens. He would like to satisfy the following requirements:

  * Each cell of the farm is assigned to exactly one chicken.
  * Each chicken is assigned at least one cell.
  * The set of cells assigned to every chicken forms a connected area. More precisely, if two cells (x, y) and (u, v) are assigned to the same chicken, this chicken is able to walk from (x, y) to (u, v) by passing only its cells and moving from each cell to another cell sharing a side.

Long also wants to prevent his chickens from fighting for food. Hence he wants the difference between the maximum and the minimum number of cells with rice assigned to a chicken to be as small as possible. Please help him.

Input

Each test contains multiple test cases. The first line contains the number of test cases T (1 ≤ T ≤ 2 ⋅ 10^4). Description of the test cases follows.

The first line of each test case contains three integers r, c and k (1 ≤ r, c ≤ 100, 1 ≤ k ≤ 62), representing the size of Long's farm and the number of chickens Long has.

Each of the next r lines contains c characters, each is either "." or "R", representing an empty cell or a cell with rice. It is guaranteed that the number of chickens is not greater than the number of cells with rice on the farm.

It is guaranteed that the sum of r ⋅ c over all test cases does not exceed 2 ⋅ 10^4.

Output

For each test case, print r lines with c characters on each line. Each character should be either a lowercase English character, an uppercase English character, or a digit. Two characters should be equal if and only if the two corresponding cells are assigned to the same chicken. Uppercase and lowercase characters are considered different, so "A" and "a" belong to two different chickens.

If there are multiple optimal answers, print any.

Example

Input

4
3 5 3
..R..
...R.
....R
6 4 6
R..R
R..R
RRRR
RRRR
R..R
R..R
5 5 4
RRR..
R.R..
RRR..
R..R.
R...R
2 31 62
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR

Output

11122
22223
33333
aacc
aBBc
aBBc
CbbA
CbbA
CCAA
11114
22244
32444
33344
33334
abcdefghijklmnopqrstuvwxyzABCDE
FGHIJKLMNOPQRSTUVWXYZ0123456789

Note

These pictures explain the sample output. Each color represents one chicken. Cells filled with patterns (not solid colors) contain rice.

In the first test case, each chicken has one cell with rice. Hence, the difference between the maximum and the minimum number of cells with rice assigned to a chicken is 0.

<image>

In the second test case, there are 4 chickens with 3 cells of rice, and 2 chickens with 2 cells of rice. Hence, the difference between the maximum and the minimum number of cells with rice assigned to a chicken is 3 - 2 = 1.

<image>

In the third test case, each chicken has 3 cells with rice. <image>

In the last test case, since there are 62 chicken with exactly 62 cells of rice, each chicken must be assigned to exactly one cell. The sample output is one of the possible way.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return 0;
}();
bool a[105][105];
int ans[105][105];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, k, tot = 0;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
      string tmp;
      cin >> tmp;
      for (int j = 0; j < m; j++) tot += (a[i][j] = (tmp[j] == 'R'));
    }
    int now = 0, cnt = (tot + k - 1 - now) / k;
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
        for (int j = 0; j < m; j++) {
          if (a[i][j]) {
            if (cnt == 0) {
              now++;
              cnt = (tot + k - 1 - now) / k;
            }
            cnt--;
          }
          ans[i][j] = now;
        }
      } else {
        for (int j = m - 1; j >= 0; j--) {
          if (a[i][j]) {
            if (cnt == 0) {
              now++;
              cnt = (tot + k - 1 - now) / k;
            }
            cnt--;
          }
          ans[i][j] = now;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (ans[i][j] < 10)
          cout << ans[i][j];
        else if (ans[i][j] < 36)
          cout << (char)(ans[i][j] - 10 + 'a');
        else
          cout << (char)(ans[i][j] - 36 + 'A');
      }
      cout << endl;
    }
  }
}

```


### Prompt

Please formulate a cpp solution to the following problem:

The determinant of a matrix 2 × 2 is defined as follows:

<image>

A matrix is called degenerate if its determinant is equal to zero.

The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements.

You are given a matrix <image>. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||.

Input

The first line contains two integers a and b (|a|, |b| ≤ 109), the elements of the first row of matrix A.

The second line contains two integers c and d (|c|, |d| ≤ 109) the elements of the second row of matrix A.

Output

Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10 - 9.

Examples

Input

1 2
3 4

Output

0.2000000000

Input

1 0
0 1

Output

0.5000000000

Note

In the first sample matrix B is <image>

In the second sample matrix B is <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long mat[2][2];
void input() {
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> mat[i][j];
    }
  }
}
const double Eps = 1e-12;
double find_res(int a, int b, int c, int d) {
  long long coefB =
                mat[0][0] * a - mat[0][1] * b - mat[1][0] * c + mat[1][1] * d,
            coefA = a * d - b * c,
            coefC = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];
  if (coefA == 0) {
    if (coefB == 0) return 1e100;
    return abs((double)coefC / coefB);
  }
  double delta = (double)coefB * coefB - 4 * (double)coefA * coefC;
  if (delta < -Eps) return 1e100;
  double tt1 = -(double)coefB / (2 * coefA), tt2 = sqrt(delta) / (2 * coefA);
  return min(abs(tt1 + tt2), abs(tt1 - tt2));
}
int main() {
  input();
  double result = 1e100;
  for (int a = -1; a <= 1; a++) {
    for (int b = -1; b <= 1; b++) {
      for (int c = -1; c <= 1; c++) {
        for (int d = -1; d <= 1; d++) {
          result = min(result, find_res(a, b, c, d));
        }
      }
    }
  }
  cout << setprecision(14) << result << endl;
}

```


### Prompt

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

This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.

There are two binary strings a and b of length n (a binary string is a string consisting of symbols 0 and 1). In an operation, you select a prefix of a, and simultaneously invert the bits in the prefix (0 changes to 1 and 1 changes to 0) and reverse the order of the bits in the prefix.

For example, if a=001011 and you select the prefix of length 3, it becomes 011011. Then if you select the entire string, it becomes 001001.

Your task is to transform the string a into b in at most 3n operations. It can be proved that it is always possible.

Input

The first line contains a single integer t (1≤ t≤ 1000) — the number of test cases. Next 3t lines contain descriptions of test cases.

The first line of each test case contains a single integer n (1≤ n≤ 1000) — the length of the binary strings.

The next two lines contain two binary strings a and b of length n.

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

Output

For each test case, output an integer k (0≤ k≤ 3n), followed by k integers p_1,…,p_k (1≤ p_i≤ n). Here k is the number of operations you use and p_i is the length of the prefix you flip in the i-th operation.

Example

Input

5
2
01
10
5
01011
11100
2
01
01
10
0110011011
1000110100
1
0
1

Output

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

Note

In the first test case, we have 01→ 11→ 00→ 10.

In the second test case, we have 01011→ 00101→ 11101→ 01000→ 10100→ 00100→ 11100.

In the third test case, the strings are already the same. Another solution is to flip the prefix of length 2, which will leave a unchanged.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long int t, n, k, i, j, m;
  cin >> t;
  while (t--) {
    vector<long long int> v;
    string a, b, s;
    long long int c = 0, d = 0;
    cin >> n >> a >> b;
    s += a[0];
    for (i = a.size() - 1; i >= 0; i--) {
      if (i == 0) {
        if (s[0] != b[i]) {
          v.push_back(1);
        }
      } else {
        if (s[0] == b[i]) {
          v.push_back(1);
          v.push_back(i + 1);
        } else {
          v.push_back(i + 1);
          if (a[i] == '0')
            s[0] = '1';
          else
            s[0] = '0';
        }
      }
      if (d % 2 == 0) {
        if (a[n - 1 - c] == '0')
          s[0] = '1';
        else
          s[0] = '0';
        c++;
      } else {
        s[0] = a[c];
      }
      d++;
    }
    if (v.size() == 0) {
      cout << 0 << endl;
      continue;
    }
    cout << v.size() << " ";
    for (i = 0; i < v.size() - 1; i++) {
      cout << v[i] << " ";
    }
    cout << v[i] << endl;
  }
  return 0;
}

```


### Prompt

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

You are given a Young diagram.

Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).

<image> Young diagram for a=[3,2,2,2,1].

Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.

Input

The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.

The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.

Output

Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.

Example

Input

5
3 2 2 2 1

Output

4

Note

Some of the possible solutions for the example:

<image> <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int infinity = 9e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int total = 0, odd = 0, even = 0;
  long long int k;
  for (int i = 0; i < n; i++) {
    cin >> k;
    total += k / 2;
    if (k & 1) {
      if (i & 1)
        odd++;
      else
        even++;
    }
  }
  cout << (total + min(odd, even));
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Tenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is fairly simple: sometimes Tenten places another shuriken (from the available shurikens) on the showcase, and sometimes a ninja comes in and buys a shuriken from the showcase. Since ninjas are thrifty, they always buy the cheapest shuriken from the showcase.

Tenten keeps a record for all events, and she ends up with a list of the following types of records:

  * + means that she placed another shuriken on the showcase;
  * - x means that the shuriken of price x was bought.

Today was a lucky day, and all shurikens were bought. Now Tenten wonders if her list is consistent, and what could be a possible order of placing the shurikens on the showcase. Help her to find this out!

Input

The first line contains the only integer n (1≤ n≤ 10^5) standing for the number of shurikens.

The following 2n lines describe the events in the format described above. It's guaranteed that there are exactly n events of the first type, and each price from 1 to n occurs exactly once in the events of the second type.

Output

If the list is consistent, print "YES". Otherwise (that is, if the list is contradictory and there is no valid order of shurikens placement), print "NO".

In the first case the second line must contain n space-separated integers denoting the prices of shurikens in order they were placed. If there are multiple answers, print any.

Examples

Input

4
+
+
- 2
+
- 3
+
- 1
- 4

Output

YES
4 2 3 1

Input

1
- 1
+

Output

NO

Input

3
+
+
+
- 2
- 1
- 3

Output

NO

Note

In the first example Tenten first placed shurikens with prices 4 and 2. After this a customer came in and bought the cheapest shuriken which costed 2. Next, Tenten added a shuriken with price 3 on the showcase to the already placed 4-ryo. Then a new customer bought this 3-ryo shuriken. After this she added a 1-ryo shuriken. Finally, the last two customers bought shurikens 1 and 4, respectively. Note that the order [2, 4, 3, 1] is also valid.

In the second example the first customer bought a shuriken before anything was placed, which is clearly impossible.

In the third example Tenten put all her shurikens onto the showcase, after which a customer came in and bought a shuriken with price 2. This is impossible since the shuriken was not the cheapest, we know that the 1-ryo shuriken was also there.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1, c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
const int N = 2e5 + 4;
int n, idx[N], ans[N];
char s[4];
set<int> s1, s2;
int main() {
  n = read();
  for (int i = 1; i <= (n << 1); i++) {
    scanf("%s", s);
    if (s[0] == '+') {
      s1.insert(i);
    } else {
      idx[read()] = i;
      s2.insert(i);
    }
  }
  for (int i = 1, x; i <= n; i++) {
    x = idx[i];
    auto it1 = s1.lower_bound(x);
    auto it2 = s2.lower_bound(x);
    if (it1 == s1.begin()) {
      puts("NO");
      return (0 - 0);
    }
    --it1;
    if (it2 != s2.begin() && (*(--it2)) > (*it1)) {
      puts("NO");
      return (0 - 0);
    }
    ans[*it1] = i;
    s1.erase(it1);
    s2.erase(x);
  }
  puts("YES");
  for (int i = 1; i <= (n << 1); i++)
    if (ans[i]) cout << ans[i] << " ";
  return (0 - 0);
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Lee is used to finish his stories in a stylish way, this time he barely failed it, but Ice Bear came and helped him. Lee is so grateful for it, so he decided to show Ice Bear his new game called "Critic"...

The game is a one versus one game. It has t rounds, each round has two integers s_i and e_i (which are determined and are known before the game begins, s_i and e_i may differ from round to round). The integer s_i is written on the board at the beginning of the corresponding round.

The players will take turns. Each player will erase the number on the board (let's say it was a) and will choose to write either 2 ⋅ a or a + 1 instead. Whoever writes a number strictly greater than e_i loses that round and the other one wins that round.

Now Lee wants to play "Critic" against Ice Bear, for each round he has chosen the round's s_i and e_i in advance. Lee will start the first round, the loser of each round will start the next round.

The winner of the last round is the winner of the game, and the loser of the last round is the loser of the game.

Determine if Lee can be the winner independent of Ice Bear's moves or not. Also, determine if Lee can be the loser independent of Ice Bear's moves or not.

Input

The first line contains the integer t (1 ≤ t ≤ 10^5) — the number of rounds the game has.

Then t lines follow, each contains two integers s_i and e_i (1 ≤ s_i ≤ e_i ≤ 10^{18}) — the i-th round's information.

The rounds are played in the same order as given in input, s_i and e_i for all rounds are known to everyone before the game starts.

Output

Print two integers.

The first one should be 1 if Lee can be the winner independent of Ice Bear's moves, and 0 otherwise.

The second one should be 1 if Lee can be the loser independent of Ice Bear's moves, and 0 otherwise.

Examples

Input

3
5 8
1 4
3 10

Output

1 1

Input

4
1 2
2 3
3 4
4 5

Output

0 0

Input

1
1 1

Output

0 1

Input

2
1 9
4 5

Output

0 0

Input

2
1 2
2 8

Output

1 0

Input

6
216986951114298167 235031205335543871
148302405431848579 455670351549314242
506251128322958430 575521452907339082
1 768614336404564650
189336074809158272 622104412002885672
588320087414024192 662540324268197150

Output

1 0

Note

Remember, whoever writes an integer greater than e_i loses.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long N = 1e5 + 7;
bool win(long long l, long long r) {
  if (r % 2) return ((l % 2) ? 0 : 1);
  if (2 * l == r) return 1;
  if (l > (r / 2)) return ((l % 2 == r % 2) ? 0 : 1);
  if (l > (r / 4)) return 1;
  return win(l, r / 4);
}
bool lose(long long l, long long r) {
  if (l > (r / 2)) return 1;
  return win(l, r / 2);
}
struct game {
  bool be_first = 0;
  bool be_second = 0;
  bool first_win = 0;
  bool first_lose = 0;
  bool second_win = 0;
  bool second_lose = 0;
};
game g[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, i, x, y;
  cin >> t;
  for (i = 1; i <= t; i++)
    cin >> x >> y,
        g[i].first_win = win(x, y), g[i].second_win = 1 - g[i].first_win,
        g[i].first_lose = lose(x, y), g[i].second_lose = 1 - g[i].first_lose;
  g[1].be_first = 1;
  for (i = 1; i < t; i++) {
    if (g[i].be_first) {
      if (g[i].first_win) g[i + 1].be_second = 1;
      if (g[i].first_lose) g[i + 1].be_first = 1;
    }
    if (g[i].be_second) {
      if (!g[i].first_win) g[i + 1].be_second = 1;
      if (!g[i].first_lose) g[i + 1].be_first = 1;
    }
  }
  y = 0;
  if (g[t].be_first && g[t].first_win) y = 1;
  if (g[t].be_second && !g[t].first_win) y = 1;
  cout << y << " ";
  y = 0;
  if (g[t].be_first && g[t].first_lose) y = 1;
  if (g[t].be_second && !g[t].first_lose) y = 1;
  cout << y << endl;
  return 0;
}

```