### Prompt

Generate a CPP solution to the following problem:

Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikhail is determined to follow his dreams and registered at a freelance site.

He has suggestions to work on n distinct projects. Mikhail has already evaluated that the participation in the i-th project will increase his experience by ai per day and bring bi dollars per day. As freelance work implies flexible working hours, Mikhail is free to stop working on one project at any time and start working on another project. Doing so, he receives the respective share of experience and money. Mikhail is only trying to become a cool programmer, so he is able to work only on one project at any moment of time.

Find the real value, equal to the minimum number of days Mikhail needs to make his dream come true.

For example, suppose Mikhail is suggested to work on three projects and a1 = 6, b1 = 2, a2 = 1, b2 = 3, a3 = 2, b3 = 6. Also, p = 20 and q = 20. In order to achieve his aims Mikhail has to work for 2.5 days on both first and third projects. Indeed, a1·2.5 + a2·0 + a3·2.5 = 6·2.5 + 1·0 + 2·2.5 = 20 and b1·2.5 + b2·0 + b3·2.5 = 2·2.5 + 3·0 + 6·2.5 = 20.

Input

The first line of the input contains three integers n, p and q (1 ≤ n ≤ 100 000, 1 ≤ p, q ≤ 1 000 000) — the number of projects and the required number of experience and money.

Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 1 000 000) — the daily increase in experience and daily income for working on the i-th project.

Output

Print a real value — the minimum number of days Mikhail needs to get the required amount of experience and money. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

3 20 20
6 2
1 3
2 6

Output

5.000000000000000

Input

4 1 1
2 3
3 2
2 3
3 2

Output

0.400000000000000

Note

