### Prompt

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

Reforms have started in Berland again! At this time, the Parliament is discussing the reform of the calendar. To make the lives of citizens of Berland more varied, it was decided to change the calendar. As more and more people are complaining that "the years fly by...", it was decided that starting from the next year the number of days per year will begin to grow. So the coming year will have exactly a days, the next after coming year will have a + 1 days, the next one will have a + 2 days and so on. This schedule is planned for the coming n years (in the n-th year the length of the year will be equal a + n - 1 day).

No one has yet decided what will become of months. An MP Palevny made the following proposal.

  * The calendar for each month is comfortable to be printed on a square sheet of paper. We are proposed to make the number of days in each month be the square of some integer. The number of days per month should be the same for each month of any year, but may be different for different years.
  * The number of days in each year must be divisible by the number of days per month in this year. This rule ensures that the number of months in each year is an integer.
  * The number of days per month for each year must be chosen so as to save the maximum amount of paper to print the calendars. In other words, the number of days per month should be as much as possible.

These rules provide an unambiguous method for choosing the number of days in each month for any given year length. For example, according to Palevny's proposition, a year that consists of 108 days will have three months, 36 days each. The year that consists of 99 days will have 11 months, 9 days each, and a year of 365 days will have 365 months, one day each.

The proposal provoked heated discussion in the community, the famous mathematician Perelmanov quickly calculated that if the proposal is supported, then in a period of n years, beginning with the year that has a days, the country will spend p sheets of paper to print a set of calendars for these years. Perelmanov's calculations take into account the fact that the set will contain one calendar for each year and each month will be printed on a separate sheet.

Repeat Perelmanov's achievement and print the required number p. You are given positive integers a and n. Perelmanov warns you that your program should not work longer than four seconds at the maximum test.

Input

The only input line contains a pair of integers a, n (1 ≤ a, n ≤ 107; a + n - 1 ≤ 107).

Output

Print the required number p.

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

Examples

Input

25 3

Output

30

Input

50 5

Output

125

Note

A note to the first sample test. A year of 25 days will consist of one month containing 25 days. A year of 26 days will consist of 26 months, one day each. A year of 27 days will have three months, 9 days each.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long d[10000001], a, n, ans;
void imnubas() {
  for (int i = 1; i * i <= 10000000; i++) {
    int k = i * i;
    for (int j = k; j <= 10000000; j += k) d[j] = k;
  }
}
int main() {
  cin >> a >> n;
  imnubas();
  for (int i = a; i < a + n; i++) ans += i / d[i];
  cout << ans;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

"QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.

Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (Diamond is so cute!).

<image> illustration by 猫屋 https://twitter.com/nekoyaliu

Bort wants to know how many subsequences "QAQ" are in the string Diamond has given. Note that the letters "QAQ" don't have to be consecutive, but the order of letters should be exact.

Input

The only line contains a string of length n (1 ≤ n ≤ 100). It's guaranteed that the string only contains uppercase English letters.

Output

Print a single integer — the number of subsequences "QAQ" in the string.

Examples

Input

QAQAQYSYIOIWIN

Output

4

Input

QAQQQZZYNOIWIN

Output

3

Note

In the first example there are 4 subsequences "QAQ": "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string second;
  vector<char> ch{'Q', 'A', 'Q'};
  cin >> second;
  vector<vector<long long> > vec(3);
  for (long long i = 0; i < 3; i++) vec[i].resize(second.length());
  for (long long i = 0; i < 3; i++)
    for (long long j = 0; j < second.length(); j++) vec[i][j] = 0;
  for (long long i = 0; i < 3; i++) {
    for (long long j = i; j < second.length(); j++) {
      if (ch[i] == second[j] && j == 0 && i == 0)
        vec[i][j] = 1;
      else if (ch[i] == second[j] && i == 0)
        vec[i][j] = vec[i][j - 1] + 1;
      else if (ch[i] == second[j])
        vec[i][j] = vec[i][j - 1] + vec[i - 1][j];
      else if (j != 0)
        vec[i][j] = vec[i][j - 1];
    }
  }
  cout << vec[2][second.length() - 1];
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

<image>

William is hosting a party for n of his trader friends. They started a discussion on various currencies they trade, but there's an issue: not all of his trader friends like every currency. They like some currencies, but not others.

For each William's friend i it is known whether he likes currency j. There are m currencies in total. It is also known that a trader may not like more than p currencies.

Because friends need to have some common topic for discussions they need to find the largest by cardinality (possibly empty) subset of currencies, such that there are at least ⌈ n/2 ⌉ friends (rounded up) who like each currency in this subset.

Input

The first line contains three integers n, m and p (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ p ≤ m ≤ 60, 1 ≤ p ≤ 15), which is the number of trader friends, the number of currencies, the maximum number of currencies each friend can like.

Each of the next n lines contain m characters. The j-th character of i-th line is 1 if friend i likes the currency j and 0 otherwise. It is guaranteed that the number of ones in each line does not exceed p.

Output

Print a string of length m, which defines the subset of currencies of the maximum size, which are liked by at least half of all friends. Currencies belonging to this subset must be signified by the character 1.

If there are multiple answers, print any.

Examples

Input

3 4 3
1000
0110
1001

Output

1000

Input

5 5 4
11001
10101
10010
01110
11011

Output

10001

Note

In the first sample test case only the first currency is liked by at least ⌈ 3/2 ⌉ = 2 friends, therefore it's easy to demonstrate that a better answer cannot be found.

In the second sample test case the answer includes 2 currencies and will be liked by friends 1, 2, and 5. For this test case there are other currencies that are liked by at least half of the friends, but using them we cannot achieve a larger subset size.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
typedef int64_t ll;
typedef long double ld;
typedef unsigned long long ULL;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
void read(vector<int> &a) {for (auto &x : a)cin >> x;}
void read(vector<ll> &a) {for (auto &x : a)cin >> x;}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c * x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
    eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = 1e9 + 7;
const int INF = (int)2e9 + 7;
const ll LINF = (ll)1e18;
const ld PI = 3.1415926535897932384626433832795;

void solve() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        ll x = 0;
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            if (s[j] == '1')
                x |= (1ll << (m - 1 - j));
        }
        v[i] = x;
    }
    ll mxb = 0, ans = 0;
    for (int turns = 0; turns < 20; turns++) {
        int pos = rng() % n;
        vector<int> sb;
        for (int i = 0; i < m; i++) {
            if (((1ll << i) & v[pos])) {
                sb.pb(i);
            }
        }
        vector<int> cmp((1 << (int)sb.size()), 0);
        for (int i = 0; i < n; i++) {
            int x = 0;
            for (int j = 0; j < (int)sb.size(); j++) {
                if (((1ll << sb[j]) & v[i])) {
                    x |= (1 << j);
                }
            }
            cmp[x]++;
        }
        for (int i = 0; i < sb.size(); i++) {
            for (int k = 0; k < (1 << (int)sb.size()); k++) {
                if (k & (1 << i)) {
                    cmp[k ^ (1 << i)] += cmp[k];
                }
            }
        }
        //debug() << imie(cmp);
        for (int i = 1; i < (1 << (int)sb.size()); i++) {
            if (cmp[i] >= (n + 1) / 2) {
                if (__builtin_popcount(i) > mxb) {
                    mxb = __builtin_popcount(i);
                    ans = 0;
                    for (int j = 0; j < (int)sb.size(); j++) {
                        if (((1 << j) & i)) {
                            ans |= (1ll << sb[j]);
                        }
                    }
                }
            }
        }
    }
    for (int i = m - 1; i >= 0; i--) {
        if (((1ll << i) & ans))
            cout << 1;
        else
            cout << 0;
    }
}

int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    auto t1 = high_resolution_clock::now();
    for (int tt = 1; tt <= t; tt++)
    {
        //cout << "Case #" << tt << ": ";
        solve();
    }
    auto t2 = high_resolution_clock::now();
    auto time = duration_cast<duration<double>>(t2 - t1);
    cerr << "Time elapsed = " << time.count() << endl;
}

```


### Prompt

Generate a cpp solution to the following problem:

You are given two integers n and k.

You need to construct k regular polygons having same [circumcircle](https://en.wikipedia.org/wiki/Circumscribed_circle), with distinct number of sides l between 3 and n.

<image> Illustration for the first example.

You can rotate them to minimize the total number of distinct points on the circle. Find the minimum number of such points.

Input

The only line of input contains two integers n and k (3 ≤ n ≤ 10^{6}, 1 ≤ k ≤ n-2), the maximum number of sides of a polygon and the number of polygons to construct, respectively.

Output

Print a single integer — the minimum number of points required for k polygons.

Examples

Input

6 2

Output

6

Input

200 50

Output

708

Note

In the first example, we have n = 6 and k = 2. So, we have 4 polygons with number of sides 3, 4, 5 and 6 to choose from and if we choose the triangle and the hexagon, then we can arrange them as shown in the picture in the statement.

Hence, the minimum number of points required on the circle is 6, which is also the minimum overall possible sets.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int inf = 1e9;
int mod = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int phi[n + 1];
  phi[1] = 1;
  bool marked[n + 1];
  memset(marked, false, sizeof(marked));
  for (int i = 1; i <= n; i++) {
    phi[i] = i;
  }
  for (int i = 2; i <= n; i++) {
    if (!marked[i]) {
      for (int j = i; j <= n; j += i) {
        phi[j] /= i;
        phi[j] *= (i - 1);
        marked[j] = true;
      }
    }
  }
  sort(phi + 1, phi + n + 1);
  if (k == 1) {
    cout << "3\n";
    return 0;
  }
  long long int L = 0;
  for (int i = 1; i <= k + 2; i++) {
    L += phi[i];
  }
  cout << L << "\n";
  return 0;
}

```


### Prompt

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

Monocarp would like to open a bakery in his local area. But, at first, he should figure out whether he can compete with other shops.

Monocarp plans that the bakery will work for n days. On the i-th day, a_i loaves of bread will be baked in the morning before the opening. At the end of the n-th day, Monocarp will sell all the remaining bread that wasn't sold earlier with a huge discount.

Because of how bread is stored, the bakery seller sells the bread in the following order: firstly, he sells the loaves that were baked that morning; secondly, he sells the loaves that were baked the day before and weren't sold yet; then the loaves that were baked two days before and weren't sold yet, and so on. That's why some customers may buy a rather stale bread and will definitely spread negative rumors.

