### Prompt

Develop a solution in CPP to the problem described below:

A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the left, 2 squares backward and 2 to the right and 2 squares backward and 2 to the left. Naturally, the semiknight cannot move beyond the limits of the chessboard.

Petya put two semiknights on a standard chessboard. Petya simultaneously moves with both semiknights. The squares are rather large, so after some move the semiknights can meet, that is, they can end up in the same square. After the meeting the semiknights can move on, so it is possible that they meet again. Petya wonders if there is such sequence of moves when the semiknights meet. Petya considers some squares bad. That is, they do not suit for the meeting. The semiknights can move through these squares but their meetings in these squares don't count.

Petya prepared multiple chess boards. Help Petya find out whether the semiknights can meet on some good square for each board.

Please see the test case analysis.

Input

The first line contains number t (1 ≤ t ≤ 50) — the number of boards. Each board is described by a matrix of characters, consisting of 8 rows and 8 columns. The matrix consists of characters ".", "#", "K", representing an empty good square, a bad square and the semiknight's position, correspondingly. It is guaranteed that matrix contains exactly 2 semiknights. The semiknight's squares are considered good for the meeting. The tests are separated by empty line.

Output

For each test, print on a single line the answer to the problem: "YES", if the semiknights can meet and "NO" otherwise.

Examples

Input

2
........
........
......#.
K..##..#
.......#
...##..#
......#.
K.......

........
........
..#.....
..#..#..
..####..
...##...
........
....K#K#

Output

YES
NO

Note

Consider the first board from the sample. We will assume the rows and columns of the matrix to be numbered 1 through 8 from top to bottom and from left to right, correspondingly. The knights can meet, for example, in square (2, 7). The semiknight from square (4, 1) goes to square (2, 3) and the semiknight goes from square (8, 1) to square (6, 3). Then both semiknights go to (4, 5) but this square is bad, so they move together to square (2, 7).

On the second board the semiknights will never meet.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct ASDF {
  ASDF& operator,(int& a) {
    scanf("%d", &a);
    return *this;
  }
  ASDF& operator,(long int& a) {
    scanf("%ld", &a);
    return *this;
  }
  ASDF& operator,(long long int& a) {
    scanf("%lld", &a);
    return *this;
  }
  ASDF& operator,(char& c) {
    scanf("%c", &c);
    return *this;
  }
  ASDF& operator,(double& d) {
    scanf("%lf", &d);
    return *this;
  }
  template <typename T>
  ASDF& operator,(T& a) {
    cin >> a;
    return *this;
  }
} asdf;
struct ASDFG {
  template <typename T>
  ASDFG& operator,(vector<T>& v) {
    printf("[");
    cout << v[0];
    for (int i = 1; i < int(v.size()); i++) {
      cout << ", " << v[i];
    }
    printf("]");
    return *this;
  }
  template <typename T>
  ASDFG& operator,(T x) {
    cout << x << " ";
    return *this;
  }
} asdfg;
bool cnt[8][8];
string board[8];
int dist[8][8];
int x[] = {2, 2, -2, -2};
int y[] = {2, -2, 2, -2};
bool isValid(int i, int j) { return -1 < i && i < 8 && -1 < j && j < 8; }
bool search(int i, int j) {
  cnt[i][j] = true;
  if (board[i][j] == 'K') {
    return dist[i][j] % 2 == 0;
  } else {
    bool res = false;
    for (int k = 0; k < 4; k++) {
      int xx, yy;
      xx = i + x[k];
      yy = j + y[k];
      if (isValid(xx, yy) && cnt[xx][yy] == false) {
        dist[xx][yy] = dist[i][j] + 1;
        res = res | search(xx, yy);
      }
    }
    return res;
  }
}
int main() {
  int kases;
  scanf("%d", &kases);
  bool result;
  while (kases--) {
    for (int i = 0; i < 8; i++) {
      cin >> board[i];
    }
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (board[i][j] == 'K') {
          dist[i][j] = 0;
          board[i][j] = '.';
          result = search(i, j);
          goto hell;
        }
      }
    }
  hell:
    if (result) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

```


### Prompt

Please formulate a cpp solution to the following problem:

The Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang.

The Berland capital's map is represented by an n × m rectangular table. Each cell of the table on the map represents some districts of the capital.

The capital's main detective Polycarpus took a map and marked there the districts where the first three robberies had been committed as asterisks. Deduction tells Polycarpus that the fourth robbery will be committed in such district, that all four robbed districts will form the vertices of some rectangle, parallel to the sides of the map.

Polycarpus is good at deduction but he's hopeless at math. So he asked you to find the district where the fourth robbery will be committed.

Input

The first line contains two space-separated integers n and m (2 ≤ n, m ≤ 100) — the number of rows and columns in the table, correspondingly.

Each of the next n lines contains m characters — the description of the capital's map. Each character can either be a "." (dot), or an "*" (asterisk). A character equals "*" if the corresponding district has been robbed. Otherwise, it equals ".".

It is guaranteed that the map has exactly three characters "*" and we can always find the fourth district that meets the problem requirements.

Output

Print two integers — the number of the row and the number of the column of the city district that is the fourth one to be robbed. The rows are numbered starting from one from top to bottom and the columns are numbered starting from one from left to right.

Examples

Input

3 2
.*
..
**

Output

1 1

Input

3 3
*.*
*..
...

Output

2 3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k = 0, n, m, x[101] = {0}, y[101] = {0};
  cin >> n >> m;
  char c;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      cin >> c;
      if (c == '*') {
        x[j]++;
        y[i]++;
      }
    }
  for (i = 0; i < m; i++) {
    if (x[i] == 1) k = i;
  }
  for (i = 0; i < n; i++) {
    if (y[i] == 1) j = i;
  }
  cout << j + 1 << ' ' << k + 1;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer.

Snuke's objective is to permute the element in a so that the following condition is satisfied:

* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.

Determine whether Snuke can achieve his objective.

Constraints

* 2 ≤ N ≤ 10^5
* a_i is an integer.
* 1 ≤ a_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.

Examples

Input

3
1 10 100

Output

Yes

Input

4
1 2 3 4

Output

No

Input

3
1 4 1

Output

Yes

Input

2
1 1

Output

No

Input

6
2 7 1 8 2 8

Output

Yes

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,n4=0,n2=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%4==0)
      n4++;
    else if(a%2==0)
      n2++;
  }
  if(n/2<=n4+n2/2)
    cout<<"Yes";
  else
    cout<<"No";
}
```


### Prompt

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

You are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences.

Let B be the sum of elements belonging to b, and C be the sum of elements belonging to c (if some of these sequences is empty, then its sum is 0). What is the maximum possible value of B - C?

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the number of elements in a.

The second line contains n integers a1, a2, ..., an ( - 100 ≤ ai ≤ 100) — the elements of sequence a.

Output

Print the maximum possible value of B - C, where B is the sum of elements of sequence b, and C is the sum of elements of sequence c.

Examples

Input

3
1 -2 0

Output

3

Input

6
16 23 16 15 42 8

Output

120

Note

In the first example we may choose b = {1, 0}, c = { - 2}. Then B = 1, C = - 2, B - C = 3.

In the second example we choose b = {16, 23, 16, 15, 42, 8}, c = {} (an empty sequence). Then B = 120, C = 0, B - C = 120.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n(0);
  cin >> n;
  vector<int> v(n);
  long long sum_b(0), sum_c(0);
  for (auto i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] >= 0)
      sum_b += v[i];
    else
      sum_c += v[i];
  }
  cout << sum_b - sum_c << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

A nearby pie shop is having a special sale. For each pie you pay full price for, you may select one pie of a strictly lesser value to get for free. Given the prices of all the pies you wish to acquire, determine the minimum total amount you must pay for all of the pies.

Input

Input will begin with an integer n (1 ≤ n ≤ 500000), the number of pies you wish to acquire. Following this is a line with n integers, each indicating the cost of a pie. All costs are positive integers not exceeding 109.

Output

Print the minimum cost to acquire all the pies.

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

Examples

Input

6
3 4 5 3 4 5

Output

14

Input

5
5 5 5 5 5

Output

25

Input

4
309999 6000 2080 2080

Output

314159

Note

In the first test case you can pay for a pie with cost 5 and get a pie with cost 4 for free, then pay for a pie with cost 5 and get a pie with cost 3 for free, then pay for a pie with cost 4 and get a pie with cost 3 for free.

In the second test case you have to pay full price for every pie.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
map<int, int> mp;
priority_queue<int, vector<int>, greater<int> > q;
void update(int price, int Y, int S) {
  int X = q.size();
  Y = min(Y, S);
  int cy = Y, cx = (S - Y) / 2;
  vector<int> removed;
  while (q.size() > cx) {
    int tmp = q.top();
    removed.push_back(tmp);
    q.pop();
  }
  reverse(removed.begin(), removed.end());
  int x = cx, y = 0;
  while (x + y < cx + cy) {
    if (y == 0 && x < X && removed[x - cx] > price) {
      q.push(removed[x - cx]);
      x++;
    } else if (y < Y && 2 * x + y < S) {
      q.push(price);
      y++;
    } else {
      if (2 * price > removed[x - cx - 1])
        q.push(2 * price - removed[x - cx - 1]);
      else
        q.push(0);
      x--;
      y += 2;
    }
  }
}
int main() {
  int n, x;
  int sum = 0;
  long long ans = 0ll;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    mp[-x]++;
    ans += x;
  }
  map<int, int>::iterator it;
  for (it = mp.begin(); it != mp.end(); it++) {
    update(-(it->first), it->second, sum);
    sum += it->second;
  }
  while (q.size()) {
    x = q.top();
    q.pop();
    ans -= x;
  }
  printf("%I64d\n", ans);
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.

Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.

Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.

void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;

cout << endl;
}

Constraints

* 3 ≤ n ≤ 10000

Input

An integer n is given in a line.

Output

Print the output result of the above program for given integer n.

Example

Input

30

Output

3 6 9 12 13 15 18 21 23 24 27 30