First sample corresponds to the example in the problem statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace std;
const double EPS = 1e-16;
struct PT {
  double x, y;
  PT() {}
  PT(double x, double y) : x(x), y(y) {}
  PT(const PT &p) : x(p.x), y(p.y) {}
  PT operator+(const PT &p) const { return PT(x + p.x, y + p.y); }
  PT operator-(const PT &p) const { return PT(x - p.x, y - p.y); }
  PT operator*(double c) const { return PT(x * c, y * c); }
  PT operator/(double c) const { return PT(x / c, y / c); }
  bool operator<(const PT &rhs) const {
    return make_pair(y, x) < make_pair(rhs.y, rhs.x);
  }
  bool operator==(const PT &rhs) const {
    return make_pair(y, x) == make_pair(rhs.y, rhs.x);
  }
};
double dot(PT p, PT q) { return p.x * q.x + p.y * q.y; }
double dist2(PT p, PT q) { return dot(p - q, p - q); }
double cross(PT p, PT q) { return p.x * q.y - p.y * q.x; }
double area2(PT a, PT b, PT c) {
  return cross(a, b) + cross(b, c) + cross(c, a);
}
bool between(const PT &a, const PT &b, const PT &c) {
  return (fabs(area2(a, b, c)) < EPS && (a.x - b.x) * (c.x - b.x) <= 0 &&
          (a.y - b.y) * (c.y - b.y) <= 0);
}
void ConvexHull(vector<PT> &pts) {
  sort(pts.begin(), pts.end());
  pts.erase(unique(pts.begin(), pts.end()), pts.end());
  vector<PT> up, dn;
  for (int i = 0; i < pts.size(); i++) {
    while (up.size() > 1 && area2(up[up.size() - 2], up.back(), pts[i]) >= 0)
      up.pop_back();
    while (dn.size() > 1 && area2(dn[dn.size() - 2], dn.back(), pts[i]) <= 0)
      dn.pop_back();
    up.push_back(pts[i]);
    dn.push_back(pts[i]);
  }
  pts = dn;
  for (int i = (int)up.size() - 2; i >= 1; i--) pts.push_back(up[i]);
}
PT ProjectPointSegment(PT a, PT b, PT c) {
  double r = dot(b - a, b - a);
  if (fabs(r) < EPS) return a;
  r = dot(c - a, b - a) / r;
  if (r < 0) return a;
  if (r > 1) return b;
  return a + (b - a) * r;
}
bool PointInPolygon(const vector<PT> &p, PT q) {
  bool c = 0;
  for (int i = 0; i < p.size(); i++) {
    int j = (i + 1) % p.size();
    if ((p[i].y <= q.y && q.y < p[j].y || p[j].y <= q.y && q.y < p[i].y) &&
        q.x < p[i].x + (p[j].x - p[i].x) * (q.y - p[i].y) / (p[j].y - p[i].y))
      c = !c;
  }
  return c;
}
bool PointOnPolygon(const vector<PT> &p, PT q) {
  for (int i = 0; i < p.size(); i++)
    if (dist2(ProjectPointSegment(p[i], p[(i + 1) % p.size()], q), q) < EPS)
      return true;
  return false;
}
vector<PT> pts;
int a[112345], b[112345];
int main() {
  int n;
  double l, r, m, p, q, ma = 0, mb = 0;
  int i, iter;
  cin >> n >> p >> q;
  for (i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    scanf("%d", &b[i]);
    ma = max(ma, (double)a[i]);
    mb = max(mb, (double)b[i]);
  }
  l = 0;
  r = 10000000;
  for (int iter = 0; iter < 50; iter++) {
    m = (l + r) / 2;
    pts.clear();
    for (i = 0; i < n; ++i) {
      pts.push_back(PT(a[i], b[i]));
    }
    pts.push_back(PT(ma, 0));
    pts.push_back(PT(0, mb));
    pts.push_back(PT(0, 0));
    ConvexHull(pts);
    if (PointOnPolygon(pts, PT(p / m, q / m)) ||
        PointInPolygon(pts, PT(p / m, q / m)) == 1) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << setprecision(20);
  cout << r << endl;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Do you know the story about the three musketeers? Anyway, you must help them now.

Richelimakieu is a cardinal in the city of Bearis. He found three brave warriors and called them the three musketeers. Athos has strength a, Borthos strength b, and Caramis has strength c.

The year 2015 is almost over and there are still n criminals to be defeated. The i-th criminal has strength ti. It's hard to defeat strong criminals — maybe musketeers will have to fight together to achieve it.

Richelimakieu will coordinate musketeers' actions. In each hour each musketeer can either do nothing or be assigned to one criminal. Two or three musketeers can be assigned to the same criminal and then their strengths are summed up. A criminal can be defeated in exactly one hour (also if two or three musketeers fight him). Richelimakieu can't allow the situation where a criminal has strength bigger than the sum of strengths of musketeers fighting him — a criminal would win then!

In other words, there are three ways to defeat a criminal.

  * A musketeer of the strength x in one hour can defeat a criminal of the strength not greater than x. So, for example Athos in one hour can defeat criminal i only if ti ≤ a.
  * Two musketeers can fight together and in one hour defeat a criminal of the strength not greater than the sum of strengths of these two musketeers. So, for example Athos and Caramis in one hour can defeat criminal i only if ti ≤ a + c. Note that the third remaining musketeer can either do nothing or fight some other criminal.
  * Similarly, all three musketeers can fight together and in one hour defeat a criminal of the strength not greater than the sum of musketeers' strengths, i.e. ti ≤ a + b + c.

Richelimakieu doesn't want musketeers to fight during the New Year's Eve. Thus, he must coordinate their actions in order to minimize the number of hours till all criminals will be defeated.

Find the minimum number of hours to defeat all criminals. If musketeers can't defeat them all then print "-1" (without the quotes) instead.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of criminals.

The second line contains three integers a, b and c (1 ≤ a, b, c ≤ 108) — strengths of musketeers.

The third line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 108) — strengths of criminals.

Output

Print one line with the answer.

If it's impossible to defeat all criminals, print "-1" (without the quotes). Otherwise, print the minimum number of hours the three musketeers will spend on defeating all criminals.

Examples

Input

5
10 20 30
1 1 1 1 50

Output

2

Input

5
10 20 30
1 1 1 1 51

Output

3

Input

7
30 20 10
34 19 50 33 88 15 20

Output

-1

Input

6
10 5 10
10 9 5 25 20 5

Output

3

Note

In the first sample Athos has strength 10, Borthos 20, and Caramis 30. They can defeat all criminals in two hours:

  * Borthos and Caramis should together fight a criminal with strength 50. In the same hour Athos can fight one of four criminals with strength 1.
  * There are three criminals left, each with strength 1. Each musketeer can fight one criminal in the second hour.

In the second sample all three musketeers must together fight a criminal with strength 51. It takes one hour. In the second hour they can fight separately, each with one criminal. In the third hour one criminal is left and any of musketeers can fight him.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int n;
int a[10], t[maxn];
bool ok(int n, int m) {
  int cnt = 0;
  int b[3];
  b[0] = b[1] = b[2] = m;
  for (int i = n - 1; i >= 0; i--) {
    if (t[i] <= a[0] && b[0]) {
      b[0]--;
    } else if (t[i] <= a[1] && b[1]) {
      b[1]--;
    } else if (t[i] <= a[2] && b[2]) {
      b[2]--;
    } else if (t[i] <= a[0] + a[1] && b[0] && b[1]) {
      b[0]--, b[1]--;
      cnt++;
    } else if (t[i] <= a[0] + a[2] && b[0] && b[2]) {
      b[0]--, b[2]--;
      cnt++;
    } else if (t[i] <= a[1] + a[2] && b[1] && b[2]) {
      b[1]--, b[2]--;
      cnt++;
    } else if (t[i] <= a[0] + a[1] + a[2] && b[0] && b[1] && b[2]) {
      b[0]--, b[1]--, b[2]--;
      cnt++;
    } else
      return false;
  }
  if (cnt > m) return false;
  return true;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    sort(a, a + 3);
    int sum = a[0] + a[1] + a[2];
    bool find = false;
    for (int i = 0; i < n; i++) {
      scanf("%d", &t[i]);
      if (t[i] > sum) find = true;
    }
    if (find) {
      printf("-1\n");
      continue;
    }
    sort(t, t + n);
    int l = 1, r = n, m, ans = n;
    while (l <= r) {
      m = l + r >> 1;
      if (ok(n, m)) {
        r = m - 1;
        ans = m;
      } else {
        l = m + 1;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

```


### Prompt

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

Given a string of length n s = s1, s2,…, sn and m queries. Each query qk (1 ≤ k ≤ m) is one of four types, "L ++", "L-", "R ++", "R-", and l [for the kth query qk. k] and r [k] are defined below.

* L ++: l [k] = l [k-1] + 1, r [k] = r [k-1]

* L-: l [k] = l [k-1] -1, r [k] = r [k-1]

* R ++: l [k] = l [k-1], r [k] = r [k-1] +1

* R-: l [k] = l [k-1], r [k] = r [k-1] -1

However, l [0] = r [0] = 1.

At this time, how many kinds of character strings are created for m substrings sl [k], sl [k] + 1,…, sr [k] -1, sr [k] (1 ≤ k ≤ m). Answer if you can.

Constraints

* The string s consists of a lowercase alphabet

* 1 ≤ n ≤ 3 x 105

* 1 ≤ m ≤ 3 × 105

* qk (1 ≤ k ≤ m) is one of "L ++", "L-", "R ++", "R-"

* 1 ≤ l [k] ≤ r [k] ≤ n (1 ≤ k ≤ m)

Input

Input is given in the following format

> n m
> s
> q1
> q2
>…
> qm
>

Output

Output the solution of the problem on one line

Examples

Input

5 4
abcde
R++
R++
L++
L--

Output

3

Input

4 6
abab
R++
L++
R++
L++
R++
L++

Output

4

Input

10 13
aacacbabac
R++
R++
L++
R++
R++
L++
L++
R++
R++
L--
L--
R--
R--

Output

11

### Response

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

struct RollingHash {
  typedef tuple<ll,ll,ll> HashType;

  const ll mod1 = 999999893;
  const ll mod2 = 999999929;
  const ll mod3 = 999999937;
  const ll b1 = 3422539;
  const ll b2 = 1245103;
  const ll b3 = 22961;
  vector<ll> h1, h2, h3;
  vector<ll> pow1, pow2, pow3;

  RollingHash(const string &s) {
    const int n = s.size();
    h1.assign(n+1, 0);
    h2.assign(n+1, 0);
    h3.assign(n+1, 0);
    pow1.assign(n+1, 1);
    pow2.assign(n+1, 1);
    pow3.assign(n+1, 1);
    REP(i, n) {
      h1[i+1] = (h1[i] * b1 + s[i]) % mod1;
      h2[i+1] = (h2[i] * b2 + s[i]) % mod2;
      h3[i+1] = (h3[i] * b3 + s[i]) % mod3;
      pow1[i+1] = pow1[i] * b1 % mod1;
      pow2[i+1] = pow2[i] * b2 % mod2;
      pow3[i+1] = pow3[i] * b3 % mod3;
    }
  }

  HashType get(int l, int r) {
    ll v1 = ((h1[r] - h1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
    ll v2 = ((h2[r] - h2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
    ll v3 = ((h3[r] - h3[l] * pow3[r-l]) % mod3 + mod3) % mod3;
    return HashType {v1, v2, v3};
  }
};

int main2() {
  int N, M; cin >> N >> M;
  string s; cin >> s;
  RollingHash hash(s);
  int l = 0;
  int r = 1;
  set<RollingHash::HashType> st;
  REP(_, M) {
    string cmd; cin >> cmd;
    if (cmd == "R++") { r++; }
    if (cmd == "R--") { r--; }
    if (cmd == "L++") { l++; }
    if (cmd == "L--") { l--; }
    auto key = hash.get(l, r);
    st.insert(key);
  }
  cout << st.size() << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

One day, ZS the Coder wrote down an array of integers a with elements a1, a2, ..., an.

A subarray of the array a is a sequence al, al + 1, ..., ar for some integers (l, r) such that 1 ≤ l ≤ r ≤ n. ZS the Coder thinks that a subarray of a is beautiful if the bitwise xor of all the elements in the subarray is at least k.

Help ZS the Coder find the number of beautiful subarrays of a!

Input

The first line contains two integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 109) — the number of elements in the array a and the value of the parameter k.

The second line contains n integers ai (0 ≤ ai ≤ 109) — the elements of the array a.

Output

Print the only integer c — the number of beautiful subarrays of the array a.

Examples

Input

3 1
1 2 3

Output

5

Input

3 2
1 2 3

Output

3

Input

3 3
1 2 3

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int N = 1e4 + 5;
struct Node {
  int cnt;
  Node* nxt[2];
  Node() {
    cnt = 0;
    memset(nxt, 0, sizeof nxt);
  }
};
Node* rt;
int n, k;
void add(int x) {
  Node* cur = rt;
  for (int i = 30; i >= 0; i--) {
    bool b = ((1 << i) & x);
    if (!cur->nxt[b]) cur->nxt[b] = new Node();
    cur = cur->nxt[b];
    cur->cnt++;
  }
}
int query(int x) {
  Node* cur = rt;
  int cnt = 0;
  for (int i = 30; i >= 0; i--) {
    bool bx = (1 << i) & x, bk = (1 << i) & k;
    if (!bk) {
      if (cur->nxt[!bx]) {
        cnt += cur->nxt[!bx]->cnt;
      }
      if (!cur->nxt[bx]) return cnt;
      cur = cur->nxt[bx];
    } else {
      if (!cur->nxt[!bx]) return cnt;
      cur = cur->nxt[!bx];
    }
  }
  return cnt + cur->cnt;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  rt = new Node();
  cin >> n >> k;
  int arr[n];
  long long ans = 0;
  add(0);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (i) arr[i] ^= arr[i - 1];
    ans += query(arr[i]);
    add(arr[i]);
  }
  cout << ans;
  return 0;
}

```


### Prompt

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

The campus has m rooms numbered from 0 to m - 1. Also the x-mouse lives in the campus. The x-mouse is not just a mouse: each second x-mouse moves from room i to the room i ⋅ x mod{m} (in fact, it teleports from one room to another since it doesn't visit any intermediate room). Starting position of the x-mouse is unknown.

You are responsible to catch the x-mouse in the campus, so you are guessing about minimum possible number of traps (one trap in one room) you need to place. You are sure that if the x-mouse enters a trapped room, it immediately gets caught.

And the only observation you made is GCD (x, m) = 1.

Input

The only line contains two integers m and x (2 ≤ m ≤ 10^{14}, 1 ≤ x < m, GCD (x, m) = 1) — the number of rooms and the parameter of x-mouse.

Output

Print the only integer — minimum number of traps you need to install to catch the x-mouse.

Examples

Input

4 3

Output

3

Input

5 2

Output

2

Note

In the first example you can, for example, put traps in rooms 0, 2, 3. If the x-mouse starts in one of this rooms it will be caught immediately. If x-mouse starts in the 1-st rooms then it will move to the room 3, where it will be caught.

In the second example you can put one trap in room 0 and one trap in any other room since x-mouse will visit all rooms 1..m-1 if it will start in any of these rooms.

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int inf = 0x3f3f3f3f;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
long long n, x, m, ans;
long long p[233], q[2333];
void d(long long x) {
  for (int i = 2; 1ll * i * i <= m; ++i)
    if (x % i == 0) {
      q[++*q] = i;
      while (x % i == 0) x /= i;
    }
  if (x > 1) q[++*q] = x;
}
long long times(long long x, long long y, long long mod) {
  long long res =
      (x * y - (long long)(((long double)x * y + 0.5) / mod) * mod) % mod;
  res = (res % mod + mod) % mod;
  return res;
}
long long qpow(long long a, long long b, long long mod) {
  long long ans = 1;
  for (; b; b >>= 1, a = times(a, a, mod))
    if (b & 1) ans = times(ans, a, mod);
  return ans;
}
long long phi(long long x) {
  long long res = x;
  for (register int i = (1); i <= int(*p); ++i)
    if (x % p[i] == 0) res = res / p[i] * (p[i] - 1);
  return res;
}
long long solve(long long a) {
  long long mod = n / a, t = phi(mod), tmp = t, xd = x % mod;
  for (int i = 1; i <= *q; ++i) {
    while (tmp % q[i] == 0 && qpow(xd, tmp / q[i], mod) == 1) tmp /= q[i];
  }
  return t / tmp;
}
int main() {
  n = read(), x = read(), m = n;
  for (int i = 2; 1ll * i * i <= m; ++i)
    if (m % i == 0) {
      p[++*p] = i;
      while (m % i == 0) m /= i;
    }
  if (m > 1) p[++*p] = m;
  for (register int i = (1); i <= int(*p); ++i) {
    q[++*q] = p[i];
    d(p[i] - 1);
  }
  sort(q + 1, q + 1 + *q);
  *q = unique(q + 1, q + 1 + *q) - q - 1;
  for (int i = 1; 1ll * i * i <= n; ++i) {
    if (n % i == 0) {
      ans += solve(i);
      if (n / i != i) ans += solve(n / i);
    }
  }
  writeln(ans);
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

You are given the array a consisting of n positive (greater than zero) integers.

In one move, you can choose two indices i and j (i ≠ j) such that the absolute difference between a_i and a_j is no more than one (|a_i - a_j| ≤ 1) and remove the smallest of these two elements. If two elements are equal, you can remove any of them (but exactly one).

Your task is to find if it is possible to obtain the array consisting of only one element using several (possibly, zero) such moves or not.

You have to answer t independent test cases.

Input

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

The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the length of a. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the i-th element of a.

Output

For each test case, print the answer: "YES" if it is possible to obtain the array consisting of only one element using several (possibly, zero) moves described in the problem statement, or "NO" otherwise.

Example

Input

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

Output

YES
YES
NO
NO
YES

Note

In the first test case of the example, we can perform the following sequence of moves:

  * choose i=1 and j=3 and remove a_i (so a becomes [2; 2]);
  * choose i=1 and j=2 and remove a_j (so a becomes [2]).

In the second test case of the example, we can choose any possible i and j any move and it doesn't matter which element we remove.

In the third test case of the example, there is no way to get rid of 2 and 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    bool oddPres = false;
    bool evenPres = false;
    for (int val : arr) {
      if (val % 2 == 0) {
        evenPres = true;
      } else {
        oddPres = true;
      }
    }
    if (n % 2 == 0) {
      if (evenPres && oddPres) {
        cout << "YES";
      } else {
        cout << "NO";
      }
    } else {
      if (oddPres) {
        cout << "YES";
      } else {
        cout << "NO";
      }
    }
    cout << "\n";
  }
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.

Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more.

Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal.

For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves:

  * Destroy the leftmost stone. After this move a = [5, 4, 3, 2];
  * Destroy the rightmost stone. After this move a = [5, 4, 3];
  * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game.

Please note that in the example above, you can complete the game in two steps. For example:

  * Destroy the leftmost stone. After this move a = [5, 4, 3, 2];
  * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game.

Input

The first line contains an integer t (1 ≤ t ≤ 100). Then t test cases follow.

The first line of each test case contains one integer n (2 ≤ n ≤ 100) — the number of stones.

The second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the power of the stones.

Output

For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power.

Example

Input

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

Output

2
4
5
3
2

### Response

```cpp
  #include "bits/stdc++.h"
  using namespace std;
  # define endl "\n"
  #define pb emplace_back
  #define mod 1000000007
  int prime[10000001];
  vector<int> primes;
  void prime_seive()
  {
     for(int i=2;i*i<10000001;i++)
     {
        if(!prime[i])
        {
           for(int j=i*i;j<10000001;j+=i)
            prime[j]=1;
        }
     }
  }
  void calc()
  {
    primes.reserve(1000001);
    for(int i=2;i<10000001;i++)
    {
       if(!prime[i])
        primes.push_back(i);
    }
  }
  long long myceil_ll(long long a,long long b)
  {
     return (a+b-1)/b;
  }
  int myceil_int(int a,int b)
  {
     return (a+b-1)/b;
  }
  bool is_square(long long temp)
  {
     long long po=sqrtl(temp);
     if(po*po==temp)
      return true;
    return false;
  }
//   bool equal(vector<int> diff)
//   {
//      for(int i=1;i<diff.size();i++)
//      {
//        if(diff[i]!=diff[i-1])return false;
//      }
//      return true;
//   }
//   int first_digit(long long num)
//   {
//      int count=0;
//      while(num>=10)
//         num/=10;
//      return num;
//   }
//   long long fact(int num)
//   {
//     long long prod=1;
//     for(int i=2;i<=num;i++)
//     {
//       prod*=i;
//       prod%=mod;
//     }
//     return prod;
//   }
//   long long power(int a,int b)
//   {
//      long long ans=1;
//      for(int i=0;i<b;i++)
//        ans = (long long)ans*a;
//      return ans;
//   }
//   bool cmp(const pair<int, int>& a,const pair<int, int>& b)
//   {
//     return (a.second > b.second);
//   }
//   // Function to sort the map according
//   // to value in a (key-value) pairs
//   void sorte(map<int, int>& M)
//   {
//     // Declare vector of pairs
//     vector<pair<int, int> > A;
//     // Copy key-value pair from Map
//     // to vector of pairs
//     for (auto& it : M) {
//         A.push_back(it);
//     }
//     // Sort using comparator function
//     sort(A.begin(), A.end());
//   }
  bool is_prime(long long num)
  {
     int is=true;
     for(int i=2;i<=sqrt(num);i++)
     {
       if((num%i)==0)
       {
         return false;
       }
     }
     return true;
  }
 bool is_valid(int row,int col,int n)
 {
    if(row<col || row<0 || row>=n || col<0 || col>=n)
      return false;
    return true;
 }
//  bool sizecom(const vector<int>& v1, const vector<int>& v2)
//  {
//     return v1.size() > v2.size();
//  }
//  void bubble_sort(int arr[],int n)
//  {
//     for(int i=0;i<n;i++)
//     {
//        for(int j=0;j<n-i-1;j++)
//        {
//          if(arr[j]<arr[j+1])
//           swap(arr[j],arr[j+1]);
//        }
//     }
//  }
//  void insertion_sort(int arr[],int n)
//  {
//     for(int i=1;i<n;i++)
//     {
//       int j=i;
//       while(j>0 && arr[j]<arr[j-1])
//         swap(arr[j],arr[j-1]),j--;
//     }
//  }
//  int partition(int arr[],int start,int end)
//  {
//     int pivot = arr[end];
//     int idx = start-1;
//     for(int i=start;i<end;i++)
//     {
//        if(arr[i]<pivot)
//        {
//          idx++;
//          swap(arr[idx],arr[i]);
//        }
//     }
//     swap(arr[idx+1],arr[end]);
//     return idx+1;
//  }
//  void quick_sort(int arr[],int start,int end)
//  {
//     if(start>=end)return;
//     int pi = partition(arr,start,end);
//     quick_sort(arr,start,pi-1);
//     quick_sort(arr,pi+1,end);
//  }
 void dbg_arr(int arr[],int n)
  {
   for(int i=0;i<n;i++)
     cout << arr[i] << " ";
   cout << endl;
  }

  void dbg_vec(vector<int>&v)
  {
   for(auto it:v)
     cout << it << " ";
   cout << endl;
  }
 void read_array(int arr[],int n)
 {
   for(int i=0;i<n;i++)
     cin >> arr[i];
 }
 void write_array(int arr[],int n)
 {
   for(int i=0;i<n;i++)
     cout << arr[i] << " ";
   cout << endl;
 }
// int len(long long num)
//   {
//      int count=0;
//      while(num>0)
//      {
//        //count++;
//        count+=(num%10);
//        num/=10;
//      }
//      return count;
//   }

  void t_c()
  {
     int n;
     cin >> n;
     int arr[n];
     read_array(arr,n);
     int s_idx,l_idx;
     for(int i=0;i<n;i++)
     {
       if(arr[i]==1)
         s_idx = i;
       if(arr[i]==n)
         l_idx = i;
     }
     int c1,c2,c3;
     // cout << l_idx << " " << s_idx << endl;
     int mini = min(s_idx,l_idx);
     int maxi = max(s_idx,l_idx);
     if(mini == s_idx)
     {
        c1 = s_idx+1 + n-l_idx;
        c2 = s_idx+1 + l_idx-s_idx;
        c3 = n-l_idx + abs(s_idx-l_idx);
     }
     else
     {
       c1 = l_idx+1 + n-s_idx;
       c2 = l_idx+1 + s_idx-l_idx;
       c3 = n-s_idx + abs(s_idx-l_idx);
     }
     // cout << c1 << " " << c2 << " " << c3 << endl;
     cout << min({c1,c2,c3}) << endl;
  }
  int main()
  {
   // prime_seive();
   // calc();
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    cin >> t;
    for(int i=0;i<t;i++)
    {
       t_c();
    }
  }
```


### Prompt

Construct a Cpp code solution to the problem outlined:

Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.

Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. In one move one can either stay at the current vertex or travel to the neighbouring one.

The game ends when Alice goes to the same vertex where Bob is standing. Alice wants to minimize the total number of moves and Bob wants to maximize it.

You should write a program which will determine how many moves will the game last.

Input

The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n).

Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.

Output

Print the total number of moves Alice and Bob will make.

Examples

Input

4 3
1 2
2 3
2 4

Output

4

Input

5 2
1 2
2 3
3 4
2 5

Output

6

Note

In the first example the tree looks like this:

<image>

The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:

B: stay at vertex 3

A: go to vertex 2

B: stay at vertex 3

A: go to vertex 3

In the second example the tree looks like this:

<image>

The moves in the optimal strategy are:

B: go to vertex 3

A: go to vertex 2

B: go to vertex 4

A: go to vertex 3

B: stay at vertex 4

A: go to vertex 4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200010;
vector<int> adj[N];
int dist[N];
void prep(int u, int d = 0, int p = -1) {
  dist[u] = d;
  for (int v : adj[u])
    if (v != p) {
      prep(v, d + 1, u);
    }
}
int dfs(int u, int d = 0, int p = -1) {
  if (dist[u] <= d) return 2 * d;
  int ans = 2 * dist[u];
  for (int v : adj[u])
    if (v != p) {
      ans = max(ans, dfs(v, d + 1, u));
    }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  prep(1);
  cout << dfs(x) << endl;
  return 0;
}

```


### Prompt

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

Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number a and Antisimon receives number b. They also have a heap of n stones. The players take turns to make a move and Simon starts. During a move a player should take from the heap the number of stones equal to the greatest common divisor of the fixed number he has received and the number of stones left in the heap. A player loses when he cannot take the required number of stones (i. e. the heap has strictly less stones left than one needs to take).

Your task is to determine by the given a, b and n who wins the game.

Input

The only string contains space-separated integers a, b and n (1 ≤ a, b, n ≤ 100) — the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile.

Output

If Simon wins, print "0" (without the quotes), otherwise print "1" (without the quotes).

Examples

Input

3 5 9

Output

0

Input

1 1 100

Output

1

Note

The greatest common divisor of two non-negative integers a and b is such maximum positive integer k, that a is divisible by k without remainder and similarly, b is divisible by k without remainder. Let gcd(a, b) represent the operation of calculating the greatest common divisor of numbers a and b. Specifically, gcd(x, 0) = gcd(0, x) = x.

In the first sample the game will go like that:

  * Simon should take gcd(3, 9) = 3 stones from the heap. After his move the heap has 6 stones left.
  * Antisimon should take gcd(5, 6) = 1 stone from the heap. After his move the heap has 5 stones left.
  * Simon should take gcd(3, 5) = 1 stone from the heap. After his move the heap has 4 stones left.
  * Antisimon should take gcd(5, 4) = 1 stone from the heap. After his move the heap has 3 stones left.
  * Simon should take gcd(3, 3) = 3 stones from the heap. After his move the heap has 0 stones left.
  * Antisimon should take gcd(5, 0) = 5 stones from the heap. As 0 < 5, it is impossible and Antisimon loses.

In the second sample each player during each move takes one stone from the heap. As n is even, Antisimon takes the last stone and Simon can't make a move after that.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x, a, b, result = 0, t, w;
  cin >> a >> b >> n;
  for (t = 1; n >= 0; t++) {
    for (i = n; i >= 1; i--) {
      if (n % i == 0 && a % i == 0) {
        x = i;
        break;
      }
    }
    n = n - x;
    if (n == 0) {
      result = 0;
    }
    for (w = n; w >= 1; w--) {
      if (n % w == 0 && b % w == 0) {
        x = w;
        break;
      }
    }
    n = n - x;
    if (n == 0) {
      result = 1;
    }
  }
  cout << result;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

The only difference between easy and hard versions is constraints.

Polycarp loves to listen to music, so he never leaves the player, even on the way home from the university. Polycarp overcomes the distance from the university to the house in exactly T minutes.

In the player, Polycarp stores n songs, each of which is characterized by two parameters: t_i and g_i, where t_i is the length of the song in minutes (1 ≤ t_i ≤ 15), g_i is its genre (1 ≤ g_i ≤ 3).

Polycarp wants to create such a playlist so that he can listen to music all the time on the way from the university to his home, and at the time of his arrival home, the playlist is over. Polycarp never interrupts songs and always listens to them from beginning to end. Thus, if he started listening to the i-th song, he would spend exactly t_i minutes on its listening. Polycarp also does not like when two songs of the same genre play in a row (i.e. successively/adjacently) or when the songs in his playlist are repeated.

Help Polycarpus count the number of different sequences of songs (their order matters), the total duration is exactly T, such that there are no two consecutive songs of the same genre in them and all the songs in the playlist are different.

Input

The first line of the input contains two integers n and T (1 ≤ n ≤ 15, 1 ≤ T ≤ 225) — the number of songs in the player and the required total duration, respectively.

Next, the n lines contain descriptions of songs: the i-th line contains two integers t_i and g_i (1 ≤ t_i ≤ 15, 1 ≤ g_i ≤ 3) — the duration of the i-th song and its genre, respectively.

Output

Output one integer — the number of different sequences of songs, the total length of exactly T, such that there are no two consecutive songs of the same genre in them and all the songs in the playlist are different. Since the answer may be huge, output it modulo 10^9 + 7 (that is, the remainder when dividing the quantity by 10^9 + 7).

Examples

Input

3 3
1 1
1 2
1 3

Output

6

Input

3 3
1 1
1 1
1 3

Output

2

Input

4 10
5 3
2 1
3 2
5 1

Output

10

Note

In the first example, Polycarp can make any of the 6 possible playlist by rearranging the available songs: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2] and [3, 2, 1] (indices of the songs are given).

In the second example, the first and second songs cannot go in succession (since they have the same genre). Thus, Polycarp can create a playlist in one of 2 possible ways: [1, 3, 2] and [2, 3, 1] (indices of the songs are given).

In the third example, Polycarp can make the following playlists: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [1, 4], [4, 1], [2, 3, 4] and [4, 3, 2] (indices of the songs are given).

### Response

```cpp
#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
long long dp[1 << 17][5], n, val[18], type[18], res = 0, t;
signed main() {
  cin >> n >> t;
  for (long long i = 1; i <= n; i++) {
    cin >> val[i] >> type[i];
    dp[1 << (i - 1)][type[i]] = 1;
  }
  for (long long i = 1; i < (1 << n); i++) {
    for (long long last = 1; last <= 3; last++) {
      for (long long j = 1; j <= n; j++) {
        if ((i & (1 << (j - 1))) == 0 && last != type[j]) {
          dp[i | (1 << (j - 1))][type[j]] =
              (dp[i | (1 << (j - 1))][type[j]] + dp[i][last]) % mod;
        }
      }
      long long sum = 0;
      for (long long k = 1; k <= n; k++) {
        if ((1 << (k - 1) & i) != 0) sum += val[k];
      }
      if (sum == t) res += dp[i][last] % mod;
      res %= mod;
    }
  }
  cout << res % mod;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.

However, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were here to steal her, and she was fighting them off. Every k-th dragon got punched in the face with a frying pan. Every l-th dragon got his tail shut into the balcony door. Every m-th dragon got his paws trampled with sharp heels. Finally, she threatened every n-th dragon to call her mom, and he withdrew in panic.

How many imaginary dragons suffered moral or physical damage tonight, if the princess counted a total of d dragons?

Input

Input data contains integer numbers k, l, m, n and d, each number in a separate line (1 ≤ k, l, m, n ≤ 10, 1 ≤ d ≤ 105).

Output

Output the number of damaged dragons.

Examples

Input

1
2
3
4
12

Output

12

Input

2
3
4
5
24

Output

17

Note

In the first case every first dragon got punched with a frying pan. Some of the dragons suffered from other reasons as well, but the pan alone would be enough.

In the second case dragons 1, 7, 11, 13, 17, 19 and 23 escaped unharmed.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, l, m, n, d;
  cin >> k >> l >> m >> n >> d;
  int count = d;
  for (int i = 1; i <= d; i++) {
    if (i % k != 0) {
      if (i % l != 0) {
        if (i % m != 0) {
          if (i % n != 0) {
            count--;
          }
        }
      }
    }
  }
  cout << count;
}

```


### Prompt

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

The Ohgas are a prestigious family based on Hachioji. The head of the family, Mr. Nemochi Ohga, a famous wealthy man, wishes to increase his fortune by depositing his money to an operation company. You are asked to help Mr. Ohga maximize his profit by operating the given money during a specified period.

From a given list of possible operations, you choose an operation to deposit the given fund to. You commit on the single operation throughout the period and deposit all the fund to it. Each operation specifies an annual interest rate, whether the interest is simple or compound, and an annual operation charge. An annual operation charge is a constant not depending on the balance of the fund. The amount of interest is calculated at the end of every year, by multiplying the balance of the fund under operation by the annual interest rate, and then rounding off its fractional part. For compound interest, it is added to the balance of the fund under operation, and thus becomes a subject of interest for the following years. For simple interest, on the other hand, it is saved somewhere else and does not enter the balance of the fund under operation (i.e. it is not a subject of interest in the following years). An operation charge is then subtracted from the balance of the fund under operation. You may assume here that you can always pay the operation charge (i.e. the balance of the fund under operation is never less than the operation charge). The amount of money you obtain after the specified years of operation is called ``the final amount of fund.'' For simple interest, it is the sum of the balance of the fund under operation at the end of the final year, plus the amount of interest accumulated throughout the period. For compound interest, it is simply the balance of the fund under operation at the end of the final year.

Operation companies use C, C++, Java, etc., to perform their calculations, so they pay a special attention to their interest rates. That is, in these companies, an interest rate is always an integral multiple of 0.0001220703125 and between 0.0001220703125 and 0.125 (inclusive). 0.0001220703125 is a decimal representation of 1/8192. Thus, interest rates' being its multiples means that they can be represented with no errors under the double-precision binary representation of floating-point numbers.

For example, if you operate 1000000 JPY for five years with an annual, compound interest rate of 0.03125 (3.125 %) and an annual operation charge of 3000 JPY, the balance changes as follows.

The balance of the fund under operation (at the beginning of year) | Interest|  The balance of the fund under operation (at the end of year)
---|---|---
A| B = A × 0.03125 (and rounding off fractions) | A + B - 3000
1000000| 31250| 1028250
1028250| 32132| 1057382
1057382| 33043| 1087425
1087425| 33982| 1118407
1118407| 34950| 1150357

After the five years of operation, the final amount of fund is 1150357 JPY.

If the interest is simple with all other parameters being equal, it looks like:

The balance of the fund under operation (at the beginning of year) | Interest | The balance of the fund under operation (at the end of year) | Cumulative interest
---|---|---|---
A| B = A × 0.03125 (and rounding off fractions)| A - 3000|
1000000| 31250| 997000| 31250
997000| 31156| 994000| 62406
994000| 31062| 991000| 93468
991000| 30968| 988000| 124436
988000| 30875| 985000| 155311

In this case the final amount of fund is the total of the fund under operation, 985000 JPY, and the cumulative interests, 155311 JPY, which is 1140311 JPY.

Input

The input consists of datasets. The entire input looks like:

> the number of datasets (=m)
>  1st dataset
>  2nd dataset
>  ...
>  m-th dataset
>

The number of datasets, m, is no more than 100. Each dataset is formatted as follows.

> the initial amount of the fund for operation
>  the number of years of operation
>  the number of available operations (=n)
>  operation 1
>  operation 2
>  ...
>  operation n
>

The initial amount of the fund for operation, the number of years of operation, and the number of available operations are all positive integers. The first is no more than 100000000, the second no more than 10, and the third no more than 100.

Each ``operation'' is formatted as follows.

> simple-or-compound annual-interest-rate annual-operation-charge

where simple-or-compound is a single character of either '0' or '1', with '0' indicating simple interest and '1' compound. annual-interest-rate is represented by a decimal fraction and is an integral multiple of 1/8192. annual-operation-charge is an integer not exceeding 100000.

Output

For each dataset, print a line having a decimal integer indicating the final amount of fund for the best operation. The best operation is the one that yields the maximum final amount among the available operations. Each line should not have any character other than this number.

You may assume the final balance never exceeds 1000000000. You may also assume that at least one operation has the final amount of the fund no less than the initial amount of the fund.

Example

Input

4
1000000
5
2
0 0.03125 3000
1 0.03125 3000
6620000
7
2
0 0.0732421875 42307
1 0.0740966796875 40942
39677000
4
4
0 0.0709228515625 30754
1 0.00634765625 26165
0 0.03662109375 79468
0 0.0679931640625 10932
10585000
6
4
1 0.0054931640625 59759
1 0.12353515625 56464
0 0.0496826171875 98193
0 0.0887451171875 78966

Output

1150357
10559683
50796918
20829397

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int m;
    cin>>m;
    int d,y,n;
    int f,c;
    double p;
    while(m--){
        cin>>d>>y>>n;
        int mx=0;
        rep(i,n){
            int td=d;
            cin>>f>>p>>c;
            if(f==0){
                int cnt=0;
                rep(j,y){
                    cnt+=p*td;
                    td-=c;
                }
                td+=cnt;
            }
            else{
                rep(j,y){
                    td=p*td+td;
                    td-=c;
                }
            }
            mx=max(mx,td);
        }
        cout<<mx<<endl;
    }
    return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.

Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consecutive vowels in the word, it deletes the first vowel in a word such that there is another vowel right before it. If there are no two consecutive vowels in the word, it is considered to be correct.

You are given a word s. Can you predict what will it become after correction?

In this problem letters a, e, i, o, u and y are considered to be vowels.

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the number of letters in word s before the correction.

The second line contains a string s consisting of exactly n lowercase Latin letters — the word before the correction.

Output

Output the word s after the correction.

Examples

Input

5
weird

Output

werd

Input

4
word

Output

word

Input

5
aaeaa

Output

a

Note

Explanations of the examples:

  1. There is only one replace: weird <image> werd;
  2. No replace needed since there are no two consecutive vowels;
  3. aaeaa <image> aeaa <image> aaa <image> aa <image> a.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  string s;
  char v[] = {'a', 'i', 'e', 'o', 'u', 'y'};
  int f = 0;
  cin >> s;
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < 6; j++) {
      if (s[i] == v[j])
        for (int z = 0; z < 6; z++)
          if (s[i + 1] == v[z]) {
            s.erase(s.begin() + i + 1);
            f = 1;
            i--;
            break;
          }
      if (f == 1) {
        f = 0;
        break;
      }
    }
  cout << s;
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Write a program that extracts n different numbers from the numbers 0 to 9 and outputs the number of combinations that add up to s. Each n number is from 0 to 9, and the same number cannot be used in one combination. For example, if n is 3 and s is 6, the combination of the three numbers totaling 6 is

1 + 2 + 3 = 6
0 + 1 + 5 = 6
0 + 2 + 4 = 6

There are three ways.

Input

Given multiple datasets. For each dataset, n (1 ≤ n ≤ 9) and s (0 ≤ s ≤ 100) are given on one line, separated by a single space. When both n and s are 0, it is the end of the input (in this case, the program is terminated without processing).

The number of datasets does not exceed 50.

Output

For each dataset, output the number of combinations in which the sum of n integers is s on one line.

Example

Input

3 6
3 1
0 0

Output

3
0

### Response

```cpp
#include <iostream>
using namespace std;
int count(int n,int s,int i)
{
  if(n == 1){
    if(i <= s && s < 10) return 1;
    return 0;
  }
  int res = 0;
  for(; i<10; i++){
    res += count(n-1, s-i,i+1);
  }
  return res;
}
int main()
{
  int n,s;
  while(cin >> n >> s, n!=0){
    int cnt = count(n,s,0);
    cout << cnt << endl;
  }
  return 0;
}
```


### Prompt

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

IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer of this game gets a small bonus.

A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.

Input

The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the prediction on the number of people who will buy the game.

Output

Output one integer showing how many numbers from 1 to n are divisible by all numbers from 2 to 10.

Examples

Input

3000

Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, y;
  cin >> x;
  y = x / 2520;
  cout << y << endl;
  return 0;
}

```


### Prompt

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

Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:

* update(s, t, x): change as, as+1, ..., at to x.
* find(i): output the value of ai.

Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 0 ≤ s ≤ t < n
* 0 ≤ i < n
* 0 ≤ x < 231−1

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 i

The first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(i).

Output

For each find operation, print the value.

Examples

Input

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

Output

1
3

Input

1 3
1 0
0 0 0 5
1 0

Output

2147483647
5

### 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 = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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; }
template<typename T>
struct RangeUpdateQuery {
	int n;
	vector<int>d;
	RangeUpdateQuery(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	int find(int i) {
		update(i, i + 1);
		return d[n + i];
	}
	void update(int a, int b, int x=-1, int k = 1, int l = 0, int r = -1) {
		if (r < 0)r = n;

		if (r <= a || b <= l)return;
		else if (a <= l&&r <= b) {
			if (x >= 0)d[k] = x;
			return;
		}
		else {
			if (d[k] != INF)d[2 * k] = d[2 * k + 1] = d[k], d[k] = INF;
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
		}
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RangeUpdateQuery<int>ruq(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com) {
			int x; cin >> x;
			cout << ruq.find(x) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			ruq.update(s, t + 1, x);
		}
	}
	return 0;
}
```


### Prompt

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

Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. The original problem is in the following paragraph.

People don't use cash as often as they used to. Having a credit card solves some of the hassles of cash, such as having to receive change when you can't form the exact amount of money needed to purchase an item. Typically cashiers will give you as few coins as possible in change, but they don't have to. For example, if your change is 30 cents, a cashier could give you a 5 cent piece and a 25 cent piece, or they could give you three 10 cent pieces, or ten 1 cent pieces, two 5 cent pieces, and one 10 cent piece. Altogether there are 18 different ways to make 30 cents using only 1 cent pieces, 5 cent pieces, 10 cent pieces, and 25 cent pieces. Two ways are considered different if they contain a different number of at least one type of coin. Given the denominations of the coins and an amount of change to be made, how many different ways are there to make change?

As we mentioned before, we lost all the test cases for this problem, so we're actually going to give you the number of ways, and want you to produce a test case for which the number of ways is the given number. There could be many ways to achieve this (we guarantee there's always at least one), so you can print any, as long as it meets the constraints described below.

Input

Input will consist of a single integer A (1 ≤ A ≤ 105), the desired number of ways.

Output

In the first line print integers N and M (1 ≤ N ≤ 106, 1 ≤ M ≤ 10), the amount of change to be made, and the number of denominations, respectively.

Then print M integers D1, D2, ..., DM (1 ≤ Di ≤ 106), the denominations of the coins. All denominations must be distinct: for any i ≠ j we must have Di ≠ Dj.

If there are multiple tests, print any of them. You can print denominations in atbitrary order.

Examples

Input

18

Output

30 4
1 5 10 25

Input

3

Output

20 2
5 2

Input

314

Output

183 4
6 5 2 139

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int arr[(int)1e6];
int n;
int main() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  for (int i = 1; i <= (int)1e6; i++) {
    arr[i] = (i / 2) + 1;
  }
  cin >> n;
  for (int i = 1; i <= (int)1e6; i++) {
    if (arr[i] == n) {
      cout << i << " " << 2 << endl;
      break;
    }
  }
  cout << 1 << " " << 2 << endl;
  return 0;
}

```


### Prompt

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

You a captain of a ship. Initially you are standing in a point (x_1, y_1) (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point (x_2, y_2).

You know the weather forecast — the string s of length n, consisting only of letters U, D, L and R. The letter corresponds to a direction of wind. Moreover, the forecast is periodic, e.g. the first day wind blows to the side s_1, the second day — s_2, the n-th day — s_n and (n+1)-th day — s_1 again and so on.

Ship coordinates change the following way:

  * if wind blows the direction U, then the ship moves from (x, y) to (x, y + 1);
  * if wind blows the direction D, then the ship moves from (x, y) to (x, y - 1);
  * if wind blows the direction L, then the ship moves from (x, y) to (x - 1, y);
  * if wind blows the direction R, then the ship moves from (x, y) to (x + 1, y).

The ship can also either go one of the four directions or stay in place each day. If it goes then it's exactly 1 unit of distance. Transpositions of the ship and the wind add up. If the ship stays in place, then only the direction of wind counts. For example, if wind blows the direction U and the ship moves the direction L, then from point (x, y) it will move to the point (x - 1, y + 1), and if it goes the direction U, then it will move to the point (x, y + 2).

You task is to determine the minimal number of days required for the ship to reach the point (x_2, y_2).

Input

The first line contains two integers x_1, y_1 (0 ≤ x_1, y_1 ≤ 10^9) — the initial coordinates of the ship.

The second line contains two integers x_2, y_2 (0 ≤ x_2, y_2 ≤ 10^9) — the coordinates of the destination point.

It is guaranteed that the initial coordinates and destination point coordinates are different.

The third line contains a single integer n (1 ≤ n ≤ 10^5) — the length of the string s.

The fourth line contains the string s itself, consisting only of letters U, D, L and R.

Output

The only line should contain the minimal number of days required for the ship to reach the point (x_2, y_2).

If it's impossible then print "-1".

Examples

Input

0 0
4 6
3
UUU

Output

5

Input

0 3
0 0
3
UDD

Output

3

Input

0 0
0 1
1
L

Output

-1

Note

In the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: (0, 0) → (1, 1) → (2, 2) → (3, 3) → (4, 4) → (4, 6).

In the second example the ship should perform the following sequence of moves: "DD" (the third day it should stay in place). Then its coordinates will change accordingly: (0, 3) → (0, 3) → (0, 1) → (0, 0).

In the third example the ship can never reach the point (0, 1).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n;
const long long maxn = 1e5 + 5;
string s;
pair<long long, long long> loc[maxn];
pair<long long, long long> dir[255];
pair<long long, long long> rd;
long long sx, sy, ex, ey;
bool check(long long mid) {
  long long rod = mid / n;
  long long mod = mid % n;
  long long dtx = ex - rod * loc[n].first - loc[mod].first;
  long long dty = ey - rod * loc[n].second - loc[mod].second;
  return mid < abs(dtx) + abs(dty);
}
long long check2(long long mid) {
  long long rod = mid / n;
  long long mod = mid % n;
  long long dtx = ex - rod * loc[n].first - loc[mod].first;
  long long dty = ey - rod * loc[n].second - loc[mod].second;
  if (mid < abs(dtx) + abs(dty))
    return mid + 1;
  else if (mid > abs(dtx) + abs(dty)) {
    cout << 1;
    return mid - 1;
  } else
    return mid;
}
signed main() {
  cin >> sx >> sy >> ex >> ey;
  ex -= sx, ey -= sy;
  dir['U'] = {0, 1};
  dir['D'] = {0, -1};
  dir['L'] = {-1, 0};
  dir['R'] = {1, 0};
  cin >> n >> s;
  for (long long i = 1; i <= n; ++i) {
    loc[i].first = loc[i - 1].first + dir[s[i - 1]].first;
    loc[i].second = loc[i - 1].second + dir[s[i - 1]].second;
    rd.first += dir[s[i - 1]].first;
    rd.second += dir[s[i - 1]].second;
  }
  long long r = 1e18, l = 0;
  while (l < r) {
    long long mid = (l + r + 1) >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  if (l > 2e17)
    cout << -1;
  else
    cout << check2(l);
  return 0;
}

```


### Prompt

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

Broken crypto generator

JAG (Japanese Alumni Group) is a mysterious organization composed of many programmers, and in order to enter the building where the headquarters of this organization is located, it is necessary to solve the ciphertext generated by a certain machine every time. This ciphertext consists of the symbols'+','-','[',']' and the uppercase alphabet, and is represented by <Cipher> defined by the following BNF.

<Cipher> :: = <String> | <Cipher> <String>
<String> :: = <Letter> |'['<Cipher>']'
<Letter> :: ='+' <Letter> |'-' <Letter> |
'A' |'B' |'C' |'D' |'E' |'F' |'G' |'H' |'I' |'J' |'K' |'L' |'M '|
'N' |'O' |'P' |'Q' |'R' |'S' |'T' |'U' |'V' |'W' |'X' |'Y' |'Z '

Here, each symbol has the following meaning.

* + (Character): Represents the alphabet following that character (provided that the alphabet following'Z'is'A')
*-(Character): Represents the alphabet before that character (provided that the alphabet before'A'is'Z')
* [(Character string)]: Represents a character string that is horizontally inverted.

However, the machine that generates this ciphertext is currently out of order, and some letters of the alphabet in the ciphertext may be broken and unreadable. Unreadable characters are tentatively represented as'?'. As a result of the investigation, it was found that the method of filling the broken characters is such that the decrypted character string is the smallest in the dictionary order among the possible character strings after decoding. Your job is to decrypt this ciphertext correctly.

Input

The input consists of multiple datasets. Each dataset consists of one line containing a string in which some uppercase letters have been replaced with ‘?’ In the ciphertext defined by BNF above. You can assume that the length of each string is less than $ 80 $. You can also assume that the number of'?' In each dataset is greater than or equal to $ 0 $ and less than or equal to $ 3 $.

The end of the input is represented by a line containing only one character,'.'.

Output

For each data set, output the decrypted character string when the ciphertext is decrypted so that the decrypted character string is the smallest in the dictionary order.

Sample Input

A + A ++ A
Z-Z--Z + -Z
[ESREVER]
J ---? --- J
++++++++ A +++ Z ----------- A +++ Z
[[++-+-? [-++-? ++-+++ L]] [-+ ----- + -O]] ++++ --- + L
..

Output for Sample Input

ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN

Example

Input

A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.

Output

ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN

### Response

```cpp
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
    string s;
    while(cin>>s && s!="."){
        int n = s.size();
        stack<string> st;
        int k = 0;
        string tmp;
        rep(i,n){
            if(s[i]=='['){
                st.push(tmp);
                tmp ="";
            }else if(s[i]==']'){
                auto x = st.top();
                st.pop();
                reverse(tmp.begin(),tmp.end());
                tmp = x + tmp;
            }else if(s[i]=='-'){
                k--;
            }else if(s[i]=='+'){
                k++;
            }else if(s[i]=='?'){
                k = 0;
                tmp.push_back('?');
            }else{
                char c = s[i];
                if(k<0){
                    while(k!=0){
                        if(c=='A'){
                            c = 'Z';
                        }else{
                            c--;
                        }
                        k++;
                    }
                }
                if(k>0){
                    while(k!=0){
                        if(c=='Z'){
                            c = 'A';
                        }else{
                            c++;
                        }
                        k--;
                    }
                }
                tmp.push_back(c);
            }
        }
        rep(i,tmp.size()){
            if(tmp[i]=='?'){
                tmp[i] = 'A';
            }
        }
        cout << tmp << "\n";
    }

    return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.

Constraints

* 1 ≤ H ≤ 300
* 1 ≤ W ≤ 300

Input

The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.

The input ends with two 0 (when both H and W are zero).

Output

For each dataset, print the rectangle made of H × W '#'.

Print a blank line after each dataset.

Example

Input

3 4
5 6
2 2
0 0

Output

####
####
####

######
######
######
######
######

##
##

### Response

```cpp
#include<stdio.h>
int main(void)
{
	int a,s,d,i,j;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
			for(i=0;i<a;i++){
				for(j=0;j<s;j++)
					printf("#");
				printf("\n");
			}
			printf("\n");
	}
	return 0;
}
```


### Prompt

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

We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.

We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Constraints

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

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible values of the sum, modulo (10^9+7).

Examples

Input

3 2

Output

10

Input

200000 200001

Output

1

Input

141421 35623

Output

220280457

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i, n, k, sum=0;
    cin>>n>>k;

    for(i=k;i<=n+1;i++)
    {
        sum+=i*(n-i+1)+1;
        sum=sum%1000000007;
    }
    cout<<sum<<endl;

    return 0;
}

```


### Prompt

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

If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`.

* The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.)
* The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)

Constraints

* All values in input are integers.
* 1 \leq N \leq 3
* 0 \leq M \leq 5
* 1 \leq s_i \leq N
* 0 \leq c_i \leq 9

Input

Input is given from Standard Input in the following format:

N M
s_1 c_1
\vdots
s_M c_M

Output

Print the answer.

Examples

Input

3 3
1 7
3 2
1 7

Output

702

Input

3 2
2 1
2 3

Output

-1

Input

3 1
1 0

Output

-1

### Response

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

using namespace std;

int arr[5];

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

  for(int i=0;i<5;i++)arr[i]=-1;

  while(m--)
  {
    int i,x;
    cin >> i >> x;
    if(arr[i]!=x and arr[i]!=-1)
    {
      cout << -1;
      return 0;
    }
    arr[i]=x;
  }

  if(arr[1]==-1 and n>1)arr[1]=1;
  else if(arr[1]==-1 and n==1)arr[1]=0;
  for(int i=2;i<=n;i++)if(arr[i]==-1)arr[i]=0;

  if(n>1 and arr[1]==0)
  {
    cout << -1;
    return 0;
  }

  for(int i=1;i<=n;i++)cout << arr[i];

}

```


### Prompt

Please create a solution in Cpp to the following problem:

Snuke is introducing a robot arm with the following properties to his factory:

* The robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.
* For each section, its mode can be specified individually. There are four modes: `L`, `R`, `D` and `U`. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):
* (x_0, y_0) = (0, 0).
* If the mode of Section i is `L`, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).
* If the mode of Section i is `R`, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).
* If the mode of Section i is `D`, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).
* If the mode of Section i is `U`, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).

Snuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections. Is this possible? If so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).

Constraints

* All values in input are integers.
* 1 \leq N \leq 1000
* -10^9 \leq X_i \leq 10^9
* -10^9 \leq Y_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N
X_1 Y_1
X_2 Y_2
:
X_N Y_N

Output

If the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print `-1`.

m
d_1 d_2 ... d_m
w_1
w_2
:
w_N

m and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means. Here, 1 \leq m \leq 40 and 1 \leq d_i \leq 10^{12} must hold. Also, m and d_i must all be integers.

w_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j). The i-th character of w_j should be one of the letters `L`, `R`, `D` and `U`, representing the mode of Section i.

Examples

Input

3
-1 0
0 3
2 -1

Output

2
1 2
RL
UU
DR

Input

5
0 0
1 0
2 0
3 0
4 0

Output

-1

Input

2
1 1
1 1

Output

2
1 1
RU
UR

Input

3
-7 -3
7 3
-3 -7

Output

5
3 1 4 1 5
LRDUL
RDULR
DULRD

### Response

```cpp
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=1005;
const int INF=1e9;
int n,X[MAXN],Y[MAXN];
int bi[100],l,f[5];
void Print(int x,int y){
	for(int i=1;i<=l;i++){
		if(abs(x)>abs(y)){
			if(x<0)printf("D"),x+=bi[i];
			else printf("U"),x-=bi[i];
		}
		else{
			if(y<0)printf("L"),y+=bi[i];
			else printf("R"),y-=bi[i];
		}
	}
	puts("");
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&X[i],&Y[i]);
		f[(X[i]+Y[i])%2]=1;
	}
	if(f[0]==f[1]){
		printf("-1\n");
		return 0;
	}
	l=0;
	for(int i=30;i>=0;i--)
		bi[++l]=(1<<i);
	if(f[0])bi[++l]=1;
	printf("%d\n",l);
	for(int i=1;i<l;i++)
		printf("%d ",bi[i]);
	printf("%d\n",bi[l]);
	for(int i=1;i<=n;i++)
		Print(Y[i],X[i]);
}
```


### Prompt

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

You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times.

* Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`.

Constraints

* 1\leq |S|\leq 10^5
* S_i(1\leq i\leq N) is either `0` or `1`.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum integer K such that we can turn all the characters of S into `0` by repeating the operation some number of times.

Examples

Input

010

Output

2

Input

100000000

Output

8

Input

00001111

Output

4

### Response

```cpp
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string S;
	cin >> S;
	int res = S.size();
	int a = S.size();
	for (int i = 1;i < S.size();i++) {
		if (S[i] != S[i - 1])
			res = min(res, max(i, a - i));
	}
	cout << res << endl;
	return 0;
}
```


### Prompt

Generate a CPP solution to the following problem:

Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of n cities, connected by n - 1 bidirectional roads. Every road connects exactly two distinct cities, and the whole road system is designed in a way that one is able to go from any city to any other city using only the given roads. There are m cities being attacked by humans. So Ari... we meant Super M have to immediately go to each of the cities being attacked to scare those bad humans. Super M can pass from one city to another only using the given roads. Moreover, passing through one road takes her exactly one kron - the time unit used in Byteforces.

<image>

However, Super M is not on Byteforces now - she is attending a training camp located in a nearby country Codeforces. Fortunately, there is a special device in Codeforces that allows her to instantly teleport from Codeforces to any city of Byteforces. The way back is too long, so for the purpose of this problem teleportation is used exactly once.

You are to help Super M, by calculating the city in which she should teleport at the beginning in order to end her job in the minimum time (measured in krons). Also, provide her with this time so she can plan her way back to Codeforces.

Input

The first line of the input contains two integers n and m (1 ≤ m ≤ n ≤ 123456) - the number of cities in Byteforces, and the number of cities being attacked respectively.

Then follow n - 1 lines, describing the road system. Each line contains two city numbers ui and vi (1 ≤ ui, vi ≤ n) - the ends of the road i.

The last line contains m distinct integers - numbers of cities being attacked. These numbers are given in no particular order.

Output

First print the number of the city Super M should teleport to. If there are many possible optimal answers, print the one with the lowest city number.

Then print the minimum possible time needed to scare all humans in cities being attacked, measured in Krons.

Note that the correct answer is always unique.

Examples

Input

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

Output

2
3

Input

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

Output

2
4

Note

In the first sample, there are two possibilities to finish the Super M's job in 3 krons. They are:

<image> and <image>.

However, you should choose the first one as it starts in the city with the lower number.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
vector<int> cities;
int root = -1;
int dp[N];
bool visited[N], rem[N];
vector<int> adj[N];
void dfsTree(int v) {
  int sum = 0;
  auto it = lower_bound(cities.begin(), cities.end(), v);
  if (it < cities.end() && *it == v) ++sum;
  for (int i = 0; i < adj[v].size(); ++i) {
    int u = adj[v][i];
    if (visited[u]) continue;
    visited[u] = true;
    dfsTree(u);
    sum += dp[u];
  }
  if (sum == 0)
    rem[v] = true;
  else if (sum == cities.size() && root == -1)
    root = v;
  else if (sum == cities.size())
    rem[v] = true;
  dp[v] = sum;
}
pair<int, int> bfsDistance(int src) {
  memset(visited, false, sizeof visited);
  queue<pair<int, int> > q;
  q.push(make_pair(src, 0));
  visited[src] = true;
  pair<int, int> ret = make_pair(src, 0);
  while (!q.empty()) {
    int v = q.front().first, dist = q.front().second;
    q.pop();
    if (dist > ret.second || (dist == ret.second && v < ret.first))
      ret = make_pair(v, dist);
    for (int i = 0; i < adj[v].size(); ++i) {
      int u = adj[v][i];
      if (visited[u] || rem[u]) continue;
      visited[u] = true;
      q.push(make_pair(u, dist + 1));
    }
  }
  return ret;
}
int main() {
  int n, c;
  scanf("%d %d", &n, &c);
  int u, v;
  for (int i = 1; i < n; ++i) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v), adj[v].push_back(u);
  }
  cities.resize(c);
  for (int i = 0; i < cities.size(); ++i) scanf("%d", &cities[i]);
  sort(cities.begin(), cities.end());
  visited[1] = true;
  dfsTree(1);
  pair<int, int> x = bfsDistance(root);
  pair<int, int> y = bfsDistance(x.first);
  printf("%d\n", min(x.first, y.first));
  int ct = 0;
  for (int i = 1; i <= n; ++i)
    if (!rem[i]) ++ct;
  int ans = 2 * (ct - 1) - y.second;
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

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