Let's define loaf spoilage as the difference between the day it was baked and the day it was sold. Then the unattractiveness of the bakery will be equal to the maximum spoilage among all loaves of bread baked at the bakery.

Suppose Monocarp's local area has consumer demand equal to k, it means that each day k customers will come to the bakery and each of them will ask for one loaf of bread (the loaves are sold according to the aforementioned order). If there is no bread left, then the person just doesn't buy anything. During the last day sale, all the remaining loaves will be sold (and they will still count in the calculation of the unattractiveness).

Monocarp analyzed his competitors' data and came up with m possible consumer demand values k_1, k_2, ..., k_m, and now he'd like to calculate the unattractiveness of the bakery for each value of demand. Can you help him?

Input

The first line contains two integers n and m (1 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ m ≤ 2 ⋅ 10^5) — the number of days the bakery is open and the number of possible values of consumer demand.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the number of bread loaves that will be baked each day.

The third line contains m integers k_1, k_2, ..., k_m (1 ≤ k_1 < k_2 < ... < k_m ≤ 10^9) — the possible consumer demand values in the ascending order.

Output

Print m integers: for each consumer demand, print the unattractiveness of the bakery.

Examples

Input

5 4
5 2 1 3 7
1 3 4 10

Output

4 2 1 0

Input

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

Output

7 5 3 3 2 1 1 1 0

Note

In the first example, let's describe what happens for couple consumer demands:

If consumer demand is equal to 1:

  * at day 1: 5 loaves are baked and only 1 is sold with spoilage equal to 1 - 1 = 0;
  * at day 2: 4 loaves are left and 2 more are baked. Only 1 loaf was sold and it was the loaf baked today with spoilage 2 - 2 = 0;
  * at day 3: 4 loaves from the first day and 1 loaf from the second day left. One more loaf was baked and was sold this day with spoilage 3 - 3 = 0;
  * at day 4: 4 loaves from the first day and 1 loaf from the second day left. 3 more loaves were baked and one of them was sold this day with spoilage 4 - 4 = 0;
  * at day 5: 4 loaves from the first day, 1 loaf from the second day and 2 loaves from the fourth day left. 7 more loaves were baked and, since it's the last day, all 14 loaves were sold. 4 loaves from the first day have the maximum spoilage equal to 5 - 1 = 4.

In total, the unattractiveness of the bakery will be equal to 4.

If consumer demand is equal to 10 then all baked bread will be sold in the day it was baked and will have spoilage equal to 0.

### Response

```cpp
/*
Author: QAQAutomaton
Lang: C++
Code: B.cpp
Mail: lk@qaq-am.com
Blog: https://www.qaq-am.com/
*/
#include<bits/stdc++.h>
#define int long long
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
#define x first
#define y second
using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cp;
typedef pair<int,int> pii;
int inf;
const double eps=1e-8;
const double pi=acos(-1.0);
template<class T,class T2>int chkmin(T &a,T2 b){return a>b?a=b,1:0;}
template<class T,class T2>int chkmax(T &a,T2 b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T,class T2>T mmin(T a,T2 b){return a<b?a:b;}
template<class T,class T2>T mmax(T a,T2 b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
template<class T>int dcmp(T a,T b){return a>b;}
template<int *a>int cmp_a(int x,int y){return a[x]<a[y];}
#define min mmin
#define max mmax
#define abs aabs
struct __INIT__{
	__INIT__(){
		fill((unsigned char *)(&inf),(unsigned char *)(&inf)+sizeof(inf),0x3f);
	}
}__INIT___;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	template<typename A>
	inline bool read (A &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
		return 1;
	}
	inline bool read (char &x) {
		while((x=gc())==' '||x=='\n' || x=='\r');
		return x!=EOF;
	}
	inline bool read(char *x){
		while((*x=gc())=='\n' || *x==' '||*x=='\r');
		if(*x==EOF)return 0;
		while(!(*x=='\n'||*x==' '||*x=='\r'||*x==EOF))*(++x)=gc();
		*x=0;
		return 1;
	}
	template<typename A,typename ...B>
	inline bool read(A &x,B &...y){
		return read(x)&&read(y...);
	}
	template<typename A>
	inline bool write (A x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
		return 0;
	}
	inline bool write (char x) {
		putc(x);
		return 0;
	}
	inline bool write(const char *x){
		while(*x){putc(*x);++x;}
		return 0;
	}
	inline bool write(char *x){
		while(*x){putc(*x);++x;}
		return 0;
	}
	template<typename A,typename ...B>
	inline bool write(A x,B ...y){
		return write(x)||write(y...);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: write;
int a[200005];
pii stk[200005];
int t;
pii req[200005];

multiset<int> xst;
set<int> st;
void Ins(int x){
	auto it=st.lower_bound(x);
	int r=*it;
	int l=*(--it);
	xst.erase(xst.lower_bound(r-l));
	xst.insert(r-x);
	xst.insert(x-l);
	st.insert(x);
}
signed main(){
#ifdef QAQAutoMaton
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
	int n,m;
	read(n,m);
	for(int i=1;i<=n;++i){
		read(a[i]);
		a[i]+=a[i-1];
	}
	stk[t=1]={0,0};
	for(int i=1;i<n;++i){
		while(t>=2 && (__int128)(a[i]-stk[t].y)*(i-stk[t-1].x)<=(__int128)(a[i]-stk[t-1].y)*(i-stk[t].x))--t;
		req[i]={(a[i]-stk[t].y-1)/(i-stk[t].x)+1,i};
		stk[++t]={i,a[i]};
		//write(a[i],' ',req[i].x,'\n');
	}
	req[n]={inf,0};
	sort(req+1,req+n);
	st.insert(0);st.insert(n);
	xst.insert(n);
	int at=1;
	for(;m;--m){
		int v;
		read(v);
		while(v>=req[at].x){
			Ins(req[at].y);
			++at;
		}
		write(*xst.rbegin()-1,m==1?'\n':' ');
	}
	return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!

Sonya is an owl and she sleeps during the day and stay awake from minute l1 to minute r1 inclusive. Also, during the minute k she prinks and is unavailable for Filya.

Filya works a lot and he plans to visit Sonya from minute l2 to minute r2 inclusive.

Calculate the number of minutes they will be able to spend together.

Input

The only line of the input contains integers l1, r1, l2, r2 and k (1 ≤ l1, r1, l2, r2, k ≤ 1018, l1 ≤ r1, l2 ≤ r2), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks.

Output

Print one integer — the number of minutes Sonya and Filya will be able to spend together.

Examples

Input

1 10 9 20 1

Output

2

Input

1 100 50 200 75

Output

50

Note

In the first sample, they will be together during minutes 9 and 10.

In the second sample, they will be together from minute 50 to minute 74 and from minute 76 to minute 100.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  l1 = max(l1, l2);
  r1 = min(r1, r2);
  long long ans = r1 - l1 + 1;
  if (ans < 0) ans = 0;
  if (k >= l1 && k <= r1) ans--;
  cout << ans;
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges.

Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex 1 to any other vertex is at most 2. Note that you are not allowed to add loops and multiple edges.

Input

The first line contains one integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of vertices in the tree.

The following n - 1 lines contain edges: edge i is given as a pair of vertices u_i, v_i (1 ≤ u_i, v_i ≤ n). It is guaranteed that the given edges form a tree. It is guaranteed that there are no loops and multiple edges in the given edges.

Output

Print a single integer — the minimum number of edges you have to add in order to make the shortest distance from the vertex 1 to any other vertex at most 2. Note that you are not allowed to add loops and multiple edges.

Examples

Input

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

Output

2

Input

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

Output

0

Input

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

Output

1

Note

The tree corresponding to the first example: <image> The answer is 2, some of the possible answers are the following: [(1, 5), (1, 6)], [(1, 4), (1, 7)], [(1, 6), (1, 7)].

The tree corresponding to the second example: <image> The answer is 0.

The tree corresponding to the third example: <image> The answer is 1, only one possible way to reach it is to add the edge (1, 3).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 200005;
vector<int> g[maxn];
int deg[maxn], dep[maxn], tag[maxn], f[maxn];
void dfs(int u, int fa) {
  if (dep[u] <= 2) tag[u] = 1;
  for (int v : g[u]) {
    if (v == fa) continue;
    dep[v] = dep[u] + 1;
    deg[u]++;
    dfs(v, u);
    f[v] = u;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  int ans = 0;
  queue<int> q;
  for (int i = 1; i <= n; ++i)
    if (!deg[i]) q.push(i);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    if (tag[cur] == 2) {
      tag[f[cur]] = max(tag[f[cur]], 1);
    } else if (tag[cur] == 0) {
      if (tag[f[cur]] != 2) {
        tag[f[cur]] = 2;
        ++ans;
      }
    }
    if (--deg[f[cur]] == 0) {
      q.push(f[cur]);
    }
  }
  cout << ans << endl;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Vasya and Petya are using an interesting data storing structure: a pyramid.

The pyramid consists of n rows, the i-th row contains i cells. Each row is shifted half a cell to the left relative to the previous row. The cells are numbered by integers from 1 to <image> as shown on the picture below.

An example of a pyramid at n = 5 is:

<image>

This data structure can perform operations of two types:

  1. Change the value of a specific cell. It is described by three integers: "t i v", where t = 1 (the type of operation), i — the number of the cell to change and v the value to assign to the cell.
  2. Change the value of some subpyramid. The picture shows a highlighted subpyramid with the top in cell 5. It is described by s + 2 numbers: "t i v1 v2 ... vs", where t = 2, i — the number of the top cell of the pyramid, s — the size of the subpyramid (the number of cells it has), vj — the value you should assign to the j-th cell of the subpyramid.

Formally: a subpyramid with top at the i-th cell of the k-th row (the 5-th cell is the second cell of the third row) will contain cells from rows from k to n, the (k + p)-th row contains cells from the i-th to the (i + p)-th (0 ≤ p ≤ n - k).

Vasya and Petya had two identical pyramids. Vasya changed some cells in his pyramid and he now wants to send his changes to Petya. For that, he wants to find a sequence of operations at which Petya can repeat all Vasya's changes. Among all possible sequences, Vasya has to pick the minimum one (the one that contains the fewest numbers).

You have a pyramid of n rows with k changed cells. Find the sequence of operations which result in each of the k changed cells being changed by at least one operation. Among all the possible sequences pick the one that contains the fewest numbers.

Input

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

The next k lines contain the coordinates of the modified cells ri and ci (1 ≤ ci ≤ ri ≤ n) — the row and the cell's number in the row. All cells are distinct.

Output

Print a single number showing how many numbers the final sequence has.

Examples

Input

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

Output

10

Input

7 11
2 2
3 1
4 3
5 1
5 2
5 5
6 4
7 2
7 3
7 4
7 5

Output

26

Note

One of the possible solutions of the first sample consists of two operations:

2 4 v4 v7 v8

2 6 v6 v9 v10

The picture shows the changed cells color-highlighted. The subpyramid used by the first operation is highlighted blue and the subpyramid used by the first operation is highlighted yellow:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int Enum(int a, int b) { return a * 100002 + b; }
const int oo = 1000000000;
int n, k;
pair<int, int> in[100005];
bitset<780 * 100005> B;
int main() {
  scanf("%d%d", &n, &k);
  int R = 0;
  for (int i = (int)(0); i < (int)(k); ++i) {
    scanf("%d%d", &in[i].first, &in[i].second);
    int r = n + 1 - in[i].first;
    if (r > 775)
      R += 3;
    else {
      --r;
      --in[i].second;
      int t = Enum(r, in[i].second);
      B[t] = 1;
    }
  }
  vector<int> V1(776);
  for (int c = n - 1; c >= 0; --c) {
    vector<int> V2(776);
    int Tmp = oo;
    int Cnt = 0;
    for (int r = 775; r >= 0; --r) {
      if (r == 0) {
        V2[0] = min(Tmp, Cnt * 3 + V1[0]);
      } else {
        V2[r] = min(Tmp, Cnt * 3 + V1[r - 1]);
        Cnt += B[Enum(r - 1, c)];
      }
      Tmp = min(Tmp, V2[r] + r * (r + 1) / 2 + 2);
    }
    swap(V1, V2);
  }
  printf("%d\n", R + V1[0]);
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.

Alice initially has a token on some cell on the line, and Bob tries to guess where it is.

Bob guesses a sequence of line cell numbers x_1, x_2, …, x_k in order. In the i-th question, Bob asks Alice if her token is currently on cell x_i. That is, Alice can answer either "YES" or "NO" to each Bob's question.

At most one time in this process, before or after answering a question, Alice is allowed to move her token from her current cell to some adjacent cell. Alice acted in such a way that she was able to answer "NO" to all of Bob's questions.

Note that Alice can even move her token before answering the first question or after answering the last question. Alice can also choose to not move at all.

You are given n and Bob's questions x_1, …, x_k. You would like to count the number of scenarios that let Alice answer "NO" to all of Bob's questions.

Let (a,b) denote a scenario where Alice starts at cell a and ends at cell b. Two scenarios (a_i, b_i) and (a_j, b_j) are different if a_i ≠ a_j or b_i ≠ b_j.

Input

The first line contains two integers n and k (1 ≤ n,k ≤ 10^5) — the number of cells and the number of questions Bob asked.

The second line contains k integers x_1, x_2, …, x_k (1 ≤ x_i ≤ n) — Bob's questions.

Output

Print a single integer, the number of scenarios that let Alice answer "NO" to all of Bob's questions.

Examples

Input

5 3
5 1 4

Output

9

Input

4 8
1 2 3 4 4 3 2 1

Output

0

Input

100000 1
42

Output

299997

Note

The notation (i,j) denotes a scenario where Alice starts at cell i and ends at cell j.

In the first example, the valid scenarios are (1, 2), (2, 1), (2, 2), (2, 3), (3, 2), (3, 3), (3, 4), (4, 3), (4, 5). For example, (3,4) is valid since Alice can start at cell 3, stay there for the first three questions, then move to cell 4 after the last question.

(4,5) is valid since Alice can start at cell 4, stay there for the first question, the move to cell 5 for the next two questions. Note that (4,5) is only counted once, even though there are different questions that Alice can choose to do the move, but remember, we only count each pair of starting and ending positions once.

In the second example, Alice has no valid scenarios.

In the last example, all (i,j) where |i-j| ≤ 1 except for (42, 42) are valid scenarios.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int inf = 1 << 30;
int f[maxn], s[maxn];
long long check(int x, int y) { return (s[y] < f[x]) ? 1LL : 0LL; }
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < maxn; i++) {
    f[i] = inf;
    s[i] = -1;
  }
  memset(s, -1, sizeof s);
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    f[x] = min(f[x], i);
    s[x] = i;
  }
  long long ans = 0LL;
  for (int i = 1; i <= n; i++) {
    if (i > 1) {
      ans += check(i, i - 1);
    }
    ans += check(i, i);
    if (i < n) {
      ans += check(i, i + 1);
    }
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

In 2215 A.D., a war between two planets, ACM and ICPC, is being more and more intense.

ACM introduced new combat planes. These planes have a special system that is called Graze, and fighting power of a plane increases when it is close to energy bullets that ICPC combat planes shoot.

Both combat planes and energy bullets have a shape of a sphere with a radius of R. Precisely, fighting power of a plane is equivalent to the number of energy bullet where distance from the plane is less than or equals to 2R.

You, helper of captain of intelligence units, are asked to analyze a war situation. The information given to you is coordinates of AN combat planes and BN energy bullets. Additionally, you know following things:

* All combat planes and energy bullet has same z-coordinates. In other word, z-coordinate can be ignored.
* No two combat planes, no two energy bullets, and no pair of combat plane and energy bullet collide (i.e. have positive common volume) each other.

Your task is to write a program that outputs total fighting power of all combat planes.

Constraints

* Jude data includes at most 20 data sets.
* 1 ≤ AN, BN ≤ 100000
* 0 < R ≤ 10
* 0 ≤ (coordinate values) < 10000

Input

Input file consists of a number of data sets. One data set is given in following format:

AN BN R
XA1 YA1
XA2 YA2
:
XAAN YAAN
XB1 YB1
XB2 YB2
:
XBBN YBBN

AN, BN, R are integers that describe the number of combat planes, energy bullets, and their radius respectively.

Following AN lines indicate coordinates of the center of combat planes. Each line has two integers that describe x-coordinate and y-coordinate.

Following BN lines indicate coordinates of the center of energy bullets, in the same format as that of combat planes.

Input ends when AN = BN = 0. You should output nothing for this case.

Output

For each data set, output the total fighting power.

Example

Input

2 2 1
0 0
0 4
2 2
2 8
0 0 0

Output

2

### Response

```cpp
//32
#include<iostream>
#include<vector>
#include<utility>

