### Prompt

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

Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the beauty of the tower as follows:

* The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored.

Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.

Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.

Constraints

* 1 ≤ N ≤ 3×10^5
* 1 ≤ A,B ≤ 3×10^5
* 0 ≤ K ≤ 18×10^{10}
* All values in the input are integers.

Input

Input is given from Standard Input in the following format:

N A B K

Output

Print the number of the ways to paint tiles, modulo 998244353.

Examples

Input

4 1 2 5

Output

40

Input

2 5 6 0

Output

1

Input

90081 33447 90629 6391049189

Output

577742975

### Response

```cpp
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

ll fac[maxn],inv[maxn],n,k,a,b,c,ans;
const ll mod=998244353;

inline ll pw(ll a,ll b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=(ans*base)%mod;
		base=(base*base)%mod; b>>=1;
	}
	return ans;
}

inline ll C(ll N,ll M){return (fac[N]*inv[M]%mod)*inv[N-M]%mod;}

int main()
{
	fac[0]=1; inv[0]=1;
	rep(i,1,(maxn-5)) fac[i]=(fac[i-1]*i)%mod;
	rep(i,1,(maxn-5)) inv[i]=pw(fac[i],mod-2);
	cin>>n>>a>>b>>k;
	for(ll i=0;i<=n;i++)
	{
		ll res=k-i*a; if(res<0) break;
		if(res%b!=0||res/b>n) continue;
		ll x=i,y=res/b; ans=(ans+C(n,x)*C(n,y))%mod;
	}
	cout<<ans<<endl;
	return 0;
}
```


### Prompt

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

It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.

Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws n sticks in a row. After that the players take turns crossing out exactly k sticks from left or right in each turn. Sasha moves first, because he is the inventor of the game. If there are less than k sticks on the paper before some turn, the game ends. Sasha wins if he makes strictly more moves than Lena. Sasha wants to know the result of the game before playing, you are to help him.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 1018, k ≤ n) — the number of sticks drawn by Sasha and the number k — the number of sticks to be crossed out on each turn.

Output

If Sasha wins, print "YES" (without quotes), otherwise print "NO" (without quotes).

You can print each letter in arbitrary case (upper of lower).

Examples

Input

1 1

Output

YES

Input

10 4

Output

NO

Note

In the first example Sasha crosses out 1 stick, and then there are no sticks. So Lena can't make a move, and Sasha wins.

