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>
#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long _x = 0;
  int _ch = getchar(), _f = 1;
  for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar())
    ;
  if (_ch == '-') {
    _f = 0;
    _ch = getchar();
  }
  for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0';
  return _f ? _x : -_x;
}
void write(long long _x) {
  if (_x >= 10)
    write(_x / 10), putchar(_x % 10 + '0');
  else
    putchar(_x + '0');
}
inline void wrt(long long _x, char _p) {
  if (_x < 0) putchar('-'), _x = -_x;
  write(_x);
  if (_p) putchar(_p);
}
struct matrix {
  int a[1 << 7 | 5][1 << 7 | 5], len;
  matrix operator*(const matrix &B) const {
    matrix ans;
    memset(ans.a, 0, sizeof ans.a);
    for (int i = int(0); i <= (int)(len); i++) {
      for (int j = int(0); j <= (int)(len); j++) {
        for (int k = int(0); k <= (int)(len); k++) {
          ans.a[i][j] = (ans.a[i][j] + 1ll * a[i][k] * B.a[k][j]) % 1000000007;
        }
      }
    }
    ans.len = len;
    return ans;
  }
};
int calc(int A, int B, int n) {
  int dp[8][2];
  memset(dp, 0, sizeof dp);
  dp[0][1] = 1;
  for (int i = int(1); i <= (int)(n); i++) {
    if ((A & (1 << (i - 1))) == 0 && (B & (1 << (i - 1))) == 0) {
      dp[i][1] = dp[i - 1][0];
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % 1000000007;
    } else {
      dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
      dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
    }
  }
  return dp[n][1];
}
int a[8];
int dp[1 << 7 | 5], tmp[1 << 7 | 5];
matrix qpow(matrix X, int k) {
  matrix ans;
  memset(ans.a, 0, sizeof ans.a);
  ans.len = X.len;
  for (int i = int(0); i <= (int)(X.len); i++) {
    ans.a[i][i] = 1;
  }
  for (; k; k >>= 1, X = X * X)
    if (k & 1) ans = ans * X;
  return ans;
}
int main() {
  for (int i = int(1); i <= (int)(7); i++) a[i] = rd();
  int la = 0;
  dp[0] = 1;
  for (int i = int(1); i <= (int)(7); i++)
    if (a[i]) {
      memset(tmp, 0, sizeof tmp);
      matrix now;
      memset(now.a, 0, sizeof now.a);
      for (int A = int(0); A <= (int)((1 << i) - 1); A++) {
        for (int B = int(0); B <= (int)((1 << i) - 1); B++) {
          now.a[A][B] = calc(A, B, i);
        }
      }
      now.len = (1 << i) - 1;
      now = qpow(now, a[i]);
      for (int j = int(0); j <= (int)((1 << i) - 1); j++) {
        for (int k = int(0); k <= (int)((1 << i) - 1); k++) {
          tmp[j] = (tmp[j] + 1ll * dp[k] * now.a[k][j]) % 1000000007;
        }
      }
      memcpy(dp, tmp, sizeof dp);
      la = i;
    }
  wrt(dp[0], '\n');
}
