JerryL/AlgoSimBench huggingface dataset:
914_G. Sum the Fibonacci

You are given an array s of n non-negative integers.

A 5-tuple of integers (a, b, c, d, e) is said to be valid if it satisfies the following conditions: 

  * 1 ≤ a, b, c, d, e ≤ n
  * (sa | sb) & sc & (sd ^ se) = 2i for some integer i
  * sa & sb = 0



Here, '|' is the bitwise OR, '&' is the bitwise AND and '^' is the bitwise XOR operation.

Find the sum of f(sa|sb) * f(sc) * f(sd^se) over all valid 5-tuples (a, b, c, d, e), where f(i) is the i-th Fibonnaci number (f(0) = 0, f(1) = 1, f(i) = f(i - 1) + f(i - 2)).

Since answer can be is huge output it modulo 109 + 7.

Input

The first line of input contains an integer n (1 ≤ n ≤ 106).

The second line of input contains n integers si (0 ≤ si < 217).

Output

Output the sum as described above, modulo 109 + 7

Examples

Input

2
1 2


Output

32


Input

3
7 4 1


Output

3520


Input

10
1 3 0 7 3 7 6 5 7 5


Output

1235424


Input

10
50 9 11 44 39 40 5 39 23 7


Output

113860062

Example input:
2
1 2

10
1 3 0 7 3 7 6 5 7 5

10
50 9 11 44 39 40 5 39 23 7

3
7 4 1


Example output:
32

1235424

113860062

3520


Tags: bitmasks
divide and conquer
dp
fft
math
Difficulty rating: 2600

Solution:
#include <bits/stdc++.h>
int n, i, j, x;
long long S, a[131072], b[131072], c[131072], an[131072], f[131072];
void FWT(long long* a, int n, int f, int op) {
  int i, j, k;
  long long x, y;
  for (i = 1; i < n; i *= 2)
    for (j = 0; j < n; j += i * 2) {
      for (k = 0; k < i; k++) {
        x = a[j + k];
        y = a[i + j + k];
        if (f == 1) {
          a[j + k] = (x + y) % 1000000007;
          if (op == 1) a[i + j + k] = (x - y + 1000000007) % 1000000007;
        } else {
          if (op == 1)
            a[j + k] = 500000004 * (x + y) % 1000000007,
                  a[i + j + k] = 500000004 * (x - y + 1000000007) % 1000000007;
          if (op == 2) a[j + k] = (x - y + 1000000007) % 1000000007;
        }
      }
    }
}
void mul(long long* a, long long* b, long long* c, int n, int op) {
  static long long A[131072], B[131072];
  for (int i = 0; i < n; i++) A[i] = a[i], B[i] = b[i];
  FWT(A, n, 1, op);
  FWT(B, n, 1, op);
  for (int i = 0; i < n; i++) c[i] = A[i] * B[i] % 1000000007;
  FWT(c, n, -1, op);
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &x), c[x]++;
  mul(c, c, a, 131072, 1);
  for (i = 0; i < 131072; b[i] = (b[i] + c[0] * c[i]) % 1000000007, i++)
    for (j = i; j; j = (j - 1) & i)
      b[i] = (b[i] + c[j] * c[i - j]) % 1000000007;
  for (f[1] = 1, i = 2; i < 131072; i++)
    f[i] = (f[i - 1] + f[i - 2]) % 1000000007;
  for (i = 0; i < 131072; i++)
    a[i] = a[i] * f[i] % 1000000007, b[i] = b[i] * f[i] % 1000000007,
    c[i] = c[i] * f[i] % 1000000007;
  mul(a, b, an, 131072, 2);
  mul(c, an, an, 131072, 2);
  for (i = 1; i < 131072; i *= 2) S = (S + an[i]) % 1000000007;
  printf("%I64d", S);
}
772_D. Varying Kibibits

You are given n integers a1, a2, ..., an. Denote this list of integers as T.

Let f(L) be a function that takes in a non-empty list of integers L.

The function will output another integer as follows: 

  * First, all integers in L are padded with leading zeros so they are all the same length as the maximum length number in L. 
  * We will construct a string where the i-th character is the minimum of the i-th character in padded input numbers. 
  * The output is the number representing the string interpreted in base 10. 