In the second example Sasha crosses out 4 sticks, then Lena crosses out 4 sticks, and after that there are only 2 sticks left. Sasha can't make a move. The players make equal number of moves, so Sasha doesn't win.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  long long int n, k, b, c, x, y, z;
  long long int counter = 0, counter1 = 0, counter2 = 0;
  long long int sum = 0, result = 0, ans = 0, flag = 0;
  cin >> n >> k;
  counter = n / k;
  if (counter & 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

```


### Prompt

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

Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has n positions to install lamps, they correspond to the integer numbers from 0 to n - 1 on the OX axis. However, some positions are blocked and no post lamp can be placed there.

There are post lamps of different types which differ only by their power. When placed in position x, post lamp of power l illuminates the segment [x; x + l]. The power of each post lamp is always a positive integer number.

The post lamp shop provides an infinite amount of lamps of each type from power 1 to power k. Though each customer is only allowed to order post lamps of exactly one type. Post lamps of power l cost a_l each.

What is the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment [0; n] of the street? If some lamps illuminate any other segment of the street, Adilbek does not care, so, for example, he may place a lamp of power 3 in position n - 1 (even though its illumination zone doesn't completely belong to segment [0; n]).

Input

The first line contains three integer numbers n, m and k (1 ≤ k ≤ n ≤ 10^6, 0 ≤ m ≤ n) — the length of the segment of the street Adilbek wants to illuminate, the number of the blocked positions and the maximum power of the post lamp available.

The second line contains m integer numbers s_1, s_2, ..., s_m (0 ≤ s_1 < s_2 < ... s_m < n) — the blocked positions.

The third line contains k integer numbers a_1, a_2, ..., a_k (1 ≤ a_i ≤ 10^6) — the costs of the post lamps.

Output

Print the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment [0; n] of the street.

If illumintaing the entire segment [0; n] is impossible, print -1.

Examples

Input

6 2 3
1 3
1 2 3

Output

6

Input

4 3 4
1 2 3
1 10 100 1000

Output

1000

Input

5 1 5
0
3 3 3 3 3

Output

-1

Input

7 4 3
2 4 5 6
3 14 15

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<bool> pos(n, false);
  for (int i = 0; i < m; i++) {
    long long x;
    cin >> x;
    pos[x] = true;
  }
  long long mx = 0;
  long long cur = 0;
  for (long long i = 0; i < n; i++) {
    if (!pos[i])
      cur = 0;
    else {
      cur++;
      mx = max(mx, cur);
    }
  }
  vector<long long> price(k + 1);
  for (long long i = 1; i <= k; i++) {
    long long x;
    cin >> x;
    price[i] = x;
  }
  if (pos[0] || mx >= k) {
    cout << "-1";
    return 0;
  }
  long long prev[n];
  prev[0] = 0;
  for (long long i = 1; i < n; i++) {
    if (pos[i] == false)
      prev[i] = i;
    else
      prev[i] = prev[i - 1];
  }
  long long ans = 1e15;
  for (int i = mx + 1; i <= k; i++) {
    long long s = 0;
    long long cnt = 0;
    while (s < n) {
      cnt++;
      s = prev[s] + i;
    }
    ans = min(ans, cnt * price[i]);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

Given a string s, find the number of ways to split s to substrings such that if there are k substrings (p1, p2, p3, ..., pk) in partition, then pi = pk - i + 1 for all i (1 ≤ i ≤ k) and k is even.

Since the number of ways can be large, print it modulo 109 + 7.

Input

The only line of input contains a string s (2 ≤ |s| ≤ 106) of even length consisting of lowercase Latin letters.

Output

Print one integer, the number of ways of partitioning the string modulo 109 + 7.

Examples

Input

abcdcdab

Output

1

Input

abbababababbab

Output

3

Note

In the first case, the only way to partition the string is ab|cd|cd|ab.

In the second case, the string can be partitioned as ab|b|ab|ab|ab|ab|b|ab or ab|b|abab|abab|b|ab or abbab|ab|ab|abbab.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010, mod = 1e9 + 7;
int ch[N][26], fa[N], g[N], f[N], tot, lst, nxt[N], l[N], s[N], dif[N], pos[N];
char t[N];
int read() {
  int x = 0;
  char c = getchar(), flag = '+';
  while (!isdigit(c)) flag = c, c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return flag == '-' ? -x : x;
}
int Insert(int x, int c) {
  int p = lst;
  while (s[x - l[p] - 1] ^ c) p = fa[p];
  if (!ch[p][c]) {
    int now = ++tot, q = fa[p];
    l[now] = l[p] + 2;
    while (s[x - l[q] - 1] ^ c) q = fa[q];
    int t = ch[q][c];
    dif[now] = l[now] - l[t];
    fa[now] = t;
    if (dif[now] == dif[t])
      nxt[now] = nxt[t];
    else
      nxt[now] = t;
    ch[p][c] = now;
  }
  return lst = ch[p][c];
}
int main() {
  scanf("%s", t + 1);
  int n = strlen(t + 1);
  for (int i = 1; i <= n; i++) {
    if (i & 1)
      s[i] = t[i + 1 >> 1] - 'a';
    else
      s[i] = t[n - i / 2 + 1] - 'a';
  }
  s[0] = -1;
  tot = 1, l[1] = -1, fa[0] = 1;
  for (int i = 1; i <= n; i++) pos[i] = Insert(i, s[i]);
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int x = pos[i]; x; x = nxt[x]) {
      g[x] = f[i - l[nxt[x]] - dif[x]];
      if (dif[x] == dif[fa[x]])
        g[x] = g[x] + g[fa[x]] >= mod ? g[x] + g[fa[x]] - mod : g[x] + g[fa[x]];
      if (!(i & 1)) f[i] = f[i] + g[x] >= mod ? f[i] + g[x] - mod : f[i] + g[x];
    }
  }
  cout << f[n];
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation.

An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$ lists, one for each vertex in $V$. For each $u \in V$, the adjacency list $Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$. That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.

An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A = a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.

Write a program which reads a directed graph $G$ represented by the adjacency list, and prints its adjacency-matrix representation. $G$ consists of $n\; (=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively.

Constraints

* $1 \leq n \leq 100$

Input

In the first line, an integer $n$ is given. In the next $n$ lines, an adjacency list $Adj[u]$ for vertex $u$ are given in the following format:

$u$ $k$ $v_1$ $v_2$ ... $v_k$

$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices adjacent to $u$.

Output

As shown in the following sample output, print the adjacent-matrix representation of $G$. Put a single space character between $a_{ij}$.

Example

Input

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

Output

0 1 0 1
0 0 0 1
0 0 0 0
0 0 1 0

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int  M[101][101];
int main(){
  int n,u,k,v;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<M[i][j];
    }
    cout<<endl;
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You are given a rooted tree. Let's denote d(x) as depth of node x: depth of the root is 1, depth of any other node x is d(y) + 1, where y is a parent of x.

The tree has the following property: every node x with d(x) = i has exactly ai children. Maximum possible depth of a node is n, and an = 0.

We define fk as the number of unordered pairs of vertices in the tree such that the number of edges on the simple path between them is equal to k.

Calculate fk modulo 109 + 7 for every 1 ≤ k ≤ 2n - 2.

Input

The first line of input contains an integer n (2 ≤ n ≤ 5 000) — the maximum depth of a node.

The second line of input contains n - 1 integers a1, a2, ..., an - 1 (2 ≤ ai ≤ 109), where ai is the number of children of every node x such that d(x) = i. Since an = 0, it is not given in the input.

Output

Print 2n - 2 numbers. The k-th of these numbers must be equal to fk modulo 109 + 7.

Examples

Input

4
2 2 2

Output

14 19 20 20 16 16

Input

3
2 3

Output

8 13 6 9

Note

This the tree from the first sample:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 3e5 + 5;
const long long INF = 1e14;
long long bpow(long long a, long long b, long long m) {
  long long x, y;
  x = 1;
  y = a;
  while (b > 0) {
    if (b % 2 == 1) x = (x * y) % MOD;
    y = (y * y) % MOD;
    b /= 2;
  }
  return x;
}
long long inv(long long i) { return bpow(i, MOD - 2, MOD); }
long long dp[3][10005][3];
long long a[5005];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long a[5005];
  for (long long i = 0; i < n - 1; i++) {
    cin >> a[i + 1];
  }
  for (long long i = 0; i < 2 * n - 1; i++) {
    for (long long j = 0; j < 3; j++) dp[1][i][j] = dp[2][i][j] = 0;
  }
  dp[2][0][0] = 1;
  long long num = 1;
  for (long long r = 2; r < n + 1; r++) {
    for (long long j = 1; j < 2 * n - 1; j++)
      for (long long p = 0; p < 3; p++) {
        dp[0][j][p] = dp[1][j][p];
        dp[1][j][p] = dp[2][j][p];
      }
    long long i = 2;
    for (long long j = 1; j < 2 * n - 1; j++) {
      dp[i][j][0] =
          ((dp[i - 1][j][0] + dp[i - 1][j][1]) % MOD + dp[i - 1][j][2]) % MOD;
      if (j == 0) {
        dp[i][j][1] = 0;
      } else if (j == 1) {
        dp[i][j][1] = (num * a[r - 1]) % MOD;
      } else {
        dp[i][j][1] = (((dp[i - 1][j - 1][2] * 2) % MOD * a[r - 1]) % MOD +
                       (dp[i - 1][j - 1][1] * a[r - 1]) % MOD) %
                      MOD;
      }
      if (j == 0 || j == 1) {
        dp[i][j][2] = 0;
      } else if (j == 2) {
        dp[i][j][2] =
            (((num * a[r - 1]) % MOD * (a[r - 1] - 1)) % MOD * inv(2)) % MOD;
      } else {
        dp[i][j][2] = ((dp[i - 1][j - 2][2] * a[r - 1]) % MOD * a[r - 1]) % MOD;
      }
    }
    num = (num * a[r - 1]) % MOD;
  }
  for (long long j = 1; j < 2 * n - 1; j++) {
    long long ans = ((dp[2][j][0] + dp[2][j][1]) % MOD + dp[2][j][2]) % MOD;
    cout << ans << " ";
  }
  cout << "\n";
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Please notice the unusual memory limit of this problem.

Orac likes games. Recently he came up with the new game, "Game of Life".

You should play this game on a black and white grid with n rows and m columns. Each cell is either black or white.

For each iteration of the game (the initial iteration is 0), the color of each cell will change under the following rules:

  * If there are no adjacent cells with the same color as this cell on the current iteration, the color of it on the next iteration will be the same.
  * Otherwise, the color of the cell on the next iteration will be different.

Two cells are adjacent if they have a mutual edge.

Now Orac has set an initial situation, and he wants to know for the cell (i,j) (in i-th row and j-th column), what will be its color at the iteration p. He may ask you these questions several times.

Input

The first line contains three integers n,m,t\ (1≤ n,m≤ 1000, 1≤ t≤ 100 000), representing the number of rows, columns, and the number of Orac queries.

Each of the following n lines contains a binary string of length m, the j-th character in i-th line represents the initial color of cell (i,j). '0' stands for white, '1' stands for black.

Each of the following t lines contains three integers i,j,p\ (1≤ i≤ n, 1≤ j≤ m, 1≤ p≤ 10^{18}), representing a query from Orac.

Output

Print t lines, in i-th line you should print the answer to the i-th query by Orac. If the color of this cell is black, you should print '1'; otherwise, you should write '0'.

Examples

Input

3 3 3
000
111
000
1 1 1
2 2 2
3 3 3

Output

1
1
1

Input

5 2 2
01
10
01
10
01
1 1 4
5 1 4

Output

0
0

Input

5 5 3
01011
10110
01101
11010
10101
1 1 4
1 2 3
5 5 3

Output

1
0
1

Input

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

Output

0
0
0

Note

<image>

For the first example, the picture above shows the initial situation and the color of cells at the iteration 1, 2, and 3. We can see that the color of (1,1) at the iteration 1 is black, the color of (2,2) at the iteration 2 is black, and the color of (3,3) at the iteration 3 is also black.

For the second example, you can prove that the cells will never change their colors.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF = 2000000000000000000LL;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
struct ITEM {
  int x, y;
} q[1010 * 1010];
int n, m, t, qh, qt;
long long f[1010][1010];
char a[1010][1010];
bool check(const int x, const int y) {
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (nx > 0 && ny > 0 && nx <= n && ny <= m && a[nx][ny] == a[x][y])
      return true;
  }
  return false;
}
void bfs() {
  while (qh < qt) {
    ITEM& u = q[qh++];
    for (int i = 0; i < 4; i++) {
      int nx = u.x + dx[i];
      int ny = u.y + dy[i];
      if (!(nx > 0 && ny > 0 && nx <= n && ny <= m)) continue;
      if (f[nx][ny] != INF) continue;
      f[nx][ny] = f[u.x][u.y] + 1;
      q[qt++] = (ITEM){nx, ny};
    }
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &t);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) f[i][j] = INF;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (check(i, j)) {
        q[qt++] = (ITEM){i, j};
        f[i][j] = 0;
      }
    }
  bfs();
  for (int i = 1, x, y; i <= t; i++) {
    long long p;
    scanf("%d %d %I64d", &x, &y, &p);
    if (p <= f[x][y] || !((p - f[x][y]) & 1))
      printf("%c\n", a[x][y]);
    else
      printf("%c\n", '0' + '1' - a[x][y]);
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represented as a square black and white image of N x N pixels. Each pixel has a value of 0 or 1 corresponding to a white or black image.

This time, the software of the image analysis system will be updated along with the equipment update of the production line. The new system has been devised to reduce the amount of communication data, and data is sent from the camera to the analysis system by the following method.

* The information of the first coaster flowing on the line is sent to the system as an N × N pixel image.
* For the coaster information on the second and subsequent images, only the difference from the previous image is sent. The difference is given as a set of pixel positions that change from "0 to 1" or "1 to 0".

For C coasters, enter the pixel information of the first image and the difference information of the following C-1 image, and create a program that reports the number of coasters that are vertically symmetrical and symmetrical.

Input

The input is given in the following format.

C N
p11p12 ... p1N
p21p22 ... p2N
::
pN1pN2 ... pNN
diff1
diff2
::
diffC-1

The first line gives the number of coasters C (1 ≤ C ≤ 10000) and the number of pixels N (2 ≤ N ≤ 1000 and N is even) in the vertical and horizontal directions of the image. Lines 2 to N + 1 are given the number pij (pij is 0 or 1) in rows N x columns N representing the pixels of the image of the first coaster.

After the N + 2nd line, the difference diffi representing the information of the 2nd and subsequent coasters is given in the following format.

D
r1 c1
r2 c2
::
rD cD

The number of changed pixels D (0 ≤ D ≤ 100) is given in the first line. The following D rows are given ri and ci (1 ≤ ri, ci ≤ N), which represent the row and column numbers of the changed pixels, respectively. The same position cannot be given more than once in diffi.

Output

The number of coasters that are vertically symmetrical and symmetrical is output on one line.

Examples

Input

7 8
00100000
00011000
10111101
01100110
01000110
10111101
00011000
00100100
2
5 3
1 6
1
6 8
3
6 8
3 3
3 6
2
6 3
6 6
0
2
3 8
6 8

Output

3

Input

1 6
000000
000000
010010
010010
000000
000000

Output

1

Input

2 2
00
00
4
1 1
1 2
2 1
2 2

Output

2

### Response

```cpp
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;
const int inf=1000000000;
const int np=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int c,n;
	string p[1000];
	cin>>c>>n;
	rep(i,n)cin>>p[i];
	int t=0;
	rep(i,n/2){
		rep(j,n/2){
			int s=0;
			if(p[i][j]==p[i][n-1-j])s++;
			if(p[i][j]==p[n-1-i][j])s++;
			if(p[n-1-i][j]==p[n-1-i][n-1-j])s++;
			if(s<3)t++;
		}
	}
	int r=0;
	if(t==0)r++;
	rep(i,c-1){
		int d;
		cin>>d;
		rep(j,d){
			int x,y;
			cin>>x>>y;
			x--;
			y--;
			int s=0;
			if(p[x][y]==p[x][n-y-1])s++;
			if(p[x][y]==p[n-1-x][y])s++;
			if(p[n-1-x][y]==p[n-1-x][n-1-y])s++;
			if(s<3)t--;
			s=0;
			if(p[x][y]=='0'){
				p[x][y]='1';
			}else{
				p[x][y]='0';
			}
			if(p[x][y]==p[x][n-y-1])s++;
			if(p[x][y]==p[n-1-x][y])s++;
			if(p[n-1-x][y]==p[n-1-x][n-1-y])s++;
			if(s<3)t++;
		}
		if(t==0)r++;
	}
	cout<<r<<endl;
	return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi.

Your task is to find any interesting array of n elements or state that such array doesn't exist.

Expression x&y means the bitwise AND of numbers x and y. In programming languages C++, Java and Python this operation is represented as "&", in Pascal — as "and".

Input

The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits.

Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi < 230) describing the i-th limit.

Output

If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n] (0 ≤ a[i] < 230) decribing the interesting array. If there are multiple answers, print any of them.

If the interesting array doesn't exist, print "NO" (without the quotes) in the single line.

Examples

Input

3 1
1 3 3

Output

YES
3 3 3

Input