There are n warriors in a row. The power of the i-th warrior is a_i. All powers are pairwise distinct.

You have two types of spells which you may cast:

  1. Fireball: you spend x mana and destroy exactly k consecutive warriors;
  2. Berserk: you spend y mana, choose two consecutive warriors, and the warrior with greater power destroys the warrior with smaller power.

For example, let the powers of warriors be [2, 3, 7, 8, 11, 5, 4], and k = 3. If you cast Berserk on warriors with powers 8 and 11, the resulting sequence of powers becomes [2, 3, 7, 11, 5, 4]. Then, for example, if you cast Fireball on consecutive warriors with powers [7, 11, 5], the resulting sequence of powers becomes [2, 3, 4].

You want to turn the current sequence of warriors powers a_1, a_2, ..., a_n into b_1, b_2, ..., b_m. Calculate the minimum amount of mana you need to spend on it.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of sequence a and the length of sequence b respectively.

The second line contains three integers x, k, y (1 ≤ x, y, ≤ 10^9; 1 ≤ k ≤ n) — the cost of fireball, the range of fireball and the cost of berserk respectively.

The third line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n). It is guaranteed that all integers a_i are pairwise distinct.

The fourth line contains m integers b_1, b_2, ..., b_m (1 ≤ b_i ≤ n). It is guaranteed that all integers b_i are pairwise distinct.

