### Prompt

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

There are several rectangular sheets placed on a flat surface. Create a program to find the area and perimeter of the part covered by these sheets.

However, when the plane is regarded as the coordinate plane, the arrangement of the sheets shall satisfy the following conditions (1) and (2).

(1) The x and y coordinates of the four vertices of the rectangle on each sheet are all integers from 0 to 10000, and each side of the rectangle is parallel to the x-axis or y-axis.

(2) The number of sheets is at most 10,000 or less.

The number n of rectangles and the integer r indicating the type of problem are separated by a space in the first line of the input data. In each line after the second line, the coordinates of the lower left vertex of each sheet (x1, y1) and The coordinates of the upper right vertex coordinates (x2, y2) are written in the order of x1, y1, x2, y2, separated by a blank.

The output outputs the area on the first line when r = 1, the area on the first line when r = 2, and the perimeter on the second line. In either case, insert a line break at the end.

In 40% of the test data, the coordinates of the vertices of the rectangle are 0 or more and 100 or less, and 1/2 of them is the problem of finding only the area. Furthermore, 1/2 of the whole is the problem of finding only the area.

Input Example 1 | Input Example 2 | Input Example 3 | Input Example 4
--- | --- | --- | ---
|
5 1 | 5 2 | 2 2 | 3 2
0 0 3 2 | 0 0 3 2 | 0 0 8 9 | 2 2 8 8
1 1 2 5 | 1 1 2 5 | 0 0 9 8 | 3 0 4 9
0 4 6 5 | 0 4 6 5 | | 5 0 7 9
3 3 5 6 | 3 3 5 6 | |
5 0 7 6 | 5 0 7 6 | |
Output example 1 | Output example 2 | Output example 3 | Output example 4
29 | 29 | 80 | 45
38 | 36 | 36

input

The input consists of multiple datasets. Input ends when both n and r are 0. The number of datasets does not exceed 10.

output

For each dataset, the area is output on the first line when r = 1, the area is output on the first line when r = 2, and the perimeter is output on the second line.

Example

Input

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

Output

29
29
38
80
36
45
36

### Response

```cpp
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#define F first
#define S second

using namespace std;

typedef pair<int,int> P;

bool cmp_x( const pair<P,P> &p , const pair<P,P> &q ){
  return p.F < q.F;
}

bool cmp_y( const pair<P,P> &p , const pair<P,P> &q ){
  return p.S < q.S;
}

int main(void){

  int n,r,x1,x2,y1,y2;

  while(cin >> n >> r){
    if(n==0 && r==0)break;

    vector<pair<P,P> > in;

    for(int i=0;i<n;i++){
      scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
      in.push_back(make_pair(make_pair(x1,x2), make_pair(y1,y2)));
    }

    sort(in.begin(),in.end(),cmp_x);

    int S=0,L=0;
    vector<P>v;
    for(int i=0;i+1<10001;i++){
      v.clear();
      for(int j=0;j<n;j++){
	if(in[j].S.S>=i+1 && i>=in[j].S.F){
	  v.push_back(make_pair(in[j].F.F,in[j].F.S));
	}
      }

      if(v.size()!=0){
	//sort(v.begin(),v.end());
	int b=v[0].F,e=v[0].S;
	for(int j=1;j<v.size();j++){
	  int B=v[j].F,E=v[j].S;
	  if(e>=B)e=max(e,E);
	  else S+=e-b, b=B, e=E, L+=2;
	}
	S+=e-b, L+=2;
      }
    }
    cout << S << endl;

    if(r==2){

      sort(in.begin(),in.end(),cmp_y);

      for(int i=0;i+1<10001;i++){

	v.clear();
	for(int j=0;j<n;j++){
	  if(in[j].F.S>=i+1 && i>=in[j].F.F)
	    v.push_back(make_pair(in[j].S.F,in[j].S.S));

	}
	if(v.size()!=0){
	  //sort(v.begin(),v.end());
	  int b=v[0].F,e=v[0].S;

	  for(int j=1;j<v.size();j++){
	    int B=v[j].F,E=v[j].S;

	    if(e>=B)e=max(e,E);
	    else b=B, e=E, L+=2;
	  }
	  L+=2;
	}
      }
      cout << L << endl;
    }
  }
  return 0;
}
```


### Prompt

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

You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.

We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.

Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.

The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.

You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of lines in the text.

The second line contains integers p1, ..., pn (0 ≤ pi ≤ 100) — the verse pattern.

Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.

Output

If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).

Examples

Input

3
2 2 3
intel
code
ch allenge

Output

YES

Input

4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz

Output

NO

Input

4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles

Output

YES

Note

In the first sample, one can split words into syllables in the following way:

    in-tel
    co-de
    ch al-len-ge

Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int p[100];
char in[1111];
int main() {
  int n;
  bool ans = true;
  fgets(in, 1111, stdin);
  sscanf(in, "%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", p + i);
  fgets(in, 11, stdin);
  for (int z = 0; z < n; z++) {
    fgets(in, 1111, stdin);
    if (!ans) continue;
    int v = 0;
    for (int i = 0; in[i]; i++) {
      if (in[i] == 'a' || in[i] == 'e' || in[i] == 'i' || in[i] == 'o' ||
          in[i] == 'u' || in[i] == 'y')
        v++;
    }
    if (v != p[z]) ans = false;
  }
  puts(ans ? "YES" : "NO");
}

```


### Prompt

Generate a cpp solution to the following problem:

Vasily the bear has got a sequence of positive integers a1, a2, ..., an. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum.

The beauty of the written out numbers b1, b2, ..., bk is such maximum non-negative integer v, that number b1 and b2 and ... and bk is divisible by number 2v without a remainder. If such number v doesn't exist (that is, for any non-negative integer v, number b1 and b2 and ... and bk is divisible by 2v without a remainder), the beauty of the written out numbers equals -1.

Tell the bear which numbers he should write out so that the beauty of the written out numbers is maximum. If there are multiple ways to write out the numbers, you need to choose the one where the bear writes out as many numbers as possible.

Here expression x and y means applying the bitwise AND operation to numbers x and y. In programming languages C++ and Java this operation is represented by "&", in Pascal — by "and".

Input

The first line contains integer n (1 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ a1 < a2 < ... < an ≤ 109).

Output

In the first line print a single integer k (k > 0), showing how many numbers to write out. In the second line print k integers b1, b2, ..., bk — the numbers to write out. You are allowed to print numbers b1, b2, ..., bk in any order, but all of them must be distinct. If there are multiple ways to write out the numbers, choose the one with the maximum number of numbers to write out. If there still are multiple ways, you are allowed to print any of them.

Examples

Input

5
1 2 3 4 5

Output

2
4 5

Input

3
1 2 4

Output

1
4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
int main() {
  int n, exp = 0;
  cin >> n;
  int v[n], m = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    m = max(m, v[i]);
  }
  int cont = 0, a;
  bool ok, deu;
  while (m >= (1 << cont)) {
    deu = true;
    for (int j = 0; j < cont; j++) {
      ok = false;
      for (int i = 0; i < n; i++) {
        if ((v[i] >> cont) % 2 == 1 && (v[i] >> j) % 2 == 0) {
          ok = true;
        }
      }
      if (!ok) deu = false;
    }
    if (deu) exp = cont;
    cont++;
  }
  for (int i = 0; i < n; i++)
    if ((v[i] >> exp) % 2 == 1) ans.push_back(v[i]);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
}

```


### Prompt

Generate a Cpp solution to the following problem:

You might have remembered Theatre square from the [problem 1A](https://codeforces.com/problemset/problem/1/A). Now it's finally getting repaved.

The square still has a rectangular shape of n × m meters. However, the picture is about to get more complicated now. Let a_{i,j} be the j-th square in the i-th row of the pavement.

You are given the picture of the squares:

  * if a_{i,j} =  "*", then the j-th square in the i-th row should be black;
  * if a_{i,j} =  ".", then the j-th square in the i-th row should be white.

The black squares are paved already. You have to pave the white squares. There are two options for pavement tiles:

  * 1 × 1 tiles — each tile costs x burles and covers exactly 1 square;
  * 1 × 2 tiles — each tile costs y burles and covers exactly 2 adjacent squares of the same row. Note that you are not allowed to rotate these tiles or cut them into 1 × 1 tiles.

You should cover all the white squares, no two tiles should overlap and no black squares should be covered by tiles.

What is the smallest total price of the tiles needed to cover all the white squares?

Input

The first line contains a single integer t (1 ≤ t ≤ 500) — the number of testcases. Then the description of t testcases follow.

The first line of each testcase contains four integers n, m, x and y (1 ≤ n ≤ 100; 1 ≤ m ≤ 1000; 1 ≤ x, y ≤ 1000) — the size of the Theatre square, the price of the 1 × 1 tile and the price of the 1 × 2 tile.

Each of the next n lines contains m characters. The j-th character in the i-th line is a_{i,j}. If a_{i,j} =  "*", then the j-th square in the i-th row should be black, and if a_{i,j} =  ".", then the j-th square in the i-th row should be white.

It's guaranteed that the sum of n × m over all testcases doesn't exceed 10^5.

Output

For each testcase print a single integer — the smallest total price of the tiles needed to cover all the white squares in burles.

Example

Input

4
1 1 10 1
.
1 2 10 1
..
2 1 10 1
.
.
3 3 3 7
..*
*..
.*.

Output

10
1
20
18

Note

In the first testcase you are required to use a single 1 × 1 tile, even though 1 × 2 tile is cheaper. So the total price is 10 burles.

In the second testcase you can either use two 1 × 1 tiles and spend 20 burles or use a single 1 × 2 tile and spend 1 burle. The second option is cheaper, thus the answer is 1.

The third testcase shows that you can't rotate 1 × 2 tiles. You still have to use two 1 × 1 tiles for the total price of 20.

In the fourth testcase the cheapest way is to use 1 × 1 tiles everywhere. The total cost is 6 ⋅ 3 = 18.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int ans = 0;
  char ch;
  if (x <= y / 2) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        cin >> ch;
        if (ch == '.') {
          ans += x;
        }
      }
    }
    cout << ans << endl;
    return;
  }
  bool flag = false;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> ch;
      if (ch == '.') {
        if (flag) {
          ans += y;
          flag = false;
        } else {
          flag = true;
        }
      } else {
        if (flag) {
          ans += x;
        }
        flag = false;
      }
    }
    if (flag) {
      ans += x;
      flag = false;
    }
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enclose as many of the points as possible. Find how many points can be simultaneously enclosed at the maximum. A point is considered enclosed by a circle when it is inside or on the circle.