3 2
1 3 3
1 3 2

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Tree {
  int sz;
  vector<int> t;
  vector<int> d;
  Tree(int sz) : sz(sz), t(sz * 4), d(sz * 4) {}
  void push(int v) {
    d[2 * v + 1] |= d[v];
    t[2 * v + 1] |= d[v];
    d[2 * v + 2] |= d[v];
    t[2 * v + 2] |= d[v];
    d[v] = 0;
  }
  int get(int v) { return t[v] & d[v]; }
  void OrImpl(int v, int tl, int tr, int l, int r, int value) {
    if (l >= r) return;
    if (l == tl && r == tr) {
      t[v] |= value;
      d[v] |= value;
      return;
    }
    push(v);
    int tm = (tl + tr) / 2;
    OrImpl(2 * v + 1, tl, tm, l, min(r, tm), value);
    OrImpl(2 * v + 2, tm, tr, max(l, tm), r, value);
    t[v] = t[2 * v + 1] & t[2 * v + 2];
  }
  void Or(int l, int r, int value) { OrImpl(0, 0, sz, l, r, value); }
  int GetAndImpl(int v, int tl, int tr, int l, int r) {
    if (l >= r) return -1;
    if (l == tl && r == tr) {
      return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    return GetAndImpl(2 * v + 1, tl, tm, l, min(r, tm)) &
           GetAndImpl(2 * v + 2, tm, tr, max(l, tm), r);
  }
  int GetAnd(int l, int r) { return GetAndImpl(0, 0, sz, l, r); }
};
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  vector<int> c(m);
  Tree t(n);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
  }
  for (int i = 0; i < m; i++) {
    t.Or(a[i], b[i], c[i]);
  }
  for (int i = 0; i < m; i++) {
    int x = t.GetAnd(a[i], b[i]);
    if (x != c[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    cout << t.GetAnd(i, i + 1) << " ";
  }
  cout << endl;
  return 0;
}

```


### Prompt

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

There was no problem about a cactus at the NERC 2020 online round. That's a bad mistake, so judges decided to fix it. You shall not pass to the World Finals 2021 without solving a problem about a cactus!

A cactus is a connected undirected graph in which every edge lies on at most one simple cycle. Intuitively, a cactus is a generalization of a tree where some cycles are allowed. Multiedges (multiple edges between a pair of vertices) and loops (edges that connect a vertex to itself) are not allowed in a cactus.

Cher has got a cactus. She calls cactus strong if it is impossible to add an edge to it in such a way that it still remains a cactus. But Cher thinks her cactus is not strong enough. She wants to add the smallest possible number of edges to it to make it strong, i. e. to create a new cactus with the same vertices, so that the original cactus is a subgraph of the new one, and it is impossible to add another edge to it so that the graph remains a cactus. Cher hired you to do this job for her. So... it's on you!

Input

The input consists of one or more independent test cases.

The first line of each test case contains two integers n and m (1 ≤ n ≤ 10^5, 0 ≤ m ≤ 10^5), where n is the number of vertices in the graph. Vertices are numbered from 1 to n. Edges of the graph are represented by a set of edge-distinct paths, where m is the number of such paths.

Each of the following m lines contains a path in the graph. A path starts with an integer number s_i (2 ≤ s_i ≤ 1000) followed by s_i integers from 1 to n. These s_i integers represent vertices of a path. Adjacent vertices in a path are distinct. The path can go through the same vertex multiple times, but every edge is traversed exactly once in the whole test case. There are no multiedges in the graph (there is at most one edge between any two vertices).

The last line of the input after all test cases always contains two zeros. It does not define a test case. It just marks the end of the input and does not require any output.

All graphs in the input are cacti. The total sum of all values of n and the total sum of all values of m throughout the input both do not exceed 10^5.

Output

For each test case, first output the line with the minimal possible number of additional edges A. Then output A lines, each describing one edge as u_i v_i, where u_i and v_i are the numbers of vertices to connect. After adding these edges, the resulting graph must be a strong cactus.

Example

Input

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

Output

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

### Response

```cpp
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
struct front_star{
    int to,next;
}e[500050];
struct grp{
    int fp,sp;
}ans[500050];
front_star eg[500050];
int n,m,cnt=1,t=0,tot=0,all=0,root;
int head[100005],dfn[100005],low[100005],brg[500005],hd[100005],vis[100005],sz[100005],dep[100005],upt[100005];
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(int x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
inline void addedge(int u,int v)
{
    cnt++;
    e[cnt].to=v;
    e[cnt].next=head[u];
    head[u]=cnt;
}
inline void adde(int u,int v)
{
    tot++;
    eg[tot].to=v;
    eg[tot].next=hd[u];
    hd[u]=tot;
}
inline void tarjan(int x,int in_edge)
{
    t++;
    dfn[x]=low[x]=t;
    for(register int i=head[x];~i;i=e[i].next)
    {
        int y=e[i].to;
        if(!dfn[y])
        {
            tarjan(y,i);
            low[x]=min(low[x],low[y]);
            if(low[y]>dfn[x])
                brg[i]=brg[i^1]=1;
        }else if(i!=(in_edge^1))
            low[x]=min(low[x],dfn[y]);
    }
}
inline void dfs(int u,int fa)
{
    int spe=0;
    vis[u]=1;
    upt[u]=u;
    for(register int i=hd[u];~i;i=eg[i].next)
    {
        int v=eg[i].to;
        if(v==fa)
            continue;
        sz[u]++;
        if(!vis[v])
        {
            dep[v]=dep[u]+1;
            dfs(v,u);
            if(v==upt[v])
                spe=v;
        }
    }
    int pt=0,num=sz[u];
    if(u==root)
    {
        if(num%2==0)
        {
            for(register int i=hd[u];~i;i=eg[i].next)
            {
                int v=eg[i].to;
                if(v==fa)
                    continue;
                pt++;
                if(pt%2==1)
                {
                    all++;
                    ans[all].fp=upt[v];
                }
                else
                    ans[all].sp=upt[v];
            }
        }
        else
        {
            if(spe)
                num--;
            for(register int i=hd[u];~i;i=eg[i].next)
            {
                int v=eg[i].to;
                if(v==fa||v==spe)
                    continue;
                pt++;
                if(pt%2==1)
                {
                    all++;
                    ans[all].fp=upt[v];
                    if(pt==num)
                        ans[all].sp=u;
                }
                else
                    ans[all].sp=upt[v];
            }
        }
    }
    else
    {
        if(num%2==0)
        {
            if(spe)
                num--;
            for(register int i=hd[u];~i;i=eg[i].next)
            {
                int v=eg[i].to;
                if(v==fa||v==spe)
                    continue;
                pt++;
                if(pt%2==1)
                {
                    if(pt==num)
                    {
                        upt[u]=upt[v];
                        continue;
                    }
                    all++;
                    ans[all].fp=upt[v];
                }
                else
                    ans[all].sp=upt[v];
            }
        }
        else
        {
            for(register int i=hd[u];~i;i=eg[i].next)
            {
                int v=eg[i].to;
                if(v==fa)
                    continue;
                pt++;
                if(pt%2==1)
                {
                    if(pt==num)
                    {
                        upt[u]=upt[v];
                        continue;
                    }
                    all++;
                    ans[all].fp=upt[v];

                }
                else
                    ans[all].sp=upt[v];
            }
        }
    }
}
int main()
{
    memset(head,-1,sizeof(head));
    memset(dfn,0,sizeof(dfn));
    memset(low,0,sizeof(low));
    memset(brg,0,sizeof(brg));
    memset(hd,-1,sizeof(hd));
    memset(vis,0,sizeof(vis));
    memset(sz,0,sizeof(sz));
    while(1)
    {
        t=0;
        cnt=1;
        tot=0;
        all=0;
        n=read();
        m=read();
        if(n==0&&m==0)
            break;
        for(register int i=1;i<=m;i++)
        {
            int s;
            s=read();
            int a,b;
            for(register int j=1;j<=s;j++)
            {
                a=read();
                if(j!=1)
                {
                    addedge(b,a);
                    addedge(a,b);
                }
                b=a;
            }
        }
        for(register int i=1;i<=n;i++)
        {
            if(!dfn[i])
                tarjan(i,0);
        }
        for(register int i=1;i<=n;i++)
            for(register int j=head[i];~j;j=e[j].next)
            {
                if(brg[j])
                    adde(i,e[j].to);
            }
        for(register int i=1;i<=n;i++)
        {
            if(!vis[i])
            {
                root=i;
                dep[i]=1;
                dfs(i,0);
            }
        }
        write(all);
        printf("\n");
        for(register int i=1;i<=all;i++)
        {
            write(ans[i].fp);
            printf(" ");
            write(ans[i].sp);
            printf("\n");
        }
        for(int i=1;i<=n;i++)
        {
            head[i]=-1;
            dfn[i]=0;
            low[i]=0;
            hd[i]=-1;
            vis[i]=0;
            sz[i]=0;
        }
        for(int i=1;i<=cnt+1;i++)
            brg[i]=0;
    }
    return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

DZY loves planting, and he enjoys solving tree problems.

DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge in the shortest path between nodes x and y. Specially g(z, z) = 0 for every z.

For every integer sequence p1, p2, ..., pn (1 ≤ pi ≤ n), DZY defines f(p) as <image>.

DZY wants to find such a sequence p that f(p) has maximum possible value. But there is one more restriction: the element j can appear in p at most xj times.

Please, find the maximum possible f(p) under the described restrictions.

Input

The first line contains an integer n (1 ≤ n ≤ 3000).

Each of the next n - 1 lines contains three integers ai, bi, ci (1 ≤ ai, bi ≤ n; 1 ≤ ci ≤ 10000), denoting an edge between ai and bi with length ci. It is guaranteed that these edges form a tree.

Each of the next n lines describes an element of sequence x. The j-th line contains an integer xj (1 ≤ xj ≤ n).

Output

Print a single integer representing the answer.

Examples

Input

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

Output

2

Input

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

Output

3

Note

In the first sample, one of the optimal p is [4, 3, 2, 1].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3001;
int ex[MAXN], ey[MAXN], w[MAXN], f[MAXN], sum, par[MAXN], sz[MAXN], sumF[MAXN];
pair<int, int> all[MAXN];
bool bad;
int find(int x) {
  if (par[x] != x) par[x] = find(par[x]);
  return par[x];
}
void merge(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  sz[x] += sz[y];
  sumF[x] += sumF[y];
  par[y] = x;
  if (sum - sumF[x] < sz[x]) bad = true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> ex[i] >> ey[i] >> w[i];
    ex[i]--;
    ey[i]--;
    all[i] = pair<int, int>(w[i], i);
  }
  for (int i = 0; i < n; i++)
    cin >> f[i], sum += f[i], sumF[i] = f[i], par[i] = i, sz[i] = 1;
  sort(all, all + n - 1);
  int ans = 0, cur = 0;
  while (cur < n - 1) {
    int edgeId = all[cur].second;
    if (!bad) ans = w[edgeId];
    merge(ex[edgeId], ey[edgeId]);
    while (cur < n - 1 && w[edgeId] == all[cur].first)
      merge(ex[all[cur].second], ey[all[cur].second]), cur++;
  }
  if (!bad && n > 1) ans = w[all[n - 2].second];
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Thank you for helping Heidi! It is now the second of April, but she has been summoned by Jenny again. The pranks do not seem to end...

In the meantime, Heidi has decided that she does not trust her friends anymore. Not too much, anyway. Her relative lack of trust is manifested as follows: whereas previously she would not be made to visit the same person twice, now she can only be sure that she will not be made to visit the same person more than k times. (In the case of Jenny, this includes her first visit in the beginning. The situation from the easy version corresponds to setting k = 1.)

This is not as bad as it looks, since a single ticket for a route between two friends allows Heidi to travel between this pair of friends the whole day (in both directions). In other words, once she pays for travel between a pair of friends, all further travels between that pair are free.

How much money will Heidi waste now, in a worst-case scenario?

Input

The first line contains two space-separated integers – the number of friends n (<image>) and the parameter k (1 ≤ k ≤ 105). The next n - 1 lines each contain three space-separated integers u, v and c (0 ≤ u, v ≤ n - 1, 1 ≤ c ≤ 104) meaning that u and v are friends and the cost for traveling between u and v is c.

It is again guaranteed that the social network of the input forms a tree.

Output

Again, output a single integer – the maximum sum of costs of tickets.

Examples

Input

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

Output

15

Input

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

Output

17

Input

11 6
1 0 7932
2 1 1952
3 2 2227
4 0 9112
5 4 6067
6 0 6786
7 6 3883
8 4 7137
9 1 2796
10 5 6200

Output

54092

Note

In the first example, the worst-case scenario for Heidi is to visit the friends in the following order: 0, 1, 5, 1, 3, 1, 0, 2, 6, 2, 7, 2, 8. Observe that no friend is visited more than 3 times.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y / 2, x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
long long int dp[100001][2] = {{0}};
vector<vector<pair<long long int, long long int> > > arr(100001);
long long int n, k;
void dfs(long long int u, long long int par) {
  long long int cnt = 0;
  vector<pair<long long int, long long int> > lol;
  long long int i;
  for (i = 0; i < arr[u].size(); i++) {
    if (arr[u][i].first != par) {
      dfs(arr[u][i].first, u);
      dp[arr[u][i].first][0] += arr[u][i].second;
      dp[arr[u][i].first][1] += arr[u][i].second;
      cnt++;
    }
  }
  if (cnt < k) {
    cnt = 0;
    for (i = 0; i < arr[u].size(); i++) {
      if (arr[u][i].first != par)
        dp[u][1] += dp[arr[u][i].first][1], cnt += dp[arr[u][i].first][1];
    }
    long long int tot = 0;
    for (i = 0; i < arr[u].size(); i++) {
      if (arr[u][i].first != par) {
        tot = max(tot, cnt - dp[arr[u][i].first][1] + dp[arr[u][i].first][0]);
      }
    }
    dp[u][0] = tot;
    return;
  }
  for (i = 0; i < arr[u].size(); i++) {
    if (arr[u][i].first != par)
      lol.push_back(make_pair(dp[arr[u][i].first][1], arr[u][i].first));
  }
  sort(lol.begin(), lol.end());
  reverse(lol.begin(), lol.end());
  set<long long int> haha;
  long long int ans = 0;
  for (i = 0; i < k - 1; i++) ans += lol[i].first, haha.insert(lol[i].second);
  dp[u][1] = ans;
  ans += lol[k - 1].first;
  haha.insert(lol[k - 1].second);
  long long int tot = 0;
  for (i = 0; i < arr[u].size(); i++) {
    if (arr[u][i].first != par) {
      if (haha.find(arr[u][i].first) != haha.end()) {
        tot = max(tot, ans - dp[arr[u][i].first][1] + dp[arr[u][i].first][0]);
      } else
        tot = max(tot, dp[arr[u][i].first][0] + dp[u][1]);
    }
  }
  dp[u][0] = tot;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  long long int i;
  for (i = 0; i < n - 1; i++) {
    long long int u, v, c;
    cin >> u >> v >> c;
    arr[u].push_back(make_pair(v, c));
    arr[v].push_back(make_pair(u, c));
  }
  dfs(0, -1);
  cout << dp[0][0];
}

```


### Prompt

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

Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.

The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Constraints

* 0 ≤ a, b ≤ 20000
* No divisions by zero are given.

Input

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

a op b

The input ends with a dataset where op = '?'. Your program should not process for this dataset.

Output

For each dataset, print the value in a line.

Example

Input

1 + 2
56 - 18
13 * 2
100 / 10
27 + 81
0 ? 0

Output

3
38
26
10
108

### Response

```cpp
#include <iostream>
using namespace std;
int main(){
  int a, b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if (op=='?') break;
    if (op=='+') cout << a+b << endl;
    else if (op=='-') cout << a-b << endl;
    else if (op=='*') cout << a*b << endl;
    else cout << a/b << endl;
  }
}

```


### Prompt

Develop a solution in CPP to the problem described below:

<image>

It is well-known that the best decoration for a flower bed in Sweetland are vanilla muffins. Seedlings of this plant need sun to grow up. Slastyona has m seedlings, and the j-th seedling needs at least kj minutes of sunlight to grow up.

Most of the time it's sunny in Sweetland, but sometimes some caramel clouds come, the i-th of which will appear at time moment (minute) li and disappear at time moment ri. Of course, the clouds make shadows, and the seedlings can't grow when there is at least one cloud veiling the sun.

Slastyona wants to grow up her muffins as fast as possible. She has exactly C candies, which is the main currency in Sweetland.

One can dispel any cloud by paying ci candies. However, in order to comply with Sweetland's Department of Meteorology regulations, one can't dispel more than two clouds.

Slastyona hasn't decided yet which of the m seedlings will be planted at the princess' garden, so she needs your help. For each seedling determine the earliest moment it can grow up if Slastyona won't break the law and won't spend more candies than she has. Note that each of the seedlings is considered independently.

The seedlings start to grow at time moment 0.

Input

The first line contains two integers n and C (0 ≤ n ≤ 3·105, 0 ≤ C ≤ 109) – the number of caramel clouds and the number of candies Slastyona has.

The next n lines contain three integers each: li, ri, ci (0 ≤ li < ri ≤ 109, 0 ≤ ci ≤ 109), describing one caramel cloud.

The next line contains single integer m (1 ≤ m ≤ 3·105) – the number of seedlings. Each of the seedlings is described with one integer kj (1 ≤ kj ≤ 109) – the required number of sunny minutes.

Output

For each seedling print one integer – the minimum minute Slastyona can grow it up.

Examples

Input

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

Output

12
7
10

Input

3 15
1 4 17
2 8 6
4 8 9
2
5
1

Output

8
1

Input

2 10
3 7 9
10 90 10
2
10
100

Output

10
104

Note

Consider the first example. For each k it is optimal to dispel clouds 1 and 3. Then the remaining cloud will give shadow on time segment [1..6]. So, intervals [0..1] and [6..inf) are sunny.

<image>

In the second example for k = 1 it is not necessary to dispel anything, and for k = 5 the best strategy is to dispel clouds 2 and 3. This adds an additional sunny segment [4..8], which together with [0..1] allows to grow up the muffin at the eight minute.

<image> <image>

If the third example the two seedlings are completely different. For the first one it is necessary to dispel cloud 1 and obtain a sunny segment [0..10]. However, the same strategy gives answer 180 for the second seedling. Instead, we can dispel cloud 2, to make segments [0..3] and [7..inf) sunny, and this allows up to shorten the time to 104.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
map<int, int> pr[300000];
class stree {
 public:
  std::vector<std::pair<int, int> > t;
  int s;
  std::pair<int, int> combine(std::pair<int, int> a, std::pair<int, int> b) {
    return make_pair(max(a.first, b.first),
                     max(max(a.second, b.second), min(a.first, b.first)));
  }
  void build(std::vector<int>& a, int v, int tl, int tr) {
    if (v == 1) {
      t.resize(a.size() * 4);
      s = a.size();
    }
    if (tl == tr)
      t[v] = make_pair(a[tl], 0);
    else {
      int tm = (tl + tr) / 2;
      build(a, v * 2, tl, tm);
      build(a, v * 2 + 1, tm + 1, tr);
      t[v] = combine(t[v * 2], t[v * 2 + 1]);
    }
  }
  void set(int v, int tl, int tr, int pos, int val) {
    if (pos == tl && tr == pos) {
      t[v] = make_pair(val, 0);
    } else {
      int tm = (tl + tr) / 2;
      if (pos <= tm)
        set(v * 2, tl, tm, pos, val);
      else
        set(v * 2 + 1, tm + 1, tr, pos, val);
      t[v] = combine(t[v * 2], t[v * 2 + 1]);
    }
  }
  std::pair<int, int> get(int v, int tl, int tr, int l, int r) {
    if (l > r) return make_pair(0, 0);
    if (tl == l && tr == r) return t[v];
    int tm = (tl + tr) / 2;
    return combine(get(v * 2, tl, tm, l, min(r, tm)),
                   get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
  }
};
std::vector<int> ctoi;
std::vector<int> lfori;
stree dj;
int main() {
  int n, c;
  scanf("%d %d", &n, &c);
  std::vector<int> l(n), r(n), cost(n);
  std::vector<std::pair<int, int> > allcost;
  for (int i = 0; i < n; i++) scanf("%d %d %d", &l[i], &r[i], &cost[i]);
  if (n == 0) {
    int m;
    scanf("%d", &m);
    std::vector<int> q(m);
    for (int i = 0; i < m; i++) {
      scanf("%d", &q[i]);
      printf("%d\n", q[i]);
    }
    return 0;
  }
  std::vector<int> def(n, 0);
  dj.build(def, 1, 0, n - 1);
  for (int i = 0; i < n; i++) allcost.push_back(make_pair(cost[i], i));
  sort((allcost).begin(), (allcost).end());
  ctoi.resize(n);
  for (int i = 0; i < n; i++) ctoi[allcost[i].second] = i;
  int re = n - 1;
  lfori.resize(n);
  for (int le = 0; le < n; le++) {
    while (re >= 0 && allcost[le].first + allcost[re].first > c) re--;
    lfori[le] = re;
  }
  std::vector<std::pair<int, int> > ev;
  for (int i = 0; i < n; i++) {
    ev.push_back(make_pair(l[i], -i - 1));
    ev.push_back(make_pair(r[i], i + 1));
  }
  int m;
  scanf("%d", &m);
  std::vector<int> q(m);
  for (int i = 0; i < m; i++) scanf("%d", &q[i]);
  std::vector<int> qs = q;
  int pq = 0;
  map<int, int> ans;
  sort((qs).begin(), (qs).end());
  const int INF = 1e9;
  ev.push_back(make_pair(2 * INF + 100, 0));
  sort((ev).begin(), (ev).end());
  const int A = 500;
  std::vector<std::vector<int> > nb(n);
  std::vector<int> big(n, 0);
  int last = 0;
  int fr = 0;
  multiset<int> op;
  int pt = 0;
  std::vector<int> biglist;
  std::pair<int, int> b2;
  int b2res = 0;
  std::vector<int> sin(n, 0);
  std::vector<int> bestpair(n, 0);
  std::vector<int> bestpval(n, 0);
  while (1) {
    if (pq == qs.size()) break;
    auto x = ev[pt];
    if (last == x.first) {
      if (x.second < 0)
        op.insert(-x.second - 1);
      else
        op.erase(op.find(x.second - 1));
      pt++;
      continue;
    }
    if (op.size() > 2)
      last = x.first;
    else if (op.size() == 2) {
      auto it = op.begin();
      int a = *it++;
      int b = *it;
      if (a > b) swap(a, b);
      if (cost[a] + cost[b] > c) {
        last = x.first;
        continue;
      }
      if (pr[a].find(b) == pr[a].end()) {
        nb[a].push_back(b);
        nb[b].push_back(a);
        pr[a][b] += x.first - last;
        pr[b][a] += x.first - last;
        if (nb[a].size() == A) {
          for (auto x : pr[a]) {
            int bt = x.first;
            int abv = x.second;
            if (bestpval[a] < abv + sin[bt] + sin[a]) {
              bestpval[a] = abv + sin[bt] + sin[a];
              bestpair[a] = bt;
            }
          }
          big[a] = 1;
          biglist.push_back(a);
        }
        if (nb[b].size() == A) {
          for (auto x : pr[b]) {
            int at = x.first;
            int abv = x.second;
            if (bestpval[b] < abv + sin[b] + sin[at]) {
              bestpval[b] = abv + sin[b] + sin[at];
              bestpair[b] = at;
            }
          }
          big[b] = 1;
          biglist.push_back(a);
        }
      } else {
        pr[a][b] += x.first - last;
        pr[b][a] += x.first - last;
      }
      int cand = fr + sin[a] + sin[b] + pr[a][b];
      if (cand - fr > b2res) {
        b2 = make_pair(a, b);
        b2res = cand - fr;
      }
      while (pq != qs.size() && qs[pq] <= cand) {
        ans[qs[pq]] = x.first - cand + qs[pq];
        pq++;
      }
      last = x.first;
    } else if (op.size() == 0) {
      fr += x.first - last;
      while (pq != qs.size() && qs[pq] <= fr + b2res) {
        ans[qs[pq]] = x.first - fr - b2res + qs[pq];
        pq++;
      }
      last = x.first;
    } else {
      int a = *op.begin();
      if (cost[a] > c) {
        last = x.first;
        continue;
      }
      sin[a] += x.first - last;
      int ind = ctoi[a];
      int lind = lfori[ind];
      dj.set(1, 0, n - 1, ind, sin[a]);
      std::pair<int, int> res = dj.get(1, 0, n - 1, 0, lind);
      if (ind <= lind && res.first == sin[a]) {
        swap(res.first, res.second);
      }
      int cand = fr + sin[a] + res.first;
      if (cand - fr > b2res) {
        b2res = cand - fr;
      }
      while (pq != qs.size() && qs[pq] <= cand) {
        ans[qs[pq]] = x.first - cand + qs[pq];
        pq++;
      }
      if (!big[a]) {
        for (auto u : pr[a]) {
          int b = u.first;
          int abv = u.second;
          int cand = fr + sin[a] + sin[b] + abv;
          if (cand - fr > b2res) {
            b2 = make_pair(a, b);
            b2res = cand - fr;
          }
          while (pq != qs.size() && qs[pq] <= cand) {
            ans[qs[pq]] = x.first - cand + qs[pq];
            pq++;
          }
          if (big[b]) {
            if ((cand - fr) > bestpval[b]) {
              bestpval[b] = cand - fr;
              bestpair[b] = a;
            }
          }
        }
      } else {
        int b = bestpair[a];
        bestpval[a] += x.first - last;
        int cand = bestpval[a] + fr;
        if (cand - fr > b2res) {
          b2 = make_pair(a, b);
          b2res = cand - fr;
        }
        while (pq != qs.size() && qs[pq] <= cand) {
          ans[qs[pq]] = x.first - cand + qs[pq];
          pq++;
        }
        for (auto bc : biglist) {
          if (bc == a) continue;
          if (pr[a].find(bc) != pr[a].end()) {
            int cand = sin[a] + sin[bc] + pr[a][bc];
            if ((cand - fr) > bestpval[bc]) {
              bestpval[bc] = cand;
              bestpair[bc] = a;
            }
          }
        }
      }
      last = x.first;
    }
  }
  for (auto x : q) printf("%d\n", ans[x]);
}

```


### Prompt

Please create a solution in CPP to the following problem:

As a New Year's gift, Dolphin received a string s of length 19.
The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`.
Dolphin wants to convert the comma-separated string s into a space-separated string.
Write a program to perform the conversion for him.

Constraints

* The length of s is 19.
* The sixth and fourteenth characters in s are `,`.
* The other characters in s are lowercase English letters.

Input

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

s

Output

Print the string after the conversion.

Examples

Input

happy,newyear,enjoy

Output

happy newyear enjoy

Input

haiku,atcoder,tasks

Output

haiku atcoder tasks

Input

abcde,fghihgf,edcba

Output

abcde fghihgf edcba

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string o;
int main(){
    cin>>o;
    for(char c:o)cout<<(c==','?' ':c);
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Now that Kuroni has reached 10 years old, he is a big boy and doesn't like arrays of integers as presents anymore. This year he wants a Bracket sequence as a Birthday present. More specifically, he wants a bracket sequence so complex that no matter how hard he tries, he will not be able to remove a simple subsequence!

We say that a string formed by n characters '(' or ')' is simple if its length n is even and positive, its first n/2 characters are '(', and its last n/2 characters are ')'. For example, the strings () and (()) are simple, while the strings )( and ()() are not simple.

Kuroni will be given a string formed by characters '(' and ')' (the given string is not necessarily simple). An operation consists of choosing a subsequence of the characters of the string that forms a simple string and removing all the characters of this subsequence from the string. Note that this subsequence doesn't have to be continuous. For example, he can apply the operation to the string ')()(()))', to choose a subsequence of bold characters, as it forms a simple string '(())', delete these bold characters from the string and to get '))()'.

Kuroni has to perform the minimum possible number of operations on the string, in such a way that no more operations can be performed on the remaining string. The resulting string does not have to be empty.

Since the given string is too large, Kuroni is unable to figure out how to minimize the number of operations. Can you help him do it instead?

A sequence of characters a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters.

Input

The only line of input contains a string s (1 ≤ |s| ≤ 1000) formed by characters '(' and ')', where |s| is the length of s.

Output

In the first line, print an integer k — the minimum number of operations you have to apply. Then, print 2k lines describing the operations in the following format:

For each operation, print a line containing an integer m — the number of characters in the subsequence you will remove.

Then, print a line containing m integers 1 ≤ a_1 < a_2 < ... < a_m — the indices of the characters you will remove. All integers must be less than or equal to the length of the current string, and the corresponding subsequence must form a simple string.

If there are multiple valid sequences of operations with the smallest k, you may print any of them.

Examples

Input

(()((

Output

1
2
1 3

Input

)(

Output

0

Input

(()())

Output

1
4
1 2 5 6

Note

In the first sample, the string is '(()(('. The operation described corresponds to deleting the bolded subsequence. The resulting string is '(((', and no more operations can be performed on it. Another valid answer is choosing indices 2 and 3, which results in the same final string.

In the second sample, it is already impossible to perform any operations.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char input[1005];
vector<int> open_idx;
vector<int> close_idx;
int valid_idxes[1005][1005];
int valid_idxes_len[1005];
int valid_idxes_sz = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  scanf("%s", input);
  while (true) {
    open_idx.clear();
    close_idx.clear();
    for (int i = 0; input[i]; ++i) {
      if (input[i] == '(')
        open_idx.push_back(i + 1);
      else if (input[i] == ')')
        close_idx.push_back(i + 1);
    }
    int mx_remove = 0;
    int mx_idx = -1;
    for (int i = 0; i < open_idx.size(); ++i) {
      int valid_close =
          close_idx.end() -
          lower_bound(close_idx.begin(), close_idx.end(), open_idx[i] + 1);
      int val = min(valid_close, i + 1);
      if (val > mx_remove) {
        mx_remove = val;
        mx_idx = i;
      }
    }
    if (mx_idx == -1) break;
    int valid_idxes_cur = 0;
    for (int i = 0; i <= mx_idx; ++i) {
      valid_idxes[valid_idxes_sz][valid_idxes_cur++] = open_idx[i];
      input[open_idx[i] - 1] = ' ';
    }
    for (int i = (int)close_idx.size() - 1 - mx_idx; i < close_idx.size();
         ++i) {
      valid_idxes[valid_idxes_sz][valid_idxes_cur++] = close_idx[i];
      input[close_idx[i] - 1] = ' ';
    }
    valid_idxes_len[valid_idxes_sz++] = valid_idxes_cur;
  }
  printf("%d\n", valid_idxes_sz);
  for (int i = 0; i < valid_idxes_sz; ++i) {
    printf("%d\n", valid_idxes_len[i]);
    for (int j = 0; j < valid_idxes_len[i]; ++j)
      printf("%d ", valid_idxes[i][j]);
    printf("\n");
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Bizon the Champion isn't just charming, he also is very smart.

While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on the intersection of the i-th row and j-th column equals i·j (the rows and columns of the table are numbered starting from 1). Then he was asked: what number in the table is the k-th largest number? Bizon the Champion always answered correctly and immediately. Can you repeat his success?

Consider the given multiplication table. If you write out all n·m numbers from the table in the non-decreasing order, then the k-th number you write out is called the k-th largest number.

Input

The single line contains integers n, m and k (1 ≤ n, m ≤ 5·105; 1 ≤ k ≤ n·m).

Output

Print the k-th largest number in a n × m multiplication table.

Examples

Input

2 2 2

Output

2

Input

2 3 4

Output

3

Input

1 10 5

Output

5

Note

A 2 × 3 multiplication table looks like this:

    1 2 3
    2 4 6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const long long llinf = 9223372036854775807LL;
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  if (n > m) swap(n, m);
  long long l = 1, r = n * m + 1;
  while (l < r) {
    long long res = 0;
    long long mid = (l + r) / 2;
    for (int i = 1; i <= n; i++) {
      res += min(m, mid / i);
    }
    if (res < k)
      l = mid + 1;
    else
      r = mid;
  }
  cout << r;
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

New Year is getting near. So it's time to change handles on codeforces. Mishka wants to change his handle but in such a way that people would not forget who he is.

To make it work, he only allowed to change letters case. More formally, during one handle change he can choose any segment of his handle [i; i + l - 1] and apply tolower or toupper to all letters of his handle on this segment (more fomally, replace all uppercase letters with corresponding lowercase or vice versa). The length l is fixed for all changes.

Because it is not allowed to change codeforces handle too often, Mishka can perform at most k such operations. What is the minimum value of min(lower, upper) (where lower is the number of lowercase letters, and upper is the number of uppercase letters) can be obtained after optimal sequence of changes?

Input

The first line of the input contains three integers n, k and l (1 ≤ n, k, l ≤ 10^6, l ≤ n) — the length of Mishka's handle, the number of changes and the length of the segment.

The second line of the input contains one string s, consisting of n lowercase and uppercase Latin letters — Mishka's handle.

Output

Print one integer — the minimum value of min(lower, upper) after that Mishka change his handle at most k times in a way described in the problem statement.

Examples

Input

7 1 4
PikMike

Output

0

Input

15 2 2
AaAaAAaaAAAAaaA

Output

2

Input

14 2 6
aBcdEFGHIJklMn

Output

0

Input

9 2 2
aAaAAAaaA

Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, k, len;
string s;
pair<long long, long long> f(long long lam, bool upper) {
  vector<long long> dp(n);
  vector<long long> cut(n);
  for (long long i = 0; i < n; i++) {
    cut[i] = (i == 0 ? 0 : cut[i - 1]);
    if (upper)
      dp[i] = (i == 0 ? 0 : dp[i - 1]) + (s[i] >= 'A' && s[i] <= 'Z');
    else
      dp[i] = (i == 0 ? 0 : dp[i - 1]) + (s[i] >= 'a' && s[i] <= 'z');
    if ((i - len < 0 ? 0 : dp[i - len]) + lam < dp[i]) {
      dp[i] = (i - len < 0 ? 0 : dp[i - len]) + lam;
      cut[i] = 1 + (i - len < 0 ? 0 : cut[i - len]);
    }
  }
  return {dp[n - 1] - k * lam, cut[n - 1]};
}
long long bs(bool upper) {
  long long l = 0, r = 1e6 + 5;
  while (l < r) {
    long long m = (r + l) / 2;
    if (f(m, upper).second > k) {
      l = m + 1;
    } else {
      r = m;
    }
  }
  return max(0ll, f(r, upper).first);
}
int32_t main() {
  cin >> n >> k >> len >> s;
  cout << min(bs(false), bs(true));
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Konrad is a Human Relations consultant working for VoltModder, a large electrical equipment producer. Today, he has been tasked with evaluating the level of happiness in the company.

There are n people working for VoltModder, numbered from 1 to n. Each employee earns a different amount of money in the company — initially, the i-th person earns i rubles per day.

On each of q following days, the salaries will be revised. At the end of the i-th day, employee v_i will start earning n+i rubles per day and will become the best-paid person in the company. The employee will keep his new salary until it gets revised again.

Some pairs of people don't like each other. This creates a great psychological danger in the company. Formally, if two people a and b dislike each other and a earns more money than b, employee a will brag about this to b. A dangerous triple is a triple of three employees a, b and c, such that a brags to b, who in turn brags to c. If a dislikes b, then b dislikes a.

At the beginning of each day, Konrad needs to evaluate the number of dangerous triples in the company. Can you help him do it?

Input

The first line contains two integers n and m (1 ≤ n ≤ 100 000, 0 ≤ m ≤ 100 000) — the number of employees in the company and the number of pairs of people who don't like each other. Each of the following m lines contains two integers a_i, b_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i) denoting that employees a_i and b_i hate each other (that is, a_i dislikes b_i and b_i dislikes a_i). Each such relationship will be mentioned exactly once.

The next line contains an integer q (0 ≤ q ≤ 100 000) — the number of salary revisions. The i-th of the following q lines contains a single integer v_i (1 ≤ v_i ≤ n) denoting that at the end of the i-th day, employee v_i will earn the most.

Output

Output q + 1 integers. The i-th of them should contain the number of dangerous triples in the company at the beginning of the i-th day.

Examples

Input

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

Output

4
3
2

Input

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

Output

1
1
1
1
1
1

Note

Consider the first sample test. The i-th row in the following image shows the structure of the company at the beginning of the i-th day. A directed edge from a to b denotes that employee a brags to employee b. The dangerous triples are marked by highlighted edges.

<image>

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef int ll;
const ll MAX = 1e5 + 20;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
ll n, m, q, in[MAX], out[MAX];
vector<ll> adj[MAX];
int main() {
  cin >> n >> m;
  ll u, v;
  for (ll i = 0; i < (ll)m; i++) {
    cin >> u >> v;
    if (u > v) swap(u, v);
    adj[u].push_back(v);
    in[u]++, out[v]++;
  }
  long long cur = 0;
  for (ll i = 1; i < (ll)n + 1; i++) cur += 1LL * in[i] * out[i];
  cout << cur << endl;
  cin >> q;
  while (q--) {
    cin >> u;
    cur -= 1LL * in[u] * out[u];
    for (ll v : adj[u]) {
      cur -= 1LL * in[v] * out[v];
      out[u]++, in[u]--;
      in[v]++, out[v]--;
      cur += 1LL * in[v] * out[v];
      adj[v].push_back(u);
    }
    adj[u].clear();
    cout << cur << endl;
  }
  return 0;
}

```


### Prompt

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

You are given an array of n integer numbers. Let sum(l, r) be the sum of all numbers on positions from l to r non-inclusive (l-th element is counted, r-th element is not counted). For indices l and r holds 0 ≤ l ≤ r ≤ n. Indices in array are numbered from 0.

For example, if a = [ - 5, 3, 9, 4], then sum(0, 1) = - 5, sum(0, 2) = - 2, sum(1, 4) = 16 and sum(i, i) = 0 for each i from 0 to 4.

Choose the indices of three delimiters delim0, delim1, delim2 (0 ≤ delim0 ≤ delim1 ≤ delim2 ≤ n) and divide the array in such a way that the value of res = sum(0, delim0) - sum(delim0, delim1) + sum(delim1, delim2) - sum(delim2, n) is maximal.

Note that some of the expressions sum(l, r) can correspond to empty segments (if l = r for some segment).

Input

The first line contains one integer number n (1 ≤ n ≤ 5000).

The second line contains n numbers a0, a1, ..., an - 1 ( - 109 ≤ ai ≤ 109).

Output

Choose three indices so that the value of res is maximal. If there are multiple answers, print any of them.

Examples

Input

3
-1 2 3

Output

0 1 3

Input

4
0 0 -1 0

Output

0 0 0

Input

1
10000

Output

1 1 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
long long dp[5005][5], p[5005][5];
long long a[5005], sum[5005];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 1; i <= n; ++i) {
    dp[i][1] = sum[i];
    p[i][1] = 0;
  }
  for (int z = 2; z <= 4; ++z) {
    for (int i = 1; i <= n; ++i) {
      dp[i][z] = z % 2 == 0 ? 9e18 : -9e18;
      for (int j = 0; j <= i; ++j) {
        long long cur = sum[i] - sum[j] - dp[j][z - 1];
        if (z % 2 == 0 && cur < dp[i][z] || z % 2 != 0 && cur > dp[i][z]) {
          dp[i][z] = cur;
          p[i][z] = j;
        }
      }
    }
  }
  int cur = n, curz = 4;
  vector<int> ans;
  while (curz > 1) {
    ans.push_back(p[cur][curz]);
    cur = p[cur][curz--];
  }
  cout << ans[2] << " " << ans[1] << " " << ans[0] << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.

Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm:

  1. Give m candies to the first child of the line.
  2. If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home.
  3. Repeat the first two steps while the line is not empty.

Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?

Input

The first line contains two integers n, m (1 ≤ n ≤ 100; 1 ≤ m ≤ 100). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100).

