Problem: You are given a figure on a grid representing stairs consisting of 7 steps. The width of the stair on height i is wi squares. Formally, the figure is created by consecutively joining rectangles of size wi × i so that the wi sides lie on one straight line. Thus, for example, if all wi = 1, the figure will look like that (different colors represent different rectangles):

<image>

And if w = {5, 1, 0, 3, 0, 0, 1}, then it looks like that:

<image>

Find the number of ways to color some borders of the figure's inner squares so that no square had all four borders colored. The borders of the squares lying on the border of the figure should be considered painted. The ways that differ with the figure's rotation should be considered distinct. 

Input

The single line of the input contains 7 numbers w1, w2, ..., w7 (0 ≤ wi ≤ 105). It is guaranteed that at least one of the wi's isn't equal to zero.

Output

In the single line of the output display a single number — the answer to the problem modulo 109 + 7.

Examples

Input

0 1 0 0 0 0 0


Output

1


Input

0 2 0 0 0 0 0


Output

7


Input

1 1 1 0 0 0 0


Output

9


Input

5 1 0 3 0 0 1


Output

411199181

Note

All the possible ways of painting the third sample are given below:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
typedef int arr[1 << 7][1 << 7];
arr a, b;
void mul(arr &a, arr b, int n) {
  arr c;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) c[i][j] = 0;
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        c[i][j] = (c[i][j] + 1LL * a[i][k] * b[k][j] % 1000000007) % 1000000007;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) a[i][j] = c[i][j];
}
void pow(arr &a, int n, int k) {
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) b[i][j] = 0;
    b[i][i] = 1;
  }
  while (n) {
    if (n & 1) mul(b, a, k);
    n >>= 1;
    mul(a, a, k);
  }
  for (int i = 0; i < k; i++)
    for (int j = 0; j < k; j++) a[i][j] = b[i][j];
}
void get(arr &a, int k) {
  for (int i = 0; i < 1 << k; i++)
    for (int j = 0; j < 1 << k; j++) {
      a[i][j] = 0;
      for (int k1 = 0; k1 < (1 << k - 1); k1++) {
        int k2 = k1 * 2 + 1 + (1 << k);
        if (i & j & k2 & (k2 >> 1)) continue;
        a[i][j]++;
      }
    }
}
int dp[1 << 7], dp2[1 << 7];
int main() {
  int i, j, k, ca = 0, m, n;
  vector<pair<int, int> > v;
  for (i = 0; i < 7; i++) {
    scanf("%d", &j);
    if (j) v.push_back(make_pair(i + 1, j));
  }
  int sz = v.size();
  int from = v[0].first, to = v[sz - 1].first;
  dp[(1 << from) - 1] = 1;
  for (i = 0; i < sz; i++) {
    k = v[i].first;
    get(a, k);
    pow(a, v[i].second, 1 << k);
    for (j = 0; j < 1 << k; j++) dp2[j] = 0;
    for (j = 0; j < 1 << k; j++)
      for (int first = 0; first < 1 << k; first++)
        dp2[first] =
            (dp2[first] + 1LL * dp[j] * a[j][first] % 1000000007) % 1000000007;
    if (i < sz - 1) {
      for (j = 0; j < 1 << 7; j++) dp[j] = 0;
      int mask = 0;
      for (j = v[i].first; j < v[i + 1].first; j++) mask |= 1 << j;
      for (j = 0; j < 1 << k; j++) dp[j | mask] = dp2[j];
    }
  }
  printf("%d\n", dp2[(1 << to) - 1]);
}