Output

Print the minimum amount of mana for turning the sequnce a_1, a_2, ..., a_n into b_1, b_2, ..., b_m, or -1 if it is impossible.

Examples

Input

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

Output

8

Input

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

Output

-1

Input

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

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], b[N], vis[N][2], vid, n, m;
long long dp[N][2], x, k, y;
long long solve(int len, bool one) {
  if (len < 0) return 1e16;
  if (len == 0) return 0;
  long long &ret = dp[len][one];
  if (vis[len][one] == vid) return ret;
  vis[len][one] = vid;
  ret = 1e16;
  if (len >= k) ret = min(ret, solve(len - k, one) + x);
  if (len > 1 or (len == 1 and one)) ret = min(ret, solve(len - 1, one) + y);
  return ret;
}
int main() {
  ++vid;
  scanf("%d%d%lld%lld%lld", &n, &m, &x, &k, &y);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < m; i++) scanf("%d", b + i);
  int ind = 0;
  vector<int> pos, val;
  pos.emplace_back(-1);
  val.emplace_back(0);
  for (int i = 0; i < n and ind < m; i++)
    if (b[ind] == a[i]) pos.emplace_back(i), val.emplace_back(b[ind++]);
  pos.emplace_back(n);
  val.emplace_back(0);
  if (ind != m) return puts("-1"), 0;
  long long ans = 0;
  for (int i = 1; i < pos.size(); i++) {
    int mx = 0, l = pos[i - 1] + 1, r = pos[i], mxB = 0;
    for (int j = l; j < r; j++) mx = max(mx, a[j]);
    mxB = max(val[i - 1], val[i]);
    long long temp = solve(pos[i] - pos[i - 1] - 1, (mxB > mx));
    if (temp == 1e16) return puts("-1"), 0;
    ans += temp;
  }
  printf("%lld\n", ans);
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

