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>
using namespace std;
const int N = 1 << 7;
const int M = 7;
const int inf = 1e9 + 7;
const long long base = 1e18;
const double pi = acos(-1);
const double ep = 1e-18;
int L[8][N][N];
int dp[N], dp1[N];
int tmp[N][N], tmp1[N][N], tmp2[N][N];
int a[8], last = -1;
void multi(int a[N][N], int b[N][N], int last) {
  memset(tmp1, 0, sizeof(tmp1));
  for (int u = 0; u < 1 << last; u++)
    for (int v = 0; v < 1 << last; v++) {
      tmp1[u][v] = 0;
      for (int k = 0; k < 1 << last; k++)
        tmp1[u][v] =
            ((long long)tmp1[u][v] + (long long)a[u][k] * b[k][v] % inf) % inf;
    }
  for (int u = 0; u < 1 << last; u++)
    for (int v = 0; v < 1 << last; v++) a[u][v] = tmp1[u][v];
}
int main() {
  for (int u = 0; u < 2; u++)
    for (int v = 0; v < 2; v++) L[1][u][v] = !(u & v);
  for (int i = 2; i < M + 1; i++) {
    int m = 1 << i;
    for (int u = 0; u < m; u++) {
      for (int v = u; v < m; v++) {
        L[i][u][v] = 0;
        for (int tmp = 0; tmp < 1 << (i - 1); tmp++) {
          int t = (tmp << 1) | 1 | m;
          int kt = 1;
          for (int j = 0; j < i; j++)
            if (((t & (1 << j)) && (u & (1 << j)) && (v & (1 << j)) &&
                 (t & (1 << (j + 1)))))
              kt = 0;
          L[i][u][v] += kt;
        }
        L[i][v][u] = L[i][u][v];
      }
    }
  }
  for (int i = 1; i < 8; i++) {
    cin >> a[i];
    if (last == -1 && a[i] > 0) last = i;
  }
  dp[(1 << last) - 1] = 1;
  int fir = last;
  for (int i = 1; i < M + 1; i++) {
    if (a[i] == 0) continue;
    if (i != fir) {
      memset(dp1, 0, sizeof(dp1));
      int comMask = 0, preLast = last;
      for (; last < i;) comMask |= 1 << last++;
      for (int mask = 0; mask < 1 << preLast; mask++)
        dp1[mask | comMask] = dp[mask];
      for (int mask = 0; mask < 1 << last; mask++) dp[mask] = dp1[mask];
    }
    memset(tmp2, 0, sizeof(tmp2));
    for (int j = 0; j < 1 << i; j++) tmp2[j][j] = 1;
    memcpy(tmp, L[i], sizeof(L[i]));
    while (a[i] > 0) {
      if (a[i] % 2 == 1) multi(tmp2, tmp, i);
      multi(tmp, tmp, i);
      a[i] /= 2;
    }
    memset(dp1, 0, sizeof(dp1));
    for (int u = 0; u < 1 << i; u++)
      for (int v = 0; v < 1 << i; v++)
        dp1[u] =
            ((long long)dp1[u] + (long long)dp[v] * tmp2[v][u] % inf) % inf;
    for (int mask = 0; mask < 1 << i; mask++) dp[mask] = dp1[mask];
  }
  cout << dp[(1 << last) - 1];
  return 0;
}