<image>

Fig 1. Circle and Points

Input

The input consists of a series of data sets, followed by a single line only containing a single character '0', which indicates the end of the input. Each data set begins with a line containing an integer N, which indicates the number of points in the data set. It is followed by N lines describing the coordinates of the points. Each of the N lines has two decimal fractions X and Y, describing the x- and y-coordinates of a point, respectively. They are given with five digits after the decimal point.

You may assume 1 <= N <= 300, 0.0 <= X <= 10.0, and 0.0 <= Y <= 10.0. No two points are closer than 0.0001. No two points in a data set are approximately at a distance of 2.0. More precisely, for any two points in a data set, the distance d between the two never satisfies 1.9999 <= d <= 2.0001. Finally, no three points in a data set are simultaneously very close to a single circle of radius one. More precisely, let P1, P2, and P3 be any three points in a data set, and d1, d2, and d3 the distances from an arbitrarily selected point in the xy-plane to each of them respectively. Then it never simultaneously holds that 0.9999 <= di <= 1.0001 (i = 1, 2, 3).

Output

For each data set, print a single line containing the maximum number of points in the data set that can be simultaneously enclosed by a circle of radius one. No other characters including leading and trailing spaces should be printed.

Example

Input

3
6.47634 7.69628
5.16828 4.79915
6.69533 6.20378
6
7.15296 4.08328
6.50827 2.69466
5.91219 3.86661
5.29853 4.16097
6.10838 3.46039
6.34060 2.41599
8
7.90650 4.01746
4.10998 4.18354
4.67289 4.01887
6.33885 4.28388
4.98106 3.82728
5.12379 5.16473
7.84664 4.67693
4.02776 3.87990
20
6.65128 5.47490
6.42743 6.26189
6.35864 4.61611
6.59020 4.54228
4.43967 5.70059
4.38226 5.70536
5.50755 6.18163
7.41971 6.13668
6.71936 3.04496
5.61832 4.23857
5.99424 4.29328
5.60961 4.32998
6.82242 5.79683
5.44693 3.82724
6.70906 3.65736
7.89087 5.68000
6.23300 4.59530
5.92401 4.92329
6.24168 3.81389
6.22671 3.62210
0

Output

2
5
5
11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
struct Point{double x,y;};
double dist(Point a,Point b) {return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));}

int main(void){
    int N;
    while(cin>>N,N){
        vector<Point> p(N);
        int maxcnt=1;
        rep(i,N)cin>>p[i].x>>p[i].y;
        rep(i,N){
            for(int j=i+1;j<N;j++){
                double d = dist(p[i],p[j]);
                if(d>2.0)continue;
                int sign[]={-1,1};
                rep(s,2){
                    Point C;
                    C.x = p[i].x + cos(atan2(p[j].y-p[i].y,p[j].x-p[i].x) + sign[s]*acos(d/2.0));
                    C.y = p[i].y + sin(atan2(p[j].y-p[i].y,p[j].x-p[i].x) + sign[s]*acos(d/2.0));
                    int cnt=0;
                    rep(k,N) cnt += (pow(C.x-p[k].x,2) + pow(C.y-p[k].y,2) <= 1.0001);
                    if(maxcnt<cnt)maxcnt=cnt;
                }
            }
        }
        cout<<maxcnt<<endl;
    }

    return 0;
}
```


### Prompt

Create a solution in Cpp for the following problem:

You have a string s consisting of n characters. Each character is either 0 or 1.

You can perform operations on the string. Each operation consists of two steps:

  1. select an integer i from 1 to the length of the string s, then delete the character s_i (the string length gets reduced by 1, the indices of characters to the right of the deleted one also get reduced by 1);
  2. if the string s is not empty, delete the maximum length prefix consisting of the same characters (the indices of the remaining characters and the string length get reduced by the length of the deleted prefix).

Note that both steps are mandatory in each operation, and their order cannot be changed.

For example, if you have a string s = 111010, the first operation can be one of the following:

  1. select i = 1: we'll get 111010 → 11010 → 010;
  2. select i = 2: we'll get 111010 → 11010 → 010;
  3. select i = 3: we'll get 111010 → 11010 → 010;
  4. select i = 4: we'll get 111010 → 11110 → 0;
  5. select i = 5: we'll get 111010 → 11100 → 00;
  6. select i = 6: we'll get 111010 → 11101 → 01.

You finish performing operations when the string s becomes empty. What is the maximum number of operations you can perform?

Input

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

The first line of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the string s.

The second line contains string s of n characters. Each character is either 0 or 1.

It's guaranteed that the total sum of n over test cases doesn't exceed 2 ⋅ 10^5.

Output

For each test case, print a single integer — the maximum number of operations you can perform.

Example

Input

5
6
111010
1
0
1
1
2
11
6
101010

Output

3
1
1
1
3

Note

In the first test case, you can, for example, select i = 2 and get string 010 after the first operation. After that, you can select i = 3 and get string 1. Finally, you can only select i = 1 and get empty string.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void _print(long long t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V>
void _print(T a[], V sz);
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << " -> ";
  _print(p.second);
  cerr << "}" << endl;
}
template <class T, class V>
void _print(T a[], V sz) {
  for (V i = 0; i < sz; i++) {
    _print(a[i]);
    cerr << " ";
  }
  cerr << endl;
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]" << endl;
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]" << endl;
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]" << endl;
}
void _printall(long long t) { cout << t; }
void _printall(int t) { cout << t; }
void _printall(string t) { cout << t; }
void _printall(char t) { cout << t; }
void _printall(long double t) { cout << t; }
void _printall(double t) { cout << t; }
void _printall(unsigned long long t) { cout << t; }
template <class T, class V>
void _printall(T a[], V sz);
template <class T, class V>
void _printall(pair<T, V> p);
template <class T>
void _printall(vector<T> v);
template <class T>
void _printall(set<T> v);
template <class T, class V>
void _printall(map<T, V> v);
template <class T>
void _printall(multiset<T> v);
template <class T, class V>
void _printall(T a[], V sz) {
  for (V i = 0; i < sz; i++) {
    _printall(a[i]);
    cout << " ";
  }
  cout << endl;
}
template <class T, class V>
void _printall(pair<T, V> p) {
  _printall(p.ff);
  cout << ",";
  _printall(p.ss);
}
template <class T>
void _printall(vector<T> v) {
  for (T i : v) {
    _printall(i);
    cout << " ";
  }
  cout << endl;
}
template <class T>
void _printall(set<T> v) {
  for (T i : v) {
    _printall(i);
    cout << " ";
  }
  cout << endl;
}
template <class T>
void _printall(multiset<T> v) {
  for (T i : v) {
    _printall(i);
    cout << " ";
  }
  cout << endl;
}
template <class T, class V>
void _printall(map<T, V> v) {
  for (auto i : v) {
    _printall(i);
    cout << " ";
  }
  cout << endl;
}
long long MAXN = 200001;
long long spf[200001];
void sieve() {
  spf[1] = 1;
  for (int i = 2; i < MAXN; i++) {
    spf[i] = i;
  }
  for (long long i = 4; i < MAXN; i += 2) {
    spf[i] = 2;
  }
  for (long long i = 3; i * i < MAXN; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < MAXN; j += i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
  }
}
vector<long long> getFactorization(long long x) {
  vector<long long> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> pre;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    pre.push_back(1);
  }
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == s[i + 1]) {
      pre[i] = pre[i + 1] + 1;
    }
  }
  reverse(pre.begin(), pre.end());
  vector<int> fin;
  for (int i = 0; i < pre.size() - 1; i++) {
    if (pre[i] == 1 && pre[i + 1] == 1) {
      fin.push_back(pre[i]);
    } else if (pre[i] >= 1 && pre[i + 1] == 1) {
      fin.push_back(pre[i]);
    }
  }
  if (pre[n - 1] >= 1) {
    fin.push_back(pre[n - 1]);
  }
  int ind1 = fin.size() - 1;
  int ind2 = fin.size() - 1;
  while (pre.size() != 0 && ind1 >= 0 && ind2 >= 0) {
    if (fin[ind1] > 1) {
      cnt++;
      fin.pop_back();
      if (ind2 == ind1) {
        ind2--;
      }
      ind1--;
    } else {
      while (fin[ind2] == 1) {
        ind2--;
      }
      if (ind2 < 0) {
        break;
      } else {
        cnt++;
        fin[ind2]--;
        fin.pop_back();
        ind1--;
      }
    }
  }
  if (pre.size() != 0) {
    cnt += (fin.size() + 1) / 2;
  }
  cout << cnt << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over.

This time Miroslav laid out n skewers parallel to each other, and enumerated them with consecutive integers from 1 to n in order from left to right. For better cooking, he puts them quite close to each other, so when he turns skewer number i, it leads to turning k closest skewers from each side of the skewer i, that is, skewers number i - k, i - k + 1, ..., i - 1, i + 1, ..., i + k - 1, i + k (if they exist).

For example, let n = 6 and k = 1. When Miroslav turns skewer number 3, then skewers with numbers 2, 3, and 4 will come up turned over. If after that he turns skewer number 1, then skewers number 1, 3, and 4 will be turned over, while skewer number 2 will be in the initial position (because it is turned again).

As we said before, the art of cooking requires perfect timing, so Miroslav wants to turn over all n skewers with the minimal possible number of actions. For example, for the above example n = 6 and k = 1, two turnings are sufficient: he can turn over skewers number 2 and 5.

Help Miroslav turn over all n skewers.

Input

The first line contains two integers n and k (1 ≤ n ≤ 1000, 0 ≤ k ≤ 1000) — the number of skewers and the number of skewers from each side that are turned in one step.

Output

The first line should contain integer l — the minimum number of actions needed by Miroslav to turn over all n skewers. After than print l integers from 1 to n denoting the number of the skewer that is to be turned over at the corresponding step.

Examples

Input

7 2

Output

2
1 6

Input

5 1

Output

2
1 4

Note

In the first example the first operation turns over skewers 1, 2 and 3, the second operation turns over skewers 4, 5, 6 and 7.

In the second example it is also correct to turn over skewers 2 and 5, but turning skewers 2 and 4, or 1 and 5 are incorrect solutions because the skewer 3 is in the initial state after these operations.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int cont[100005];
int main() {
  long long n, k;
  while (cin >> n >> k) {
    if (n < k * 2) {
      if (n == 1) {
        cout << 1 << '\n' << 1 << '\n';
      } else {
        cout << 1 << '\n' << n / 2 + 1 << '\n';
        ;
      }
      continue;
    }
    int gap = (k << 1) + 1;
    vector<int> ans;
    int left = n % gap;
    int now;
    if (left == 0) {
      now = k + 1;
    } else if (left >= k)
      now = left - k + 1;
    else {
      now = 1;
    }
    while (now <= n) {
      ans.push_back(now);
      now += gap;
    }
    cout << ans.size() << '\n';
    for (auto i : ans) {
      cout << i << ' ';
    }
    cout << '\n';
  }
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".

To play Mau-Mau, you need a pack of 52 cards. Each card has a suit (Diamonds — D, Clubs — C, Spades — S, or Hearts — H), and a rank (2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, or A).

At the start of the game, there is one card on the table and you have five cards in your hand. You can play a card from your hand if and only if it has the same rank or the same suit as the card on the table.

In order to check if you'd be a good playing partner, Gennady has prepared a task for you. Given the card on the table and five cards in your hand, check if you can play at least one card.

Input

The first line of the input contains one string which describes the card on the table. The second line contains five strings which describe the cards in your hand.

Each string is two characters long. The first character denotes the rank and belongs to the set \{{\tt 2}, {\tt 3}, {\tt 4}, {\tt 5}, {\tt 6}, {\tt 7}, {\tt 8}, {\tt 9}, {\tt T}, {\tt J}, {\tt Q}, {\tt K}, {\tt A}\}. The second character denotes the suit and belongs to the set \{{\tt D}, {\tt C}, {\tt S}, {\tt H}\}.

All the cards in the input are different.

Output

If it is possible to play a card from your hand, print one word "YES". Otherwise, print "NO".

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

Examples

Input

AS
2H 4C TH JH AD

Output

YES

Input

2H
3D 4C AC KD AS

Output

NO

Input

4D
AS AC AD AH 5H

Output

YES

Note

In the first example, there is an Ace of Spades (AS) on the table. You can play an Ace of Diamonds (AD) because both of them are Aces.

In the second example, you cannot play any card.

In the third example, you can play an Ace of Diamonds (AD) because it has the same suit as a Four of Diamonds (4D), which lies on the table.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  char odin, dva;
  char table[1];
  string itog, itog2;
  vector<pair<char, char> > allkarts;
  allkarts.resize(5);
  cin >> odin >> dva;
  allkarts[0].first = odin;
  allkarts[0].second = dva;
  odin = '\0';
  dva = '\0';
  for (int i = 1; i < 6; i++) {
    cin >> odin >> dva;
    allkarts[i].first = odin;
    allkarts[i].second = dva;
    odin = '\0';
    dva = '\0';
  }
  for (int i = 1; i < 6; i++) {
    if ((allkarts[0].first == allkarts[i].first) ||
        (allkarts[0].second == allkarts[i].second)) {
      itog = "YES";
      break;
    } else {
      itog = "NO";
    }
  }
  cout << itog;
  return EXIT_SUCCESS;
}

```