Output

Output a single integer, representing the number of the last child.

Examples

Input

5 2
1 3 1 4 2

Output

4

Input

6 4
1 1 2 2 3 3

Output

6

Note

Let's consider the first sample.

Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the end of the line. Currently the line looks like [5, 2, 4]. Then child 5 gets 2 candies and goes home. Then child 2 gets two candies and goes home, and finally child 4 gets 2 candies and goes home.

Child 4 is the last one who goes home.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int mxsize = 1e5 + 15;
const long long int linf = 1e16;
const long long int mod = 1e9 + 7;
long long int pow(long long int x, long long int n) {
  if (n == 0) return 1ll;
  long long int temp;
  temp = pow(x, n / 2);
  if (n % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int sum_digit(int val) {
  if (val < 0) return -1;
  if (val == 0) return 0;
  int ans = 0;
  while (val > 0) {
    ans = ans + val % 10;
    val = val / 10;
  }
  return ans;
}
long long int count_div(long long int l, long long int r, long long int val) {
  if (l % val == 0)
    return (((r / val) - (l / val)) + 1);
  else
    return ((r / val) - (l / val));
}
int powmod(int x, int y, int m) {
  int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % m;
    cout << res << endl;
    y = y / 2;
    cout << x << endl;
    x = (x * x) % m;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  queue<int> q;
  int ans = -1;
  for (int i = 0; i < n; i++) q.push(i + 1);
  while (!q.empty()) {
    int curr = q.front();
    q.pop();
    arr[curr - 1] = arr[curr - 1] - m;
    ans = curr;
    if (arr[curr - 1] > 0) q.push(curr);
  }
  cout << ans << endl;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2n - 1 non-empty subsequences in it.

Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence -  Minimum_element_of_subsequence ≥ d

Pikachu was finally left with X subsequences.

However, he lost the initial array he had, and now is in serious trouble. He still remembers the numbers X and d. He now wants you to construct any such array which will satisfy the above conditions. All the numbers in the final array should be positive integers less than 1018.

Note the number of elements in the output array should not be more than 104. If no answer is possible, print  - 1.

Input

The only line of input consists of two space separated integers X and d (1 ≤ X, d ≤ 109).

Output

Output should consist of two lines.

First line should contain a single integer n (1 ≤ n ≤ 10 000)— the number of integers in the final array.

Second line should consist of n space separated integers — a1, a2, ... , an (1 ≤ ai < 1018).

If there is no answer, print a single integer -1. If there are multiple answers, print any of them.

Examples

Input

10 5

Output

6
5 50 7 15 6 100

Input

4 2

Output

4
10 100 1000 10000

Note

In the output of the first example case, the remaining subsequences after removing those with Maximum_element_of_the_subsequence -  Minimum_element_of_subsequence ≥ 5 are [5], [5, 7], [5, 6], [5, 7, 6], [50], [7], [7, 6], [15], [6], [100]. There are 10 of them. Hence, the array [5, 50, 7, 15, 6, 100] is valid.

Similarly, in the output of the second example case, the remaining sub-sequences after removing those with Maximum_element_of_the_subsequence -  Minimum_element_of_subsequence ≥ 2 are [10], [100], [1000], [10000]. There are 4 of them. Hence, the array [10, 100, 1000, 10000] is valid.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const long long MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
long long power_md(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) res = (res % md * a % md) % md;
    a = (a % md * a % md) % md;
    n /= 2;
  }
  res %= md;
  return res;
}
long long power(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) res *= a;
    a = a * a;
    n /= 2;
  }
  return res;
}
long long abst(long long a) { return ((a < 0) ? (-1 * a) : (a)); }
class cmp_set {
 public:
  bool operator()(long long a, long long b) { return a > b; }
};
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long x, d;
  cin >> x >> d;
  long long p = 1;
  vector<long long> res;
  for (long long i = 60; i >= 1; i--) {
    if (x & ((long long)1 << i)) {
      for (long long j = 0; j < i; j++) {
        res.push_back(p);
      }
      p += (d + 1);
      res.push_back(p);
      p += (d + 1);
    }
  }
  if (x % 2) {
    res.push_back(p);
  }
  cout << res.size() << "\n";
  for (long long i = 0; i < res.size(); i++) cout << res[i] << " ";
  cout << "\n";
  return 0;
}

