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;
char _;
const int maxN = 400 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int SQ = 317;
const int maxL = 20;
const int L = 1 << 7;
struct Mat {
  int n;
  int val[L][L];
  Mat(int fl = 0) {
    for (int i = 0; i < L; i++)
      for (int j = 0; j < L; j++)
        if (i != j)
          val[i][j] = 0;
        else
          val[i][j] = fl;
  }
} p[7];
Mat operator*(const Mat &p, const Mat &q) {
  Mat ans;
  ans.n = max(p.n, q.n);
  for (int i = 0; i < ans.n; i++)
    for (int j = 0; j < ans.n; j++)
      for (int k = 0; k < ans.n; k++)
        ans.val[i][j] =
            (ans.val[i][j] + (1LL) * p.val[i][k] * q.val[k][j] % mod) % mod;
  return ans;
}
Mat power(Mat q, int k) {
  Mat ans(1);
  ans.n = q.n;
  while (k) {
    if (k & 1) ans = ans * q;
    k >>= 1;
    q = q * q;
  }
  return ans;
}
void solve(int n) {
  p[n - 1].n = (1 << n);
  for (int mask = 0; mask < (1 << n); mask++)
    for (int smask = 0; smask < (1 << n); smask++)
      for (int bmask = 0; bmask < (1 << (n - 1)); bmask++) {
        bool fl = 1;
        for (int i = 0; i < n; i++) {
          bool x = mask >> i & 1;
          bool y = smask >> i & 1;
          bool z = (i ? (bmask >> (i - 1) & 1) : 0);
          bool w = bmask >> i & 1;
          if (x == 0 && y == 0 && z == 0 && w == 0) {
            fl = 0;
            break;
          }
        }
        if (fl) p[n - 1].val[mask][smask]++;
      }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 1; i < 8; i++) solve(i);
  Mat ans;
  ans.n = L;
  ans.val[0][0] = 1;
  for (int i = 0; i < 7; i++) {
    int x;
    cin >> x;
    ans = ans * power(p[i], x);
  }
  cout << ans.val[0][0] << endl;
  return 0;
}