For example f(10, 9) = 0, f(123, 321) = 121, f(530, 932, 81) = 30.

Define the function 

<image> Here, <image> denotes a subsequence.

In other words, G(x) is the sum of squares of sum of elements of nonempty subsequences of T that evaluate to x when plugged into f modulo 1 000 000 007, then multiplied by x. The last multiplication is not modded. 

You would like to compute G(0), G(1), ..., G(999 999). To reduce the output size, print the value <image>, where <image> denotes the bitwise XOR operator.

Input

The first line contains the integer n (1 ≤ n ≤ 1 000 000) — the size of list T.

The next line contains n space-separated integers, a1, a2, ..., an (0 ≤ ai ≤ 999 999) — the elements of the list. 

Output

Output a single integer, the answer to the problem.

Examples

Input

3
123 321 555


Output

292711924


Input

1
999999


Output

997992010006992


Input

10
1 1 1 1 1 1 1 1 1 1


Output

28160

Note

For the first sample, the nonzero values of G are G(121) = 144 611 577, G(123) = 58 401 999, G(321) = 279 403 857, G(555) = 170 953 875. The bitwise XOR of these numbers is equal to 292 711 924.

For example, <image>, since the subsequences [123] and [123, 555] evaluate to 123 when plugged into f.

For the second sample, we have <image>

For the last sample, we have <image>, where <image> is the binomial coefficient.

Example input:
3
123 321 555

10
1 1 1 1 1 1 1 1 1 1

1
999999


Example output:
292711924

28160

997992010006992


Tags: bitmasks
dp
Difficulty rating: 2700

Solution:
#include <bits/stdc++.h>
const int MAXN = 1100000;
const int P = 1E9 + 7;
int a[MAXN], b[MAXN], c[MAXN];
int pow2[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int s;
    scanf("%d", &s);
    a[s]++, b[s] += s, c[s] = (c[s] + 1ll * s * s) % P;
  }
  int t[] = {1, 10, 100, 1000, 10000, 100000};
  for (int i = 0; i < 6; i++)
    for (int s = 1E6 - 1; s >= 0; s--)
      if (s / t[i] % 10 < 9) {
        a[s] = (a[s] + a[s + t[i]]) % P;
        b[s] = (b[s] + b[s + t[i]]) % P;
        c[s] = (c[s] + c[s + t[i]]) % P;
      }
  pow2[0] = 1;
  for (int i = 1; i <= n; i++) pow2[i] = 2 * pow2[i - 1] % P;
  for (int s = 0; s < 1E6; s++)
    if (a[s] >= 2) c[s] = pow2[a[s] - 2] * (1ll * b[s] * b[s] % P + c[s]) % P;
  for (int i = 0; i < 6; i++)
    for (int s = 0; s < 1E6; s++)
      if (s / t[i] % 10 < 9) c[s] = (c[s] - c[s + t[i]] + P) % P;
  long long ans = 0;
  for (int s = 0; s < 1E6; s++) ans ^= 1ll * s * c[s];
  printf("%lld\n", ans);
  return 0;
}
329_C. Graph Reconstruction

I have an undirected graph consisting of n nodes, numbered 1 through n. Each node has at most two incident edges. For each pair of nodes, there is at most an edge connecting them. No edge connects a node to itself.

I would like to create a new graph in such a way that: 

  * The new graph consists of the same number of nodes and edges as the old graph. 
  * The properties in the first paragraph still hold. 
  * For each two nodes u and v, if there is an edge connecting them in the old graph, there is no edge connecting them in the new graph. 



Help me construct the new graph, or tell me if it is impossible.

Input

The first line consists of two space-separated integers: n and m (1 ≤ m ≤ n ≤ 105), denoting the number of nodes and edges, respectively. Then m lines follow. Each of the m lines consists of two space-separated integers u and v (1 ≤ u, v ≤ n; u ≠ v), denoting an edge between nodes u and v.

Output

If it is not possible to construct a new graph with the mentioned properties, output a single line consisting of -1. Otherwise, output exactly m lines. Each line should contain a description of edge in the same way as used in the input format.

Examples

Input

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


Output

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


Input

3 2
1 2
2 3


Output

-1


Input