### Prompt

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

Tavas is a cheerleader in the new sports competition named "Pashmaks".

<image>

This competition consists of two part: swimming and then running. People will immediately start running R meters after they finished swimming exactly S meters. A winner is a such person that nobody else finishes running before him/her (there may be more than one winner).

Before the match starts, Tavas knows that there are n competitors registered for the match. Also, he knows that i-th person's swimming speed is si meters per second and his/her running speed is ri meters per second. Unfortunately, he doesn't know the values of R and S, but he knows that they are real numbers greater than 0.

As a cheerleader, Tavas wants to know who to cheer up. So, he wants to know all people that might win. We consider a competitor might win if and only if there are some values of R and S such that with these values, (s)he will be a winner.

Tavas isn't really familiar with programming, so he asked you to help him.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 2 × 105).

The next n lines contain the details of competitors. i-th line contains two integers si and ri (1 ≤ si, ri ≤ 104).

Output

In the first and the only line of output, print a sequence of numbers of possible winners in increasing order.

Examples

Input

3
1 3
2 2
3 1

Output

1 2 3

Input

3
1 2
1 1
2 1

Output

1 3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
struct CUN {
  int x, y, pos;
} use[N];
int n, tot, top;
int neet[N], sta[N];
double k[N];
bool vis[N];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return (f) ? x : (-x);
}
inline int my(CUN a, CUN b) {
  if (a.x != b.x) return a.x > b.x;
  return a.y > b.y;
}
inline double gett(int ax, int ay, int bx, int by) {
  return ((double)ax * bx * (by - ay)) / ((double)ay * by * (bx - ax));
}
inline double suan(CUN &a, CUN &b) {
  return ((double)a.x * b.x * (b.y - a.y)) / ((double)a.y * b.y * (b.x - a.x));
}
signed main() {
  n = read();
  int nx, ny = 0;
  for (register int i = 1; i <= n; i++) {
    use[i].x = read();
    use[i].y = read();
    use[i].pos = i;
    if (use[i].y > ny || ((use[i].y == ny) && (nx < use[i].x))) {
      ny = use[i].y;
      nx = use[i].x;
    }
  }
  sort(use + 1, use + n + 1, my);
  top = 1;
  sta[top] = 1;
  for (register int i = 2; (i <= n) && (use[i].x >= nx); i++) {
    if (use[i].x == use[sta[top]].x) {
      if (use[i].y == use[sta[top]].y) {
        neet[use[i].pos] = neet[use[sta[top]].pos];
        neet[use[sta[top]].pos] = use[i].pos;
      }
      continue;
    }
    while ((top > 1) && (k[top] > gett(use[sta[top]].x, use[sta[top]].y,
                                       use[i].x, use[i].y)))
      --top;
    sta[++top] = i;
    k[top] = gett(use[sta[top - 1]].x, use[sta[top - 1]].y, use[i].x, use[i].y);
  }
  while (top) {
    for (register int i = use[sta[top]].pos; i; i = neet[i]) vis[i] = 1;
    --top;
  }
  for (register int i = 1; i <= n; i++)
    if (vis[i]) printf("%d ", i);
  printf("\n");
}

```


### Prompt

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

Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, if Vasya types the word "ahhellllloou", it will be considered that he said hello, and if he types "hlelo", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.

Input

The first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.

Output

If Vasya managed to say hello, print "YES", otherwise print "NO".

Examples

Input

ahhellllloou

Output

YES

Input

hlelo

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int h = 0, e = 0, l = 0, l1 = 0, o = 0;
  for (char tem : s) {
    if (h == 0) {
      if (tem == 'h') h = 1;
    } else if (e == 0) {
      if (tem == 'e') e = 1;
    } else if (l == 0) {
      if (tem == 'l') l = 1;
    } else if (l1 == 0) {
      if (tem == 'l') l1 = 1;
    } else if (o == 0) {
      if (tem == 'o') o = 1;
    }
  }
  if (h && e && l && l1 & o) {
    cout << "YES" << endl;
  } else
    cout << "NO";
}

```


### Prompt

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

We have a string S consisting of lowercase English letters.

If the length of S is at most K, print S without change.

If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result.

Constraints

* K is an integer between 1 and 100 (inclusive).
* S is a string consisting of lowercase English letters.
* The length of S is between 1 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

K
S

Output

Print a string as stated in Problem Statement.

Examples

Input

7
nikoandsolstice

Output

nikoand...

Input

40
ferelibenterhominesidquodvoluntcredunt

Output

ferelibenterhominesidquodvoluntcredunt

### Response

```cpp
#include<iostream>
using namespace std;
int main(){
	string s;
	int k;
	cin>>k>>s;
	if(k>=s.length())cout<<s<<'\n';
	else{
		for(int i=0;i<k;i++)cout<<s[i];
		cout<<"...\n";
	}
}
```


### Prompt

Please formulate a cpp solution to the following problem:

You have two strings A = A_1 A_2 ... A_n and B = B_1 B_2 ... B_n of the same length consisting of 0 and 1.

You can transform A using the following operations in any order and as many times as you want:

* Shift A by one character to the left (i.e., if A = A_1 A_2 ... A_n, replace A with A_2 A_3 ... A_n A_1).
* Shift A by one character to the right (i.e., if A = A_1 A_2 ... A_n, replace A with A_n A_1 A_2 ... A_{n-1}).
* Choose any i such that B_i = 1. Flip A_i (i.e., set A_i = 1 - A_i).

You goal is to make strings A and B equal.

Print the smallest number of operations required to achieve this, or -1 if the goal is unreachable.

Constraints

* 1 \leq |A| = |B| \leq 2,000
* A and B consist of 0 and 1.

Input

Input is given from Standard Input in the following format:

A
B

Output

Print the smallest number of operations required to make strings A and B equal, or -1 if the goal is unreachable.

Examples

Input

1010
1100

Output

3

Input

1
0

Output

-1

Input

11010
10001

Output

4

Input

0100100
1111111

Output