We will play a one-player game using a number line and N pieces.

First, we place each of these pieces at some integer coordinate.

Here, multiple pieces can be placed at the same coordinate.

Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:

Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.

Note that the coordinates where we initially place the pieces are already regarded as visited.

Find the minimum number of moves required to achieve the objective.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.

Input

Input is given from Standard Input in the following format:

N M
X_1 X_2 ... X_M

Output

Find the minimum number of moves required to achieve the objective.

Examples

Input

2 5
10 12 1 2 14

Output

5

Input

3 7
-10 -3 0 9 -100 2 17

Output

19

Input

100 1
-100000

Output

0

### Response

```cpp
#include <iostream>
#include <algorithm>
#define MAX 100001
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  int x[MAX],l[MAX];
  for(int i = 0;i < M;i++){
    cin >> x[i];
  }
  sort(x,x+M);
  for(int i = 0;i < M - 1;i++){
    l[i] = x[i+1] - x[i];
  }
  sort(l,l+M-1);
  int total = 0;
  for(int i = 0;i < M - N;i++){
    total+= l[i];
  }
  cout << total << endl;
}

```


### Prompt

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

<image>

Input

The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.

The second line of the input is an integer between 0 and 26, inclusive.

Output

Output the required string.

Examples

Input

AprilFool
14