5 4
1 2
2 3
3 4
4 1


Output

1 3
3 5
5 2
2 4

Note

The old graph of the first example:

<image>

A possible new graph for the first example:

<image>

In the second example, we cannot create any new graph.

The old graph of the third example:

<image>

A possible new graph for the third example:

<image>

Example input:
5 4
1 2
2 3
3 4
4 1

3 2
1 2
2 3

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


Example output:
1 3
3 5
5 4
4 2

-1

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


Tags: constructive algorithms
Difficulty rating: 2400

Solution:
import random,time as T
n,m=map(int,raw_input().split())
M=xrange(m)
e={frozenset(map(int,raw_input().split())) for _ in M}
t=T.time()
x=range(1,n+1)
while T.time()-t<2.8:
	random.shuffle(x)
	if all(frozenset((x[i],x[i-1])) not in e for i in M):
		for i in M: print x[i], x[i-1]
		break
else:
	print -1
343_B. Alternating Current

Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended up entangled and now have to be untangled again.

The device is powered by two wires "plus" and "minus". The wires run along the floor from the wall (on the left) to the device (on the right). Both the wall and the device have two contacts in them on the same level, into which the wires are plugged in some order. The wires are considered entangled if there are one or more places where one wire runs above the other one. For example, the picture below has four such places (top view):

<image>

Mike knows the sequence in which the wires run above each other. Mike also noticed that on the left side, the "plus" wire is always plugged into the top contact (as seen on the picture). He would like to untangle the wires without unplugging them and without moving the device. Determine if it is possible to do that. A wire can be freely moved and stretched on the floor, but cannot be cut.

To understand the problem better please read the notes to the test samples.

Input

The single line of the input contains a sequence of characters "+" and "-" of length n (1 ≤ n ≤ 100000). The i-th (1 ≤ i ≤ n) position of the sequence contains the character "+", if on the i-th step from the wall the "plus" wire runs above the "minus" wire, and the character "-" otherwise.

Output

Print either "Yes" (without the quotes) if the wires can be untangled or "No" (without the quotes) if the wires cannot be untangled.

Examples

Input

-++-


Output

Yes


Input

+-


Output

No


Input

++


Output

Yes


Input

-


Output

No

Note

The first testcase corresponds to the picture in the statement. To untangle the wires, one can first move the "plus" wire lower, thus eliminating the two crosses in the middle, and then draw it under the "minus" wire, eliminating also the remaining two crosses.

In the second testcase the "plus" wire makes one full revolution around the "minus" wire. Thus the wires cannot be untangled: 

<image>

In the third testcase the "plus" wire simply runs above the "minus" wire twice in sequence. The wires can be untangled by lifting "plus" and moving it higher: 

<image>

In the fourth testcase the "minus" wire runs above the "plus" wire once. The wires cannot be untangled without moving the device itself: 

<image>

Example input:
-++-

++

+-

-


Example output:
YES

YES

NO

NO


Tags: data structures
greedy
implementation
Difficulty rating: 1600

Solution:
print 'YNeos'[sum(map(lambda (j,i): (44 - ord(i))*(1-2*(j%2)), enumerate(raw_input())))!=0::2]
12_E. Start of the season

Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never allow to start the championship without it. Matrix should contain integers from 0 to n - 1, main diagonal should contain only zeroes and matrix should be symmetric. Moreover, all numbers in each row should be different. Magicians are very tired of the thinking process, so they ask you to write a program to find such matrix.

Input

The first line contains one integer n (2 ≤ n ≤ 1000), n is even.

Output

Output n lines with n numbers each — the required matrix. Separate numbers with spaces. If there are several solutions, output any.

Examples

Input

2


Output

0 1
1 0


Input

4


Output

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

Example input:
2

4


Example output:
0 1 
1 0 

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


Tags: constructive algorithms
Difficulty rating: 2100

Solution:
n = int(input())
a = [[(i + j) % (n - 1) + 1 for j in range(n - 1)] + [2 * i % (n - 1) + 1] for i in range(n - 1)] +\
    [[2 * i % (n - 1) + 1 for i in range(n)]]
for i in range(n):
    a[i][i] = 0
for row in a:
    print(*row)
622_F. The Sum of the k-th Powers