using namespace std;

typedef pair<int,int> pii;

#define S(X) ((X)*(X))

int main(){
  for(int a,b,r;cin>>a>>b>>r,a|b|r;){
    int x[100000],y[100000];
    for(int i=0;i<a;i++){
      cin>>x[i]>>y[i];
    }
    vector<pii> v[250][250];
    for(int i=0;i<b;i++){
      int xb,yb;
      cin>>xb>>yb;
      v[yb/40][xb/40].push_back(pii(yb,xb));
    }
    int s=0;
    for(int i=0;i<a;i++){
      int yy=y[i]/40,xx=x[i]/40;
      for(int j=-1;j<=1;j++){
	for(int k=-1;k<=1;k++){
	  int yt=yy+j,xt=xx+k;
	  if(0<=yt&&yt<250&&0<=xt&&xt<250){
	    for(int l=0;l<v[yt][xt].size();l++){
	      s+=S(y[i]-v[yt][xt][l].first)+S(x[i]-v[yt][xt][l].second)<=S(4*r);
	    }
	  }
	}
      }
    }
    cout<<s<<endl;
  }
  return 0;
}
```


### Prompt

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

While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not necessarily distinct. Then he picked some sequence f1, f2, ..., fn of length n and for each number ai got number bi = fai. To finish the prank he erased the initial sequence ai.

It's hard to express how sad Patrick was when he returned home from shopping! We will just say that Spongebob immediately got really sorry about what he has done and he is now trying to restore the original sequence. Help him do this or determine that this is impossible.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100 000) — the lengths of sequences fi and bi respectively.

The second line contains n integers, determining sequence f1, f2, ..., fn (1 ≤ fi ≤ n).

The last line contains m integers, determining sequence b1, b2, ..., bm (1 ≤ bi ≤ n).

Output

Print "Possible" if there is exactly one sequence ai, such that bi = fai for all i from 1 to m. Then print m integers a1, a2, ..., am.

If there are multiple suitable sequences ai, print "Ambiguity".

If Spongebob has made a mistake in his calculations and no suitable sequence ai exists, print "Impossible".

Examples

Input

3 3
3 2 1
1 2 3

Output

Possible
3 2 1

Input

3 3
1 1 1
1 1 1

Output

Ambiguity

Input

3 3
1 2 1
3 3 3

Output

Impossible

Note

In the first sample 3 is replaced by 1 and vice versa, while 2 never changes. The answer exists and is unique.

In the second sample all numbers are replaced by 1, so it is impossible to unambiguously restore the original sequence.

In the third sample fi ≠ 3 for all i, so no sequence ai transforms into such bi and we can say for sure that Spongebob has made a mistake.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000100;
const int INF = (1 << 29);
const double EPS = 1e-13;
const double Pi = acos(-1.0);
int n, m;
long long f[maxn], b[maxn], F[maxn];
long long a[maxn];
int main() {
  while (cin >> n >> m) {
    memset(F, -1, sizeof(F));
    for (int i = 1; i <= n; i++) {
      scanf("%I64d", &f[i]);
      if (F[f[i]] == -1)
        F[f[i]] = i;
      else
        F[f[i]] = -2;
    }
    for (int i = 1; i <= m; i++) scanf("%I64d", &b[i]);
    int flag = 0;
    for (int i = 1; i <= m; i++) {
      if (F[b[i]] == -2) {
        flag = 2;
        break;
      } else
        a[i] = F[b[i]];
    }
    for (int i = 1; i <= m; i++) {
      if (F[b[i]] == -1) {
        flag = -1;
        break;
      } else
        a[i] = F[b[i]];
    }
    if (!flag) {
      puts("Possible");
      for (int i = 1; i <= m; i++) {
        if (i != m)
          printf("%d ", a[i]);
        else
          printf("%d\n", a[i]);
      }
    } else if (flag == 2)
      puts("Ambiguity");
    else
      puts("Impossible");
  }
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers represents how many groups of black squares there are in corresponding row or column, and the integers themselves represents the number of consecutive black squares in corresponding group (you can find more detailed explanation in Wikipedia <https://en.wikipedia.org/wiki/Japanese_crossword>).

Adaltik decided that the general case of japanese crossword is too complicated and drew a row consisting of n squares (e.g. japanese crossword sized 1 × n), which he wants to encrypt in the same way as in japanese crossword.

<image> The example of encrypting of a single row of japanese crossword.

Help Adaltik find the numbers encrypting the row he drew.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the length of the row. The second line of the input contains a single string consisting of n characters 'B' or 'W', ('B' corresponds to black square, 'W' — to white square in the row that Adaltik drew).

Output

The first line should contain a single integer k — the number of integers encrypting the row, e.g. the number of groups of black squares in the row.

The second line should contain k integers, encrypting the row, e.g. corresponding to sizes of groups of consecutive black squares in the order from left to right.

Examples

Input

3
BBW

Output

1
2

Input

5
BWBWB

Output

3
1 1 1

Input

4
WWWW

Output

0

Input

4
BBBB

Output

1
4

Input

13
WBBBBWWBWBBBW

Output

3
4 1 3

Note

The last sample case correspond to the picture in the statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int MX = 1e6 + 6;
void solve() {
  vector<int> ans;
  int n;
  string s;
  cin >> n >> s;
  int ln = 1;
  if (s[0] == 'B' and n == 1) {
    cout << 1 << "\n" << 1;
    return;
  }
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == 'B') {
      if (s[i + 1] == 'B') {
        ln++;
      } else {
        ans.push_back(ln);
        ln = 1;
      }
    } else {
      if (s[i + 1] == 'B' and i + 2 == n) {
        ans.push_back(1);
      }
    }
  }
  if (ln > 1) {
    ans.push_back(ln);
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << " ";
  }
}
int main() {
  solve();
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

There are N cells arranged in a row, numbered 1, 2, \ldots, N from left to right.

Tak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.

You are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \ldots, [L_K, R_K]. Let S be the union of these K segments. Here, the segment [l, r] denotes the set consisting of all integers i that satisfy l \leq i \leq r.

* When you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.

To help Tak, find the number of ways to go to Cell N, modulo 998244353.

Constraints

* 2 \leq N \leq 2 \times 10^5
* 1 \leq K \leq \min(N, 10)
* 1 \leq L_i \leq R_i \leq N
* [L_i, R_i] and [L_j, R_j] do not intersect (i \neq j)
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
L_1 R_1
L_2 R_2
:
L_K R_K

Output

Print the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.

Examples

Input

5 2
1 1
3 4

Output

4

Input

5 2
3 3
5 5

Output

0

Input

5 1
1 2

Output

5

Input

60 3
5 8
1 3
10 15

Output

221823067

### Response

```cpp
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=2e5;
const int mod=998244353;
int n,k;
struct Seq{
	int l,r;
}a[15];
ll f[maxn+5],sf[maxn+5];
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++)
		scanf("%d %d",&a[i].l,&a[i].r);
	f[1]=sf[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(a[j].l>=i) continue;
			if(a[j].r>=i) f[i]=((f[i]+sf[i-a[j].l])%mod-sf[0]+mod)%mod;
			else f[i]=((f[i]+sf[i-a[j].l])%mod-sf[i-a[j].r-1]+mod)%mod;
		}
		sf[i]=(sf[i-1]+f[i])%mod;
	}
	printf("%lld\n",f[n]);
	return 0;
}