```


### Prompt

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

You've got an undirected graph, consisting of n vertices and m edges. We will consider the graph's vertices numbered with integers from 1 to n. Each vertex of the graph has a color. The color of the i-th vertex is an integer ci.

Let's consider all vertices of the graph, that are painted some color k. Let's denote a set of such as V(k). Let's denote the value of the neighbouring color diversity for color k as the cardinality of the set Q(k) = {cu : cu ≠ k and there is vertex v belonging to set V(k) such that nodes v and u are connected by an edge of the graph}.

Your task is to find such color k, which makes the cardinality of set Q(k) maximum. In other words, you want to find the color that has the most diverse neighbours. Please note, that you want to find such color k, that the graph has at least one vertex with such color.

Input

The first line contains two space-separated integers n, m (1 ≤ n, m ≤ 105) — the number of vertices end edges of the graph, correspondingly. The second line contains a sequence of integers c1, c2, ..., cn (1 ≤ ci ≤ 105) — the colors of the graph vertices. The numbers on the line are separated by spaces.

Next m lines contain the description of the edges: the i-th line contains two space-separated integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi) — the numbers of the vertices, connected by the i-th edge.

It is guaranteed that the given graph has no self-loops or multiple edges.

Output

Print the number of the color which has the set of neighbours with the maximum cardinality. It there are multiple optimal colors, print the color with the minimum number. Please note, that you want to find such color, that the graph has at least one vertex with such color.

Examples

Input

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

Output

3

Input

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

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
set<int> fuck;
map<int, int> color;
vector<int> g[100005];
int n, m, ans, mx;
void solve(int x) {
  set<int> s;
  int sum = 0;
  for (auto i : v[x]) {
    sum += g[i].size();
    for (auto j : g[i]) {
      if (x != color[j]) {
        s.insert(color[j]);
      }
    }
  }
  if (s.size() > mx) {
    ans = x;
    mx = s.size();
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    fuck.insert(t);
    v[t].push_back(i);
    color[i] = t;
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ans = *fuck.begin();
  for (auto i : fuck) {
    solve(i);
  }
  cout << ans;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 × 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make a move, Bessie or Elsie can slide a tile adjacent to the empty cell into the empty cell as shown below:

<image>

In order to determine if they are truly Best Friends For Life (BFFLs), Bessie and Elsie would like to know if there exists a sequence of moves that takes their puzzles to the same configuration (moves can be performed in both puzzles). Two puzzles are considered to be in the same configuration if each tile is on top of the same grid cell in both puzzles. Since the tiles are labeled with letters, rotations and reflections are not allowed.

Input

The first two lines of the input consist of a 2 × 2 grid describing the initial configuration of Bessie's puzzle. The next two lines contain a 2 × 2 grid describing the initial configuration of Elsie's puzzle. The positions of the tiles are labeled 'A', 'B', and 'C', while the empty cell is labeled 'X'. It's guaranteed that both puzzles contain exactly one tile with each letter and exactly one empty position.

Output

Output "YES"(without quotes) if the puzzles can reach the same configuration (and Bessie and Elsie are truly BFFLs). Otherwise, print "NO" (without quotes).

Examples

Input

AB
XC
XB
AC

Output

YES

Input

AB
XC
AC
BX

Output

NO

Note

The solution to the first sample is described by the image. All Bessie needs to do is slide her 'A' tile down.

In the second sample, the two puzzles can never be in the same configuration. Perhaps Bessie and Elsie are not meant to be friends after all...

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T& input(T& v) {
  for (int i = 0; i < v.size(); i++) cin >> v[i];
  return v;
}
template <typename T>
T& input_2d(T& v) {
  int N = v.size();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < v[i].size(); j++) cin >> v[i][j];
  }
}
template <typename T>
T& input_pair(T& v) {
  for (int i = 0; i < v.size(); i++) cin >> v[i].first >> v[i].second;
  return v;
}
template <typename T>
void print(const T& v) {
  int N = v.size();
  for (int i = 0; i < N; i++) cout << v[i] << " ";
  cout << '\n';
}
template <typename T>
void print_2d(T& v) {
  int N = v.size();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < v[i].size(); j++) cout << v[i][j] << " ";
    cout << '\n';
  }
}
template <typename T>
void print_pair(const T& v) {
  int N = v.size();
  for (int i = 0; i < N; i++) cout << v[i].first << " " << v[i].second << '\n';
}
template <typename T>
inline int digits(const T& N) {
  return (N > 0 ? (int)((log10(N)) + 1) : 1);
}
inline bool ispoweroftwo(int x) { return (x && (!(x & (x - 1)))); }
bool if_integer(double x) {
  if (x - floor(x) == 0 && x > 0)
    return true;
  else
    return false;
}
int binomial(int n, int k) {
  vector<int> C(k + 1, 0);
  C[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = min(i, k); j > 0; j--) C[j] = C[j] + C[j - 1];
  }
  return C[k];
}
inline double distance(int a, int b, int c, int d) {
  return sqrt(((long long)(a - c)) * (a - c) + ((long long)(b - d)) * (b - d));
}
class compare {
  bool operator()(pair<int, int>& p1, pair<int, int>& p2) {
    if (p1.first == p2.first) return p1.second > p2.second;
    return p1.first > p2.first;
  }
};
bool sortbysec(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first == b.first) return (a.second < b.second);
  return (a.first > b.first);
}
bool mysort(const vector<int>& a, const vector<int>& b) {
  return (a.size() < b.size());
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<string> s(4);
  input(s);
  vector<int> v(4), v2(4);
  int m = 0, k1, k2;
  for (int i = 0; i < 2; i++) {
    int j = 0, k;
    if (i == 0) {
      j = 0;
      k = 1;
    } else {
      j = 1;
      k = -1;
    }
    for (; j >= 0 && j < 2; j = j + k) {
      if (s[i][j] == 'X') v[m] = 0;
      if (s[i][j] == 'A') {
        v[m] = 1;
        k1 = m;
      }
      if (s[i][j] == 'B') v[m] = 2;
      if (s[i][j] == 'C') v[m] = 3;
      m++;
    }
  }
  m = 0;
  for (int i = 2; i < 4; i++) {
    int j = 0, k;
    if (i == 2) {
      j = 0;
      k = 1;
    } else {
      j = 1;
      k = -1;
    }
    for (; j >= 0 && j < 2; j = j + k) {
      if (s[i][j] == 'X') v2[m] = 0;
      if (s[i][j] == 'A') {
        v2[m] = 1;
        k2 = m;
      }
      if (s[i][j] == 'B') v2[m] = 2;
      if (s[i][j] == 'C') v2[m] = 3;
      m++;
    }
  }
  int k = 0;
  for (int i = 0; i < 3; i++) {
    if (v[k1] == 0) k1++;
    if (v2[k2] == 0) k2++;
    if (k1 > 3) k1 = 0;
    if (k2 > 3) k2 = 0;
    if (v[k1] == v2[k2]) k++;
    k1++;
    k2++;
    if (k1 > 3) k1 = 0;
    if (k2 > 3) k2 = 0;
  }
  if (k == 3) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

<image>

Arrange integers (0 or more and 99 or less) in a rhombus as illustrated in Fig. 1. Create a program that reads the data representing the rhombus and outputs the maximum value of the sum of the integers that pass when starting from the top and proceeding to the bottom according to the following rules.

* At each step, you can proceed to the lower left diagonal or the lower right diagonal.

For example, in the example of Fig. 1, as shown in Fig. 2, when 7,3,8,7,5,7,8,3,7 is selected and passed, the sum is the maximum 55 (7 + 3 + 8). + 7 + 5 + 7 + 8 + 3 + 7 = 55).

Input

As shown in the input example, a comma-separated sequence of integers is given to the diamond. Each line does not contain whitespace. The input example corresponds to Fig. 1. There are less than 100 rows of data.

Output

Outputs the maximum value of the sum of integers that pass according to the rules on one line.

Example

Input

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

Output

55

### Response

```cpp
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int s[111][111];
int main(void){
  int a,k;
  for(k = 0; cin >> a; k++){
    s[k][0] = a;
    for(int i = 1; getchar()==','; i++){
      cin >> s[k][i];
    }
  }

  int n=2,p=1;
  //cout << s[0][0] << endl;
  for(int i = 1; i < k; i++){
    for(int j = 0; j < n; j++){
      a = 0;
      if(k/2 >= i && j > 0) a = max(a,s[i-1][j-1]);
      if(k/2 < i && j+1 < p) a = max(a,s[i-1][j+1]);
      if(j < p) a = max(a,s[i-1][j]);
      s[i][j] += a;
      //cout << s[i][j] << ",";
    }
    //cout << endl;
    p = n;
    n += (k/2>i)?1:-1;
  }
  cout << s[k-1][0] << endl;
}
```


### Prompt

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

I see a pink boar and I want it painted black. Black boars look much more awesome and mighty than the pink ones. Since Jaggy became the ruler of the forest, he has been trying his best to improve the diplomatic relations between the forest region and the nearby ones.

Some other rulers, however, have requested too much in return for peace between their two regions, so he realized he has to resort to intimidation. Once a delegate for diplomatic relations of a neighboring region visits Jaggy’s forest, if they see a whole bunch of black boars, they might suddenly change their mind about attacking Jaggy. Black boars are really scary, after all.

Jaggy’s forest can be represented as a tree (connected graph without cycles) with n vertices. Each vertex represents a boar and is colored either black or pink. Jaggy has sent a squirrel to travel through the forest and paint all the boars black. The squirrel, however, is quite unusually trained and while it traverses the graph, it changes the color of every vertex it visits, regardless of its initial color: pink vertices become black and black vertices become pink.

Since Jaggy is too busy to plan the squirrel’s route, he needs your help. He wants you to construct a walk through the tree starting from vertex 1 such that in the end all vertices are black. A walk is a sequence of vertices, such that every consecutive pair has an edge between them in a tree.

Input

The first line of input contains integer n (2 ≤ n ≤ 200 000), denoting the number of vertices in the tree. The following n lines contains n integers, which represent the color of the nodes.

If the i-th integer is 1, if the i-th vertex is black and  - 1 if the i-th vertex is pink.

Each of the next n - 1 lines contains two integers, which represent the indexes of the vertices which are connected by the edge. Vertices are numbered starting with 1.

Output

Output path of a squirrel: output a sequence of visited nodes' indexes in order of visiting. In case of all the nodes are initially black, you should print 1. Solution is guaranteed to exist. If there are multiple solutions to the problem you can output any of them provided length of sequence is not longer than 107.

Example

Input

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

Output

1 4 2 5 2 4 3 4 1 4 1

Note

At the beginning squirrel is at node 1 and its color is black. Next steps are as follows:

  * From node 1 we walk to node 4 and change its color to pink.
  * From node 4 we walk to node 2 and change its color to pink.
  * From node 2 we walk to node 5 and change its color to black.
  * From node 5 we return to node 2 and change its color to black.
  * From node 2 we walk to node 4 and change its color to black.
  * We visit node 3 and change its color to black.
  * We visit node 4 and change its color to pink.
  * We visit node 1 and change its color to pink.
  * We visit node 4 and change its color to black.
  * We visit node 1 and change its color to black.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int vis[200005], c[200005], fa[200005];
vector<int> g[200005];
vector<int> ans;
int flag;
void init(int u) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (vis[v]) continue;
    fa[v] = u;
    init(v);
  }
}
void f(int u) {
  ans.push_back(u);
  c[u] = -c[u];
  if (g[u].size() == 1 && u != 1) return;
  for (int v : g[u]) {
    if (fa[u] == v) continue;
    f(v);
    if (c[v] == -1) {
      ans.push_back(u);
      ans.push_back(v);
      ans.push_back(u);
      c[v] = 1;
    } else {
      ans.push_back(u);
      c[u] = -c[u];
    }
  }
}
void work(int u) {
  ans.push_back(u);
  for (int v : g[u]) {
    f(v);
    if (c[v] == -1) {
      ans.push_back(u);
      ans.push_back(v);
      ans.push_back(u);
      c[v] = 1;
    } else {
      ans.push_back(u);
      c[u] = -c[u];
    }
  }
  if (c[u] == -1) flag = 1;
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> c[i];
  for (int i = 1; i <= n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  init(1);
  work(1);
  if (flag) {
    ans.push_back(g[1][0]);
    ans.push_back(1);
    ans.push_back(g[1][0]);
    c[1] = -c[1];
  }
  for (int i : ans) cout << i << " ";
}

```