Output

AprILFooL

### Response

```cpp
#include <bits/stdc++.h>
int asalmi(int x) {
  int i, k = (int)sqrt(x);
  for (i = 2; i <= k; i++)
    if (x % i == 0) return 0;
  return 1;
}
int ters(int x) {
  int bas = 0, t = x, i, k = 0;
  while (t) {
    bas++;
    t /= 10;
  }
  for (i = 1; i <= bas; i++) {
    k *= 10;
    k += x % 10;
    x /= 10;
  }
  return k;
}
using namespace std;
long long m, n;
void read() {}
void solve() {
  int n;
  string s;
  cin >> s >> n;
  for (int i = 0; i <= int(s.size()) - 1; i += 1) {
    s[i] = tolower(s[i]);
    if (s[i] - 'a' < n) s[i] = toupper(s[i]);
  }
  cout << s << endl;
}
void write() { int i, j; }
int main() {
  read();
  solve();
  write();
  return 0;
}

```


### Prompt

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

Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where

  * <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
  * <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
  * <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.

The content of square brackets is optional — it can be present or can be absent.

There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.

Your task is to write program which checks if given string is a correct Jabber ID.

Input

The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.

Output

Print YES or NO.

Examples

Input

mike@codeforces.com

Output

YES

Input

john.smith@codeforces.ru/contest.icpc/12

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
char str[110];
int ok(char ch) {
  if (ch >= '0' && ch <= '9') return 1;
  if (ch >= 'a' && ch <= 'z') return 1;
  if (ch >= 'A' && ch <= 'Z') return 1;
  if (ch == '_') return 1;
  return 0;
}
int user(char *s, int len) {
  int i;
  if (len < 1 || len > 16) return 0;
  for (i = 0; i < len; ++i)
    if (!ok(s[i])) return 0;
  return 1;
}
int host(char *s, int len) {
  int i, p = 0;
  if (len < 1 || len > 32) return 0;
  for (i = 0; i < len; ++i) {
    if (s[i] == '.') {
      if (!user(s + p, i - p)) return 0;
      p = i + 1;
    }
  }
  if (!user(s + p, i - p)) return 0;
  return 1;
}
int main() {
  gets(str);
  int n, i, len, p = 0, flag = 1;
  len = strlen(str);
  for (i = 0; i < len; ++i) {
    if (str[i] == '@') {
      if (user(str, i)) {
        p = i + 1;
        break;
      } else {
        flag = 0;
        goto L;
      }
    }
  }
  if (i == len) {
    flag = 0;
    goto L;
  }
  for (; i < len; ++i) {
    if (str[i] == '/') {
      if (host(str + p, i - p)) {
        p = i + 1;
        break;
      } else {
        flag = 0;
        goto L;
      }
    }
  }
  if (i == len) {
    if (!host(str + p, i - p)) {
      flag = 0;
    }
  } else {
    if (!user(str + p, len - p)) flag = 0;
  }
L:
  printf("%s\n", flag ? "YES" : "NO");
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR.

Find the maximum possible value of <image> after performing at most k operations optimally.

Input

The first line contains three integers n, k and x (1 ≤ n ≤ 200 000, 1 ≤ k ≤ 10, 2 ≤ x ≤ 8).

The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).