```


### Prompt

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

Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high.

At the beginning of the first experiment there is a single bacterium in the test tube. Every second each bacterium in the test tube divides itself into k bacteria. After that some abnormal effects create b more bacteria in the test tube. Thus, if at the beginning of some second the test tube had x bacteria, then at the end of the second it will have kx + b bacteria.

The experiment showed that after n seconds there were exactly z bacteria and the experiment ended at this point.

For the second experiment Qwerty is going to sterilize the test tube and put there t bacteria. He hasn't started the experiment yet but he already wonders, how many seconds he will need to grow at least z bacteria. The ranger thinks that the bacteria will divide by the same rule as in the first experiment.

Help Qwerty and find the minimum number of seconds needed to get a tube with at least z bacteria in the second experiment.

Input

The first line contains four space-separated integers k, b, n and t (1 ≤ k, b, n, t ≤ 106) — the parameters of bacterial growth, the time Qwerty needed to grow z bacteria in the first experiment and the initial number of bacteria in the second experiment, correspondingly.

Output

Print a single number — the minimum number of seconds Qwerty needs to grow at least z bacteria in the tube.

Examples

Input

3 1 3 5

Output

2

Input

1 4 4 7

Output

3

Input

2 2 4 100

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long k, b, n, t, x = 1;
  cin >> k >> b >> n >> t;
  long long cnt = 0;
  while (k * x + b <= t) {
    cnt++;
    x = k * x + b;
  }
  cout << ((n - cnt > 0) ? n - cnt : 0) << "\n";
  return 0;
}

```


### Prompt

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

Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).

Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.

Input

The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.

Output

Print a single integer, the minimum amount of lost milk.

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

Examples

Input

4
0 0 1 0

Output

1

Input

5
1 0 1 0 1

Output

3

Note

In the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a[200000], k = 0;
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int z = 0, c = 0;
  long long int zer[200000];
  for (long long int i = n - 1; i >= 0; i--) {
    if (a[i] == 1) {
      zer[k++] = z;
    } else
      z++;
  }
  for (long long int i = 0; i < k; i++) {
    c += zer[i];
  }
  cout << c;
  return 0;
}

```


### Prompt

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

During the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.

Standing in a queue that isn't being served is so boring! So, each of the students wrote down the number of the student ID of the student that stands in line directly in front of him, and the student that stands in line directly behind him. If no one stands before or after a student (that is, he is the first one or the last one), then he writes down number 0 instead (in Berland State University student IDs are numerated from 1).

After that, all the students went about their business. When they returned, they found out that restoring the queue is not such an easy task.

Help the students to restore the state of the queue by the numbers of the student ID's of their neighbors in the queue.

Input

The first line contains integer n (2 ≤ n ≤ 2·105) — the number of students in the queue.

Then n lines follow, i-th line contains the pair of integers ai, bi (0 ≤ ai, bi ≤ 106), where ai is the ID number of a person in front of a student and bi is the ID number of a person behind a student. The lines are given in the arbitrary order. Value 0 is given instead of a neighbor's ID number if the neighbor doesn't exist.

The ID numbers of all students are distinct. It is guaranteed that the records correspond too the queue where all the students stand in some order.

Output

Print a sequence of n integers x1, x2, ..., xn — the sequence of ID numbers of all the students in the order they go in the queue from the first student to the last one.

Examples

Input

4
92 31
0 7
31 0
7 141

Output

92 7 31 141

Note

The picture illustrates the queue for the first sample.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[1000005], b[1000005];
int v[1000005];
int ans[1000005];
int main() {
  int n, i, x, y;
  scanf("%d", &n);
  memset(v, 0, sizeof(v));
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    a[x] = y;
    b[y] = x;
    v[x] = 1;
    v[y] = 1;
  }
  int t = a[0];
  for (i = 2;; i += 2) {
    ans[i] = t;
    v[t] = 0;
    if (a[t] == 0) break;
    t = a[t];
  }
  for (i = 1; i <= 1000000; i++) {
    if (v[i]) break;
  }
  t = i;
  while (b[t] != 0) {
    t = b[t];
  }
  for (i = 1;; i += 2) {
    ans[i] = t;
    if (a[t] == 0) break;
    t = a[t];
  }
  for (i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:

The track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track.

Her friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively.

<image> Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7].

There are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks.

Write the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above.

Input

The first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length.

The second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.

The second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.

Output

Print "YES" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print "NO" (without quotes).

Examples

Input

3 8
2 4 6
1 5 7

Output

YES

Input

4 9
2 3 5 8
0 1 3 6

Output

YES

Input

2 4
1 3
1 2

Output

NO

Note

The first test is analyzed in the statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace std;
const double pi = acos(-1.0);
int n, l;
int input[2][50];
int a[2][50];
bool solve() {
  for (int i = 0; i < n; ++i) {
    bool work = true;
    for (int j = 0; j < n; ++j)
      if (a[0][(i + j) % n] != a[1][j]) {
        work = false;
        break;
      }
    if (work) return true;
  }
  return false;
}
int main() {
  cin >> n >> l;
  for (long long(i) = (0); (i) < (2); ++(i))
    for (long long(j) = (0); (j) < (n); ++(j)) cin >> input[i][j];
  for (long long(i) = (0); (i) < (2); ++(i))
    for (long long(j) = (0); (j) < (n); ++(j))
      a[i][j] = (l + input[i][(j + 1) % n] - input[i][j]) % l;
  cout << (solve() ? "YES" : "NO") << '\n';
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given n positive integers a_1, …, a_n, and an integer k ≥ 2. Count the number of pairs i, j such that 1 ≤ i < j ≤ n, and there exists an integer x such that a_i ⋅ a_j = x^k.

Input

The first line contains two integers n and k (2 ≤ n ≤ 10^5, 2 ≤ k ≤ 100).

The second line contains n integers a_1, …, a_n (1 ≤ a_i ≤ 10^5).

Output

Print a single integer — the number of suitable pairs.

Example

Input

6 3
1 3 9 8 24 1

Output

5

Note

In the sample case, the suitable pairs are:

  * a_1 ⋅ a_4 = 8 = 2^3;
  * a_1 ⋅ a_6 = 1 = 1^3;
  * a_2 ⋅ a_3 = 27 = 3^3;
  * a_3 ⋅ a_5 = 216 = 6^3;
  * a_4 ⋅ a_6 = 8 = 2^3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const long long mod = 998244353;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, k;
map<unsigned long long, int> mp;
int prime[100005], cnt, f[100005];
unsigned long long bin[100005 / 3][104];
bool vis[100005];
long long ans;
unsigned long long get_now(int x) {
  unsigned long long ans = 1;
  while (x != 1) {
    int now = 0, p = f[x];
    while (x % prime[p] == 0) now++, x /= prime[p];
    now = now % k;
    ans = ans * bin[p][now];
  }
  return ans;
}
unsigned long long get_nxt(int x) {
  unsigned long long ans = 1;
  while (x != 1) {
    int now = 0, p = f[x];
    while (x % prime[p] == 0) now++, x /= prime[p];
    now = (now - 1) % k + 1;
    now = k - now;
    ans = ans * bin[p][now];
  }
  return ans;
}
int main() {
  int i, j, x;
  for (i = 2; i <= 100000; i++) {
    if (!vis[i]) {
      prime[++cnt] = i, f[i] = cnt;
      bin[cnt][0] = 1;
      for (j = 1; j <= 100; j++) bin[cnt][j] = bin[cnt][j - 1] * prime[cnt];
    }
    for (j = 1; j <= cnt && prime[j] * i <= 100000; j++) {
      vis[prime[j] * i] = 1;
      f[prime[j] * i] = f[i];
      if (i % prime[j] == 0) break;
    }
  }
  n = read(), k = read();
  for (i = 1; i <= n; i++) {
    x = read();
    unsigned long long now = get_now(x), nxt = get_nxt(x);
    ans += mp[nxt];
    mp[now]++;
  }
  printf("%lld\n", ans);
  return 0;
}

```