There are well-known formulas: <image>, <image>, <image>. Also mathematicians found similar formulas for higher degrees.

Find the value of the sum <image> modulo 109 + 7 (so you should find the remainder after dividing the answer by the value 109 + 7).

Input

The only line contains two integers n, k (1 ≤ n ≤ 109, 0 ≤ k ≤ 106).

Output

Print the only integer a — the remainder after dividing the value of the sum by the value 109 + 7.

Examples

Input

4 1


Output

10


Input

4 2


Output

30


Input

4 3


Output

100


Input

4 0


Output

4

Example input:
4 1

4 0

4 2

4 3


Example output:
10

4

30

100


Tags: math
Difficulty rating: 2600

Solution:
#include <bits/stdc++.h>
const int MAXK = 1E6 + 10;
const long long MOD = 1E9 + 7;
long long y[MAXK];
long long modExp(long long e, long long n, long long m = MOD) {
  long long ret = 1;
  for (; n; n >>= 1, e = e * e % m)
    if (n & 1) ret = ret * e % MOD;
  return ret;
}
int main() {
  int n, K;
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= K + 1; ++i) y[i] = (y[i - 1] + modExp(i, K)) % MOD;
  if (n <= K + 1)
    printf("%d\n", (int)y[n]);
  else {
    long long num = n, den = 1;
    for (int i = 1; i <= K + 1; ++i) {
      num = num * (n - i) % MOD;
      den = den * (MOD - i) % MOD;
    }
    den = modExp(den, MOD - 2);
    long long ans = 0;
    for (int i = 0; i <= K + 1; ++i) {
      ans = (ans + num * modExp(n - i, MOD - 2) % MOD * den % MOD * y[i]) % MOD;
      den = den * modExp(i + 1, MOD - 2) % MOD * (MOD + i - K - 1) % MOD;
    }
    printf("%d", (int)ans);
  }
  return 0;
}
472_G. Design Tutorial: Increase the Constraints

There is a simple way to create hard tasks: take one simple problem as the query, and try to find an algorithm that can solve it faster than bruteforce. This kind of tasks usually appears in OI contest, and usually involves data structures.

Let's try to create a task, for example, we take the "Hamming distance problem": for two binary strings s and t with the same length, the Hamming distance between them is the number of positions at which the corresponding symbols are different. For example, the Hamming distance between "00111" and "10101" is 2 (the different symbols are marked with bold).

We use the Hamming distance problem as a query in the following way: you are given two strings a and b and several queries. Each query will be: what is the Hamming distance between two strings ap1ap1 + 1...ap1 + len - 1 and bp2bp2 + 1...bp2 + len - 1?

Note, that in this problem the strings are zero-based, that is s = s0s1... s|s| - 1.

Input

The first line contains a string a (1 ≤ |a| ≤ 200000). The second line contains a string b (1 ≤ |b| ≤ 200000). Each character of both strings is either "0" or "1".

The third line contains an integer q (1 ≤ q ≤ 400000) — the number of queries. Each of the following q lines contains three integers: p1, p2 and len (0 ≤ p1 ≤ |a| - len; 0 ≤ p2 ≤ |b| - len), these numbers denote the parameters of the current query.

Output

Output q integers — the answers for the queries.

Examples

Input

101010
11110000
3
0 0 3
2 3 4
5 7 1


Output

1
1
0


Input

10001010101011001010100101010011010
101010100101001010100100101010
5
0 0 12
3 9 7
6 4 15
12 15 10
13 3 20


Output

5
4
3
5
13

Example input:
10001010101011001010100101010011010
101010100101001010100100101010
5
0 0 12
3 9 7
6 4 15
12 15 10
13 3 20

101010
11110000
3
0 0 3
2 3 4
5 7 1


Example output:
5
4
3
5
13

1
1
0