### Response

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

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		if( i % 3 == 0 || i % 10 == 3 || i / 10 % 10 == 3 || i / 100 % 10 == 3 ||  i / 1000 % 10 == 3) cout << " " << i;
	}
	cout<<endl;
	// your code goes here
	return 0;
}
```


### Prompt

Please create a solution in Cpp to the following problem:

A programming competition site AtCode provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode.

A user of AtCode has a value called total score. The total score of a user is the sum of the following two elements:

* Base score: the sum of the scores of all problems solved by the user.
* Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).

Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?

Constraints

* 1 ≤ D ≤ 10
* 1 ≤ p_i ≤ 100
* 100 ≤ c_i ≤ 10^6
* 100 ≤ G
* All values in input are integers.
* c_i and G are all multiples of 100.
* It is possible to have a total score of G or more points.

Input

Input is given from Standard Input in the following format:

D G
p_1 c_1
:
p_D c_D

Output

Print the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).

Examples

Input

2 700
3 500
5 800

Output

3

Input

2 2000
3 500
5 800

Output

7

Input

2 400
3 500
5 800

Output

2

Input

5 25000
20 1000
40 1000
50 1000
30 1000
1 1000

Output

66

### Response

```cpp
#include <iostream>
using namespace std;
int main(){
  int D, G, p[10], c[10] ;
  cin >> D >> G;
  for(int i=0; i<D; ++i){
    cin >> p[i] >> c[i];
  }
  int ans=1e3;
  for(int mask=0; mask<(1<<D); ++mask){
    int s=0, num=0, rest_max=0;
    for(int i=0; i<D; ++i){
      if(mask >>i &1){
        s+= 100*p[i]*(i+1)+c[i];
        num+=p[i];
      }
      else{
        rest_max=i;
      }
    }
    int need=0;
    if(s<G){
      int s1=100*(rest_max+1);
      need=(G-s+s1-1)/s1;
      if(need>= p[rest_max]) continue;
      num+= need;
    }
    ans= min(ans,num);
  }
  cout << ans << endl;
}
```


### Prompt

Please formulate a cpp solution to the following problem:

One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.

According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.

Every day Vasya puts on new socks in the morning and throws them away before going to bed as he doesn't want to wash them.

Vasya wonders, what is the maximum number of days when he can dress fashionable and wear different socks, and after that, for how many days he can then wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.

Can you help him?

Input

The single line of the input contains two positive integers a and b (1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got.

Output

Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.

Keep in mind that at the end of the day Vasya throws away the socks that he's been wearing on that day.

Examples

Input

3 1

Output

1 1

Input

2 3

Output

2 0

Input

7 3

Output

3 2

Note

In the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int inf = 1000;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int a, b;
  cin >> a >> b;
  cout << min(a, b) << ' ';
  a = max(a, b) - min(a, b);
  cout << a / 2;
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves.

The great kingdom consisted of n cities numbered from 1 to n and m bidirectional roads between these cities, numbered from 1 to m. The i-th road had length equal to wi. The Great Arya and Pari The Great were discussing about destructing some prefix (all road with numbers less than some x) and suffix (all roads with numbers greater than some x) of the roads so there will remain only the roads with numbers l, l + 1, ..., r - 1 and r.

After that they will divide the great kingdom into two pieces (with each city belonging to exactly one piece) such that the hardness of the division is minimized. The hardness of a division is the maximum length of a road such that its both endpoints are in the same piece of the kingdom. In case there is no such road, the hardness of the division is considered to be equal to  - 1.

Historians found the map of the great kingdom, and they have q guesses about the l and r chosen by those great rulers. Given these data, for each guess li and ri print the minimum possible hardness of the division of the kingdom.

Input

The first line of the input contains three integers n, m and q (1 ≤ n, q ≤ 1000, <image>) — the number of cities and roads in the great kingdom, and the number of guesses, respectively.

The i-th line of the following m lines contains three integers ui, vi and wi (1 ≤ ui, vi ≤ n, 0 ≤ wi ≤ 109), denoting the road number i connects cities ui and vi and its length is equal wi. It's guaranteed that no road connects the city to itself and no pair of cities is connected by more than one road.

Each of the next q lines contains a pair of integers li and ri (1 ≤ li ≤ ri ≤ m) — a guess from the historians about the remaining roads in the kingdom.

Output

For each guess print the minimum possible hardness of the division in described scenario.

Example

Input

5 6 5
5 4 86
5 1 0
1 3 38
2 1 33
2 4 28
2 3 40
3 5
2 6
1 3
2 3
1 6

Output

-1
33
-1
-1
33

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct str {
  int a, b, len;
} edge[1010 * 1010], sing[1010 * 1010];
vector<str> Edge[501000 << 2];
int n, m, Q;
int top, ans;
int re[1010], fa[1010];
bool cmp(const str &a, const str &b) { return (a.len > b.len); }
int find(int a) {
  if (a == fa[a]) return a;
  int f = fa[a];
  fa[a] = find(f);
  re[a] ^= re[f];
  return fa[a];
}
void build(int u, int L, int R) {
  int n = 0;
  for (int i = L; i <= R; i++) sing[++n] = edge[i];
  sort(sing + 1, sing + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    int a = sing[i].a, b = sing[i].b;
    if (find(a) != find(b)) {
      re[fa[a]] = re[a] ^ re[b] ^ 1;
      fa[fa[a]] = fa[b];
      Edge[u].push_back(sing[i]);
    } else if (re[a] == re[b]) {
      Edge[u].push_back(sing[i]);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    int a = sing[i].a, b = sing[i].b;
    re[a] = 0;
    re[b] = 0;
    fa[a] = a;
    fa[b] = b;
  }
  if (L < R) {
    build((u << 1), L, ((L + R) >> 1));
    build((u << 1 | 1), (((L + R) >> 1) + 1), R);
  }
  return;
}
void proc(int u, int L, int R, int l, int r) {
  if (L == l && R == r) {
    for (int i = 0; i < (int)Edge[u].size(); i++) sing[++top] = Edge[u][i];
    return;
  }
  if (r < (((L + R) >> 1) + 1))
    proc((u << 1), L, ((L + R) >> 1), l, r);
  else if (l > ((L + R) >> 1))
    proc((u << 1 | 1), (((L + R) >> 1) + 1), R, l, r);
  else {
    proc((u << 1), L, ((L + R) >> 1), l, ((L + R) >> 1));
    proc((u << 1 | 1), (((L + R) >> 1) + 1), R, (((L + R) >> 1) + 1), r);
  }
  return;
}
int main() {
  scanf("%d %d %d", &n, &m, &Q);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &edge[i].a, &edge[i].b, &edge[i].len);
  }
  for (int i = 1; i <= n; i++) fa[i] = i;
  build(1, 1, m);
  for (; Q; Q--) {
    int l, r;
    for (int i = 1; i <= n; i++) re[i] = 0, fa[i] = i;
    scanf("%d %d", &l, &r);
    top = 0;
    proc(1, 1, m, l, r);
    sort(sing + 1, sing + top + 1, cmp);
    ans = -1;
    for (int i = 1; i <= top; i++) {
      int a = sing[i].a, b = sing[i].b;
      if (find(a) != find(b)) {
        re[fa[a]] = re[a] ^ re[b] ^ 1;
        fa[fa[a]] = fa[b];
      } else if (re[a] == re[b]) {
        ans = sing[i].len;
        break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.

For instance, if we are given an array [10, 20, 30, 40], we can permute it so that it becomes [20, 40, 10, 30]. Then on the first and the second positions the integers became larger (20>10, 40>20) and did not on the third and the fourth, so for this permutation, the number that Vasya wants to maximize equals 2. Read the note for the first example, there is one more demonstrative test case.

Help Vasya to permute integers in such way that the number of positions in a new array, where integers are greater than in the original one, is maximal.

Input

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

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the elements of the array.

Output

Print a single integer — the maximal number of the array's elements which after a permutation will stand on the position where a smaller element stood in the initial array.

Examples

Input

7
10 1 1 1 5 5 3

Output

4

Input

5
1 1 1 1 1

Output

0

Note

In the first sample, one of the best permutations is [1, 5, 5, 3, 10, 1, 1]. On the positions from second to fifth the elements became larger, so the answer for this permutation is 4.

In the second sample, there is no way to increase any element with a permutation, so the answer is 0.

### Response

```cpp
#include <bits/stdc++.h>
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
void run(void) {
  int n;
  scanf("%d", &n);
  int *a = (int *)malloc(sizeof(int) * n);
  int i;
  for (i = 0; i < n; i++) scanf("%d", a + i);
  qsort(a, n, sizeof(int), cmp);
  int ans = 0;
  int l, r;
  l = r = 0;
  while (r < n) {
    while (r < n && a[l] < a[r]) {
      ans++;
      l++;
      r++;
    }
    while (r < n && a[l] == a[r]) r++;
  }
  printf("%d\n", ans);
}
int main(void) {
  run();
  return 0;
}

```


### Prompt

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

There is a cave.

The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.

It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.

Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.

* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.

Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Constraints

* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
:
A_M B_M

Output

If there is no way to place signposts satisfying the objective, print `No`.

Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.

Examples

Input

4 4
1 2
2 3
3 4
4 2

Output

Yes
1
2
2

Input

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

Output

Yes
6
5
5
1
1

### Response

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

int main(){
  int n, m; cin >> n >> m;

  vector<vector<int>> graph(n+1);

  for(int i = 0; i < m; i++){
  	int a, b; cin >> a >> b;

  	graph[a].push_back(b);
  	graph[b].push_back(a);
  }

  queue<int> que;
  que.push(1);

  vector<int> seen(n+1, -1);
  seen[1] = 1;

  vector<int> parent(n+1);

  while(!que.empty()){
  	int nv = que.front();
    que.pop();

  	for(int v : graph[nv]){
    	if(seen[v] != -1) continue;
      	que.push(v);

      	seen[v] = 1;

      	parent[v] = nv;
  	}

  }

  cout << "Yes" << endl;
  for(int i = 2; i <= n; i++) cout << parent[i] << endl;
}

```


### Prompt

Generate a cpp solution to the following problem:

Mahmoud and Ehab are on the third stage of their adventures now. As you know, Dr. Evil likes sets. This time he won't show them any set from his large collection, but will ask them to create a new set to replenish his beautiful collection of sets.

Dr. Evil has his favorite evil integer x. He asks Mahmoud and Ehab to find a set of n distinct non-negative integers such the bitwise-xor sum of the integers in it is exactly x. Dr. Evil doesn't like big numbers, so any number in the set shouldn't be greater than 106.

Input

The only line contains two integers n and x (1 ≤ n ≤ 105, 0 ≤ x ≤ 105) — the number of elements in the set and the desired bitwise-xor, respectively.

Output

If there is no such set, print "NO" (without quotes).

Otherwise, on the first line print "YES" (without quotes) and on the second line print n distinct integers, denoting the elements in the set is any order. If there are multiple solutions you can print any of them.

Examples

Input

5 5

Output

YES
1 2 4 5 7

Input

3 6

Output

YES
1 2 5

Note

You can read more about the bitwise-xor operation here: <https://en.wikipedia.org/wiki/Bitwise_operation#XOR>

For the first sample <image>.