### Prompt

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

The round carousel consists of n figures of animals. Figures are numbered from 1 to n in order of the carousel moving. Thus, after the n-th figure the figure with the number 1 follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger and so on). The type of animal of the i-th figure equals t_i.

<image> The example of the carousel for n=9 and t=[5, 5, 1, 15, 1, 5, 5, 1, 1].

You want to color each figure in one of the colors. You think that it's boring if the carousel contains two different figures (with the distinct types of animals) going one right after another and colored in the same color.

Your task is to color the figures in such a way that the number of distinct colors used is the minimum possible and there are no figures of the different types going one right after another and colored in the same color. If you use exactly k distinct colors, then the colors of figures should be denoted with integers from 1 to k.

Input

The input contains one or more test cases.

The first line contains one integer q (1 ≤ q ≤ 10^4) — the number of test cases in the test. Then q test cases follow. One test case is given on two lines.

The first line of the test case contains one integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of figures in the carousel. Figures are numbered from 1 to n in order of carousel moving. Assume that after the n-th figure the figure 1 goes.

The second line of the test case contains n integers t_1, t_2, ..., t_n (1 ≤ t_i ≤ 2 ⋅ 10^5), where t_i is the type of the animal of the i-th figure.

The sum of n over all test cases does not exceed 2⋅10^5.

Output

Print q answers, for each test case print two lines.

In the first line print one integer k — the minimum possible number of distinct colors of figures.

In the second line print n integers c_1, c_2, ..., c_n (1 ≤ c_i ≤ k), where c_i is the color of the i-th figure. If there are several answers, you can print any.

Example

Input

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

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int M = 1e9 + 7;
const long double dinf = 0x3f3f3f3f3f3f3f3f;
int a[maxn], b[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int t = 1;
    for (int i = (0); i < (n); i++) {
      cin >> a[i];
    }
    int f = 0;
    int k = 0;
    int ff = 0;
    for (int i = (0); i < (n); i++) {
      int r = (i + 1) % n;
      if (a[i] == a[r]) {
        k = r;
        ff = 1;
      }
      if (a[i] != a[r]) {
        f = 1;
      }
    }
    if (!f) {
      t = 1;
      for (int i = (0); i < (n); i++) b[i] = 1;
    } else if (!ff && n % 2 != 0) {
      t = b[0] = 3;
      for (int i = (1); i < (n); i++) b[i] = (i & 1) + 1;
    } else {
      t = 2;
      if (n % 2 == 0) ff = 0;
      for (int i = (0); i < (n); i++) b[i] = 0;
      if (ff) {
        int l = (k - 1 + n) % n;
        int r = k;
        b[l] = b[r] = 1;
      }
      int fff = 1;
      for (int i = (k + 1) % n; !b[i]; i = (i + 1) % n) {
        b[i] = fff + 1;
        fff = !fff;
      }
    }
    cout << t << '\n';
    for (int i = (0); i < (n); i++) {
      cout << b[i] << ' ';
    }
    cout << '\n';
  }
}

```


### Prompt

Develop a solution in CPP to the problem described below:

There are n children, who study at the school №41. It is well-known that they are good mathematicians. Once at a break, they arranged a challenge for themselves. All children arranged in a row and turned heads either to the left or to the right.

Children can do the following: in one second several pairs of neighboring children who are looking at each other can simultaneously turn the head in the opposite direction. For instance, the one who was looking at the right neighbor turns left and vice versa for the second child. Moreover, every second at least one pair of neighboring children performs such action. They are going to finish when there is no pair of neighboring children who are looking at each other.

You are given the number n, the initial arrangement of children and the number k. You have to find a way for the children to act if they want to finish the process in exactly k seconds. More formally, for each of the k moves, you need to output the numbers of the children who turn left during this move.

For instance, for the configuration shown below and k = 2 children can do the following steps:

<image> At the beginning, two pairs make move: (1, 2) and (3, 4). After that, we receive the following configuration:  <image> At the second move pair (2, 3) makes the move. The final configuration is reached. Good job.  <image>

It is guaranteed that if the solution exists, it takes not more than n^2 "headturns".

Input

The first line of input contains two integers n and k (2 ≤ n ≤ 3000, 1 ≤ k ≤ 3000000) — the number of children and required number of moves.

The next line contains a string of length n and consists only of characters L and R, where L means that the child looks to the left and R means that the child looks to the right.

Output

If there is no solution, print a single line with number -1.

Otherwise, output k lines. Each line has to start with a number n_i (1≤ n_i ≤ n/2) — the number of pairs of children, who turn at this move. After that print n_i distinct integers — the numbers of the children who will turn left during this move.

After performing all "headturns", there can't be a pair of two neighboring children looking at each other.

If there are many solutions, print any of them.

Examples

Input

2 1
RL

Output

1 1

Input

2 1
LR

Output

-1

Input

4 2
RLRL

Output

2 1 3
1 2

Note

The first sample contains a pair of children who look at each other. After one move, they can finish the process.

In the second sample, children can't make any move. As a result, they can't end in k>0 moves.

The third configuration is described in the statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 1e7 + 100;
int n, k;
char s[maxn], t[maxn];
vector<int> ans[maxn];
void findmi(int lpos, int rpos) {
  int cnt = 0, tot = 0;
  while (1) {
    tot++;
    int flag = 1;
    for (int i = lpos; i <= rpos; i++) {
      if (s[i] == 'R' && s[i + 1] == 'L') {
        swap(s[i], s[i + 1]);
        ans[tot].push_back(i);
        i++;
        cnt++;
        flag = 0;
      }
    }
    tot -= flag;
    while (s[lpos] == 'L') lpos++;
    while (s[rpos] == 'R') rpos--;
    if (lpos > rpos) break;
  }
  if (tot > k || cnt < k) {
    printf("-1\n");
    return;
  } else if (cnt >= k) {
    for (int i = 1; i <= tot; i++) {
      int sz = ans[i].size();
      for (int j = 0; j <= sz - 1; j++) {
        if (tot - i + 1 == k) {
          printf("%d ", sz - j);
          for (int k = j; k <= sz - 1; k++) printf("%d ", ans[i][k]);
          printf("\n");
          for (int j = i + 1; j <= tot; j++) {
            printf("%d ", ans[j].size());
            for (auto to : ans[j]) printf("%d ", to);
            printf("\n");
          }
          exit(0);
        }
        printf("1 %d\n", ans[i][j]);
        k--;
      }
    }
  }
}
int solve() {
  int lpos = 1, rpos = n, lcnt = 0, rcnt = 0;
  while (s[lpos] == 'L') lpos++;
  while (s[rpos] == 'R') rpos--;
  findmi(lpos, rpos);
}
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) t[i] = s[i];
  solve();
}

```


### Prompt

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

A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.

The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.

Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?

Input

The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).

Output

Output the amount of possible positions of the new house.

Examples

Input

2 2
0 4
6 2

Output

4

Input

2 2
0 4
5 2

Output

3

Input

2 3
0 4
5 2

Output

2

Note

It is possible for the x-coordinate of the new house to have non-integer value.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef struct house {
  int start, end;
} House;
bool mycompare(House a, House b) { return a.start < b.start; }
int main(int argc, char *argv[]) {
  int N, T;
  int i, x, a;
  House h[1001];
  scanf("%d%d", &N, &T);
  T *= 2;
  for (i = 0; i < N; i++) {
    scanf("%d%d", &x, &a);
    h[i].start = 2 * x - a;
    h[i].end = 2 * x + a;
  }
  sort(h, h + N, mycompare);
  int sum = 2;
  for (i = 0; i < N - 1; i++) {
    if (h[i].end + T < h[i + 1].start)
      sum += 2;
    else if (h[i].end + T == h[i + 1].start)
      sum++;
  }
  printf("%d\n", sum);
  return 0;
}