5

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int n,Lp[2010],Rp[2010],Mis[2010],buc[2010],tmpMis[2010],mn=0x3f3f3f3f,Suf[2010];
char tms[2010];
bool a[2010],b[2010],s1,s2;
void Sort(){//use a bucket sort to let the complexity of sorting become O(n)
    for(int i=0;i<=n;i++)buc[i]=0;
    for(int i=1;i<=Mis[0];i++)buc[Rp[Mis[i]]+1]++;
    for(int i=1;i<=n;i++)buc[i]+=buc[i-1];
    for(int i=1;i<=Mis[0];i++)tmpMis[++buc[Rp[Mis[i]]]]=Mis[i];
    for(int i=1;i<=Mis[0];i++)Mis[i]=tmpMis[i];
}
int main(){
    scanf("%s",tms),n=strlen(tms);
    for(int i=0;i<n;i++)a[i]=tms[i]-'0';
    scanf("%s",tms);
    for(int i=0;i<n;i++)b[i]=tms[i]-'0';
    memset(Lp,0x3f3f3f3f,sizeof(Lp)),memset(Rp,0x3f3f3f3f,sizeof(Rp));
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(b[j])Lp[i]=min(Lp[i],(i-j+n)%n),Rp[i]=min(Rp[i],(j-i+n)%n);
    for(int i=0;i<n;i++)s1|=a[i],s2|=b[i];//check if there's no '1' in array b. If so, only if there's no '1' in array a, it is unable to get a proper answer.
    if(!s2){
        if(!s1)puts("0");
        else puts("-1");
        return 0;
    }
    for(int i=0;i<n;i++){//numerate the end position of a_i
        Mis[0]=0;
        for(int j=0,k=i;j<n;j++,k++,k%=n)if(a[k]!=b[j])Mis[++Mis[0]]=k;//find the mismatched positions
        Sort();
        Suf[Mis[0]+1]=0;
        for(int j=Mis[0];j;j--)Suf[j]=max(Suf[j+1],Lp[Mis[j]]);//suffix maximum
        mn=min(mn,max(i,Suf[1])*2-i+Mis[0]);//only go left/right situations
        mn=min(mn,(Suf[1]+(n-i)%n)*2-(n-i)%n+Mis[0]);
        for(int j=1;j<=Mis[0];j++){
            mn=min(mn,(Rp[Mis[j]]+max(i,Suf[j+1]))*2-i+Mis[0]);
            mn=min(mn,(Suf[j+1]+max((n-i)%n,Rp[Mis[j]]))*2-(n-i)%n+Mis[0]);
        }
    }
    printf("%d\n",mn);
    return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

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;
int n = 0;
long long sum = 0;
map<long long, int, greater<long long> > a;
priority_queue<long long, vector<long long>, greater<long long> > q, tmp;
int main() {
  scanf("%d", &n);
  long long x = 0;
  for (int i = 1; i <= n; ++i) scanf("%lld", &x), sum += x, ++a[x];
  int left = 0;
  for (auto const &obj : a) {
    long long v = obj.first;
    int c = obj.second;
    while (left > 0 && c > 0) {
      tmp.push(v);
      --left;
      --c;
    }
    while (c >= 2 && (!q.empty() && 2 * v > q.top())) {
      if (q.top() < v) {
        tmp.push(v);
        tmp.push(v);
      } else {
        tmp.push(2 * v - q.top());
        tmp.push(q.top());
      }
      q.pop();
      c -= 2;
    }
    if (c > 0 && !q.empty() && q.top() < v) q.pop(), q.push(v);
    while (!tmp.empty()) {
      q.push(tmp.top());
      tmp.pop();
    }
    left += c;
  }
  long long free = 0;
  while (!q.empty()) {
    free += q.top();
    q.pop();
  }
  printf("%lld", sum - free);
  return 0;
}

```


### Prompt

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

The Little Elephant loves strings very much.

He has an array a from n strings, consisting of lowercase English letters. Let's number the elements of the array from 1 to n, then let's denote the element number i as ai. For each string ai (1 ≤ i ≤ n) the Little Elephant wants to find the number of pairs of integers l and r (1 ≤ l ≤ r ≤ |ai|) such that substring ai[l... r] is a substring to at least k strings from array a (including the i-th string).

Help the Little Elephant solve this problem.

If you are not familiar with the basic notation in string problems, you can find the corresponding definitions in the notes.

Input

The first line contains two space-separated integers — n and k (1 ≤ n, k ≤ 105). Next n lines contain array a. The i-th line contains a non-empty string ai, consisting of lowercase English letter. The total length of all strings ai does not exceed 105.

Output

On a single line print n space-separated integers — the i-th number is the answer for string ai.

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

3 1
abc
a
ab

Output

6 1 3

Input

7 4
rubik
furik
abab
baba
aaabbbababa
abababababa
zero

Output

1 0 9 9 21 30 0

Note

Let's assume that you are given string a = a1a2... a|a|, then let's denote the string's length as |a| and the string's i-th character as ai.

A substring a[l... r] (1 ≤ l ≤ r ≤ |a|) of string a is string alal + 1... ar.

String a is a substring of string b, if there exists such pair of integers l and r (1 ≤ l ≤ r ≤ |b|), that b[l... r] = a.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int ALPHA = 26;
int n, k;
string st[N];
struct Suffix_Automaton {
  int sz, last;
  int father[N], depth[N], child[N][ALPHA], cnt[N];
  set<int> s[N];
  vector<int> a[N];
  Suffix_Automaton() {
    sz = 1;
    last = 1;
  }
  inline int new_node(int dep) {
    depth[++sz] = dep;
    father[sz] = 0;
    memset(child[sz], 0, sizeof(child[sz]));
    return sz;
  }
  inline void extend(int ch, int col) {
    int np = child[last][ch];
    if (np) {
      if (depth[np] == depth[last] + 1) {
        s[np].insert(col);
        last = np;
        return;
      } else {
        int nq = new_node(depth[last] + 1);
        father[nq] = father[np];
        father[np] = nq;
        memcpy(child[nq], child[np], sizeof(child[nq]));
        for (int p = last; child[p][ch] == np; p = father[p]) child[p][ch] = nq;
        s[nq].insert(col);
        last = nq;
        return;
      }
    } else {
      np = new_node(depth[last] + 1);
      int p = last;
      for (; child[p][ch] == 0; p = father[p]) child[p][ch] = np;
      if (child[p][ch] == np) {
        father[np] = 1;
        s[np].insert(col);
        last = np;
        return;
      } else {
        int q = child[p][ch];
        if (depth[q] == depth[p] + 1) {
          father[np] = q;
          s[np].insert(col);
          last = np;
          return;
        } else {
          int nq = new_node(depth[p] + 1);
          father[nq] = father[q];
          father[np] = father[q] = nq;
          memcpy(child[nq], child[q], sizeof(child[nq]));
          for (; child[p][ch] == q; p = father[p]) child[p][ch] = nq;
          s[np].insert(col);
          last = np;
        }
      }
    }
  }
  inline void insert(string s, int col) {
    last = 1;
    for (register int i = 0; i < (int)s.size(); ++i) extend(s[i] - 'a', col);
  }
  inline void dfs(int u) {
    for (unsigned i = 0; i < a[u].size(); ++i) {
      int v = a[u][i];
      dfs(v);
      if ((int)s[u].size() < (int)s[v].size()) swap(s[u], s[v]);
      for (set<int>::iterator it = s[v].begin(); it != s[v].end(); ++it)
        s[u].insert(*it);
    }
    cnt[u] = (int)s[u].size();
  }
  inline void work() {
    for (register int i = 2; i <= sz; ++i) a[father[i]].push_back(i);
    dfs(1);
  }
} SAM;
template <typename T>
inline void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
  x *= f;
}
int main() {
  read(n);
  read(k);
  for (register int i = 1; i <= n; ++i) {
    cin >> st[i];
    SAM.insert(st[i], i);
  }
  SAM.work();
  for (register int i = 1; i <= n; ++i) {
    int now = 1;
    long long ans = 0;
    for (register int j = 0; j < st[i].size(); ++j) {
      now = SAM.child[now][st[i][j] - 'a'];
      while (now != 1 && SAM.cnt[now] < k) now = SAM.father[now];
      ans += (long long)SAM.depth[now];
    }
    printf("%lld ", ans);
  }
  printf("\n");
  return 0;
}

```


### Prompt

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

There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.

The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.

For each ant, find its position after T seconds.

Constraints

* All input values are integers.
* 1 \leq N \leq 10^5
* 1 \leq L \leq 10^9
* 1 \leq T \leq 10^9
* 0 \leq X_1 < X_2 < ... < X_N \leq L - 1
* 1 \leq W_i \leq 2

Input

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

N L T
X_1 W_1
X_2 W_2
:
X_N W_N

Output

Print N lines. The i-th line should contain the coordinate of ant i after T seconds. Here, each coordinate must be between 0 and L-1, inclusive.

Examples

Input

3 8 3
0 1
3 2
6 1

Output

1
3
0

Input

4 20 9
7 2
9 1
12 1
18 1

Output

7
18
18
1

### Response

```cpp
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=100005;
int n,L,T,x,w,a[N],id;

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

int main()
{
	n=getint(),L=getint(),T=getint();
	rep(i,1,n)
	{
		x=getint(),w=getint()==2?-1:1;
		int dis=x+w*T;
		if(dis>0) id=(id+dis/L)%n;
		if(dis<0) id=(id+(dis+1)/L-1)%n;
		a[i]=(dis%L+L)%L;
	}
	sort(a+1,a+1+n),id=(id+n)%n;
	rep(i,id+1,n) printf("%d\n",a[i]);
	rep(i,1,id) printf("%d\n",a[i]);
	return 0;
}
```


### Prompt

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

problem

You are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you are looking for. However, there is a possibility that extra stars are shown in the photograph other than the stars that make up the constellation.

For example, the constellations in Figure 1 are included in the photo in Figure 2 (circled). If you translate the coordinates of a star in a given constellation by 2 in the x direction and −3 in the y direction, it will be the position in the photo.

Given the shape of the constellation you want to look for and the position of the star in the picture, write a program that answers the amount to translate to convert the coordinates of the constellation to the coordinates in the picture.

<image> | <image>
--- | ---
Figure 1: The constellation you want to find | Figure 2: Photograph of the starry sky

input

The input consists of multiple datasets. Each dataset is given in the following format.

The first line of the input contains the number of stars m that make up the constellation you want to find. In the following m line, the integers indicating the x and y coordinates of the m stars that make up the constellation you want to search for are written separated by blanks. The number n of stars in the photo is written on the m + 2 line. In the following n lines, the integers indicating the x and y coordinates of the n stars in the photo are written separated by blanks.

The positions of the m stars that make up the constellation are all different. Also, the positions of the n stars in the picture are all different. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of a star are all 0 or more and 1000000 or less.

When m is 0, it indicates the end of input. The number of datasets does not exceed 5.

output

The output of each dataset consists of one line, with two integers separated by blanks. These show how much the coordinates of the constellation you want to find should be translated to become the coordinates in the photo. The first integer is the amount to translate in the x direction, and the second integer is the amount to translate in the y direction.

Examples

Input

5
8 5
6 4
4 3
7 10
0 10
10
10 5
2 7
9 7
8 10
10 2
1 2
8 1
6 7
6 0
0 9
5
904207 809784
845370 244806
499091 59863
638406 182509
435076 362268
10
757559 866424
114810 239537
519926 989458
461089 424480
674361 448440
81851 150384
459107 795405
299682 6700
254125 362183
50795 541942
0

Output

2 -3
-384281 179674

Input

None

Output

None

### Response

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

int main()
{
	int m, n;

	cin >> m;

	while (m > 0) {
		vector<pair <int, int>> p, q;

		for (int i = 0; i < m; i++) {
			int x, y;
			cin >> x >> y;
			p.push_back(make_pair(x, y));
		}

		cin >> n;

		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			q.push_back(make_pair(x, y));
		}

		int xp = p[0].first, yp = p[0].second;

		for (int i = 0; i < n; i++) {
			bool f = 1;
			int xf = q[i].first, yf = q[i].second;

			for (int j = 1; j < m; j++) {
				pair<int, int> pk = make_pair(p[j].first - xp + xf, p[j].second - yp + yf);
				if (find(q.begin(), q.end(), pk) == q.end()) {
					f = 0;
					break;
				}
			}

			if (f) {
				cout << xf - xp << " " << yf - yp << endl;
				break;
			}
		}

		cin >> m;
	}

	return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

There are N squares aligned in a row. The i-th square from the left contains an integer a_i.

Initially, all the squares are white. Snuke will perform the following operation some number of times:

* Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten.

After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.

Constraints

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

Input

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

N K
a_1 a_2 ... a_N

Output

Print the maximum possible score.

Examples

Input

5 3
-10 10 -10 10 -10

Output

10

Input

4 2
10 -10 -10 10

Output

20

Input

1 1
-10

Output

0

Input

10 5
5 -4 -5 -8 -4 7 2 -4 0 7

Output

17

### Response

```cpp
#include <iostream>
using namespace std;
int a[100010];
long long num[100010],t[100010],sum[100010];
int main(){
    int n,k;
    long long ans=0;
    cin>>n>>k;
    int i;
    for(i=1;i<=n;i++)cin>>a[i];
    for(i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    for(i=1;i<=n;i++)num[i]=num[i-1]+max(a[i],0);
    for(i=n;i>=1;i--)t[i]=t[i+1]+max(a[i],0);
    for(i=0;i<=n-k;i++)
    ans=max(ans,num[i]+t[i+k+1]+max(sum[i+k]-sum[i],0LL));
    cout<<ans<<endl;
    return 0;
}

```


### Prompt

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

We have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.

If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost of this arrangement is computed as:

\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)