For the second sample <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long magicconst = 2000000000000000000;
long long gcd(long long a, long long b) {
  if (b > a) swap(a, b);
  while (a > 0 && b > 0) {
    a %= b;
    swap(a, b);
  }
  return a + b;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
int getrandomint(int max) {
  return (int)(((long long)rand() * (RAND_MAX + 1) + rand()) % max);
}
int main() {
  ios_base::sync_with_stdio(false);
  srand(505);
  int n, m;
  cin >> n >> m;
  if (n == 2 && m == 0) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  if (n == 1) {
    cout << m;
    return 0;
  }
  bool f = true;
  while (f) {
    set<int> answer;
    int x = 0;
    for (int i = 0; i < n - 1; i++) {
      bool tr = true;
      int temp;
      while (tr) {
        temp = getrandomint(399998) + 100001;
        if (answer.find(temp) == answer.end()) {
          tr = false;
        }
      }
      x ^= temp;
      answer.insert(temp);
    }
    int last = m ^ x;
    if (answer.find(last) == answer.end()) {
      cout << last << " ";
      for (int k : answer) {
        cout << k << " ";
      }
      return 0;
    }
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Berkomnadzor — Federal Service for Supervision of Communications, Information Technology and Mass Media — is a Berland federal executive body that protects ordinary residents of Berland from the threats of modern internet.

Berkomnadzor maintains a list of prohibited IPv4 subnets (blacklist) and a list of allowed IPv4 subnets (whitelist). All Internet Service Providers (ISPs) in Berland must configure the network equipment to block access to all IPv4 addresses matching the blacklist. Also ISPs must provide access (that is, do not block) to all IPv4 addresses matching the whitelist. If an IPv4 address does not match either of those lists, it's up to the ISP to decide whether to block it or not. An IPv4 address matches the blacklist (whitelist) if and only if it matches some subnet from the blacklist (whitelist). An IPv4 address can belong to a whitelist and to a blacklist at the same time, this situation leads to a contradiction (see no solution case in the output description).

An IPv4 address is a 32-bit unsigned integer written in the form a.b.c.d, where each of the values a,b,c,d is called an octet and is an integer from 0 to 255 written in decimal notation. For example, IPv4 address 192.168.0.1 can be converted to a 32-bit number using the following expression 192 ⋅ 2^{24} + 168 ⋅ 2^{16} + 0 ⋅ 2^8 + 1 ⋅ 2^0. First octet a encodes the most significant (leftmost) 8 bits, the octets b and c — the following blocks of 8 bits (in this order), and the octet d encodes the least significant (rightmost) 8 bits.

The IPv4 network in Berland is slightly different from the rest of the world. There are no reserved or internal addresses in Berland and use all 2^{32} possible values.

An IPv4 subnet is represented either as a.b.c.d or as a.b.c.d/x (where 0 ≤ x ≤ 32). A subnet a.b.c.d contains a single address a.b.c.d. A subnet a.b.c.d/x contains all IPv4 addresses with x leftmost (most significant) bits equal to x leftmost bits of the address a.b.c.d. It is required that 32 - x rightmost (least significant) bits of subnet a.b.c.d/x are zeroes.

Naturally it happens that all addresses matching subnet a.b.c.d/x form a continuous range. The range starts with address a.b.c.d (its rightmost 32 - x bits are zeroes). The range ends with address which x leftmost bits equal to x leftmost bits of address a.b.c.d, and its 32 - x rightmost bits are all ones. Subnet contains exactly 2^{32-x} addresses. Subnet a.b.c.d/32 contains exactly one address and can also be represented by just a.b.c.d.

For example subnet 192.168.0.0/24 contains range of 256 addresses. 192.168.0.0 is the first address of the range, and 192.168.0.255 is the last one.

Berkomnadzor's engineers have devised a plan to improve performance of Berland's global network. Instead of maintaining both whitelist and blacklist they want to build only a single optimised blacklist containing minimal number of subnets. The idea is to block all IPv4 addresses matching the optimised blacklist and allow all the rest addresses. Of course, IPv4 addresses from the old blacklist must remain blocked and all IPv4 addresses from the old whitelist must still be allowed. Those IPv4 addresses which matched neither the old blacklist nor the old whitelist may be either blocked or allowed regardless of their accessibility before.

Please write a program which takes blacklist and whitelist as input and produces optimised blacklist. The optimised blacklist must contain the minimal possible number of subnets and satisfy all IPv4 addresses accessibility requirements mentioned above.

IPv4 subnets in the source lists may intersect arbitrarily. Please output a single number -1 if some IPv4 address matches both source whitelist and blacklist.

Input

The first line of the input contains single integer n (1 ≤ n ≤ 2⋅10^5) — total number of IPv4 subnets in the input.

The following n lines contain IPv4 subnets. Each line starts with either '-' or '+' sign, which indicates if the subnet belongs to the blacklist or to the whitelist correspondingly. It is followed, without any spaces, by the IPv4 subnet in a.b.c.d or a.b.c.d/x format (0 ≤ x ≤ 32). The blacklist always contains at least one subnet.

All of the IPv4 subnets given in the input are valid. Integer numbers do not start with extra leading zeroes. The provided IPv4 subnets can intersect arbitrarily.

Output

Output -1, if there is an IPv4 address that matches both the whitelist and the blacklist. Otherwise output t — the length of the optimised blacklist, followed by t subnets, with each subnet on a new line. Subnets may be printed in arbitrary order. All addresses matching the source blacklist must match the optimised blacklist. All addresses matching the source whitelist must not match the optimised blacklist. You can print a subnet a.b.c.d/32 in any of two ways: as a.b.c.d/32 or as a.b.c.d.

If there is more than one solution, output any.

Examples

Input

1
-149.154.167.99

Output

1
0.0.0.0/0

Input

4
-149.154.167.99
+149.154.167.100/30
+149.154.167.128/25
-149.154.167.120/29

Output

2
149.154.167.99
149.154.167.120/29

Input

5
-127.0.0.4/31
+127.0.0.8
+127.0.0.0/30
-195.82.146.208/29
-127.0.0.6/31

Output

2
195.0.0.0/8
127.0.0.4/30

Input

2
+127.0.0.1/32
-127.0.0.1

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 7000000;
int dp[N], chd[N][2], e[4], T = 1, fa[N];
short val[N];
bool sel[N], sgn[N], cn[N][3];
char s[44];
void dfs(int u) {
  cn[u][1] = cn[u][2] = 0;
  cn[u][val[u]] = 1;
  for (int i = 0; i < 2; i++) {
    int v = chd[u][i];
    if (!v) continue;
    dp[v] = dp[u] + 1;
    dfs(v);
    for (int j = 1; j <= 2; j++) cn[u][j] |= cn[v][j];
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    int len = strlen(s);
    int x = 0, tp = 1;
    int j;
    for (j = len - 1; j >= 0; j--) {
      if (s[j] == '/') break;
      x = (s[j] - '0') * tp + x;
      tp *= 10;
    }
    if (j == -1) x = 32;
    long long X = 0;
    for (int c = 0, j = 1; c < 4; c++) {
      int d = 0;
      for (; s[j] != '.' && s[j] != '/' && j < len; j++)
        d = d * 10 + s[j] - '0';
      j++;
      X = X << 8 | d;
    }
    if (((1LL << (32 - x)) - 1) & X) return puts("-1"), 0;
    int root = 1;
    for (j = 0; j < x; j++) {
      int c = X >> (31 - j) & 1;
      if (!chd[root][c]) chd[root][c] = ++T, fa[T] = root, sgn[T] = c;
      root = chd[root][c];
    }
    int t = (s[0] == '-' ? 1 : 2);
    if (val[root] + t == 3) return puts("-1"), 0;
    val[root] = t;
  }
  dfs(1);
  for (int i = 1; i <= T; i++)
    if (val[i]) {
      if (cn[i][3 - val[i]]) return puts("-1"), 0;
      if (val[i] == 2) continue;
      int j = i;
      while (j > 1 && !cn[fa[j]][2]) j = fa[j];
      sel[j] = 1;
    }
  int tot = 0;
  for (int i = 1; i <= T; i++) tot += sel[i];
  cout << tot << endl;
  for (int i = 1; i <= T; i++) {
    if (!sel[i]) continue;
    int j = i, x = 0;
    long long tp = (1LL << (32 - dp[i]));
    long long X = 0;
    while (j != 1) {
      X += tp * sgn[j], j = fa[j], tp *= 2, x++;
    }
    for (int c = 0; c < 4; c++) e[c] = X % 256, X /= 256;
    printf("%d.%d.%d.%d", e[3], e[2], e[1], e[0]);
    if (x < 32) printf("/%d", x);
    puts("");
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

One of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal s towards a faraway galaxy. Recently they've received a response t which they believe to be a response from aliens! The scientists now want to check if the signal t is similar to s.

The original signal s was a sequence of zeros and ones (everyone knows that binary code is the universe-wide language). The returned signal t, however, does not look as easy as s, but the scientists don't give up! They represented t as a sequence of English letters and say that t is similar to s if you can replace all zeros in s with some string r_0 and all ones in s with some other string r_1 and obtain t. The strings r_0 and r_1 must be different and non-empty.

Please help Arkady's friend and find the number of possible replacements for zeros and ones (the number of pairs of strings r_0 and r_1) that transform s to t.

Input

The first line contains a string s (2 ≤ |s| ≤ 10^5) consisting of zeros and ones — the original signal.

The second line contains a string t (1 ≤ |t| ≤ 10^6) consisting of lowercase English letters only — the received signal.

It is guaranteed, that the string s contains at least one '0' and at least one '1'.

Output

Print a single integer — the number of pairs of strings r_0 and r_1 that transform s to t.

In case there are no such pairs, print 0.

Examples

Input

01
aaaaaa

Output

4

Input

001
kokokokotlin

Output

2

Note

In the first example, the possible pairs (r_0, r_1) are as follows:

  * "a", "aaaaa"
  * "aa", "aaaa"
  * "aaaa", "aa"
  * "aaaaa", "a"

The pair "aaa", "aaa" is not allowed, since r_0 and r_1 must be different.

In the second example, the following pairs are possible:

  * "ko", "kokotlin"
  * "koko", "tlin"

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod[] = {1000000007, 1000000009};
const int base[] = {79, 271};
string s1, s2;
int pws[2][1000009], pre[2][1000009], lol[2], n, m;
pair<int, int> unini;
pair<int, int> getHash(int l, int r) {
  if (l == 0) {
    return make_pair(pre[0][r], pre[1][r]);
  }
  int i, j, t1, t2, t3, t4;
  long long int buf1, buf2, buf3, buf4;
  for (i = 0; i < 2; i++) {
    buf1 = (1ll * pre[i][l - 1] * pws[i][r - l + 1]) % mod[i];
    buf1 = (pre[i][r] - buf1) % mod[i];
    if (buf1 < 0) {
      buf1 += mod[i];
    }
    lol[i] = buf1;
  }
  return make_pair(lol[0], lol[1]);
}
int solve(int l1, int l2) {
  int i, j, t1, t2, t3, t4;
  pair<int, int> p1, p2;
  p1 = p2 = unini;
  t1 = 0;
  for (i = 0; i < n; i++) {
    if (s1[i] == '0') {
      if (p1 == unini) {
        p1 = getHash(t1, t1 + l1 - 1);
      } else {
        if (p1 != getHash(t1, t1 + l1 - 1)) {
          return 0;
        }
      }
      t1 += l1;
    } else {
      if (p2 == unini) {
        p2 = getHash(t1, t1 + l2 - 1);
      } else {
        if (p2 != getHash(t1, t1 + l2 - 1)) {
          return 0;
        }
      }
      t1 += l2;
    }
  }
  if (p1 == p2) {
    return 0;
  }
  return (t1 == m);
}
int main() {
  ios::sync_with_stdio(0);
  int i, j, t1, t2, t3, t4, cnt0, cnt1, ans = 0;
  string temp1, temp2;
  cin >> s1 >> s2;
  n = s1.length();
  m = s2.length();
  unini = make_pair(-1, -1);
  pws[0][0] = pws[1][0] = 1;
  for (i = 0; i < 2; i++) {
    for (j = 1; j <= m; j++) {
      pws[i][j] = (1ll * pws[i][j - 1] * base[i]) % mod[i];
    }
  }
  pre[0][0] = pre[1][0] = (s2[0] - 'a' + 1);
  for (i = 0; i < 2; i++) {
    for (j = 1; j < m; j++) {
      pre[i][j] = (1ll * pre[i][j - 1] * base[i]) % mod[i];
      pre[i][j] += (s2[j] - 'a' + 1);
      pre[i][j] %= mod[i];
    }
  }
  if (s1[0] == '1') {
    for (i = 0; i < n; i++) {
      if (s1[i] == '0') {
        s1[i] = '1';
      } else {
        s1[i] = '0';
      }
    }
  }
  cnt0 = cnt1 = 0;
  for (i = 0; i < n; i++) {
    if (s1[i] == '0') {
      cnt0++;
    } else {
      cnt1++;
    }
  }
  for (i = 1; i <= m; i++) {
    t1 = cnt0 * i;
    t2 = (m - t1) / cnt1;
    t3 = (cnt1 * t2) + t1;
    if ((m - t1) % cnt1 || t3 != m || t2 <= 0) {
      continue;
    }
    ans += solve(i, (m - t1) / cnt1);
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

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

One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.

But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name.

It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita".

Names are case sensitive.

Input

The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem.

Output

Print "YES", if problem is from this contest, and "NO" otherwise.

Examples

Input

Alex_and_broken_contest

Output

NO

Input

NikitaAndString

Output

YES

Input

Danil_and_Olya

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a[] = {"Danil", "Olya", "Slava", "Ann", "Nikita"};
  string str;
  cin >> str;
  int num = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < str.size(); j++) {
      if (str.substr(j, a[i].size()) == a[i]) {
        num++;
      }
    }
  }
  if (num == 1)
    printf("YES");
  else
    printf("NO");
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You are given an array a of n integers.

You want to make all elements of a equal to zero by doing the following operation exactly three times:

  * Select a segment, for each number in this segment we can add a multiple of len to it, where len is the length of this segment (added integers can be different).

It can be proven that it is always possible to make all elements of a equal to zero.

Input

The first line contains one integer n (1 ≤ n ≤ 100 000): the number of elements of the array.

The second line contains n elements of an array a separated by spaces: a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9).

Output

The output should contain six lines representing three operations.

For each operation, print two lines:

  * The first line contains two integers l, r (1 ≤ l ≤ r ≤ n): the bounds of the selected segment.

  * The second line contains r-l+1 integers b_l, b_{l+1}, ..., b_r (-10^{18} ≤ b_i ≤ 10^{18}): the numbers to add to a_l, a_{l+1}, …, a_r, respectively; b_i should be divisible by r - l + 1.

Example

Input

4
1 3 2 4

Output

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

### Response

```cpp
#include <bits/stdc++.h>
const unsigned long long int M = 1000000007;
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = x * res;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long power(long long x, long long y, long long mod) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = x * res % mod;
    y = y >> 1;
    x = x * x % mod;
  }
  return res;
}
void nik() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
signed main() {
  nik();
  long long test = 1;
  while (test--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    if (n == 1) {
      cout << "1 1\n";
      cout << -a[0] << "\n";
      cout << "1 1\n";
      cout << 0 << "\n";
      cout << "1 1\n";
      cout << 0 << "\n";
      continue;
    }
    cout << "1 1\n";
    cout << -a[0] << "\n";
    cout << "1 " << n << "\n";
    a[0] = 0;
    for (long long i = 0; i < n; i++) cout << -n * a[i] << " ";
    cout << "\n2 " << n << "\n";
    for (long long i = 1; i < n; i++) cout << ((n - 1) * a[i]) << " ";
  }
  return 0;
}

```


### Prompt

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

Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat.

One day the director of the F company got hold of the records of a part of an online meeting of one successful team. The director watched the record and wanted to talk to the team leader. But how can he tell who the leader is? The director logically supposed that the leader is the person who is present at any conversation during a chat meeting. In other words, if at some moment of time at least one person is present on the meeting, then the leader is present on the meeting.

You are the assistant director. Given the 'user logged on'/'user logged off' messages of the meeting in the chronological order, help the director determine who can be the leader. Note that the director has the record of only a continuous part of the meeting (probably, it's not the whole meeting).

Input

The first line contains integers n and m (1 ≤ n, m ≤ 105) — the number of team participants and the number of messages. Each of the next m lines contains a message in the format:

  * '+ id': the record means that the person with number id (1 ≤ id ≤ n) has logged on to the meeting.
  * '- id': the record means that the person with number id (1 ≤ id ≤ n) has logged off from the meeting.

Assume that all the people of the team are numbered from 1 to n and the messages are given in the chronological order. It is guaranteed that the given sequence is the correct record of a continuous part of the meeting. It is guaranteed that no two log on/log off events occurred simultaneously.

Output

In the first line print integer k (0 ≤ k ≤ n) — how many people can be leaders. In the next line, print k integers in the increasing order — the numbers of the people who can be leaders.

If the data is such that no member of the team can be a leader, print a single number 0.

Examples

Input

5 4
+ 1
+ 2
- 2
- 1

Output

4
1 3 4 5

Input

3 2
+ 1
- 2

Output

1
3

Input

2 4
+ 1
- 1
+ 2
- 2

Output

0

Input

5 6
+ 1
- 1
- 3
+ 3
+ 4
- 4

Output

3
2 3 5

Input

2 4
+ 1
- 2
+ 2
- 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
char c[100001];
int a[100001];
int f[100001];
bool mark[100001];
int cnt;
set<int> s;
void cl() {
  for (set<int>::iterator i = s.begin(); i != s.end(); i++) mark[*i] = true;
  s.clear();
}
int main() {
  memset(f, -1, sizeof(f));
  scanf("%d %d\n", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%c %d\n", &c[i], &a[i]);
    if (f[a[i]] == -1) {
      if (c[i] == '+')
        f[a[i]] = 0;
      else
        f[a[i]] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (f[i] == 1) cnt++;
    if (f[i] == 0) s.insert(i);
  }
  if (cnt > 0) cl();
  for (int i = 1; i <= m; i++) {
    if (c[i] == '+') {
      f[a[i]] = 1;
      cnt++;
      s.erase(a[i]);
      cl();
    } else {
      f[a[i]] = 0;
      cnt--;
      if (!mark[a[i]]) s.insert(a[i]);
      if (cnt > 0) cl();
    }
  }
  cnt = 0;
  for (int i = 1; i <= n; i++)
    if (!mark[i]) cnt++;
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++)
    if (!mark[i]) printf("%d ", i);
  printf("\n");
  return 0;
}

```


### Prompt

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

Jeff has become friends with Furik. Now these two are going to play one quite amusing game.

At the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of n numbers: p1, p2, ..., pn. Then the guys take turns to make moves, Jeff moves first. During his move, Jeff chooses two adjacent permutation elements and then the boy swaps them. During his move, Furic tosses a coin and if the coin shows "heads" he chooses a random pair of adjacent elements with indexes i and i + 1, for which an inequality pi > pi + 1 holds, and swaps them. But if the coin shows "tails", Furik chooses a random pair of adjacent elements with indexes i and i + 1, for which the inequality pi < pi + 1 holds, and swaps them. If the coin shows "heads" or "tails" and Furik has multiple ways of adjacent pairs to take, then he uniformly takes one of the pairs. If Furik doesn't have any pair to take, he tosses a coin one more time. The game ends when the permutation is sorted in the increasing order.

Jeff wants the game to finish as quickly as possible (that is, he wants both players to make as few moves as possible). Help Jeff find the minimum mathematical expectation of the number of moves in the game if he moves optimally well.

You can consider that the coin shows the heads (or tails) with the probability of 50 percent.

Input

The first line contains integer n (1 ≤ n ≤ 3000). The next line contains n distinct integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the permutation p. The numbers are separated by spaces.

Output

In a single line print a single real value — the answer to the problem. The answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6.

Examples

Input

2
1 2

Output

0.000000

Input

5
3 5 2 4 1

Output

13.000000

Note

In the first test the sequence is already sorted, so the answer is 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX = 3010;
int p[MAX];
int main() {
  int i, j, n, br = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &p[i]);
  for (i = 0; i < n; i++)
    for (j = 0; j < i; j++)
      if (p[j] > p[i]) br++;
  if (br % 2)
    printf("%d.000000\n", br * 2 - 1);
  else
    printf("%d.000000\n", br * 2);
  return 0;
}

```


### Prompt

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

Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows:

  * choose indexes i and j (i ≠ j) that haven't been chosen yet;
  * round element ai to the nearest integer that isn't more than ai (assign to ai: ⌊ ai ⌋);
  * round element aj to the nearest integer that isn't less than aj (assign to aj: ⌈ aj ⌉).

Nevertheless, Jeff doesn't want to hurt the feelings of the person who gave him the sequence. That's why the boy wants to perform the operations so as to make the absolute value of the difference between the sum of elements before performing the operations and the sum of elements after performing the operations as small as possible. Help Jeff find the minimum absolute value of the difference.

Input

The first line contains integer n (1 ≤ n ≤ 2000). The next line contains 2n real numbers a1, a2, ..., a2n (0 ≤ ai ≤ 10000), given with exactly three digits after the decimal point. The numbers are separated by spaces.

Output

In a single line print a single real number — the required difference with exactly three digits after the decimal point.

Examples

Input

3
0.000 0.500 0.750 1.000 2.000 3.000

Output

0.250

Input

3
4469.000 6526.000 4864.000 9356.383 7490.000 995.896

Output

0.279

Note

In the first test case you need to perform the operations as follows: (i = 1, j = 4), (i = 2, j = 3), (i = 5, j = 6). In this case, the difference will equal |(0 + 0.5 + 0.75 + 1 + 2 + 3) - (0 + 0 + 1 + 1 + 2 + 3)| = 0.25.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const double pi = 2 * asin(1.0);
int n;
int m;
int main() {
  scanf("%d", &n);
  int n1, n2, n12 = 0, n3, s1 = 0, res = (int)1e9;
  for (int i = 0; i < 2 * n; i++) {
    int x, y;
    scanf("%d.%d", &x, &y);
    if (y != 0) {
      s1 += y;
      n12++;
    }
  }
  n3 = 2 * n - n12;
  for (int i = 0; i <= n3 / 2; i++) {
    n1 = n - n3 + i;
    n2 = n - i;
    if (n1 < 0 || n2 < 0 || n1 + n2 + n3 != 2 * n) continue;
    res = min(min(abs(n1 * 1000 - s1), abs(n2 * 1000 - s1)), res);
  }
  float ans = (float)res / 1000;
  printf("%0.3lf\n", ans);
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Snuke has a permutation (P_0,P_1,\cdots,P_{N-1}) of (0,1,\cdots,N-1).

Now, he will perform the following operation exactly once:

* Choose K consecutive elements in P and sort them in ascending order.

Find the number of permutations that can be produced as P after the operation.

Constraints

* 2 \leq N \leq 200000
* 2 \leq K \leq N
* 0 \leq P_i \leq N-1
* P_0,P_1,\cdots,P_{N-1} are all different.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
P_0 P_1 \cdots P_{N-1}

Output

Print the number of permutations that can be produced as P after the operation.

Examples

Input

5 3
0 2 1 4 3

Output

2

Input

4 4
0 1 2 3

Output

1

Input

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

Output

6

### Response

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

const int MAXN = 200010;
int a[MAXN];
int main() {
	int n, k;
	cin>>n>>k;
	for (int i=0; i<n; i++)
		cin>>a[i];
	set<int> s;
	for (int i=0; i<k; i++)
		s.insert(a[i]);
	int ans = 0, flagasc = 0;
	int rcount = 0;
	for (int i=1; i<k; i++)
		if (a[i-1] > a[i])
			rcount++;
	if (rcount)
		ans = 1;
	else
		flagasc = 1;
	for (int i=k; i<n; i++) {
		int round = 0;
		s.erase(a[i-k]);
		if (a[i-k] > a[i-k+1])
			rcount--;

		if (a[i-k] > *s.begin() && rcount != 0)
			round = 1;
		if (a[i] < *s.rbegin())
			round = 1;

		s.insert(a[i]);
		if (a[i-1] > a[i])
			rcount++;
		ans += round;
		if (rcount == 0)
			flagasc = 1;
	}
	cout<<ans + flagasc<<endl;
	return 0;
}
```


### Prompt

Generate a CPP solution to the following problem:

You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.

Constraints

* 1 \leq |S| \leq 2 × 10^5
* S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If we cannot turn S into a palindrome, print `-1`. Otherwise, print the minimum required number of operations.

Examples

Input

eel

Output

1

Input

ataatmma

Output

4

Input

snuke

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
int const N = 202000;
char s[N];
deque<int>nex[26];
bool vis[N];
vector<int>ans;
int seg[N*4] , k;
int get(int node , int start , int end){
	if(end < k)return 0;
	if(start >= k)return seg[node];
	int mid = (start+end)/2;
	return get(node*2,start,mid) + get(node*2+1,mid+1,end);
}
int up(int node , int start , int end){
	if(start==end)seg[node] = 1;
	else{
		int mid = (start+end)/2;
		if(mid >= k)up(node*2,start,mid);
		else up(node*2+1,mid+1,end);
		seg[node] = seg[node*2] + seg[node*2+1];
	}
}
int main()
{

	scanf("%s",s);
	int len = strlen(s);
	int frq[26];
	memset(frq,0,sizeof frq);
	for(int i = 0 ; i < len ; i++){
		nex[s[i]-'a'].push_back(i);
		frq[s[i]-'a']++;
	}
	bool odd = 0;
	for(int i = 0 ; i < 26 ; i++){
		if(frq[i]%2==1)if(!odd)odd = 1;else {puts("-1");return 0;}
	}
	string s1 = "";
	int l = 0 , r = len-1;
	ans.resize(len);
	for(int i = 0 ; i < len ; i++){
		if(vis[i])continue;
		if(frq[s[i]-'a']<=1)continue;
		ans[l] = nex[s[i]-'a'].front()+1;
		ans[r] = nex[s[i]-'a'].back()+1;
		vis[ans[r]-1] = 1;
		nex[s[i]-'a'].pop_back();
		nex[s[i]-'a'].pop_front();
		l++;
		r--;
		frq[s[i]-'a']-=2;
	}
	if(odd)for(int i = 0 ; i < 26 ; i++)
		if(frq[i]==1)ans[l] = nex[i].front()+1;
	ll res = 0;
	for(int i = 0 ; i < len ; i++){
		k = ans[i];
		res += get(1,1,len);
		up(1,1,len);
	}
	printf("%lld\n", res);
	return 0;

}
```


### Prompt

Create a solution in cpp for the following problem:

Your friend has a hidden directed graph with n nodes.

Let f(u, v) be true if there is a directed path from node u to node v, and false otherwise. For each pair of distinct nodes, u, v, you know at least one of the three statements is true:

  1. <image>
  2. <image>
  3. <image>

Here AND, OR and XOR mean AND, OR and exclusive OR operations, respectively.

You are given an n by n matrix saying which one of the three statements holds for each pair of vertices. The entry in the u-th row and v-th column has a single character.

  1. If the first statement holds, this is represented by the character 'A'.
  2. If the second holds, this is represented by the character 'O'.
  3. If the third holds, this is represented by the character 'X'.
  4. The diagonal of this matrix will only contain the character '-'.

Note that it is possible that a pair of nodes may satisfy multiple statements, in which case, the character given will represent one of the true statements for that pair. This matrix is also guaranteed to be symmetric.

You would like to know if there is a directed graph that is consistent with this matrix. If it is impossible, print the integer -1. Otherwise, print the minimum number of edges that could be consistent with this information.

Input

The first line will contain an integer n (1 ≤ n ≤ 47), the number of nodes.

The next n lines will contain n characters each: the matrix of what you know about the graph connectivity in the format described in the statement.

Output

Print the minimum number of edges that is consistent with the given information, or -1 if it is impossible.

Examples

Input

4
-AAA
A-AA
AA-A
AAA-

Output

4

Input

3
-XX
X-X
XX-

Output

2

Note

Sample 1: The hidden graph is a strongly connected graph. We can put all four nodes in a cycle.

Sample 2: One valid graph is 3 → 1 → 2. For each distinct pair, exactly one of f(u, v), f(v, u) holds.

### Response

```cpp
#include <bits/stdc++.h>
const int mod = 1000000007;
const int gmod = 3;
const int inf = 1039074182;
const double eps = 1e-9;
const long long llinf = 2LL * inf * inf;
template <typename T1, typename T2>
inline void chmin(T1 &x, T2 b) {
  if (b < x) x = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &x, T2 b) {
  if (b > x) x = b;
}
inline void chadd(int &x, int b) {
  x += b - mod;
  x += (x >> 31 & mod);
}
template <typename T1, typename T2>
inline void chadd(T1 &x, T2 b) {
  x += b;
  if (x >= mod) x -= mod;
}
template <typename T1, typename T2>
inline void chmul(T1 &x, T2 b) {
  x = 1LL * x * b % mod;
}
template <typename T1, typename T2>
inline void chmod(T1 &x, T2 b) {
  x %= b, x += b;
  if (x >= b) x -= b;
}
template <typename T>
inline T mabs(T x) {
  return (x < 0 ? -x : x);
}
using namespace std;
using namespace std;
template <typename T>
ostream &operator<<(ostream &cout, vector<T> vec) {
  cout << "{";
  for (int i = 0; i < (int)vec.size(); i++) {
    cout << vec[i];
    if (i != (int)vec.size() - 1) cout << ',';
  }
  cout << "}";
  return cout;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &cout, pair<T1, T2> p) {
  cout << "(" << p.first << ',' << p.second << ")";
  return cout;
}
template <typename T, typename T2>
ostream &operator<<(ostream &cout, set<T, T2> s) {
  vector<T> t;
  for (auto x : s) t.push_back(x);
  cout << t;
  return cout;
}
template <typename T, typename T2>
ostream &operator<<(ostream &cout, multiset<T, T2> s) {
  vector<T> t;
  for (auto x : s) t.push_back(x);
  cout << t;
  return cout;
}
template <typename T>
ostream &operator<<(ostream &cout, queue<T> q) {
  vector<T> t;
  while (q.size()) {
    t.push_back(q.front());
    q.pop();
  }
  cout << t;
  return cout;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &cout, map<T1, T2, T3> m) {
  for (auto &x : m) {
    cout << "Key: " << x.first << ' ' << "Value: " << x.second << endl;
  }
  return cout;
}
template <typename T1, typename T2>
void operator+=(pair<T1, T2> &x, const pair<T1, T2> y) {
  x.first += y.first;
  x.second += y.second;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &x, const pair<T1, T2> &y) {
  return make_pair(x.first + y.first, x.second + y.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &x, const pair<T1, T2> &y) {
  return make_pair(x.first - y.first, x.second - y.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(pair<T1, T2> x) {
  return make_pair(-x.first, -x.second);
}
template <typename T>
vector<vector<T>> operator~(vector<vector<T>> vec) {
  vector<vector<T>> v;
  int n = vec.size(), m = vec[0].size();
  v.resize(m);
  for (int i = 0; i < m; i++) {
    v[i].resize(n);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      v[i][j] = vec[j][i];
    }
  }
  return v;
}
void print0x(int x) {
  std::vector<int> vec;
  while (x) {
    vec.push_back(x & 1);
    x >>= 1;
  }
  std::reverse(vec.begin(), vec.end());
  for (int i = 0; i < (int)vec.size(); i++) {
    std::cout << vec[i];
  }
  std::cout << ' ';
}
template <typename T>
void print0x(T x, int len) {
  std::vector<int> vec;
  while (x) {
    vec.push_back(x & 1);
    x >>= 1;
  }
  reverse(vec.begin(), vec.end());
  for (int i = (int)vec.size(); i < len; i++) {
    putchar('0');
  }
  for (size_t i = 0; i < vec.size(); i++) {
    std::cout << vec[i];
  }
  std::cout << ' ';
}
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
struct DSUAE {
  int *f;
  inline void clear(int n) {
    for (int i = 0; i < n; i++) {
      f[i] = i;
    }
  }
  inline void init(int n) {
    f = new int[n + 5];
    clear(n);
  }
  inline int find(int x) { return (f[x] == x ? x : f[x] = find(f[x])); }
  inline void merge(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (x & 1)
      f[x] = y;
    else
      f[y] = x;
  }
};
struct DSU {
  int *f;
  int *depth;
  int *sz;
  inline void clear(int n) {
    for (int i = 0; i < n; i++) {
      f[i] = i;
      depth[i] = 1;
      sz[i] = 1;
    }
  }
  inline void init(int n) {
    f = new int[n + 5];
    depth = new int[n + 5];
    sz = new int[n + 5];
    clear(n);
  }
  inline int find(int x) { return (f[x] == x ? x : f[x] = find(f[x])); }
  inline int getSize(int x) { return sz[find(x)]; }
  inline int merge(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (depth[x] > depth[y]) {
      f[y] = x;
      sz[x] += sz[y];
    } else if (depth[y] > depth[x]) {
      f[x] = y;
      sz[y] += sz[x];
    } else {
      sz[y] += sz[x];
      f[x] = y;
      depth[y]++;
    }
    return true;
  }
  inline int same(int x, int y) { return (find(x) == find(y)); }
  ~DSU() {
    delete f;
    delete depth;
    delete sz;
  }
};
struct PersistentDSU : public DSU {
  int find(int x) { return (x == f[x] ? x : find(f[x])); }
  inline int merge(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (depth[x] > depth[y]) {
      f[y] = x;
      sz[x] += sz[y];
    } else if (depth[y] > depth[x]) {
      f[x] = y;
      sz[y] += sz[x];
    } else {
      sz[y] += sz[x];
      f[x] = y;
      depth[y]++;
    }
    return true;
  }
};
using namespace std;
int n;
char c[55][55];
DSUAE dsu;
vector<int> scc[55];
vector<vector<int>> a;
int b[55][55];
int p[55];
int main() {
  double t = clock();
  scanf("%d", &n);
  dsu.init(n);
  for (int i = 0; i < n; i++) scanf("%s", c[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (c[i][j] == 'A') dsu.merge(i, j);
    }
  }
  for (int i = 0; i < n; i++) scc[dsu.find(i)].push_back(i);
  int now = 0;
  for (int i = 0; i < n; i++) {
    if (scc[i].empty()) continue;
    for (auto x : scc[i]) {
      for (auto y : scc[i]) {
        if (c[x][y] == 'X') {
          cout << "-1" << endl;
          exit(0);
        };
      }
    }
    if (scc[i].size() > 1)
      now += scc[i].size();
    else
      now += 1;
    if (scc[i].size() > 1) a.push_back(scc[i]);
  }
  n = a.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      bool noXor = true;
      for (auto x : a[i]) {
        for (auto y : a[j]) {
          noXor &= (c[x][y] != 'X');
        }
      }
      if (!noXor)
        b[i][j] = 1;
      else
        b[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) p[i] = i;
  int res = inf;
  while ((clock() - t) / CLOCKS_PER_SEC <= 0.001) {
    random_shuffle(p, p + n);
    vector<vector<int>> v;
    for (int i = 0; i < n; i++) {
      int x = p[i];
      int found = false;
      for (auto &vv : v) {
        int ok = true;
        for (auto &u : vv) {
          ok &= (b[u][x] == 0);
        }
        if (ok) {
          found = true;
          vv.push_back(x);
          break;
        }
      }
      if (!found) {
        v.push_back(vector<int>{x});
      }
    }
    chmin(res, v.size());
  }
  cout << res + now - 1 << endl;
  return 0;
}

```


### Prompt

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

Takahashi has an N \times M grid, with N horizontal rows and M vertical columns. Determine if we can place A 1 \times 2 tiles (1 vertical, 2 horizontal) and B 2 \times 1 tiles (2 vertical, 1 horizontal) satisfying the following conditions, and construct one arrangement of the tiles if it is possible:

* All the tiles must be placed on the grid.
* Tiles must not stick out of the grid, and no two different tiles may intersect.
* Neither the grid nor the tiles may be rotated.
* Every tile completely covers exactly two squares.

Constraints

* 1 \leq N,M \leq 1000
* 0 \leq A,B \leq 500000
* N, M, A and B are integers.

Input

Input is given from Standard Input in the following format:

N M A B

Output

If it is impossible to place all the tiles, print `NO`. Otherwise, print the following:

YES
c_{11}...c_{1M}
:
c_{N1}...c_{NM}

Here, c_{ij} must be one of the following characters: `.`, `<`, `>`, `^` and `v`. Represent an arrangement by using each of these characters as follows:

* When c_{ij} is `.`, it indicates that the square at the i-th row and j-th column is empty;
* When c_{ij} is `<`, it indicates that the square at the i-th row and j-th column is covered by the left half of a 1 \times 2 tile;
* When c_{ij} is `>`, it indicates that the square at the i-th row and j-th column is covered by the right half of a 1 \times 2 tile;
* When c_{ij} is `^`, it indicates that the square at the i-th row and j-th column is covered by the top half of a 2 \times 1 tile;
* When c_{ij} is `v`, it indicates that the square at the i-th row and j-th column is covered by the bottom half of a 2 \times 1 tile.

Examples

Input

3 4 4 2

Output

YES
<><>
^<>^
v<>v

Input

4 5 5 3

Output

YES
<>..^
^.<>v
v<>.^
<><>v

Input

7 9 20 20

Output

NO

### Response

```cpp
#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second

const ll INFL = 1LL << 60;//10^18 = 2^60
//ll MOD = 998244353;

int N, M;
char mp[1010][1010];

int main(){
  int A, B;
  cin >> N >> M >> A >> B;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      mp[i][j] = '.';
    }
  }
  if(N % 2){
    for(int j = 0; j < M-1; j += 2){
      if(A == 0) break;
      A--;
      mp[N-1][j] = '<';
      mp[N-1][j+1] = '>';
    }
  }
  if(M % 2){
    for(int i = 0; i < N-1; i += 2){
      if(B == 0) break;
      B--;
      mp[i][M-1] = '^';
      mp[i+1][M-1] = 'v';
    }
  }
  if(N % 2 && M % 2){
    if(mp[N-1][M-2] == '>'){
      mp[N-1][M-1] = '>';
      mp[N-1][M-2] = '<';
      mp[N-1][M-3] = '.';
    }
  }

  for(int i = 0; i < N-1; i += 2){
    for(int j = 0; j < M-1; j += 2){
      if(A >= 2){
        A -= 2;
        mp[i][j] = '<';
        mp[i][j+1] = '>';
        mp[i+1][j] = '<';
        mp[i+1][j+1] = '>';
      }else if(B >= 2){
        B -= 2;
        mp[i][j] = '^';
        mp[i+1][j] = 'v';
        mp[i][j+1] = '^';
        mp[i+1][j+1] = 'v';
      }
    }
  }

  for(int i = N-1; i >= 1; i--){
    if(B == 0) break;
    for(int j = 0; j < M; j++){
      if(B == 0) break;
      if(mp[i-1][j] == '.' && mp[i][j] == '.'){
        mp[i-1][j] = '^';
        mp[i][j] = 'v';
        B--;
      }
    }
  }

  for(int i = 0; i < N; i++){
    if(A == 0) break;
    for(int j = 0; j < M-1; j++){
      if(A == 0) break;
      if(mp[i][j] == '.' && mp[i][j+1] == '.'){
        mp[i][j] = '<';
        mp[i][j+1] = '>';
        A--;
      }
    }
  }

  if(A || B){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < M; j++){
        cout << mp[i][j];
      }
      cout << endl;
    }
  }
}

```


### Prompt

Develop a solution in CPP to the problem described below:

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;
int n, a[10000][1000], res, flag, x[1000], y[1000], cnt;
char q;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> q;
      if (q == '.')
        a[i][j] = 1;
      else
        a[i][j] = 2;
    }
    scanf("\n");
  }
  res = n;
  cnt = 1;
  for (int i = 1; i <= n; i++) {
    flag = 0;
    for (int j = 1; j <= n; j++)
      if (a[j][i] == 1) {
        flag = 1;
        x[cnt] = j;
        y[cnt] = i;
        cnt++;
        break;
      }
    if (flag == 0) {
      res = -1;
      break;
    }
  }
  if (res == n) {
    for (int i = 1; i <= n; i++) cout << x[i] << " " << y[i] << "\n";
    return 0;
  }
  res = n;
  cnt = 1;
  for (int i = 1; i <= n; i++) {
    flag = 0;
    for (int j = 1; j <= n; j++)
      if (a[i][j] == 1) {
        flag = 1;
        x[cnt] = i;
        y[cnt] = j;
        cnt++;
        break;
      }
    if (flag == 0) {
      res = -1;
      break;
    }
  }
  if (res == n) {
    for (int i = 1; i <= n; i++) cout << x[i] << " " << y[i] << "\n";
    return 0;
  }
  cout << res;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You've got an n × m table (n rows and m columns), each cell of the table contains a "0" or a "1".

Your task is to calculate the number of rectangles with the sides that are parallel to the sides of the table and go along the cell borders, such that the number one occurs exactly k times in the rectangle.

Input

The first line contains three space-separated integers n, m and k (1 ≤ n, m ≤ 2500, 0 ≤ k ≤ 6) — the sizes of the table and the required number of numbers one.

Next n lines each contains m characters "0" or "1". The i-th character of the j-th line corresponds to the character that is in the j-th row and the i-th column of the table.

Output

Print a single number — the number of rectangles that contain exactly k numbers one.

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

Examples

Input

3 3 2
101
000
101

Output

8

Input

5 5 1
00000
00000
00100
00000
00000

Output

81

Input

5 5 6
01010
10101
01010
10101
01010

Output

12

Input

3 3 0
001
010
000

Output

15

Input

4 4 0
0000
0101
0000
0000

Output

52

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int sum[2505][2505], f[2][10];
char s[2505];
long long ans;
int get(int l1, int r1, int l2, int r2) {
  return sum[l2][r2] - sum[l2][r1] - sum[l1][r2] + sum[l1][r1];
}
void solve(int l1, int r1, int l2, int r2, int flg) {
  if (l1 == l2 || r1 == r2) return;
  if (l1 + 1 == l2 && r1 + 1 == r2) {
    ans += (get(l1, r1, l2, r2) == k);
    return;
  }
  if (!flg) {
    int mid = (l1 + l2) >> 1, i, j, l;
    solve(l1, r1, mid, r2, flg ^ 1);
    solve(mid, r1, l2, r2, flg ^ 1);
    for (i = r1; i < r2; i++) {
      f[0][0] = f[1][0] = mid;
      for (l = 1; l <= k + 1; l++) f[0][l] = l1, f[1][l] = l2;
      for (j = i + 1; j <= r2; j++) {
        for (l = 1; l <= k + 1; l++) {
          while (get(f[0][l], i, mid, j) >= l) f[0][l]++;
          while (get(mid, i, f[1][l], j) >= l) f[1][l]--;
        }
        for (l = 0; l <= k; l++)
          ans +=
              1ll * (f[0][l] - f[0][l + 1]) * (f[1][k - l + 1] - f[1][k - l]);
      }
    }
  } else {
    int mid = (r1 + r2) >> 1, i, j, l;
    solve(l1, r1, l2, mid, flg ^ 1);
    solve(l1, mid, l2, r2, flg ^ 1);
    for (i = l1; i < l2; i++) {
      f[0][0] = f[1][0] = mid;
      for (l = 1; l <= k + 1; l++) f[0][l] = r1, f[1][l] = r2;
      for (j = i + 1; j <= l2; j++) {
        for (l = 1; l <= k + 1; l++) {
          while (get(i, f[0][l], j, mid) >= l) f[0][l]++;
          while (get(i, mid, j, f[1][l]) >= l) f[1][l]--;
        }
        for (l = 0; l <= k; l++)
          ans +=
              1ll * (f[0][l] - f[0][l + 1]) * (f[1][k - l + 1] - f[1][k - l]);
      }
    }
  }
}
int main() {
  int i, j;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (j = 1; j <= m; j++)
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + s[j] - 48;
  }
  solve(0, 0, n, m, 0);
  printf("%I64d", ans);
}

```


### Prompt

Develop a solution in CPP to the problem described below:

I guess there's not much point in reminding you that Nvodsk winters aren't exactly hot. That increased the popularity of the public transport dramatically. The route of bus 62 has exactly n stops (stop 1 goes first on its way and stop n goes last). The stops are positioned on a straight line and their coordinates are 0 = x1 < x2 < ... < xn.

Each day exactly m people use bus 62. For each person we know the number of the stop where he gets on the bus and the number of the stop where he gets off the bus. A ticket from stop a to stop b (a < b) costs xb - xa rubles. However, the conductor can choose no more than one segment NOT TO SELL a ticket for. We mean that conductor should choose C and D (С <= D) and sell a ticket for the segments [A, C] and [D, B], or not sell the ticket at all. The conductor and the passenger divide the saved money between themselves equally. The conductor's "untaxed income" is sometimes interrupted by inspections that take place as the bus drives on some segment of the route located between two consecutive stops. The inspector fines the conductor by c rubles for each passenger who doesn't have the ticket for this route's segment.

You know the coordinated of all stops xi; the numbers of stops where the i-th passenger gets on and off, ai and bi (ai < bi); the fine c; and also pi — the probability of inspection on segment between the i-th and the i + 1-th stop. The conductor asked you to help him make a plan of selling tickets that maximizes the mathematical expectation of his profit.

Input

The first line contains three integers n, m and c (2 ≤ n ≤ 150 000, 1 ≤ m ≤ 300 000, 1 ≤ c ≤ 10 000).

The next line contains n integers xi (0 ≤ xi ≤ 109, x1 = 0, xi < xi + 1) — the coordinates of the stops on the bus's route.

The third line contains n - 1 integer pi (0 ≤ pi ≤ 100) — the probability of inspection in percents on the segment between stop i and stop i + 1.

Then follow m lines that describe the bus's passengers. Each line contains exactly two integers ai and bi (1 ≤ ai < bi ≤ n) — the numbers of stops where the i-th passenger gets on and off.

Output

Print the single real number — the maximum expectation of the conductor's profit. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

3 3 10
0 10 100
100 0
1 2
2 3
1 3

Output

90.000000000

Input

10 8 187
0 10 30 70 150 310 630 1270 2550 51100
13 87 65 0 100 44 67 3 4
1 10
2 9
3 8
1 5
6 10
2 7
4 10
4 5

Output

76859.990000000

Note

A comment to the first sample:

The first and third passengers get tickets from stop 1 to stop 2. The second passenger doesn't get a ticket. There always is inspection on the segment 1-2 but both passengers have the ticket for it. There never is an inspection on the segment 2-3, that's why the second passenger gets away with the cheating. Our total profit is (0 + 90 / 2 + 90 / 2) = 90.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct node {
  double l, c, r, t;
  int a, b;
} tree[4 * 150000];
double expv[150000];
void build(int x, int a, int b) {
  tree[x].a = a;
  tree[x].b = b;
  if (tree[x].a != tree[x].b) {
    build(2 * x, a, (a + b) / 2);
    build(2 * x + 1, (a + b) / 2 + 1, b);
    tree[x].l = max(tree[2 * x].l, tree[2 * x].t + tree[2 * x + 1].l);
    tree[x].t = tree[2 * x].t + tree[2 * x + 1].t;
    tree[x].r = max(tree[2 * x + 1].r, tree[2 * x + 1].t + tree[2 * x].r);
    tree[x].c = max(tree[2 * x].r + tree[2 * x + 1].l,
                    max(tree[2 * x].c, tree[2 * x + 1].c));
  } else
    tree[x].c = max(0.0, tree[x].l = tree[x].t = tree[x].r = expv[tree[x].a]);
}
node query(int x, int a, int b) {
  node ans;
  ans.l = -1;
  if (a > tree[x].b || b < tree[x].a) return ans;
  if (a <= tree[x].a && tree[x].b <= b) return tree[x];
  node a1 = query(2 * x, a, b), a2 = query(2 * x + 1, a, b);
  ans.l = max(a1.l, a1.t + a2.l);
  ans.t = a1.t + a2.t;
  ans.r = max(a2.r, a2.t + a1.r);
  ans.c = max(a1.r + a2.l, max(a1.c, a2.c));
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, c;
  cin >> n >> m >> c;
  double x[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < n - 1; i++) {
    double p;
    cin >> p;
    expv[i] = (x[i + 1] - x[i]) * 0.5 - c * p * 0.01;
  }
  build(1, 0, n - 2);
  double ans = 0;
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--;
    b -= 2;
    node n = query(1, a, b);
    ans += n.c;
  }
  cout << fixed << setprecision(7) << ans << endl;
  return 0;
}

```


### Prompt

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

Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, which are not necessarily convex. Since there's no gravity on his spaceship, the hoops are standing still in the air. Since the hoops are very elastic, Cowboy Beblop can stretch, rotate, translate or shorten their edges as much as he wants.

For both hoops, you are given the number of their vertices, as well as the position of each vertex, defined by the X , Y and Z coordinates. The vertices are given in the order they're connected: the 1st vertex is connected to the 2nd, which is connected to the 3rd, etc., and the last vertex is connected to the first one. Two hoops are connected if it's impossible to pull them to infinity in different directions by manipulating their edges, without having their edges or vertices intersect at any point – just like when two links of a chain are connected. The polygons' edges do not intersect or overlap.

To make things easier, we say that two polygons are well-connected, if the edges of one polygon cross the area of the other polygon in two different directions (from the upper and lower sides of the plane defined by that polygon) a different number of times.

Cowboy Beblop is fascinated with the hoops he has obtained and he would like to know whether they are well-connected or not. Since he’s busy playing with his dog, Zwei, he’d like you to figure it out for him. He promised you some sweets if you help him!

Input

The first line of input contains an integer n (3 ≤ n ≤ 100 000), which denotes the number of edges of the first polygon. The next N lines each contain the integers x, y and z ( - 1 000 000 ≤ x, y, z ≤ 1 000 000) — coordinates of the vertices, in the manner mentioned above. The next line contains an integer m (3 ≤ m ≤ 100 000) , denoting the number of edges of the second polygon, followed by m lines containing the coordinates of the second polygon’s vertices.

It is guaranteed that both polygons are simple (no self-intersections), and in general that the obtained polygonal lines do not intersect each other. Also, you can assume that no 3 consecutive points of a polygon lie on the same line.

Output

Your output should contain only one line, with the words "YES" or "NO", depending on whether the two given polygons are well-connected.

Example

Input

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

Output

YES

Note

On the picture below, the two polygons are well-connected, as the edges of the vertical polygon cross the area of the horizontal one exactly once in one direction (for example, from above to below), and zero times in the other (in this case, from below to above). Note that the polygons do not have to be parallel to any of the xy-,xz-,yz- planes in general. <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
tuple<double, double> simultaneous_equation(double a, double b, double c,
                                            double d, double u, double v) {
  return make_tuple((u * d - b * v) / (a * d - b * c),
                    (a * v - u * c) / (a * d - b * c));
}
tuple<double, double, double> cross_product(double x1, double y1, double z1,
                                            double x2, double y2, double z2) {
  return make_tuple(y1 * z2 - y2 * z1, z1 * x2 - z2 * x1, x1 * y2 - x2 * y1);
}
double dot_product(double x1, double y1, double z1, double x2, double y2,
                   double z2) {
  return x1 * x2 + y1 * y2 + z1 * z2;
}
int main(int argc, char const *argv[]) {
  int n, m;
  scanf("%d", &n);
  double x1[n], y1[n], z1[n];
  tuple<double, double, double> normal1;
  for (int i = 0; i < n; i++) {
    scanf("%lf %lf %lf", &x1[i], &y1[i], &z1[i]);
    if (i == 2) {
      normal1 = cross_product(x1[1] - x1[0], y1[1] - y1[0], z1[1] - z1[0],
                              x1[2] - x1[1], y1[2] - y1[1], z1[2] - z1[1]);
    }
  }
  scanf("%d", &m);
  double x2[m], y2[m], z2[m];
  tuple<double, double, double> normal2;
  for (int i = 0; i < m; i++) {
    scanf("%lf %lf %lf", &x2[i], &y2[i], &z2[i]);
    if (i == 2) {
      normal2 = cross_product(x2[1] - x2[0], y2[1] - y2[0], z2[1] - z2[0],
                              x2[2] - x2[1], y2[2] - y2[1], z2[2] - z2[1]);
    }
  }
  tuple<double, double, double> intersection_vector =
      cross_product(get<0>(normal1), get<1>(normal1), get<2>(normal1),
                    get<0>(normal2), get<1>(normal2), get<2>(normal2));
  double a1 = get<0>(normal1);
  double b1 = get<1>(normal1);
  double c1 = get<2>(normal1);
  double d1 = -(get<0>(normal1) * x1[0] + get<1>(normal1) * y1[0] +
                get<2>(normal1) * z1[0]);
  double a2 = get<0>(normal2);
  double b2 = get<1>(normal2);
  double c2 = get<2>(normal2);
  double d2 = -(get<0>(normal2) * x2[0] + get<1>(normal2) * y2[0] +
                get<2>(normal2) * z2[0]);
  double intersection_x;
  double intersection_y;
  double intersection_z;
  double max = 0;
  if (abs(get<0>(intersection_vector)) > max) {
    max = abs(get<0>(intersection_vector));
    intersection_x = 0;
    intersection_y = (c1 * d2 - c2 * d1) / (b1 * c2 - b2 * c1);
    intersection_z = (b2 * d1 - b1 * d2) / (b1 * c2 - b2 * c1);
  }
  if (abs(get<1>(intersection_vector)) > max) {
    max = abs(get<1>(intersection_vector));
    intersection_x = (c1 * d2 - c2 * d1) / (a1 * c2 - a2 * c1);
    intersection_y = 0;
    intersection_z = (a2 * d1 - a1 * d2) / (a1 * c2 - a2 * c1);
  }
  if (abs(get<2>(intersection_vector)) > max) {
    max = abs(get<2>(intersection_vector));
    intersection_x = (b1 * d2 - b2 * d1) / (a1 * b2 - a2 * b1);
    intersection_y = (a2 * d1 - a1 * d2) / (a1 * b2 - a2 * b1);
    intersection_z = 0;
  }
  tuple<double, double, double> intersection_normal_1 =
      cross_product(get<0>(normal1), get<1>(normal1), get<2>(normal1),
                    get<0>(intersection_vector), get<1>(intersection_vector),
                    get<2>(intersection_vector));
  tuple<double, double, double> intersection_normal_2 =
      cross_product(get<0>(normal2), get<1>(normal2), get<2>(normal2),
                    get<0>(intersection_vector), get<1>(intersection_vector),
                    get<2>(intersection_vector));
  int sign1[n];
  for (int i = 0; i < n; i++) {
    if (dot_product(x1[i] - intersection_x, y1[i] - intersection_y,
                    z1[i] - intersection_z, get<0>(intersection_normal_1),
                    get<1>(intersection_normal_1),
                    get<2>(intersection_normal_1)) > 0) {
      sign1[i] = 1;
    } else if (dot_product(x1[i] - intersection_x, y1[i] - intersection_y,
                           z1[i] - intersection_z,
                           get<0>(intersection_normal_1),
                           get<1>(intersection_normal_1),
                           get<2>(intersection_normal_1)) < 0) {
      sign1[i] = -1;
    } else {
      sign1[i] = 0;
    }
  }
  int sign2[m];
  for (int i = 0; i < m; i++) {
    if (dot_product(x2[i] - intersection_x, y2[i] - intersection_y,
                    z2[i] - intersection_z, get<0>(intersection_normal_2),
                    get<1>(intersection_normal_2),
                    get<2>(intersection_normal_2)) > 0) {
      sign2[i] = 1;
    } else if (dot_product(x2[i] - intersection_x, y2[i] - intersection_y,
                           z2[i] - intersection_z,
                           get<0>(intersection_normal_2),
                           get<1>(intersection_normal_2),
                           get<2>(intersection_normal_2)) < 0) {
      sign2[i] = -1;
    } else {
      sign2[i] = 0;
    }
  }
  vector<pair<double, int>> intersection_list_1;
  for (int i = 0; i < n; i++) {
    int previous_i = i - 1;
    int current_i = i;
    int next_i = i + 1;
    int next_next_i = i + 2;
    if (i == 0) {
      previous_i = n - 1;
    } else if (i == n - 1) {
      next_i = 0;
      next_next_i = 1;
    } else if (i == n - 2) {
      next_next_i = 0;
    }
    if (sign1[current_i] * sign1[next_i] == -1) {
      double multiplier;
      if (!isnan(get<1>(simultaneous_equation(
              x1[current_i] - x1[next_i], -get<0>(intersection_vector),
              y1[current_i] - y1[next_i], -get<1>(intersection_vector),
              intersection_x - x1[current_i],
              intersection_y - y1[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            x1[current_i] - x1[next_i], -get<0>(intersection_vector),
            y1[current_i] - y1[next_i], -get<1>(intersection_vector),
            intersection_x - x1[current_i], intersection_y - y1[current_i]));
      } else if (!isnan(get<1>(simultaneous_equation(
                     y1[current_i] - y1[next_i], -get<1>(intersection_vector),
                     z1[current_i] - z1[next_i], -get<2>(intersection_vector),
                     intersection_y - y1[current_i],
                     intersection_z - z1[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            y1[current_i] - y1[next_i], -get<1>(intersection_vector),
            z1[current_i] - z1[next_i], -get<2>(intersection_vector),
            intersection_y - y1[current_i], intersection_z - z1[current_i]));
      } else if (!isnan(get<1>(simultaneous_equation(
                     z1[current_i] - z1[next_i], -get<2>(intersection_vector),
                     x1[current_i] - x1[next_i], -get<0>(intersection_vector),
                     intersection_z - z1[current_i],
                     intersection_x - x1[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            z1[current_i] - z1[next_i], -get<2>(intersection_vector),
            x1[current_i] - x1[next_i], -get<0>(intersection_vector),
            intersection_z - z1[current_i], intersection_x - x1[current_i]));
      }
      intersection_list_1.push_back(pair<double, int>(
          dot_product(get<0>(intersection_vector) * multiplier + intersection_x,
                      get<1>(intersection_vector) * multiplier + intersection_y,
                      get<2>(intersection_vector) * multiplier + intersection_z,
                      get<0>(intersection_vector), get<1>(intersection_vector),
                      get<2>(intersection_vector)),
          1));
    } else if ((sign1[current_i] == 0 &&
                sign1[previous_i] * sign1[next_i] == -1) ||
               (n >= 4 && sign1[current_i] == 0 && sign1[next_i] == 0 &&
                sign1[previous_i] * sign1[next_next_i] == -1)) {
      intersection_list_1.push_back(pair<double, int>(
          dot_product(x1[current_i], y1[current_i], z1[current_i],
                      get<0>(intersection_vector), get<1>(intersection_vector),
                      get<2>(intersection_vector)),
          1));
    }
  }
  vector<pair<double, int>> intersection_list_2;
  for (int i = 0; i < m; i++) {
    int previous_i = i - 1;
    int current_i = i;
    int next_i = i + 1;
    int next_next_i = i + 2;
    if (i == 0) {
      previous_i = m - 1;
    } else if (i == m - 1) {
      next_i = 0;
      next_next_i = 1;
    } else if (i == m - 2) {
      next_next_i = 0;
    }
    if (sign2[current_i] * sign2[next_i] == -1) {
      double multiplier;
      if (!isnan(get<1>(simultaneous_equation(
              x2[current_i] - x2[next_i], -get<0>(intersection_vector),
              y2[current_i] - y2[next_i], -get<1>(intersection_vector),
              intersection_x - x2[current_i],
              intersection_y - y2[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            x2[current_i] - x2[next_i], -get<0>(intersection_vector),
            y2[current_i] - y2[next_i], -get<1>(intersection_vector),
            intersection_x - x2[current_i], intersection_y - y2[current_i]));
      } else if (!isnan(get<1>(simultaneous_equation(
                     y2[current_i] - y2[next_i], -get<1>(intersection_vector),
                     z2[current_i] - z2[next_i], -get<2>(intersection_vector),
                     intersection_y - y2[current_i],
                     intersection_z - z2[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            y2[current_i] - y2[next_i], -get<1>(intersection_vector),
            z2[current_i] - z2[next_i], -get<2>(intersection_vector),
            intersection_y - y2[current_i], intersection_z - z2[current_i]));
      } else if (!isnan(get<1>(simultaneous_equation(
                     z2[current_i] - z2[next_i], -get<2>(intersection_vector),
                     x2[current_i] - x2[next_i], -get<0>(intersection_vector),
                     intersection_z - z2[current_i],
                     intersection_x - x2[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            z2[current_i] - z2[next_i], -get<2>(intersection_vector),
            x2[current_i] - x2[next_i], -get<0>(intersection_vector),
            intersection_z - z2[current_i], intersection_x - x2[current_i]));
      }
      intersection_list_2.push_back(pair<double, int>(
          dot_product(get<0>(intersection_vector) * multiplier + intersection_x,
                      get<1>(intersection_vector) * multiplier + intersection_y,
                      get<2>(intersection_vector) * multiplier + intersection_z,
                      get<0>(intersection_vector), get<1>(intersection_vector),
                      get<2>(intersection_vector)),
          2));
    } else if ((sign2[current_i] == 0 &&
                sign2[previous_i] * sign2[next_i] == -1) ||
               (m >= 4 && sign2[current_i] == 0 && sign2[next_i] == 0 &&
                sign2[previous_i] * sign2[next_next_i] == -1)) {
      intersection_list_2.push_back(pair<double, int>(
          dot_product(x2[current_i], y2[current_i], z2[current_i],
                      get<0>(intersection_vector), get<1>(intersection_vector),
                      get<2>(intersection_vector)),
          2));
    }
  }
  intersection_list_1.insert(intersection_list_1.end(),
                             intersection_list_2.begin(),
                             intersection_list_2.end());
  sort(intersection_list_1.begin(), intersection_list_1.end());
  vector<int> result_list;
  while (!intersection_list_1.empty()) {
    if (result_list.empty() ||
        (!result_list.empty() &&
         intersection_list_1.back().second != result_list.back())) {
      result_list.push_back(intersection_list_1.back().second);
    } else if (!result_list.empty() &&
               intersection_list_1.back().second == result_list.back()) {
      result_list.pop_back();
    }
    intersection_list_1.pop_back();
  }
  if (result_list.empty()) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Nauuo is a girl who loves playing chess.

One day she invented a game by herself which needs n chess pieces to play on a m× m chessboard. The rows and columns are numbered from 1 to m. We denote a cell on the intersection of the r-th row and c-th column as (r,c).

The game's goal is to place n chess pieces numbered from 1 to n on the chessboard, the i-th piece lies on (r_i,\,c_i), while the following rule is satisfied: for all pairs of pieces i and j, |r_i-r_j|+|c_i-c_j|≥|i-j|. Here |x| means the absolute value of x.

However, Nauuo discovered that sometimes she couldn't find a solution because the chessboard was too small.

She wants to find the smallest chessboard on which she can put n pieces according to the rules.

She also wonders how to place the pieces on such a chessboard. Can you help her?

Input

The only line contains a single integer n (1≤ n≤ 1000) — the number of chess pieces for the game.

Output

The first line contains a single integer — the minimum value of m, where m is the length of sides of the suitable chessboard.

The i-th of the next n lines contains two integers r_i and c_i (1≤ r_i,c_i≤ m) — the coordinates of the i-th chess piece.

If there are multiple answers, print any.

Examples

Input

2

Output

2
1 1
1 2

Input

4

Output

3
1 1
1 3
3 1
3 3

Note

In the first example, you can't place the two pieces on a 1×1 chessboard without breaking the rule. But you can place two pieces on a 2×2 chessboard like this:

<image>

In the second example, you can't place four pieces on a 2×2 chessboard without breaking the rule. For example, if you place the pieces like this:

<image>

then |r_1-r_3|+|c_1-c_3|=|1-2|+|1-1|=1, |1-3|=2, 1<2; and |r_1-r_4|+|c_1-c_4|=|1-2|+|1-2|=2, |1-4|=3, 2<3. It doesn't satisfy the rule.

However, on a 3×3 chessboard, you can place four pieces like this:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int m = (n + 1) / 2;
  if (n % 2 == 0) m++;
  cout << m << "\n";
  int a[m][m], i, j;
  memset(a, 0, sizeof(a));
  for (i = 0; i < m; i++) a[0][i] = 1;
  int tot = n - m;
  i = 1;
  while (tot--) {
    a[i][m - 1] = 1;
    i++;
  }
  for (i = 0; i < m; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j] != 0) {
        cout << i + 1 << " " << j + 1 << "\n";
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int tc = 0;
  if (tc) {
    int tcs;
    cin >> tcs;
    while (tcs--) solve();
  } else
    solve();
}

```