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 mod = 1e9 + 7;
const int K = 127;
int a[9], dp[9][K + 1], curmul[K + 1][K + 1], tempdp[9][2];
void muls(int A[K + 1][K + 1], int B[K + 1][K + 1], int siz) {
  int i, j, k, C[K + 1][K + 1], lim;
  long long int buf1;
  lim = (1 << siz) - 1;
  for (i = 0; i <= lim; i++) {
    for (j = 0; j <= lim; j++) {
      C[i][j] = 0;
      for (k = 0; k <= lim; k++) {
        buf1 = (1ll * A[i][k] * B[k][j]) % mod;
        C[i][j] = (C[i][j] + buf1) % mod;
      }
    }
  }
  for (i = 0; i <= lim; i++) {
    for (j = 0; j <= lim; j++) {
      A[i][j] = C[i][j];
    }
  }
  return;
}
void poweryay(int n, int ans[K + 1], int siz) {
  int i, j, t1, t2, t3, t4, T[K + 1][K + 1], mulmat[K + 1][K + 1], F1[K + 1],
      lim;
  long long int buf1, buf2;
  lim = (1 << siz) - 1;
  for (i = 0; i <= lim; i++) {
    for (j = 0; j <= lim; j++) {
      T[i][j] = curmul[i][j];
      mulmat[i][j] = (i == j) ? 1 : 0;
    }
  }
  for (i = 0; i <= lim; i++) {
    F1[i] = ans[i];
  }
  while (n > 0) {
    if (n & 1) {
      muls(mulmat, T, siz);
    }
    n >>= 1;
    muls(T, T, siz);
  }
  for (i = 0; i <= lim; i++) {
    buf1 = buf2 = 0;
    for (j = 0; j <= lim; j++) {
      buf2 = (1ll * mulmat[i][j] * F1[j]) % mod;
      buf1 = (buf1 + buf2) % mod;
    }
    ans[i] = buf1;
  }
  return;
}
void getmat(int val) {
  int i, j, k, t1, t2, t3, t4, allmask;
  long long int finalval;
  memset(curmul, 0, sizeof(curmul));
  allmask = (1 << val) - 1;
  for (i = 0; i <= allmask; i++) {
    for (j = 0; j <= allmask; j++) {
      tempdp[val][1] = 1;
      tempdp[val][0] = 0;
      for (k = val - 1; k >= 0; k--) {
        t1 = i & (1 << k);
        t2 = j & (1 << k);
        if (t1 > 0 && t2 > 0) {
          tempdp[k][0] = (tempdp[k + 1][1] + tempdp[k + 1][0]) % mod;
          tempdp[k][1] = (tempdp[k + 1][0]) % mod;
        } else {
          tempdp[k][0] = (tempdp[k + 1][1] + tempdp[k + 1][0]) % mod;
          tempdp[k][1] = (tempdp[k + 1][1] + tempdp[k + 1][0]) % mod;
        }
      }
      finalval = tempdp[0][1];
      curmul[j][i] = finalval;
    }
  }
  return;
}
int main() {
  int i, j, t1, t2, t3, t4, finalmask, ans;
  for (i = 1; i <= 7; i++) {
    scanf("%d", &a[i]);
  }
  dp[0][0] = 1;
  finalmask = (1 << 7) - 1;
  for (i = 1; i <= 7; i++) {
    for (j = 0; j <= finalmask; j++) {
      t1 = (1 << (i - 1)) + j;
      if (t1 <= finalmask) {
        dp[i][t1] = (dp[i][t1] + dp[i - 1][j]) % mod;
      }
    }
    if (a[i] > 0) {
      getmat(i);
      poweryay(a[i], dp[i], i);
    }
  }
  ans = dp[7][finalmask];
  printf("%d\n", ans);
  return 0;
}