Find the sum of the costs of all possible arrangements of the pieces. Since this value can be tremendous, print it modulo 10^9+7.

We consider two arrangements of the pieces different if and only if there is a square that contains a piece in one of the arrangements but not in the other.

Constraints

* 2 \leq N \times M \leq 2 \times 10^5
* 2 \leq K \leq N \times M
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M K

Output

Print the sum of the costs of all possible arrangements of the pieces, modulo 10^9+7.

Examples

Input

2 2 2

Output

8

Input

4 5 4

Output

87210

Input

100 100 5000

Output

817260251

### Response

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

using namespace std;

const ll MOD = 1e9 + 7;

ll lgput(ll b, int p) {
    ll ans = 1;
    while(p) {
        if(p % 2)
          ans = (ans * b) % MOD;
        b = (b * b) % MOD;
        p /= 2;
    }
    return ans;
}

ll invmod(ll x) {
    return lgput(x, MOD - 2);
}

int main() {

    ios::sync_with_stdio(false);

    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> fact(n * m + 1, 1);
    for(int i = 1; i <= n * m; i ++)
      fact[i] = (i * fact[i - 1]) % MOD;
    ll comb = (((fact[n * m - 2] * invmod(fact[k - 2])) % MOD) * invmod(fact[n * m - k])) % MOD;

    ll s = 0;
    for(int i = -(n - 1); i <= n - 1; i ++)
      for(int j = -(m - 1); j <= m - 1; j ++) {
        s = (s + (1LL * (abs(i) + abs(j)) * (n - abs(i)) * (m - abs(j))) % MOD) % MOD;
        //cout << i << " " << j << " -> " << s << endl;
       }
    s = (s * comb) % MOD;
    cout << (s * invmod(2)) % MOD;
    return 0;
}

```


### Prompt

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

You are given a permutation of integers from 1 to n. Exactly once you apply the following operation to this permutation: pick a random segment and shuffle its elements. Formally:

  1. Pick a random segment (continuous subsequence) from l to r. All <image> segments are equiprobable.
  2. Let k = r - l + 1, i.e. the length of the chosen segment. Pick a random permutation of integers from 1 to k, p1, p2, ..., pk. All k! permutation are equiprobable.
  3. This permutation is applied to elements of the chosen segment, i.e. permutation a1, a2, ..., al - 1, al, al + 1, ..., ar - 1, ar, ar + 1, ..., an is transformed to a1, a2, ..., al - 1, al - 1 + p1, al - 1 + p2, ..., al - 1 + pk - 1, al - 1 + pk, ar + 1, ..., an.

Inversion if a pair of elements (not necessary neighbouring) with the wrong relative order. In other words, the number of inversion is equal to the number of pairs (i, j) such that i < j and ai > aj. Find the expected number of inversions after we apply exactly one operation mentioned above.

Input

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the length of the permutation.

The second line contains n distinct integers from 1 to n — elements of the permutation.

Output

Print one real value — the expected number of inversions. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 9.

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>.

Example

Input

3
2 3 1

Output

1.916666666666666666666666666667

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int INF = 2e9 + 5;
const double eps = 1e-6;
template <class T>
T gcd(T a, T b) {
  if (!b) return a;
  return gcd(b, a % b);
}
const int maxn = 1e5 + 100;
int n, a[maxn];
long long bit[maxn];
double ans = 0;
inline int lowbit(int x) { return x & (-x); }
long long query(int x) {
  long long res = 0;
  while (x > 0) {
    res += bit[x];
    x -= lowbit(x);
  }
  return res;
}
void add(int x, int v) {
  while (x <= n) {
    bit[x] += v;
    x += lowbit(x);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++)
    ans += 1.0 * (1LL * i * (n - i) * (n - i + 1)) / 2 / n / (n + 1);
  for (int i = n; i >= 1; i--) {
    long long k = query(a[i] - 1);
    ans += 1.0 * (k * (1LL * n * (n + 1) - 2.0 * i * (n + 1)) / n / (n + 1));
    add(a[i], 1);
  }
  memset(bit, 0, sizeof(bit));
  for (int i = n; i >= 1; i--) {
    long long k = query(a[i] - 1);
    ans += 1.0 * (2 * k * i) / n / (n + 1);
    add(a[i], i);
  }
  printf("%.16f\n", ans);
  return 0;
}

```


### Prompt

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

Sereja owns a restaurant for n people. The restaurant hall has a coat rack with n hooks. Each restaurant visitor can use a hook to hang his clothes on it. Using the i-th hook costs ai rubles. Only one person can hang clothes on one hook.

Tonight Sereja expects m guests in the restaurant. Naturally, each guest wants to hang his clothes on an available hook with minimum price (if there are multiple such hooks, he chooses any of them). However if the moment a guest arrives the rack has no available hooks, Sereja must pay a d ruble fine to the guest.

Help Sereja find out the profit in rubles (possibly negative) that he will get tonight. You can assume that before the guests arrive, all hooks on the rack are available, all guests come at different time, nobody besides the m guests is visiting Sereja's restaurant tonight.

Input

The first line contains two integers n and d (1 ≤ n, d ≤ 100). The next line contains integers a1, a2, ..., an (1 ≤ ai ≤ 100). The third line contains integer m (1 ≤ m ≤ 100).

Output

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

Examples

Input

2 1
2 1
2

Output

3

Input

2 1
2 1
10

Output

-5

Note

In the first test both hooks will be used, so Sereja gets 1 + 2 = 3 rubles.

In the second test both hooks will be used but Sereja pays a fine 8 times, so the answer is 3 - 8 = - 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100 + 10;
int A[MAX_N];
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    A[i] = temp;
  }
  int m;
  cin >> m;
  sort(A, A + n);
  int ans = 0;
  if (m <= n)
    for (int i = 0; i < m; i++) ans += A[i];
  else {
    for (int i = 0; i < n; i++) ans += A[i];
    for (int i = n; i < m; i++) ans -= d;
  }
  cout << ans << endl;
}

```


### Prompt

Generate a CPP solution to the following problem:

DO YOU EXPECT ME TO FIND THIS OUT?

WHAT BASE AND/XOR LANGUAGE INCLUDES string?

DON'T BYTE OF MORE THAN YOU CAN CHEW

YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR

SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD

THE LAST STACK RUPTURES. ALL DIE. OH, THE EMBARRASSMENT!

I HAVE NO ARRAY AND I MUST SCREAM

ELEMENTS MAY NOT BE STORED IN WEST HYPERSPACE

Input

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

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

Output

Output a single integer.

Example

Input

4
2 5 3 1

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
int a[111111];
int mx;
int main() {
  int num;
  cin >> num;
  for (int i = 1; i <= num; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  cout << (mx ^ a[num]) << endl;
  return 0;
}

```


### Prompt

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

Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.

Constraints

* 1\leq N \leq 10^{16}
* N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.

Examples

Input

100

Output

18

Input

9995

Output

35

Input

3141592653589793

Output

137

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
signed main(){
	scanf("%lld",&n);
	int k,flag=1,cnt=0;
	while (n){
		k=n%10;
		n/=10;
		if (n)flag&=(k==9);
		cnt++;
	}
	printf("%lld\n",(cnt-1)*9+(flag?k:k-1));
}
```


### Prompt

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

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

Input

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

Output

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

Examples

Input

13 50

Output

699998

Input

61 2

Output

1000000000000000000000000000001

Input

15 50

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int d, s;
bool vis[505][5005];
struct state {
  int d, s;
  string cur;
  state(int d = 0, int s = 0, string cur = "") : d(d), s(s), cur(cur){};
};
void bfs() {
  cin >> d >> s;
  queue<state> q;
  q.push(state(0, 0, ""));
  vis[0][0] = true;
  while (not q.empty()) {
    state val = q.front();
    q.pop();
    if (val.s > s) continue;
    if (val.d == 0 and val.s == s) {
      cout << val.cur << "\n";
      return;
    }
    for (int i = 0; i < 10; i++) {
      int cur_d = (val.d * 10 + i) % d;
      int cur_s = val.s + i;
      if (!vis[cur_d][cur_s]) {
        vis[cur_d][cur_s] = true;
        q.push(state(cur_d, cur_s, val.cur + (char)(i + '0')));
      }
    }
  }
  cout << -1 << "\n";
}
int main() {
  bfs();
  return 0;
}

```


### Prompt

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

Given is an integer N. Find the number of digits that N has in base K.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^9
* 2 \leq K \leq 10

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of digits that N has in base K.

Examples

Input

11 2

Output

4

Input

1010101 10

Output

7

Input

314159265 3

Output

18

### Response

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

int n,k;