```


### Prompt

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

You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connects vertex a_i and b_i.

The phantom thief Nusook likes to choose some vertex as the startpoint and traverse an edge zero or more times. Today, he will make a string after traveling as above, by placing the labels of the visited vertices in the order visited, beginning from the startpoint.

For example, in a graph where Vertex 1 has the label `A` and Vertex 2 has the label `B`, if Nusook travels along the path 1 \rightarrow 2 \rightarrow 1 \rightarrow 2 \rightarrow 2, the resulting string is `ABABB`.

Determine if Nusook can make all strings consisting of `A` and `B`.

Constraints

* 2 \leq N \leq 2 \times 10^{5}
* 1 \leq M \leq 2 \times 10^{5}
* |s| = N
* s_i is `A` or `B`.
* 1 \leq a_i, b_i \leq N
* The given graph may NOT be simple or connected.

Input

Input is given from Standard Input in the following format:

N M
s
a_1 b_1
:
a_{M} b_{M}

Output

If Nusook can make all strings consisting of `A` and `B`, print `Yes`; otherwise, print `No`.

Examples

Input

2 3
AB
1 1
1 2
2 2

Output

Yes

Input

4 3
ABAB
1 2
2 3
3 1

Output

No

Input

13 23
ABAAAABBBBAAB
7 1
10 6
1 11
2 10
2 8
2 11
11 12
8 3
7 12
11 2
13 13
11 9
4 1
9 7
9 6
8 13
8 6
4 10
8 7
4 3
2 1
8 12
6 9

Output

Yes

Input

13 17
BBABBBAABABBA
7 1
7 9
11 12
3 9
11 9
2 1
11 5
12 11
10 8
1 11
1 8
7 7
9 10
8 8
8 12
6 2
13 11

Output

No

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;

vector<int> G[200010];
int ABC[200010][2];
bool er[200010];

int main() {
	for (int i = 0;i < 200010;i++)ABC[i][0] = ABC[i][1] = er[i] = 0;
	int N, M, a, b;
	cin >> N >> M;
	string S;
	cin >> S;
	for (int i = 0;i < M;i++) {
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	queue<int> Q;
	for (int i = 0;i < N;i++) {
		for (int x : G[i]) {
			if (S[x] == 'A') {
				ABC[i][0]++;
			}
			if (S[x] == 'B') {
				ABC[i][1]++;
			}
		}
		if (ABC[i][0] == 0 || ABC[i][1] == 0) {
			Q.push(i);
			er[i] = 1;
		}
	}
	bool ab = 0;
	while (!Q.empty()) {
		a = Q.front();
		Q.pop();
		if (S[a] == 'A')ab = 0;
		else ab = 1;
		for (int x : G[a]) {
			ABC[x][ab]--;
			if (ABC[x][ab] == 0 && !er[x]) {
				Q.push(x);
				er[x] = 1;
			}
		}
	}
	for (int i = 0;i < N;i++) {
		if (!er[i]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}
```


### Prompt

Develop a solution in CPP to the problem described below:

There are many freight trains departing from Kirnes planet every day. One day on that planet consists of h hours, and each hour consists of m minutes, where m is an even number. Currently, there are n freight trains, and they depart every day at the same time: i-th train departs at h_i hours and m_i minutes.

The government decided to add passenger trams as well: they plan to add a regular tram service with half-hour intervals. It means that the first tram of the day must depart at 0 hours and t minutes, where 0 ≤ t < {m \over 2}, the second tram departs m \over 2 minutes after the first one and so on. This schedule allows exactly two passenger trams per hour, which is a great improvement.

To allow passengers to board the tram safely, the tram must arrive k minutes before. During the time when passengers are boarding the tram, no freight train can depart from the planet. However, freight trains are allowed to depart at the very moment when the boarding starts, as well as at the moment when the passenger tram departs. Note that, if the first passenger tram departs at 0 hours and t minutes, where t < k, then the freight trains can not depart during the last k - t minutes of the day.

<image> A schematic picture of the correct way to run passenger trams. Here h=2 (therefore, the number of passenger trams is 2h=4), the number of freight trains is n=6. The passenger trams are marked in red (note that the spaces between them are the same). The freight trains are marked in blue. Time segments of length k before each passenger tram are highlighted in red. Note that there are no freight trains inside these segments.

Unfortunately, it might not be possible to satisfy the requirements of the government without canceling some of the freight trains. Please help the government find the optimal value of t to minimize the number of canceled freight trains in case all passenger trams depart according to schedule.

Input

The first line of input contains four integers n, h, m, k (1 ≤ n ≤ 100 000, 1 ≤ h ≤ 10^9, 2 ≤ m ≤ 10^9, m is even, 1 ≤ k ≤ {m \over 2}) — the number of freight trains per day, the number of hours and minutes on the planet, and the boarding time for each passenger tram.

n lines follow, each contains two integers h_i and m_i (0 ≤ h_i < h, 0 ≤ m_i < m) — the time when i-th freight train departs. It is guaranteed that no freight trains depart at the same time.

Output

The first line of output should contain two integers: the minimum number of trains that need to be canceled, and the optimal starting time t. Second line of output should contain freight trains that need to be canceled.

Examples

Input

2 24 60 15
16 0
17 15

Output

0 0

Input

2 24 60 16
16 0
17 15

Output

1 0
2

Note

In the first test case of the example the first tram can depart at 0 hours and 0 minutes. Then the freight train at 16 hours and 0 minutes can depart at the same time as the passenger tram, and the freight train at 17 hours and 15 minutes can depart at the same time as the boarding starts for the upcoming passenger tram.

In the second test case of the example it is not possible to design the passenger tram schedule without cancelling any of the freight trains: if t ∈ [1, 15], then the freight train at 16 hours and 0 minutes is not able to depart (since boarding time is 16 minutes). If t = 0 or t ∈ [16, 29], then the freight train departing at 17 hours 15 minutes is not able to depart. However, if the second freight train is canceled, one can choose t = 0. Another possible option is to cancel the first train and choose t = 13.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 14;
int n, h, m, k, ti[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> h >> m >> k;
  m /= 2;
  map<int, int> sweep;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    int mi;
    cin >> mi >> mi;
    mi %= m;
    ti[i] = mi;
    if (mi + k > m) {
      cur++;
      sweep[mi + k - m]--;
    } else
      sweep[mi + k]--;
    sweep[mi + 1]++;
  }
  sweep.erase(m);
  int ans = cur, cer = 0;
  for (auto [t, v] : sweep) {
    cur += v;
    if (ans > cur) ans = cur, cer = t;
  }
  cout << ans << ' ' << cer << '\n';
  for (int i = 0; i < n; i++)
    if (ti[i] < cer && ti[i] > cer - k || cer + m - ti[i] < k)
      cout << i + 1 << ' ';
  cout << '\n';
}

```


### Prompt

Generate a Cpp solution to the following problem:

Mr. Tanaka died leaving the orchard of HW Earl. The orchard is divided into H x W plots in the north, south, east, and west directions, and apples, oysters, and oranges are planted in each plot. Mr. Tanaka left such a will.

Divide the orchard into as many relatives as possible on a parcel basis. However, if the same kind of fruit is planted in a plot that is located in either the north, south, east, or west direction of a plot, treat them as one large plot because the boundaries of the plot are unknown.

For example, in the following 3 × 10 section ('li' represents an apple,'ka' represents an oyster, and'mi' represents a mandarin orange)

<image>

Eliminating the boundaries between plots with the same tree gives:

<image>

In the end, it will be divided into 10 compartments, or 10 people.

The distribution must be completed before it snows and the boundaries of the plot disappear. Your job is to determine the number of plots to distribute based on the map of the orchard.

Create a program that reads the map of the orchard and outputs the number of relatives who can receive the distribution.

Input

Given multiple datasets. Each dataset is given a string of H lines consisting of the characters H x W, starting with a line containing H, W (H, W ≤ 100) separated by blanks. Only three characters appear in this string:'@' for apples,'#' for oysters, and'*' for oranges.

The input ends with two lines of zeros. The number of datasets does not exceed 20.

Output

For each dataset, output the number of people to be distributed on one line.

Examples

Input

10 10
####*****@
@#@@@@#*#*
@##***@@@*
#****#*@**
##@*#@@*##
*@@@@*@@@#
***#@*@##*
*@@@*@@##@
*@*#*@##**
@****#@@#@
0 0

Output

33

Input

10 10
*****@
@#@@@@#*#*
@##***@@@*
****#*@**
@*#@@*##
*@@@@*@@@#
***#@*@##*
*@@@*@@##@
*@*#*@##**
@****#@@#@
0 0

Output

33

### Response

```cpp
#include <iostream>
using namespace std;
int dh[]={-1,0,1,0},dw[]={0,1,0,-1},h,w;
char s[105][105];
void dfs(int _h,int _w,char ch){
	s[_h][_w]='.';
	for(int i=0;i<4;i++){
		int H=_h+dh[i],W=_w+dw[i];
		if(H>=0 && H<h && W>=0 && W<w && s[H][W]==ch)dfs(H,W,ch);
	}
}
int main(){
	while(cin>>h>>w,h){
		int count=0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>s[i][j];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(s[i][j]!='.')count++,dfs(i,j,s[i][j]);
		cout<<count<<endl;
	}
}
```


### Prompt

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

Illumination

Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bulb is either on or off.

A machine that operates a light bulb is sleeping in the warehouse of JOI High School. When a continuous light bulb is specified in the illumination, this machine turns all the specified light bulbs with the light on and all the light bulbs without the light on. However, the machine is aging and can only be used once.

JOI high school students like alternating rows of light bulbs with and without lights (such rows of light bulbs are called alternating rows). Therefore, I decided to use this machine only once if necessary to make illuminations containing alternating rows as long as possible.

Example

For example, the arrangement of illuminations is from west to east

<image>

(○ indicates a light bulb with a light, ● indicates a light bulb without a light). At this time, if you operate the machine for the four light bulbs from the 4th to the 7th,

<image>

The second to eighth bulbs form an alternating row of length 7.

<image>

Also, if you operate the machine only for the 8th light bulb,

<image>

The 4th to 10th light bulbs form an alternating row of length 7.

<image>

It is not possible to create alternating rows longer than 8 by using the machine up to once.

Task

Given the illumination information, write a program to find the maximum possible length of the alternating rows in the array of light bulbs that can be obtained by using the machine up to once.

Limits

* 2 ≤ N ≤ 100 000 Number of light bulbs that make up the illumination

input

Read the following data from standard input.

* The integer N is written on the first line.
* On the second line, N 0s or 1s are written with a space as a delimiter. Each integer represents the information of the light bulb before operating the machine. The i (1 ≤ i ≤ N) th integer from the left represents the information of the i-th light bulb from the west, and if the integer is 1, the light bulb is on, and if it is 0, the light bulb is off.

output

Output an integer representing the maximum length of the alternating columns contained in the columns of light bulbs that can be created to the standard output on one line.

Input / output example

Input example 1

Ten
1 1 0 0 1 0 1 1 1 0

Output example 1

7

This is an example explained in the problem statement.

Input example 2

Ten
1 0 0 0 0 1 0 1 0 1

Output example 2

8

Manipulating only the fourth bulb from the west yields an alternating sequence that satisfies the maximum value of 8.

Input example 3

Five
1 1 0 1 1

Output example 3

Five

By manipulating the second to fourth light bulbs counting from the west, you can create an alternating row of all light bulbs.

Input example 4

3
0 1 0

Output example 4

3

Note that you may not need to use a machine.

The question text and the data used for the automatic referee are the question text and the test data for scoring, which are created and published by the Japan Committee for Information Olympics.

Example

Input

10
1 1 0 0 1 0 1 1 1 0

Output

7

### Response

```cpp
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	vector<int> v(n);
	rep(i, n) cin >> v[i];

	vector<int> t;
	t.push_back(0);
	REP(i, 1, n) {
		if(v[i-1] == v[i]) {
			t.push_back(i);
		}
	}
	t.push_back(n);

	int ans = 0;
	rep(i, t.size()-1) {
		ans = max(ans, t[i+1] - t[i]);
	}

	// cout << " -------- t ------ " << endl;
	// rep(i, t.size()-1) {
	// 	cout << t[i] << " <-> " << t[i+1] << "  : " << t[i+1] - t[i] << endl;
	// }

	rep(i, n) {
		int j = upper_bound(t.begin(), t.end(), i) - t.begin();
		int res = t[j+1] - t[j-2];
		ans = max(ans, res);
	}

	cout << ans << endl;

	return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

