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 GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 128, LOG = 7;
struct MAT {
  int A[MAXN][MAXN];
  MAT() { memset(A, 0, sizeof(A)); }
  int *operator[](int i) { return A[i]; }
  void ID() {
    for (int i = 0; i < MAXN; i++)
      for (int j = 0; j < MAXN; j++) A[i][j] = (i == j);
  }
};
MAT operator*(MAT &A, MAT &B) {
  MAT C;
  for (int i = 0; i < MAXN; i++)
    for (int k = 0; k < MAXN; k++)
      for (int j = 0; j < MAXN; j++)
        C[i][j] = (C[i][j] + 1ll * A[i][k] * B[k][j]) % mod;
  return C;
}
MAT operator^(MAT &M, int tav) {
  MAT A;
  A.ID();
  for (MAT B = M; tav; tav >>= 1, B = B * B)
    if (tav & 1) A = A * B;
  return A;
}
int n, m, k, u, v, x, y, t, a, b;
int W[8];
long long dp[MAXN];
long long tmp[MAXN];
void MUL(MAT &T) {
  for (int i = 0; i < MAXN; i++)
    for (int j = 0; j < MAXN; j++) tmp[j] = (tmp[j] + dp[i] * T[i][j]) % mod;
  for (int i = 0; i < MAXN; i++) dp[i] = tmp[i], tmp[i] = 0;
}
void TOF(MAT &M, int tav) {
  for (; tav; tav >>= 1, M = M * M)
    if (tav & 1) MUL(M);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  dp[0] = 1;
  for (int len = 1; len <= 7; len++) {
    MAT T;
    for (int i = 127; i >= (1 << (len - 1)); i--) {
      dp[i] = dp[i - (1 << (len - 1))];
      dp[i - (1 << (len - 1))] = 0;
    }
    for (int mask1 = 0; mask1 < (1 << len); mask1++)
      for (int mask2 = (1 << len) + 1; mask2 < (1 << (len + 1)); mask2 += 2)
        for (int mask3 = 0; mask3 < (1 << len); mask3++) {
          bool f = 1;
          for (int i = 0; i < len && f; i++)
            if ((((mask1 & mask3) >> (i)) & 1) && (((mask2) >> (i)) & 1) &&
                (((mask2) >> (i + 1)) & 1))
              f = 0;
          if (f) T[mask1][mask3]++;
        }
    cin >> W[len];
    if (!W[len]) continue;
    TOF(T, W[len]);
  }
  cout << dp[127] << '\n';
  return 0;
}