Output

Output the maximum value of a bitwise OR of sequence elements after performing operations.

Examples

Input

3 1 2
1 1 1

Output

3

Input

4 2 3
1 2 4 8

Output

79

Note

For the first sample, any possible choice of doing one operation will result the same three numbers 1, 1, 2 so the result is <image>.

For the second sample if we multiply 8 by 3 two times we'll get 72. In this case the numbers will become 1, 2, 4, 72 so the OR value will be 79 and is the largest possible result.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
long long a[maxn], pre[maxn], suf[maxn];
long long power(int x, int k) {
  long long ans = 1;
  for (int i = 1; i <= k; i++) ans *= (long long)x;
  return ans;
}
int main() {
  int n, k, x;
  scanf("%d%d%d", &n, &k, &x);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  pre[0] = 0;
  for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] | a[i];
  suf[n + 1] = 0;
  for (int i = n; i >= 1; i--) suf[i] = suf[i + 1] | a[i];
  long long mult = power(x, k);
  long long best = 0;
  for (int i = 1; i <= n; i++)
    best = max(best, pre[i - 1] | suf[i + 1] | (a[i] * mult));
  printf("%I64d\n", best);
  return 0;
}

```


### Prompt

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

Nauuo is a girl who loves drawing circles.

One day she has drawn a circle and wanted to draw a tree on it.

The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n.

Nauuo wants to draw a tree on the circle, the nodes of the tree should be in n distinct points on the circle, and the edges should be straight without crossing each other.

"Without crossing each other" means that every two edges have no common point or the only common point is an endpoint of both edges.

Nauuo wants to draw the tree using a permutation of n elements. A permutation of n elements is a sequence of integers p_1,p_2,…,p_n in which every integer from 1 to n appears exactly once.

After a permutation is chosen Nauuo draws the i-th node in the p_i-th point on the circle, then draws the edges connecting the nodes.

The tree is given, Nauuo wants to know how many permutations are there so that the tree drawn satisfies the rule (the edges are straight without crossing each other). She only wants to know the answer modulo 998244353, can you help her?

It is obvious that whether a permutation is valid or not does not depend on which n points on the circle are chosen.

Input

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

Each of the next n-1 lines contains two integers u and v (1≤ u,v≤ n), denoting there is an edge between u and v.

It is guaranteed that the given edges form a tree.

Output

The output contains a single integer — the number of permutations suitable to draw the given tree on a circle satisfying the rule, modulo 998244353.

Examples

Input

4
1 2
1 3
2 4

Output

16

Input

4
1 2
1 3
1 4

Output

24

Note

Example 1

All valid permutations and their spanning trees are as follows.

<image>

Here is an example of invalid permutation: the edges (1,3) and (2,4) are crossed.

<image>

Example 2

Every permutation leads to a valid tree, so the answer is 4! = 24.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  ;
  cin.tie(NULL);
  ;
  long long int t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    vector<vector<long long int>> adj(n + 1);
    vector<long long int> cnt(n + 1, 0);
    long long int i, j, k;
    for (i = 0; i < n - 1; i++) {
      cin >> j >> k;
      adj[j].push_back(k);
      adj[k].push_back(j);
    }
    long long int ans = 1;
    list<long long int> l;
    l.push_back(1);
    while (!l.empty()) {
      long long int node = l.front();
      l.pop_front();
      for (auto nei : adj[node]) {
        if (cnt[nei]) continue;
        ans *= (cnt[node] + 1);
        ans %= 998244353;
        cnt[node]++;
        cnt[nei]++;
        l.push_back(nei);
      }
    }
    cout << (ans * n) % 998244353 << "\n";
  }
}

```