You are given an array a_1, a_2 ... a_n. Calculate the number of tuples (i, j, k, l) such that:

  * 1 ≤ i < j < k < l ≤ n;
  * a_i = a_k and a_j = a_l;

Input

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

The first line of each test case contains a single integer n (4 ≤ n ≤ 3000) — the size of the array a.

The second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — the array a.

It's guaranteed that the sum of n in one test doesn't exceed 3000.

Output

For each test case, print the number of described tuples.

Example

Input

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

Output

5
2

Note

In the first test case, for any four indices i < j < k < l are valid, so the answer is the number of tuples.

In the second test case, there are 2 valid tuples:

  * (1, 2, 4, 6): a_1 = a_4 and a_2 = a_6;
  * (1, 3, 4, 6): a_1 = a_4 and a_3 = a_6.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 1e6 + 7, SM = 1e3 + 5, logN = 20;
const long long MOD = 1e9 + 7, INF = 1e18 + 9;
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};
void debug() { cerr << "\n"; }
template <typename Head, typename... Tail>
void debug(Head a, Tail... b) {
  cerr << a << " ";
  debug(b...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    vector<long long> a(n + 1);
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
    }
    vector<vector<long long>> pref(n + 1, vector<long long>(n + 1)),
        suff(n + 1, vector<long long>(n + 1));
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        if (i > 1) pref[i][j] = pref[i - 1][j];
        pref[i][j] += (a[i] == j);
      }
    }
    for (long long i = n; i >= 1; i--) {
      for (long long j = 1; j <= n; j++) {
        if (i < n) suff[i][j] = suff[i + 1][j];
        suff[i][j] += (a[i] == j);
      }
    }
    long long ans = 0;
    for (long long i = 2; i <= n; i++) {
      for (long long j = i + 1; j < n; j++) {
        ans += pref[i - 1][a[j]] * suff[j + 1][a[i]];
      }
    }
    cout << ans << "\n";
  }
  cout << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

The time was 3xxx, and the highly developed civilization was in a stagnation period. Historians decided to learn the wisdom of the past in an attempt to overcome this situation. What I paid attention to was the material left by the genius of the early days of computers. The calculation formula is written in this material and I would like to know the calculation result, but unfortunately some of the characters are fading and cannot be read. Since there is no help for it, I decided to find the largest possible number as a calculation result. The calculation formula is written in binary numbers, and there are three types of operations: addition, subtraction, and multiplication. Parentheses are also used, but the numbers inside the parentheses are not the only ones. To be exact, it is necessary to satisfy the grammar defined by the following BNF.

<expression> :: = <number> | <expression> <operation> <expression>
| (<expression> <operation> <expression>)
<number> :: = <digit> | <number> <digit>
<operation> :: = + |-| *
<digit> :: = 0 | 1

Due to the limited computing power of computers at that time, numbers are integers between 0 and 210 and do not go out of this range during calculations. However, the calculation is done in parentheses first, and the multiplication is done before addition / subtraction. In other cases, the calculation is performed in order from the left.

Constraints

* Formulas must be between 1 and 100 characters
* All characters except line breaks are either 01 +-* ().
*. Number is 5 or less

Input

The input consists of one line and is given one formula to decipher. The formula is 1 to 100 characters. Up to 5 characters cannot be read for one formula and are represented by ".". The characters contained in the given formula are either 01 +-* ().

Output

Find the one that maximizes the calculation result among the original formulas, and output the calculation result in decimal notation. Output -1 if you can't make what you think is the original formula no matter how you fill in the unreadable characters.

Examples

Input

000

Output

0

Input

0.0

Output

2

Input

...

Output

7

Input

(1.1)

Output

2

Input

0-1.

Output

-1

### Response

```cpp
#include<iostream>
#include<map>
#include<stack>
#include<vector>
#include<algorithm>
#include<sstream>
#include<cmath>
using namespace std;

char ln[7]={'0','1','+','-','*','(',')'};
int n=0,ans=-1;
int p[5]={};
int ind[5]={};
string s,t;
map<int,int> mp;

string f(string a){
  if(a=="+" || a=="-" || a=="*" || a=="(" || a==")")return a;
  reverse(a.begin(),a.end());
  int res=0;
  for(int i=0;i<a.length();i++)res+=(pow(2,i)*(a[i]-'0'));
  ostringstream os;
  os<<res;
  return os.str();
}

int cal(vector<string> v){
  if(v.empty())return -1;
  //if(v.size()==3 && (v[1][0]=='0' || v[1][0]=='1') && v[0]=="(" && v[2]==")")return -1;
  vector<string> vs1,vs2,vs3;
  for(int i=0;i<v.size();i++){
    if(v[i]=="("){
      vector<string> tmp;
      int l=1,r=0,count=0;
      for(int j=i+1;j<v.size();j++){
	if(v[j]=="(")l++;
	if(v[j]==")")r++;
	if((l-r)==1 && (v[j]=="+" || v[j]=="*" || v[j]=="-"))count++;
	if(r==l){
	  if(count==0)return -1;
	  i=j;
	  break;
	}
	tmp.push_back(v[j]);
      }
      int res=cal(tmp);
      if(res==-1 || 1024<=res)return -1;
      ostringstream os;
      os<<res;
      vs1.push_back(os.str());
    }
    else vs1.push_back(v[i]);
  }
  //if((vs1[1][0]=='0' || vs1[1][0]=='1') && vs1[0]=="(" && vs1[2]==")")return -1;
  if(vs1[0]=="+" || vs1[0]=="*" || vs1[0]=="-")return -1;
  int size=vs1.size()-1;
  if(vs1[size]=="+" || vs1[size]=="*" || vs1[size]=="-")return -1;
  for(int i=0;i<vs1.size();i++){
    if(vs1[i]=="*"){
      if('0'<=vs1[i+1][0] && vs1[i+1][0]<='9' && '0'<=vs2.back()[0] && vs2.back()[0]<='9' ){
	int tmp1=atoi(vs2.back().c_str()),tmp2=atoi(vs1[i+1].c_str());
	if(tmp1<0 || 2014<=tmp1)return -1;
        if(tmp2<0 || 2014<=tmp2)return -1;
	vs2.pop_back();
	ostringstream os;
	os<<(tmp1*tmp2);
	if(1024<=tmp1*tmp2)return -1;
	vs2.push_back(os.str());
	i++;
      }
      else return -1;
    }
    else vs2.push_back(vs1[i]);
  }
  for(int i=0;i<vs2.size();i++){
    if(vs2[i]=="+" || vs2[i]=="-"){
      string tmp=vs3.back();
      if('0'<=vs2[i+1][0] && vs2[i+1][0]<='9' && '0'<=tmp[0] && tmp[0]<='9' ){
	int tmp1=atoi(tmp.c_str()),tmp2=atoi(vs2[i+1].c_str());
        if(tmp1<0 || 2014<=tmp1)return -1;
        if(tmp2<0 || 2014<=tmp2)return -1;
	vs3.pop_back();
	ostringstream os;
	int res;
	if(vs2[i]=="+")res=(tmp1+tmp2);
	if(vs2[i]=="-")res=(tmp1-tmp2);
	if(res<0 || 1024<=res)return -1;
	os<<res;
	vs3.push_back(os.str());
	i++;
      }
      else return -1;
    }
    else vs3.push_back(vs2[i]);
  }
  int res=-1;
  if(vs3.size()==1 && '0'<=vs3[0][0] && vs3[0][0]<='9')res=atoi(vs3[0].c_str());
  if(res<0 || 1024<=res)res=-1;
  return res;
}

void rec(int v){
  if(v==n){
    t=s;
    for(int i=0;i<n;i++)t[ind[i]]=ln[p[i]];
    string tmp="";
    vector<string> vs;
    for(int i=0;i<t.length();i++){
      if(t[i]=='0' || t[i]=='1')tmp+=t[i];
      else {
	if(tmp!="")vs.push_back(tmp);
	tmp="";
	string st="";
	st+=t[i];
	vs.push_back(st);
      }
    }
    if(tmp!="")vs.push_back(tmp);
    stack<int> st;
    for(int i=0;i<vs.size();i++){
      if(vs[i]=="(")st.push(i);
      if(vs[i]==")"){
        if(st.empty())return;
        st.pop();
      }
    }
    if(!st.empty())return;
    /*
    for(int i=1;i<vs.size()-1;i++){
      if((vs[i][0]=='0' || vs[i][0]=='1') && vs[i-1]=="(" && vs[i+1]==")")return;
    }
    for(int i=1;i<vs.size();i++){
      if(vs[i]==")" && !('0'<=vs[i-1][0] && vs[i-1][0]<='9'))return;
    }
    for(int i=0;i<vs.size()-1;i++){
      if(vs[i]=="(" && !('0'<=vs[i+1][0] && vs[i+1][0]<='9'))return;
      }*/
    for(int i=0;i<vs.size();i++)vs[i]=f(vs[i]);
    int res=cal(vs);
    ans=max(ans,res);
  }
  else {
    for(int i=0;i<7;i++){
      rec(v+1);
      p[v]++;
    }
    p[v]=0;
  }
}

int main()
{
  cin>>s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='.'){
      ind[n]=i;
      n++;
    }
  }
  rec(0);
  cout<<ans<<endl;
  return 0;
}
```