Tags: bitmasks
data structures
fft
Difficulty rating: 2800

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
char s[N], t[N];
int q, l1, l2, len;
unsigned long long a[N], b[N];
int main() {
  scanf("%s%s", s, t);
  int n = strlen(s), m = strlen(t);
  for (int i = 0; i < n - 63; i++)
    for (int j = i; j < i + 64; j++) a[i] = a[i] << 1 | (s[j] - '0');
  for (int i = 0; i < m - 63; i++)
    for (int j = i; j < i + 64; j++) b[i] = b[i] << 1 | (t[j] - '0');
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &l1, &l2, &len);
    int ans = 0;
    while (len >= 64) {
      ans += __builtin_popcountll(a[l1] ^ b[l2]);
      len -= 64;
      l1 += 64;
      l2 += 64;
    }
    for (int i = 0; i < len; i++) ans += s[l1] != t[l2], l1++, l2++;
    printf("%d\n", ans);
  }
}
623_E. Transforming Sequence

Let's define the transformation P of a sequence of integers a1, a2, ..., an as b1, b2, ..., bn, where bi = a1 | a2 | ... | ai for all i = 1, 2, ..., n, where | is the bitwise OR operation.

Vasya consequently applies the transformation P to all sequences of length n consisting of integers from 1 to 2k - 1 inclusive. He wants to know how many of these sequences have such property that their transformation is a strictly increasing sequence. Help him to calculate this number modulo 109 + 7.

Input

The only line of the input contains two integers n and k (1 ≤ n ≤ 1018, 1 ≤ k ≤ 30 000).

Output

Print a single integer — the answer to the problem modulo 109 + 7.

Examples

Input

1 2


Output

3


Input

2 3


Output

30


Input

3 3


Output

48

Example input:
3 3

2 3

1 2


Example output:
48

30

3


Tags: combinatorics
dp
fft
math
Difficulty rating: 3300

Solution:
#include <bits/stdc++.h>
using namespace std;
long long cnt, g[16];
int n, m, bin[70005], inv[70005], a[70005], b[70005], c[70005], f[70005];
void mul(int *a, int *b, int *c, int n) {
  if (n <= 8) {
    memset(g, 0, sizeof(g));
    int i, j;
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) g[i + j] += (long long)a[i] * b[j];
    for (i = 0; i < (n << 1); i++) c[i] = g[i] % 1000000007;
    return;
  }
  int mid = n >> 1;
  mul(a, b, c, mid);
  mul(a + mid, b + mid, c + n, mid);
  int i, x[mid], y[mid], z[n];
  for (i = 0; i < mid; i++) {
    x[i] = (a[i] + a[i + mid]) % 1000000007;
    y[i] = (b[i] + b[i + mid]) % 1000000007;
  }
  mul(x, y, z, mid);
  for (i = 0; i < n; i++) z[i] -= c[i] + c[i + n];
  for (i = 0; i < n; i++)
    c[i + mid] = ((c[i + mid] + z[i]) % 1000000007 + 1000000007) % 1000000007;
}
int main() {
  scanf("%lld%d", &cnt, &n);
  if (cnt > n) {
    puts("0");
    return 0;
  }
  m = 1;
  while (m <= n) m <<= 1;
  int i, k, x, y;
  bin[0] = 1;
  for (i = 1; i <= cnt; i++) bin[i] = (bin[i - 1] << 1) % 1000000007;
  inv[0] = inv[1] = 1;
  for (i = 2; i < m; i++)
    inv[i] = 1000000007 -
             (long long)inv[1000000007 % i] * (1000000007 / i) % 1000000007;
  for (i = 3; i < m; i++) inv[i] = (long long)inv[i - 1] * inv[i] % 1000000007;
  for (i = 1; i < m; i++) a[i] = inv[i];
  f[0] = 1;
  for (k = 1; k <= cnt; k <<= 1) {
    if (k > 1) {
      x = 1;
      y = bin[k >> 1];
      for (i = 0; i < m; i++, x = (long long)x * y % 1000000007)
        b[i] = (long long)a[i] * x % 1000000007;
      mul(a, b, c, m);
      for (i = 0; i < m; i++) a[i] = c[i];
    }
    if (cnt & k) {
      x = 1;
      y = bin[cnt & k - 1];
      for (i = 0; i < m; i++, x = (long long)x * y % 1000000007)
        b[i] = (long long)a[i] * x % 1000000007;
      mul(f, b, c, m);
      for (i = 0; i < m; i++) f[i] = c[i];
    }
  }
  int ans = 0;
  for (i = 0; i <= n; i++)
    ans = (ans + (long long)f[i] * inv[n - i]) % 1000000007;
  for (i = 2; i <= n; i++) ans = (long long)ans * i % 1000000007;
  printf("%d\n", ans);
  return 0;
}
1096_G. Lucky Tickets