### Prompt

Please create a solution in cpp to the following problem:

In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.

More precisely, two different numbers a and b are friends if gcd(a,b), (a)/(gcd(a,b)), (b)/(gcd(a,b)) can form sides of a triangle.

Three numbers a, b and c can form sides of a triangle if a + b > c, b + c > a and c + a > b.

In a group of numbers, a number is lonely if it doesn't have any friends in that group.

Given a group of numbers containing all numbers from 1, 2, 3, ..., n, how many numbers in that group are lonely?

Input

The first line contains a single integer t (1 ≤ t ≤ 10^6) - number of test cases.

On next line there are t numbers, n_i (1 ≤ n_i ≤ 10^6) - meaning that in case i you should solve for numbers 1, 2, 3, ..., n_i.

Output

For each test case, print the answer on separate lines: number of lonely numbers in group 1, 2, 3, ..., n_i.

Example

Input

3
1 5 10

Output

1
3
3

Note

For first test case, 1 is the only number and therefore lonely.

For second test case where n=5, numbers 1, 3 and 5 are lonely.

For third test case where n=10, numbers 1, 5 and 7 are lonely.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[1000005], b[1000005];
void seive() {
  for (int i = 4; i <= 1000000; i += 2) a[i] = 1;
  for (int i = 3; i * i <= 1000000; i += 2) {
    if (a[i] == 0) {
      for (int j = i * i; j <= 1000000; j += 2 * i) a[j] = 1;
    }
  }
  int x = 0;
  b[0] = b[1] = 0;
  for (int i = 2; i <= 1000000; i++) {
    if (a[i] == 0) x++;
    b[i] = x;
  }
}
int main() {
  seive();
  int t;
  scanf("%d", &t);
  int n;
  while (t--) {
    scanf("%d", &n);
    int d = sqrt(n);
    printf("%d\n", b[n] - b[d] + 1);
  }
}

```


### Prompt

Please create a solution in cpp to the following problem:

Ivan is a student at Berland State University (BSU). There are n days in Berland week, and each of these days Ivan might have some classes at the university.

There are m working hours during each Berland day, and each lesson at the university lasts exactly one hour. If at some day Ivan's first lesson is during i-th hour, and last lesson is during j-th hour, then he spends j - i + 1 hours in the university during this day. If there are no lessons during some day, then Ivan stays at home and therefore spends 0 hours in the university.

Ivan doesn't like to spend a lot of time in the university, so he has decided to skip some lessons. He cannot skip more than k lessons during the week. After deciding which lessons he should skip and which he should attend, every day Ivan will enter the university right before the start of the first lesson he does not skip, and leave it after the end of the last lesson he decides to attend. If Ivan skips all lessons during some day, he doesn't go to the university that day at all.

Given n, m, k and Ivan's timetable, can you determine the minimum number of hours he has to spend in the university during one week, if he cannot skip more than k lessons?

Input

The first line contains three integers n, m and k (1 ≤ n, m ≤ 500, 0 ≤ k ≤ 500) — the number of days in the Berland week, the number of working hours during each day, and the number of lessons Ivan can skip, respectively.

Then n lines follow, i-th line containing a binary string of m characters. If j-th character in i-th line is 1, then Ivan has a lesson on i-th day during j-th hour (if it is 0, there is no such lesson).

Output

Print the minimum number of hours Ivan has to spend in the university during the week if he skips not more than k lessons.

Examples

Input

2 5 1
01001
10110

Output

5

Input

2 5 0
01001
10110

Output

8

Note

In the first example Ivan can skip any of two lessons during the first day, so he spends 1 hour during the first day and 4 hours during the second day.

In the second example Ivan can't skip any lessons, so he spends 4 hours every day.

### Response

```cpp
#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
char clas[505];
int sum[505];
int skip[505][505];
int cost[505][505];
int dp[505];
int MIN(int x, int y) {
  if (x < y)
    return x;
  else
    return y;
}
int MAX(int x, int y) {
  if (x > y)
    return x;
  else
    return y;
}
int main() {
  int n, m, k, j, i, p, r, l, mi;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= n; i++) {
    scanf("%s", clas + 1);
    for (j = 1; j <= m; j++) {
      if (clas[j] == '1') {
        sum[i]++;
        skip[i][sum[i]] = j;
      }
    }
    for (p = 0; p <= sum[i] - 1; p++) {
      mi = inf;
      for (l = 0; l <= sum[i] - 1; l++) {
        if (p - l < 0) break;
        r = p - l;
        mi = MIN(mi, skip[i][sum[i] - r] - skip[i][l + 1] + 1);
      }
      cost[i][p] = m - mi;
    }
    cost[i][sum[i]] = m;
  }
  for (i = 1; i <= n; i++)
    for (j = k; j >= 0; j--)
      for (p = 0; p <= MIN(sum[i], j); p++) {
        dp[j] = MAX(dp[j], dp[j - p] + cost[i][p]);
      }
  printf("%d\n", n * m - dp[k]);
  return 0;
}

```


### Prompt

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

Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.

The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, and so on, the m-th face contains m dots. Twilight Sparkle is sure that when the dice is tossed, each face appears with probability <image>. Also she knows that each toss is independent from others. Help her to calculate the expected maximum number of dots she could get after tossing the dice n times.

Input

A single line contains two integers m and n (1 ≤ m, n ≤ 105).

Output

Output a single real number corresponding to the expected maximum. The answer will be considered correct if its relative or absolute error doesn't exceed 10  - 4.

Examples

Input

6 1

Output

3.500000000000

Input

6 3

Output

4.958333333333

Input

2 2

Output

1.750000000000

Note

Consider the third test example. If you've made two tosses:

  1. You can get 1 in the first toss, and 2 in the second. Maximum equals to 2.
  2. You can get 1 in the first toss, and 1 in the second. Maximum equals to 1.
  3. You can get 2 in the first toss, and 1 in the second. Maximum equals to 2.
  4. You can get 2 in the first toss, and 2 in the second. Maximum equals to 2.

The probability of each outcome is 0.25, that is expectation equals to:

<image>

You can read about expectation using the following link: http://en.wikipedia.org/wiki/Expected_value

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 100 + 10;
const int MOD = 1000 * 1000 * 1000 + 7;
long double n, m;
long double Pow(long double a, int b) {
  if (b == 0) return 1;
  long double x = Pow(a, b / 2);
  x *= x;
  if (b % 2) x *= a;
  return x;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(10);
  cin >> m >> n;
  long double ans = 0;
  for (long double i = 1; i < m; i++) {
    ans += Pow(i / m, n);
  }
  cout << m - ans;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

You are given two integers n and k. You are asked to choose maximum number of distinct integers from 1 to n so that there is no subset of chosen numbers with sum equal to k.

A subset of a set is a set that can be obtained from initial one by removing some (possibly all or none) elements of it.

Input

The first line contains the number of test cases T (1 ≤ T ≤ 100).

Each of the next T lines contains two integers n and k (1 ≤ k ≤ n ≤ 1000) — the description of test cases.

Output

For each test case output two lines. In the first line output a single integer m — the number of chosen integers.

In the second line output m distinct integers from 1 to n — the chosen numbers.

If there are multiple answers, print any. You can print the numbers in any order.

Example

Input

3
3 2
5 3
1 1

Output

2
3 1
3
4 5 2
0

### Response

```cpp
#include<bits/stdc++.h>
#define pb push_back
#define fon(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		vector<int>x;
		int m=0;
		int i=n;
		while(i>k){
			x.pb(i);
			i--;
			m++;
		}
		if(k%2==0){
			fon(j,k/2,k){
				x.pb(j);
				m++;
			}
		}
		else{
			fon(j,(k+1)/2,k){
				x.pb(j);
				m++;
			}
		}
		cout<<m<<endl;
		fon(j,0,m){
			cout<<x[j]<<" ";
		}
		cout<<endl;

	}
}
```