int main(){
	cin>>n>>k;

	int ans=0;
	while (n){

		n/=k;
		ans++;
	}

	cout<<ans;
}
```


### Prompt

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

On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can stick pins in some of them and the cost of sticking in the marble number i is equal to ci, number ci may be negative. After you choose and stick the pins you need, the marbles will start to roll left according to the rule: if a marble has a pin stuck in it, then the marble doesn't move, otherwise the marble rolls all the way up to the next marble which has a pin stuck in it and stops moving there. If there is no pinned marble on the left to the given unpinned one, it is concluded that the marble rolls to the left to infinity and you will pay an infinitely large fine for it. If no marble rolled infinitely to the left, then the fine will consist of two summands:

  * the sum of the costs of stuck pins;
  * the sum of the lengths of the paths of each of the marbles, that is the sum of absolute values of differences between their initial and final positions.

Your task is to choose and pin some marbles in the way that will make the fine for you to pay as little as possible.

Input

The first input line contains an integer n (1 ≤ n ≤ 3000) which is the number of marbles. The next n lines contain the descriptions of the marbles in pairs of integers xi, ci ( - 109 ≤ xi, ci ≤ 109). The numbers are space-separated. Each description is given on a separate line. No two marbles have identical initial positions.

Output

Output the single number — the least fine you will have to pay.

Examples

Input

3
2 3
3 4
1 2

Output

5

Input

4
1 7
3 1
5 10
6 1

Output

11

### Response

```cpp
#include <bits/stdc++.h>
bool debug = false;
using namespace std;
long long convertToNum(string s) {
  long long val = 0;
  for (int i = 0; i < (s.size()); i++) val = val * 10 + s[i] - '0';
  return val;
}
string convertToString(long long a) {
  string res = "";
  if (!a) return "0";
  while (a) {
    res = (char)(a % 10 + 48) + res;
    a /= 10;
  }
  return res;
}
long long GCD(long long x, long long y) {
  if (!x) return y;
  if (!y) return x;
  if (x == y) return x;
  if (x < y)
    return GCD(x, y % x);
  else
    return GCD(x % y, y);
}
long long POW(long long x, long long y, long long Base) {
  if (!y) return 1;
  long long u = POW(x, y / 2, Base);
  u = (u * u) % Base;
  if (y & 1)
    return (u * x) % Base;
  else
    return u;
}
const int Dice[24][6] = {
    {1, 2, 3, 4, 5, 6}, {1, 6, 3, 5, 2, 4}, {1, 4, 3, 2, 6, 5},
    {1, 5, 3, 6, 4, 2}, {2, 1, 4, 3, 6, 5}, {6, 1, 5, 3, 4, 2},
    {5, 1, 6, 3, 2, 4}, {4, 1, 2, 3, 5, 6}, {3, 2, 1, 4, 6, 5},
    {3, 5, 1, 6, 2, 4}, {3, 4, 1, 2, 5, 6}, {3, 6, 1, 5, 4, 2},
    {2, 3, 4, 1, 5, 6}, {4, 3, 2, 1, 6, 5}, {5, 3, 6, 1, 4, 2},
    {6, 3, 5, 1, 2, 4}, {2, 5, 4, 6, 1, 3}, {4, 6, 2, 5, 1, 3},
    {5, 4, 6, 2, 1, 3}, {6, 2, 5, 4, 1, 3}, {2, 6, 4, 5, 3, 1},
    {4, 5, 2, 6, 3, 1}, {5, 2, 6, 4, 3, 1}, {6, 4, 5, 2, 3, 1}};
const double eps = 1e-10;
double PI = acos(-1.0);
int cmp(double q, double w) {
  return (q < w + eps) ? (q > w - eps) ? 0 : -1 : 1;
}
struct point {
  double x, y;
  point(double x, double y) : x(x), y(y) {}
  point() { x = y = 0.0; }
  point operator+(point q) { return point(x + q.x, y + q.y); }
  point operator-(point q) { return point(x - q.x, y - q.y); }
  point operator*(double t) { return point(x * t, y * t); }
  point operator/(double t) { return point(x / t, y / t); }
  double operator*(point q) { return q.x * x + q.y * y; }
  double operator%(point q) { return x * q.y - y * q.x; }
  int cmp(point q) const {
    if (int t = ::cmp(x, q.x)) return t;
    return ::cmp(y, q.y);
  }
  bool operator>(point q) const { return cmp(q) > 0; }
  bool operator<(point q) const { return cmp(q) < 0; }
  bool operator==(point q) const { return cmp(q) == 0; }
  bool operator>=(point q) const { return cmp(q) >= 0; }
  bool operator<=(point q) const { return cmp(q) <= 0; }
  bool operator!=(point q) const { return cmp(q) != 0; }
};
pair<int, int> p[3004];
long long Sum[3004], n;
long long F[3004];
int main() {
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> p[i].first >> p[i].second;
  sort(p + 1, p + n + 1);
  long long limit = p[1].first;
  p[n + 1] = make_pair(1000000003, 0);
  for (int i = (1); i <= (n); i++) Sum[i] = Sum[i - 1] + p[i].first - limit;
  F[1] = p[1].second;
  for (int i = (2); i <= (n + 1); i++) {
    F[i] = 1000000000000000LL;
    for (int j = (i - 1); j >= (1); j--) {
      long long cost = Sum[i - 1] - Sum[j];
      int sl = i - j - 1;
      cost = cost - sl * (p[j].first - limit);
      F[i] = min(F[i], F[j] + cost + p[i].second);
    }
  }
  cout << F[n + 1] << endl;
  return 0;
}

```


### Prompt

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

Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place.

To decide who exactly would clean the apartment, the friends want to play a counting-out game. First, all the guys stand in a circle, and then each of them shows some number of fingers on one hand (one to five), and then the boys count in a circle, starting from Dima, the number of people, respective to the total number of fingers shown. The person on who the countdown stops will clean the apartment.

For example, if Dima and one of his friends played hide and seek, and 7 fingers were shown during the counting-out, then Dima would clean the place. If there were 2 or say, 8 fingers shown, then his friend would clean the place.

Dima knows how many fingers each of his friends will show during the counting-out. Now he is interested in the number of ways to show some number of fingers on one hand (one to five), so that he did not have to clean the place. Help Dima.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of Dima's friends. Dima himself isn't considered to be his own friend. The second line contains n positive integers, not exceeding 5, representing, how many fingers the Dima's friends will show.

The numbers in the lines are separated by a single space.

Output

In a single line print the answer to the problem.

Examples

Input

1
1

Output

3

Input

1
2

Output

2

Input

2
3 5

Output

3

Note

In the first sample Dima can show 1, 3 or 5 fingers. If Dima shows 3 fingers, then the counting-out will go like that: Dima, his friend, Dima, his friend.

In the second sample Dima can show 2 or 4 fingers.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int ans, n, k, i, x;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    k = k + x;
  }
  for (i = 1; i <= 5; i++)
    if ((k + i - 1) % (n + 1)) ans++;
  cout << ans;
}

```


### Prompt

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

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

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

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

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

Input

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

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

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

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

Output

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

Example

Input

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

Output

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

Note

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

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

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string a, b;
    cin >> a;
    cin >> b;
    vector<long long int> ans;
    for (long long int i = n - 1; i >= 1; i--) {
      if (a[i] != b[i]) {
        ans.push_back(i + 1);
        ans.push_back(1);
        ans.push_back(i + 1);
      }
    }
    if (a[0] != b[0]) ans.push_back(1);
    cout << ans.size() << " ";
    for (auto i : ans) {
      cout << i << " ";
    }
    cout << '\n';
  }
  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>
int main() {
  int n;
  scanf("%d", &n);
  int s = n / 2 + 1;
  printf("%d\n", s);
  printf("1 1\n");
  int l = 1, r = 2;
  for (int i = 2; i <= n; i++) {
    printf("%d %d\n", l, r);
    if (l < r)
      l++;
    else
      r++;
  }
}