### Prompt

Create a solution in Cpp for the following problem:

On a random day, Neko found n treasure chests and m keys. The i-th chest has an integer a_i written on it and the j-th key has an integer b_j on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as many treasure chests as possible.

The j-th key can be used to unlock the i-th chest if and only if the sum of the key number and the chest number is an odd number. Formally, a_i + b_j ≡ 1 \pmod{2}. One key can be used to open at most one chest, and one chest can be opened at most once.

Find the maximum number of chests Neko can open.

Input

The first line contains integers n and m (1 ≤ n, m ≤ 10^5) — the number of chests and the number of keys.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers written on the treasure chests.

The third line contains m integers b_1, b_2, …, b_m (1 ≤ b_i ≤ 10^9) — the numbers written on the keys.

Output

Print the maximum number of chests you can open.

Examples

Input

5 4
9 14 6 2 11
8 4 7 20

Output

3

Input

5 1
2 4 6 8 10
5

Output

1

Input

1 4
10
20 30 40 50

Output

0

Note

In the first example, one possible way to unlock 3 chests is as follows:

  * Use first key to unlock the fifth chest,
  * Use third key to unlock the second chest,
  * Use fourth key to unlock the first chest.

In the second example, you can use the only key to unlock any single chest (note that one key can't be used twice).

In the third example, no key can unlock the given chest.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, oc = 0, ec = 0, ok = 0, ek = 0, i, a, b;
  cin >> n >> m;
  int a1[n], a2[m];
  for (i = 0; i < n; i++) {
    cin >> a1[i];
    if (a1[i] % 2 == 0)
      ec++;
    else
      oc++;
  }
  for (i = 0; i < m; i++) {
    cin >> a2[i];
    if (a2[i] % 2 == 0)
      ek++;
    else
      ok++;
  }
  if ((oc == 0 && ok == 0) || (ec == 0 && ek == 0))
    cout << 0;
  else {
    if (oc > ek)
      a = ek;
    else
      a = oc;
    if (ok > ec)
      b = ec;
    else
      b = ok;
    cout << a + b;
  }
  return 0;
}