All bus tickets in Berland have their numbers. A number consists of n digits (n is even). Only k decimal digits d_1, d_2, ..., d_k can be used to form ticket numbers. If 0 is among these digits, then numbers may have leading zeroes. For example, if n = 4 and only digits 0 and 4 can be used, then 0000, 4004, 4440 are valid ticket numbers, and 0002, 00, 44443 are not.

A ticket is lucky if the sum of first n / 2 digits is equal to the sum of remaining n / 2 digits. 

Calculate the number of different lucky tickets in Berland. Since the answer may be big, print it modulo 998244353.

Input

The first line contains two integers n and k (2 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ k ≤ 10) — the number of digits in each ticket number, and the number of different decimal digits that may be used. n is even.

The second line contains a sequence of pairwise distinct integers d_1, d_2, ..., d_k (0 ≤ d_i ≤ 9) — the digits that may be used in ticket numbers. The digits are given in arbitrary order.

Output

Print the number of lucky ticket numbers, taken modulo 998244353.

Examples

Input

4 2
1 8


Output

6


Input

20 1
6


Output

1


Input

10 5
6 1 4 0 3


Output

569725


Input

1000 7
5 4 0 1 8 3 2


Output

460571165

Note

In the first example there are 6 lucky ticket numbers: 1111, 1818, 1881, 8118, 8181 and 8888.

There is only one ticket number in the second example, it consists of 20 digits 6. This ticket number is lucky, so the answer is 1.

Example input:
4 2
1 8

20 1
6

1000 7
5 4 0 1 8 3 2

10 5
6 1 4 0 3


Example output:
6

1

460571165

569725


Tags: divide and conquer
dp
fft
Difficulty rating: 2400

Solution:
import os
from io import BytesIO
from math import trunc
 
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
 
MOD = 998244353
MODF = float(MOD)
SHRT = float(1 << 16)
 
fmod = lambda x: x - MODF * trunc(x / MODF)
mod_prod = lambda a, b, c=0: fmod(trunc(a / SHRT) * fmod(b * SHRT) + (a - SHRT * trunc(a / SHRT)) * b + c)
 
n, k = map(int, input().split())
n //= 2
 
inv = [1.0] * (9 * n + 2)
for i in range(2, 9 * n + 2):
    inv[i] = mod_prod(trunc(MODF / i), -inv[MOD % i])
 
a = [int(i) for i in input().split()]
mi = min(a)
 
a = [ai - mi for ai in a]
a.remove(0)
 
b = [0.0] * 16
b[0] = 1.0
 
ans = 0.0
for i in range(9 * n + 1):
    ans = mod_prod(b[i & 15], b[i & 15], ans)
 
    s = 0.0
    for ai in a:
        s = mod_prod(b[(i - ai + 17) & 15], n * ai - (i - ai + 1), s)
    b[(i + 1) & 15] = mod_prod(s, inv[i + 1])
 
print(int(ans % MODF))
p04028 AtCoder Regular Contest 059 - Unhappy Hacking

Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.

To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:

* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.



Sig has launched the editor, and pressed these keys N times in total. As a result, the editor displays a string s. Find the number of such ways to press the keys, modulo 10^9 + 7.

Constraints

* 1 ≦ N ≦ 5000
* 1 ≦ |s| ≦ N
* s consists of the letters `0` and `1`.

Input

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


N
s


Output

Print the number of the ways to press the keys N times in total such that the editor displays the string s in the end, modulo 10^9+7.

Examples

Input

3
0


Output

5


Input

300
1100100


Output

519054663


Input

5000
01000001011101000100001101101111011001000110010101110010000


Output

500886057

Example input:
5000
01000001011101000100001101101111011001000110010101110010000
3
0
300
1100100

Example output:
500886057
5
519054663

Difficulty rating: 0

Solution:
n=int(input())
p=[0]*5001
p[len(input())]=1
while n:
	p=[((2*p[j-1]if j else p[j])+p[j+1])%(10**9+7)for j in range(n)]
	n=n-1
print(p[0])