```


### Prompt

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

In this problem, your task is to use ASCII graphics to paint a cardiogram.

A cardiogram is a polyline with the following corners:

<image>

That is, a cardiogram is fully defined by a sequence of positive integers a1, a2, ..., an.

Your task is to paint a cardiogram by given sequence ai.

Input

The first line contains integer n (2 ≤ n ≤ 1000). The next line contains the sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 1000). It is guaranteed that the sum of all ai doesn't exceed 1000.

Output

Print max |yi - yj| lines (where yk is the y coordinate of the k-th point of the polyline), in each line print <image> characters. Each character must equal either « / » (slash), « \ » (backslash), « » (space). The printed image must be the image of the given polyline. Please study the test samples for better understanding of how to print a cardiogram.

Note that in this problem the checker checks your answer taking spaces into consideration. Do not print any extra characters. Remember that the wrong answer to the first pretest doesn't give you a penalty.

Examples

Input

5
3 1 2 5 1

Output

      / \
   / \ /   \
  /       \
 /         \
          \ /

Input

3
1 5 1

Output

 / \
  \
   \
    \
     \ /

Note

Due to the technical reasons the answers for the samples cannot be copied from the statement. We've attached two text documents with the answers below.

http://assets.codeforces.com/rounds/435/1.txt

http://assets.codeforces.com/rounds/435/2.txt

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
void Error(string err) {
  cout << err;
  cerr << err;
  while (1)
    ;
}
int main() {
  int n, arr[1010];
  pair<int, int> p[1010];
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> arr[i];
  p[0].first = p[0].second = 0;
  bool pos = true;
  int mx = 0, mn = 0;
  for (int i = (0); i < (n); i++) {
    p[i + 1].first = p[i].first + arr[i];
    if (pos)
      p[i + 1].second = p[i].second + arr[i];
    else
      p[i + 1].second = p[i].second - arr[i];
    pos = !pos;
    mx = max(mx, p[i + 1].second);
    mn = min(mn, p[i + 1].second);
  }
  vector<string> v;
  v.resize(mx - mn);
  for (int i = (0); i < (p[n].first); i++) v[0] += ' ';
  for (int i = (1); i < (v.size()); i++) v[i] = v[0];
  for (int i = 1; i <= n; i++) {
    pair<int, int> last_pnt = p[i - 1], nw_pnt = p[i];
    if (last_pnt.second > nw_pnt.second)
      for (int j = last_pnt.first; j < nw_pnt.first; j++)
        v[mx - last_pnt.second + (j - last_pnt.first)][j] = '\\';
    else
      for (int j = last_pnt.first; j < nw_pnt.first; j++)
        v[-1 + mx - last_pnt.second - (j - last_pnt.first)][j] = '/';
  }
  for (int i = (0); i < (v.size()); i++) cout << v[i] << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to be sad, so he would ensure to give at least one sweet to each friend.

He wants to celebrate it in a unique style, so he would like to ensure following condition for the distribution of sweets. Assume that he has distributed n sweets to his friends such that ith friend is given ai sweets. He wants to make sure that there should not be any positive integer x > 1, which divides every ai.

Please find the number of ways he can distribute sweets to his friends in the required way. Note that the order of distribution is important, for example [1, 2] and [2, 1] are distinct distributions. As the answer could be very large, output answer modulo 1000000007 (109 + 7).

To make the problem more interesting, you are given q queries. Each query contains an n, f pair. For each query please output the required number of ways modulo 1000000007 (109 + 7).

Input

The first line contains an integer q representing the number of queries (1 ≤ q ≤ 105). Each of the next q lines contains two space space-separated integers n, f (1 ≤ f ≤ n ≤ 105).

Output

For each query, output a single integer in a line corresponding to the answer of each query.

Examples

Input

5
6 2
7 2
6 3
6 4
7 4

Output

2
6
9
10
20

Note

For first query: n = 6, f = 2. Possible partitions are [1, 5] and [5, 1].

For second query: n = 7, f = 2. Possible partitions are [1, 6] and [2, 5] and [3, 4] and [4, 3] and [5, 3] and [6, 1]. So in total there are 6 possible ways of partitioning.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100010];
long long fac[100010], revfac[100010];
long long pow(long long a, int k) {
  if (!k) return 1;
  long long ans = pow(a, k >> 1);
  ans = ans * ans % 1000000007;
  if (k & 1) ans = ans * a % 1000000007;
  return ans;
}
long long H(int n, int f) {
  if (n < f) return 0;
  return fac[n - 1] * revfac[n - f] % 1000000007 * revfac[f - 1] % 1000000007;
}
long long val[100010];
int calc(int n, int f) {
  if (f == 1) return n == 1;
  long long ans = H(n, f);
  for (int i = 0, sz = adj[n].size(); i < sz; i++) {
    int d = adj[n][i];
    if (d < f) {
      val[d] = 0;
      continue;
    }
    val[d] = H(d, f);
    for (int j = adj[d].size(); j--;) {
      int dd = adj[d][j];
      val[d] -= val[dd];
    }
    val[d] %= 1000000007;
    if (val[d] < 0) val[d] += 1000000007;
    ans -= val[d];
  }
  ans %= 1000000007;
  if (ans < 0) ans += 1000000007;
  return ans;
}
void pre() {
  fac[0] = revfac[0] = 1;
  for (int i = 1; i < 100010; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    revfac[i] = pow(fac[i], 1000000007 - 2);
  }
  for (int i = 2, j; i < 100010; i++) {
    for (j = 2; j * j < i; j++) {
      if (i % j == 0) adj[i].push_back(j);
    }
    if (j * j == i) adj[i].push_back(j);
    for (j--; j > 1; j--) {
      if (i % j == 0) adj[i].push_back(i / j);
    }
  }
}
int main() {
  pre();
  int q, n, f;
  cin >> q;
  while (q--) {
    scanf("%d %d", &n, &f);
    printf("%d\n", calc(n, f));
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

You are working for an administration office of the International Center for Picassonian Cubism (ICPC), which plans to build a new art gallery for young artists. The center is organizing an architectural design competition to find the best design for the new building.

Submitted designs will look like a screenshot of a well known game as shown below.

<image>

This is because the center specifies that the building should be constructed by stacking regular units called pieces, each of which consists of four cubic blocks. In addition, the center requires the competitors to submit designs that satisfy the following restrictions.

* All the pieces are aligned. When two pieces touch each other, the faces of the touching blocks must be placed exactly at the same position.
* All the pieces are stable. Since pieces are merely stacked, their centers of masses must be carefully positioned so as not to collapse.
* The pieces are stacked in a tree-like form in order to symbolize boundless potentiality of young artists. In other words, one and only one piece touches the ground, and each of other pieces touches one and only one piece on its bottom faces.
* The building has a flat shape. This is because the construction site is a narrow area located between a straight moat and an expressway where no more than one block can be placed between the moat and the expressway as illustrated below.

<image>

It will take many days to fully check stability of designs as it requires complicated structural calculation. Therefore, you are asked to quickly check obviously unstable designs by focusing on centers of masses. The rules of your quick check are as follows.

Assume the center of mass of a block is located at the center of the block, and all blocks have the same weight. We denote a location of a block by xy-coordinates of its left-bottom corner. The unit length is the edge length of a block.

Among the blocks of the piece that touch another piece or the ground on their bottom faces, let xL be the leftmost x-coordinate of the leftmost block, and let xR be the rightmost x-coordinate of the rightmost block. Let the x-coordinate of its accumulated center of mass of the piece be M, where the accumulated center of mass of a piece P is the center of the mass of the pieces that are directly and indirectly supported by P, in addition to P itself. Then the piece is stable, if and only if xL < M < xR. Otherwise, it is unstable. A design of a building is unstable if any of its pieces is unstable.

Note that the above rules could judge some designs to be unstable even if it would not collapse in reality. For example, the left one of the following designs shall be judged to be unstable.

<image> |  | <image>
---|---|---

Also note that the rules judge boundary cases to be unstable. For example, the top piece in the above right design has its center of mass exactly above the right end of the bottom piece. This shall be judged to be unstable.

Write a program that judges stability of each design based on the above quick check rules.

Input

The input is a sequence of datasets. The end of the input is indicated by a line containing two zeros separated by a space. Each dataset, which represents a front view of a building, is formatted as follows.

> w h
>  p0(h-1)p1(h-1)...p(w-1)(h-1)
>  ...
>  p01p11...p(w-1)1
>  p00p10...p(w-1)0
>

The integers w and h separated by a space are the numbers of columns and rows of the layout, respectively. You may assume 1 ≤ w ≤ 10 and 1 ≤ h ≤ 60. The next h lines specify the placement of the pieces. The character pxy indicates the status of a block at (x,y), either ``.`', meaning empty, or one digit character between ``1`' and ``9`', inclusive, meaning a block of a piece. (As mentioned earlier, we denote a location of a block by xy-coordinates of its left-bottom corner.)

When two blocks with the same number touch each other by any of their top, bottom, left or right face, those blocks are of the same piece. (Note that there might be two different pieces that are denoted by the same number.) The bottom of a block at (x,0) touches the ground.

You may assume that the pieces in each dataset are stacked in a tree-like form.

Output

For each dataset, output a line containing a word `STABLE` when the design is stable with respect to the above quick check rules. Otherwise, output `UNSTABLE`. The output should be written with uppercase letters, and should not contain any other extra characters.

Sample Input

4 5
..33
..33
2222
..1.
.111
5 7
....1
.1..1
.1..1
11..1
.2222
..111
...1.
3 6
.3.
233
23.
22.
.11
.11
4 3
2222
..11
..11
4 5
.3..
33..
322.
2211
.11.
3 3
222
2.1
111
3 4
11.
11.
.2.
222
3 4
.11
.11
.2.
222
2 7
11
.1
21
22
23
.3
33
2 3
1.
11
.1
0 0

Output for the Sample Input

STABLE
STABLE
STABLE
UNSTABLE
STABLE
STABLE
UNSTABLE
UNSTABLE
UNSTABLE
UNSTABLE

Example

Input

4 5
..33
..33
2222
..1.
.111
5 7
....1
.1..1
.1..1
11..1
.2222
..111
...1.
3 6
.3.
233
23.
22.
.11
.11
4 3
2222
..11
..11
4 5
.3..
33..
322.
2211
.11.
3 3
222
2.1
111
3 4
11.
11.
.2.
222
3 4
.11
.11
.2.
222
2 7
11
.1
21
22
23
.3
33
2 3
1.
11
.1
0 0

Output

STABLE
STABLE
STABLE
UNSTABLE
STABLE
STABLE
UNSTABLE
UNSTABLE
UNSTABLE
UNSTABLE

### Response

```cpp
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

char field[100][100];
bool visited[100][100];
int W, H;

int tx[] = {1, 0, -1, 0};
int ty[] = {0, -1, 0, 1};
struct Tree {
  int lx, rx;
  int block[15];
  vector<Tree> child;
  Tree () {
      fill(block, block + 15, 0);
  }
  Tree(int rx, int ry, vector<Tree> child) : lx(lx), rx(rx), child(child) {
    fill(block, block + 15, 0);
  }
  void print() {
    printf("lx, rx = %d, %d\n", lx, rx);
    for (int i = 0; i < child.size(); i++) {
      child[i].print();
    }
  }

  int num(int idx) {
    int n = 0;
    for (int i = 0; i < child.size(); i++) {
      n += child[i].num(idx);
    }
    n += block[idx];
    return n;
  }

  int numChild() {
    int n = 0;
    for (int i = 0; i < child.size(); i++) {
      n += child[i].numChild();
    }
    return n + 1;
  }
};

typedef pair<int, int> P;
typedef pair<Tree, bool> Res;

void init() {
  fill(&field[0][0], &field[99][100], '!');
  fill(&visited[0][0], &visited[99][100], false);
}

Res search(char c, int cx, int cy, bool isBottom) {
  //printf("called\n");
  //printf("%c, %d, %d\n", c, cx, cy);
  queue<P> Q;
  Q.push(P(cx, cy));
  Tree t;
  vector<P> next;
  t.lx = cx, t.rx = cx;
  bool p = false;
  while (!Q.empty()) {
    P cur = Q.front();
    Q.pop();
    int x = cur.first;
    int y = cur.second;

    if (visited[y][x] || field[y][x] != c) {
      continue;
    }
    p = true;
    //printf("%d %d\n", x, y);
    visited[y][x] = true;
    t.block[x]++;

    if (field[y - 1][x] != '.' && field[y - 1][x] != '!' && field[y - 1][x] != c) {
      next.push_back(P(x, y - 1));
      //printf("%d, %d\n", x, y - 1);
    }

    if (!isBottom && field[y + 1][x] != '.' && field[y + 1][x] != '!' && field[y + 1][x] != c) {
      t.lx = min(t.lx, x);
      t.rx = max(t.rx, x);
    }

    if (isBottom && field[y + 1][x] == '!') {
      t.lx = min(t.lx, x);
      t.rx = max(t.rx, x);
    }

    for (int i = 0; i < 4; i++) {
      int nx = x + tx[i];
      int ny = y + ty[i];
      if (field[ny][nx] == c && !visited[ny][nx]) {
        Q.push(P(nx, ny));
      }
    }
  }
  if (!p) {
    return Res(Tree(), false);
  }
  for (int i = 0; i < next.size(); i++) {
    int x = next[i].first;
    int y = next[i].second;
    Res res = search(field[y][x], x, y, false);
    if (res.second) {
      t.child.push_back(res.first);
    }
  }
  return Res(t, true);
}