```


### Prompt

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

You are given a correct solution of the sudoku puzzle. If you don't know what is the sudoku, you can read about it [here](http://tiny.cc/636xmz).

The picture showing the correct sudoku solution:

<image>

Blocks are bordered with bold black color.

Your task is to change at most 9 elements of this field (i.e. choose some 1 ≤ i, j ≤ 9 and change the number at the position (i, j) to any other number in range [1; 9]) to make it anti-sudoku. The anti-sudoku is the 9 × 9 field, in which:

  * Any number in this field is in range [1; 9];
  * each row contains at least two equal elements;
  * each column contains at least two equal elements;
  * each 3 × 3 block (you can read what is the block in the link above) contains at least two equal elements.

It is guaranteed that the answer exists.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.

Each test case consists of 9 lines, each line consists of 9 characters from 1 to 9 without any whitespaces — the correct solution of the sudoku puzzle.

Output

For each test case, print the answer — the initial field with at most 9 changed elements so that the obtained field is anti-sudoku. If there are several solutions, you can print any. It is guaranteed that the answer exists.

Example

Input

1
154873296
386592714
729641835
863725149
975314628
412968357
631457982
598236471
247189563

Output

154873396
336592714
729645835
863725145
979314628
412958357
631457992
998236471
247789563

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    for (int i = 0; i < 9; i++) {
      string a;
      cin >> a;
      for (int i = 0; i < 9; i++) {
        if (a[i] == '5') {
          a[i] = '6';
        }
      }
      cout << a << "\n";
    }
  }
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Happy PMP is freshman and he is learning about algorithmic problems. He enjoys playing algorithmic games a lot.

One of the seniors gave Happy PMP a nice game. He is given two permutations of numbers 1 through n and is asked to convert the first one to the second. In one move he can remove the last number from the permutation of numbers and inserts it back in an arbitrary position. He can either insert last number between any two consecutive numbers, or he can place it at the beginning of the permutation.

Happy PMP has an algorithm that solves the problem. But it is not fast enough. He wants to know the minimum number of moves to convert the first permutation to the second.

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — the quantity of the numbers in the both given permutations.

Next line contains n space-separated integers — the first permutation. Each number between 1 to n will appear in the permutation exactly once.

Next line describe the second permutation in the same format.

Output

Print a single integer denoting the minimum number of moves required to convert the first permutation to the second.

Examples

Input

3
3 2 1
1 2 3

Output

2

Input

5
1 2 3 4 5
1 5 2 3 4

Output

1

Input

5
1 5 2 3 4
1 2 3 4 5

Output

3

Note

In the first sample, he removes number 1 from end of the list and places it at the beginning. After that he takes number 2 and places it between 1 and 3.

In the second sample, he removes number 5 and inserts it after 1.

In the third sample, the sequence of changes are like this:

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

So he needs three moves.

### Response

```cpp
#include <bits/stdc++.h>
int a[1000000], b[1000000], c[1000000];
int main() {
  int n, i, j, x;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    b[x - 1] = i;
  }
  for (i = 0; i < n; i++) {
    a[i] = b[a[i]];
  }
  for (i = 1; i < n; i++) {
    if (a[i] < a[i - 1]) break;
  }
  printf("%d\n", n - i);
  return 0;
}

