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;
class matrix {
 public:
  vector<vector<long long int> > A;
  int n;
  void create(int N) {
    n = N;
    A.resize(n + 3);
    for (long long int i = 0; i <= n + 2; i++) A[i].resize(n + 3, 0);
  }
};
matrix operator*(matrix a, matrix b) {
  assert(a.n == b.n);
  matrix t;
  t.create(a.n);
  for (long long int i = 1; i <= t.n; i++)
    for (long long int j = 1; j <= t.n; j++)
      for (long long int k = 1; k <= t.n; k++)
        (t.A[i][j] += a.A[i][k] * b.A[k][j]) %= 1000000007LL;
  return t;
}
matrix birim(int n) {
  matrix t;
  t.create(n);
  for (long long int i = 1; i <= n; i++) t.A[i][i] = 1;
  return t;
}
matrix operator^(matrix a, int b) {
  if (!b) return birim(a.n);
  matrix t = a ^ (b / 2);
  t = t * t;
  if (b & 1) t = t * a;
  return t;
}
long long int dp[8][128][128][2];
long long int bul(int k, int state1, int state2, int ok) {
  long long int &ret = dp[k][state1][state2][ok];
  if (ret != -1) return ret;
  if (!k) {
    if (!ok or !(state1 & (1 << k)) or !(state2 & (1 << k))) return ret = 1;
    return ret = 0;
  }
  bool can = (!(state1 & (1 << k)) or !(state2 & (1 << k)) or !ok);
  (ret = bul(k - 1, state1, state2, 0) + can * bul(k - 1, state1, state2, 1)) %=
      1000000007LL;
  return ret;
}
long long int f(int state1, int state2, int k) {
  return bul(k - 1, state1, state2, 1);
}
long long int mul[8][128][128];
void create(int h, int x) {
  matrix A;
  A.create(1 << h);
  for (long long int i = 0; i <= (1 << h) - 1; i++)
    for (long long int j = 0; j <= (1 << h) - 1; j++)
      A.A[i + 1][j + 1] = f(i, j, h);
  A = A ^ x;
  for (long long int i = 0; i <= (1 << h) - 1; i++)
    for (long long int j = 0; j <= (1 << h) - 1; j++)
      mul[h][i][j] = A.A[i + 1][j + 1];
}
long long int DP[8][128];
long long int solve(int h, int state) {
  if (h == 0) return 1;
  long long int &ret = DP[h][state];
  if (ret != -1) return ret;
  ret = 0;
  for (long long int i = 0; i <= (1 << h) - 1; i++)
    if ((i & 1))
      (ret += solve(h - 1, i >> 1) * mul[h][state][i]) %= 1000000007LL;
  return ret;
}
int main() {
  memset(dp, -1, sizeof dp);
  memset(DP, -1, sizeof DP);
  create(2, 1);
  for (long long int i = 1; i <= 7; i++) {
    int x;
    cin >> x;
    create(i, x);
  }
  cout << solve(7, 127) << endl;
}