Tree make_tree() {
  for (int i = H; i >= 1; i--) {
    for (int j = 1; j <= W; j++) {
      if (field[i][j] != '.') {
        char c = field[i][j];
        Res r = search(c, j, i, true);
        Tree t = r.first;
        return t;
      }
    }
  }
}

bool check(Tree t) {
  if (t.child.size() == 0) {
    double g = 0.0;
    for (int i = 1; i <= W; i++) {
      g += t.block[i] * (i - 0.5);
    }
    g /= 4;
    // printf("g = %lf\n", g);
    if (t.lx - 1 < g && g < t.rx) {
      return true;
    } else {
      return false;
    }
  }

  for (int i = 0; i < t.child.size(); i++) {
    if (!check(t.child[i])) {
      return false;
    }
  }

  double g = 0;
  for (int i = 1; i <= W; i++) {
    g += (i - 0.5) * t.num(i);
  }
  g /= (4 * (t.numChild()));
  //printf("G = %lf\n", g);
  if (t.lx - 1 < g && g < t.rx) {
    return true;
  } else {
    return false;
  }
}

void solve() {
  Tree t = make_tree();
  //t.print();

  if (check(t)) {
    printf("STABLE\n");
  } else {
    printf("UNSTABLE\n");
  }
}

int main() {
  while (true) {
    scanf("%d %d ", &W, &H);
    init();
    if (W == 0 && H == 0) {
      return 0;
    }
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        scanf("%c ", &field[i][j]);
      }
    }
    solve();
  }
}
```


### Prompt

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

You are given a rectangular table 3 × n. Each cell contains an integer. You can move from one cell to another if they share a side.

Find such path from the upper left cell to the bottom right cell of the table that doesn't visit any of the cells twice, and the sum of numbers written in the cells of this path is maximum possible.

Input

The first line contains an integer n (1 ≤ n ≤ 105) — the number of columns in the table.

Next three lines contain n integers each — the description of the table. The j-th number in the i-th line corresponds to the cell aij ( - 109 ≤ aij ≤ 109) of the table.

Output

Output the maximum sum of numbers on a path from the upper left cell to the bottom right cell of the table, that doesn't visit any of the cells twice.

Examples

Input

3
1 1 1
1 -1 1
1 1 1

Output

7

Input

5
10 10 10 -1 -1
-1 10 10 10 10
-1 10 10 10 10

Output

110

Note

The path for the first example:

<image>

The path for the second example:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
long long a[N][4], dp[N][4], bk[N][4];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= n; j++) scanf("%lld", &a[j][i]);
  for (int i = 1; i <= 3; i++)
    dp[1][i] = dp[1][i - 1] + a[1][i], bk[1][i] = a[1][i];
  for (int i = 2; i <= n; i++) {
    dp[i][1] = bk[i][1] = dp[i - 1][1] + a[i][1];
    dp[i][2] = bk[i][2] = dp[i - 1][2] + a[i][2];
    dp[i][3] = bk[i][3] = dp[i - 1][3] + a[i][3];
    dp[i][1] = max(dp[i][1], bk[i][2] + a[i][1]);
    dp[i][1] = max(dp[i][1], bk[i][3] + a[i][2] + a[i][1]);
    dp[i][2] = max(dp[i][2], bk[i][1] + a[i][2]);
    dp[i][2] = max(dp[i][2], bk[i][3] + a[i][2]);
    dp[i][3] = max(dp[i][3], bk[i][2] + a[i][3]);
    dp[i][3] = max(dp[i][3], bk[i][1] + a[i][2] + a[i][3]);
    dp[i][1] = max(dp[i][1], bk[i - 1][3] + a[i][3] + a[i][2] + a[i - 1][2] +
                                 a[i - 1][1] + a[i][1]);
    dp[i][3] = max(dp[i][3], bk[i - 1][1] + a[i][1] + a[i][2] + a[i - 1][2] +
                                 a[i - 1][3] + a[i][3]);
  }
  printf("%lld\n", dp[n][3]);
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries:

* Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does `AC` occurs as a substring?

Constraints

* 2 \leq N \leq 10^5
* 1 \leq Q \leq 10^5
* S is a string of length N.
* Each character in S is `A`, `C`, `G` or `T`.
* 1 \leq l_i < r_i \leq N

Input

Input is given from Standard Input in the following format:

N Q
S
l_1 r_1
:
l_Q r_Q

Output

Print Q lines. The i-th line should contain the answer to the i-th query.

Example

Input

8 3
ACACTACG
3 7
2 3
1 8

Output

2
0
3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
    int n,q;
    cin >> n >> q;
    string S;
    cin >> S;
    for(int i=1;i<n;i++){
        a[i+1]+=a[i];
        if(S[i-1]=='A' && S[i]=='C')a[i+1]++;
    }
    int l,r;
    for(int i=0;i<q;i++){
        cin >> l >> r;
        cout << a[r]-a[l] << endl;
    }
}
```


### Prompt

Generate a cpp solution to the following problem:

The organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in increasing order). The t-shirts are already prepared. For each size from S to XXXL you are given the number of t-shirts of this size.

During the registration, the organizers asked each of the n participants about the t-shirt size he wants. If a participant hesitated between two sizes, he could specify two neighboring sizes — this means that any of these two sizes suits him.

Write a program that will determine whether it is possible to present a t-shirt to each participant of the competition, or not. Of course, each participant should get a t-shirt of proper size:

  * the size he wanted, if he specified one size;
  * any of the two neibouring sizes, if he specified two sizes.

If it is possible, the program should find any valid distribution of the t-shirts.

Input

The first line of the input contains six non-negative integers — the number of t-shirts of each size. The numbers are given for the sizes S, M, L, XL, XXL, XXXL, respectively. The total number of t-shirts doesn't exceed 100 000.

The second line contains positive integer n (1 ≤ n ≤ 100 000) — the number of participants.

The following n lines contain the sizes specified by the participants, one line per participant. The i-th line contains information provided by the i-th participant: single size or two sizes separated by comma (without any spaces). If there are two sizes, the sizes are written in increasing order. It is guaranteed that two sizes separated by comma are neighboring.

Output

If it is not possible to present a t-shirt to each participant, print «NO» (without quotes).

Otherwise, print n + 1 lines. In the first line print «YES» (without quotes). In the following n lines print the t-shirt sizes the orginizers should give to participants, one per line. The order of the participants should be the same as in the input.

If there are multiple solutions, print any of them.

Examples

Input

0 1 0 1 1 0
3
XL
S,M
XL,XXL

Output

YES
XL
M
XXL

Input

1 1 2 0 1 1
5
S
M
S,M
XXL,XXXL
XL,XXL

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
int r[6];
map<string, int> c;
map<int, string> cc;
bool vis[N];
vector<pair<int, int> > w[6];
int ans[N];
int main() {
  c["S"] = 0;
  c["M"] = 1;
  c["L"] = 2;
  c["XL"] = 3;
  c["XXL"] = 4;
  c["XXXL"] = 5;
  cc[0] = "S";
  cc[1] = "M";
  cc[2] = "L";
  cc[3] = "XL";
  cc[4] = "XXL";
  cc[5] = "XXXL";
  for (int i = 0, ttto = 6; i < ttto; i++) cin >> r[i];
  int n, f = 1;
  cin >> n;
  for (int i = 0, ttto = n; i < ttto; i++) {
    string s, t;
    cin >> s;
    int p = s.find(",");
    if (p != string::npos) t = s.substr(p + 1, s.size());
    if (p == string::npos) {
      r[c[s]]--;
      vis[i] = 1;
      ans[i] = c[s];
      if (r[c[s]] < 0) f = 0;
    } else {
      s = s.substr(0, p);
      int u = c[s], v = c[t];
      if (u > v) swap(u, v);
      w[u].push_back(pair<int, int>(1, i));
      w[v].push_back(pair<int, int>(0, i));
    }
  }
  if (f == 0)
    puts("NO");
  else {
    for (int i = 0, ttto = 6; i < ttto; i++) {
      sort(w[i].begin(), w[i].end());
      for (int j = 0, ttto = w[i].size(); j < ttto; j++)
        if (!vis[w[i][j].second] && r[i])
          ans[w[i][j].second] = i, vis[w[i][j].second] = 1, r[i]--;
    }
    for (int i = 0, ttto = n; i < ttto; i++)
      if (!vis[i]) {
        cerr << i << endl;
        puts("NO");
        return 0;
      }
    puts("YES");
    for (int i = 0, ttto = n; i < ttto; i++) cout << cc[ans[i]] << "\n";
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke network assigns a unique ID to this call, a positive integer session number.

One day Polycarpus wondered which secretaries are talking via the Spyke and which are not. For each secretary, he wrote out either the session number of his call or a 0 if this secretary wasn't talking via Spyke at that moment.

Help Polycarpus analyze these data and find out the number of pairs of secretaries that are talking. If Polycarpus has made a mistake in the data and the described situation could not have taken place, say so.

Note that the secretaries can correspond via Spyke not only with each other, but also with the people from other places. Also, Spyke conferences aren't permitted — that is, one call connects exactly two people.

Input

The first line contains integer n (1 ≤ n ≤ 103) — the number of secretaries in Polycarpus's corporation. The next line contains n space-separated integers: id1, id2, ..., idn (0 ≤ idi ≤ 109). Number idi equals the number of the call session of the i-th secretary, if the secretary is talking via Spyke, or zero otherwise.

Consider the secretaries indexed from 1 to n in some way.

Output

Print a single integer — the number of pairs of chatting secretaries, or -1 if Polycarpus's got a mistake in his records and the described situation could not have taken place.

Examples

Input

6
0 1 7 1 7 10

Output

2

Input

3
1 1 1

Output

-1

Input

1
0

Output

0

Note

In the first test sample there are two Spyke calls between secretaries: secretary 2 and secretary 4, secretary 3 and secretary 5.

In the second test sample the described situation is impossible as conferences aren't allowed.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n;
  map<int, int> A;
  map<int, int>::iterator it;
  for (int i = 0; i < (n); i++) {
    cin >> x;
    if (x == 0) continue;
    A[x]++;
  }
  bool possible = 1;
  int twoc = 0;
  for (it = A.begin(); it != A.end(); it++) {
    if (it->second > 2) {
      possible = 0;
      break;
    } else if (it->second == 2)
      twoc++;
  }
  if (possible)
    cout << twoc << endl;
  else
    cout << -1 << endl;
  return 0;
}

```