```


### Prompt

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

Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and travels around the network of stations in a circular manner. More precisely, the immediate station that the train will visit after station i is station i+1 if 1 ≤ i < n or station 1 if i = n. It takes the train 1 second to travel to its next station as described.

Bob gave Alice a fun task before he left: to deliver m candies that are initially at some stations to their independent destinations using the train. The candies are enumerated from 1 through m. Candy i (1 ≤ i ≤ m), now at station a_i, should be delivered to station b_i (a_i ≠ b_i).

<image> The blue numbers on the candies correspond to b_i values. The image corresponds to the 1-st example.

The train has infinite capacity, and it is possible to load off any number of candies at a station. However, only at most one candy can be loaded from a station onto the train before it leaves the station. You can choose any candy at this station. The time it takes to move the candies is negligible.

Now, Alice wonders how much time is needed for the train to deliver all candies. Your task is to find, for each station, the minimum time the train would need to deliver all the candies were it to start from there.

Input

The first line contains two space-separated integers n and m (2 ≤ n ≤ 5 000; 1 ≤ m ≤ 20 000) — the number of stations and the number of candies, respectively.

The i-th of the following m lines contains two space-separated integers a_i and b_i (1 ≤ a_i, b_i ≤ n; a_i ≠ b_i) — the station that initially contains candy i and the destination station of the candy, respectively.

Output

In the first and only line, print n space-separated integers, the i-th of which is the minimum time, in seconds, the train would need to deliver all the candies were it to start from station i.

Examples

Input

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

Output

10 9 10 10 9

Input

2 3
1 2
1 2
1 2

Output

5 6

Note

Consider the second sample.

If the train started at station 1, the optimal strategy is as follows.

  1. Load the first candy onto the train.
  2. Proceed to station 2. This step takes 1 second.
  3. Deliver the first candy.
  4. Proceed to station 1. This step takes 1 second.
  5. Load the second candy onto the train.
  6. Proceed to station 2. This step takes 1 second.
  7. Deliver the second candy.
  8. Proceed to station 1. This step takes 1 second.
  9. Load the third candy onto the train.
  10. Proceed to station 2. This step takes 1 second.
  11. Deliver the third candy.

Hence, the train needs 5 seconds to complete the tasks.

If the train were to start at station 2, however, it would need to move to station 1 before it could load the first candy, which would take one additional second. Thus, the answer in this scenario is 5+1 = 6 seconds.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[20005], b[20005];
vector<int> c[5005];
int lens[5005];
multiset<int> s;
int ans[5005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    if (b[i] < a[i]) b[i] += n;
    c[a[i]].push_back(b[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (c[i].size() == 0)
      lens[i] = 0;
    else {
      sort(c[i].begin(), c[i].end());
      lens[i] = c[i][0] + (c[i].size() - 1) * n;
    }
    s.insert(lens[i]);
  }
  for (int i = 1; i <= n; i++) {
    ans[i] = *(--s.end()) - i;
    if (lens[i] != 0) s.erase(s.find(lens[i])), s.insert(lens[i] + n);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
}

```


### Prompt

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

Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal.

Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points.

Input

The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide.

Output

First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices.

Then print k lines, each containing a pair of integer — possible coordinates of the fourth point.

Example

Input

0 0
1 0
0 1

Output

3
1 -1
-1 1
1 1

Note

If you need clarification of what parallelogram is, please check Wikipedia page:

https://en.wikipedia.org/wiki/Parallelogram

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<long long int> a;
int main() {
#pragma warning(disable : 4996)
  int x1, y1, x2, y2, x3, y3;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  cout << 3 << endl;
  cout << x1 + x2 - x3 << " " << y1 + y2 - y3 << endl;
  cout << x1 + x3 - x2 << " " << y1 + y3 - y2 << endl;
  cout << x3 + x2 - x1 << " " << y3 + y2 - y1;
  return 0;
}

```