### Prompt

Generate a CPP solution to the following problem:

You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence.

For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.

Constraints

* 1 \leq n \leq 10^5
* 1 \leq a_i \leq n
* Each of the integers 1,...,n appears in the sequence.
* n and a_i are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_{n+1}

Output

Print n+1 lines. The k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.

Examples

Input

3
1 2 1 3

Output

3
5
4
1

Input

1
1 1

Output

1
1

Input

32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9

Output

32
525
5453
40919
237336
1107568
4272048
13884156
38567100
92561040
193536720
354817320
573166440
818809200
37158313
166803103
166803103
37158313
818809200
573166440
354817320
193536720
92561040
38567100
13884156
4272048
1107568
237336
40920
5456
528
33
1

### Response

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

ifstream in ( "test.in"  );
ofstream out( "test.out" );

const int DIM = 1e5 + 5;
const int MOD = 1e9 + 7;

int pos[DIM], ans[DIM];
int fct[DIM], inv[DIM];

int lgput( int x, int n ) {
    if( n == 0 )
        return 1;

    int y = lgput( x, n >> 1 );
    y = ( 1LL * y * y ) % MOD;

    if( n & 1 )
        y = ( 1LL * y * x ) % MOD;

    return y;
}

inline int comb( int n, int k ) {
    if( n < k ) return 0;
    return 1LL * fct[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int main() {

    int n;
    cin >> n;

    int p1 = 0, p2 = 0; n ++;
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;

        if( pos[x] == 0 )
            pos[x] = i;
        else
            p1 = pos[x], p2 = i;
    }

    fct[0] = inv[0] = 1;
    for( int i = 1; i <= n; i ++ ) {
        fct[i] = ( 1LL * fct[i - 1] * i ) % MOD;
        inv[i] = lgput( fct[i], MOD - 2 );
    }

    ans[1] = n - 1;
    for( int i = 2; i <= n; i ++ )
        ans[i] = ( comb( n, i ) - comb( n - (p2 - p1 + 1), i - 1 ) + MOD ) % MOD;

    for( int i = 1; i <= n; i ++ )
        cout << ans[i] << "\n";

    return 0;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

When a boy was cleaning up after his grand father passing, he found an old paper:

<image>

In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer".

His grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper.

For simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with "0, 0". Your program should print the coordinate (x, y) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town.

You can assume that d ≤ 100 and -180 ≤ t ≤ 180.

Input

A sequence of pairs of integers d and t which end with "0,0".

Output

Print the integer portion of x and y in a line respectively.

Example

Input

56,65
97,54
64,-4
55,76
42,-27
43,80
87,-86
55,-6
89,34
95,5
0,0

Output

171
-302

### Response

```cpp
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define PI acos(-1)
using namespace std;
int main(){
double x=0,y=0,ka=PI/2;
int ho,kai;
char d;
while(cin>>ho>>d>>kai,ho||kai){
x+=ho*cos(ka);
y+=ho*sin(ka);
ka-=PI/180*kai;
}
//cout<<(double)sin(0)<<endl;
cout<<(int)x<<endl<<(int)y<<endl;
}
```


### Prompt

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

We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the path u-v.

It is expected that one of the vertices will be invaded by aliens from outer space. Snuke wants to immediately identify that vertex when the invasion happens. To do so, he has decided to install an antenna on some vertices.

First, he decides the number of antennas, K (1 ≤ K ≤ N). Then, he chooses K different vertices, x_0, x_1, ..., x_{K - 1}, on which he installs Antenna 0, 1, ..., K - 1, respectively. If Vertex v is invaded by aliens, Antenna k (0 ≤ k < K) will output the distance d(x_k, v). Based on these K outputs, Snuke will identify the vertex that is invaded. Thus, in order to identify the invaded vertex no matter which one is invaded, the following condition must hold:

* For each vertex u (0 ≤ u < N), consider the vector (d(x_0, u), ..., d(x_{K - 1}, u)). These N vectors are distinct.

Find the minumum value of K, the number of antennas, when the condition is satisfied.

Constraints

* 2 ≤ N ≤ 10^5
* 0 ≤ a_i, b_i < N
* The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_0 b_0
a_1 b_1
:
a_{N - 2} b_{N - 2}

Output

Print the minumum value of K, the number of antennas, when the condition is satisfied.

Examples

Input

5
0 1
0 2
0 3
3 4

Output

2

Input

2
0 1

Output

1

Input

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

Output

3

### Response

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

template<typename t>inline t min_(t a,t b){return a<=b?a:b;}
template<typename t>inline t max_(t a,t b){return a>=b?a:b;}
template<typename t>inline void chkmin(t&a,t b){if(a>b)a=b;}
template<typename t>inline void chkmax(t&a,t b){if(a<b)a=b;}

typedef long long ll;
const int maxn=1e5+10;
int n,rt=-1,ans;
vector<int> g[maxn];

bool dfs(int pos,int fa){
	int cnt0=0,cnt1=0;
	for(int i=0,v;i<g[pos].size();++i)
		if((v=g[pos][i])!=fa){
			if(dfs(v,pos))
				++cnt1;
			else
				++cnt0;
		}
	if(cnt0>1){
		ans+=cnt0-1;
		return true;
	}
	else
		return cnt1>0;
}

int main(){
	cin>>n;
	for(int i=1,u,v;i<n;++i){
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=0;i<n;++i)
		if(g[i].size()>2){
			rt=i;
			break;
		}
	if(rt==-1){
		puts("1");
		return 0;
	}
	dfs(rt,-1);
	printf("%d\n",ans);
	return 0;
}
```


### Prompt

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

A: Alphabet block

Wakana Nakawa loves palindromes. Because my name is also a palindrome.

Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create your favorite character string by changing the order of the blocks and combining them. Wakana is wondering if she can make a palindrome with this set.

The following three types of operations are possible in the set of alphabet blocks, and the cost of each operation is 1.

1. Add one alphabet block (any letter is listed)
2. Change one alphabet block you have to another block (whatever the letters are listed)
3. Delete one alphabet block you currently have

I want to make a set that can be rearranged into palindromes by operating the set of alphabet blocks several times. What is the minimum cost of such an operation? Let's think with Wakana-chan.

Input

The input consists of one line of the string S that points to the information in the first set of alphabet blocks.

S consists of lowercase letters only and satisfies 1 \ leq | S | \ leq 10 ^ 3.

Output

Output the minimum cost for creating a palindrome. Don't forget the newline at the end.

Sample Input 1

hcpc

Sample Output 1

1

In this case, a palindrome can be created at a cost of 1, but multiple methods are possible. For example, if you add a block of'h', you can make a'hcpch', so you can make a palindrome at a cost of 1. Also, if you delete the block of'h', you can make'cpc', so you can make a palindrome with this method at cost 1.

Sample Input 2

ritscamp

Sample Output 2

Four

Sample Input 3

nakawawakana

Sample Output 3

0

If you can create a palindrome from scratch, the cost is zero.

Example

Input

hcpc

Output

1

### Response

```cpp
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s; cin >> s;

	vector<int>c(256, 0); // ???????????????????????°

	rep(i, 0, s.size())c[s[i]]++;

	vector<int>sum(1010, 0);// ???????????°????????°

	int odd(0);
	rep(i, 0, 256){
		if (c[i] & 1)odd++;
	}
	cout << odd/2 << endl;

	return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

In this task you have to write a program dealing with nonograms on fields no larger than 5 × 20.

Simplified nonogram is a task where you have to build such field (each cell is either white or black) that satisfies the given information about rows and columns. For each row and each column the number of contiguous black segments is specified.

For example if size of the field is n = 3, m = 5, аnd numbers of contiguous black segments in rows are: [2, 3, 2] and in columns are: [1, 0, 1, 2, 1] then the solution may look like:

<image>

It is guaranteed that on each test in the testset there exists at least one solution.

Input

In the first line there follow two integers n, m (1 ≤ n ≤ 5, 1 ≤ m ≤ 20) — number of rows and number of columns respectively.

Second line contains n integers a1, a2, ..., an where ai is the number of contiguous black segments in i-th row of the field.

Similarly, third line contains m integers b1, b2, ..., bm where bi is the number of contiguous black segments in the i-th column of the field.

It is guaranteed that there exists at least one solution.

Output

Output any possible solution. Output should consist of n lines each containing m characters. Denote white cell as "." and black cell as "*".

Examples

Input

3 5
2 3 2
1 0 1 2 1

Output

*.**.
*.*.*
*..**

Input

3 3
2 1 2
2 1 2

Output

*.*
.*.
*.*

Input

3 3
1 0 1
2 2 2

Output

***
...
***

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int rows, cols;
int a[5], b[20];
vector<int> csol[5];
unsigned tried[20][11][11][11][11][11];
char sol[5][21];
bool solve(int c, int pmask) {
  if (c == cols) {
    for (int i = 0; i < rows; i++)
      if (a[i] != 0) return false;
    return true;
  }
  unsigned &tt = tried[c][a[0]][a[1]][a[2]][a[3]][a[4]];
  if (tt & 1 << pmask) return false;
  for (auto mask : csol[b[c]]) {
    tt |= 1 << pmask;
    bool ok = true;
    for (int i = 0; i < rows; i++) {
      sol[i][c] = ".*"[mask >> i & 1];
      if (!(pmask >> i & 1) and (mask >> i & 1)) {
        a[i]--;
        if (a[i] < 0 or a[i] > (cols - c - 1) / 2) ok = false;
      }
    }
    if (ok) {
      if (solve(c + 1, mask)) return true;
    }
    for (int i = 0; i < rows; i++)
      if (!(pmask >> i & 1) and (mask >> i & 1)) a[i]++;
  }
  return false;
}
int main() {
  scanf("%d%d", &rows, &cols);
  for (int i = 0; i < rows; i++) scanf("%d", &a[i]);
  for (int i = 0; i < cols; i++) scanf("%d", &b[i]);
  for (int mask = 0; mask < 1 << rows; mask++) {
    int count = 0;
    for (int i = 0; i < rows; i++)
      if ((mask >> i & 3) == 1) count++;
    csol[count].push_back(mask);
  }
  assert(solve(0, 0));
  for (int i = 0; i < rows; i++) puts(sol[i]);
}

```