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;
long long power(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * power(a * a % md, b / 2, md) % md
                      : power(a * a % md, b / 2, md) % md));
}
const int xn = 2e2 + 10;
const int xm = 10;
const int sq = 320;
const int inf = 1e9 + 10;
const long long INF = 1e18 + 10;
const int mod = 1e9 + 7;
const int base = 257;
struct matrix {
  long long n, m, a[xn][xn];
  matrix(int n1, int m1, int x = 0) {
    n = n1;
    m = m1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) a[i][j] = x;
  }
  matrix operator*(const matrix &t) {
    matrix r = matrix(n, t.m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < t.m; j++)
        for (int k = 0; k < m; k++)
          r.a[i][j] = (r.a[i][j] + a[i][k] * t.a[k][j] % mod) % mod;
    return r;
  }
};
matrix Pow(matrix a, long long b) {
  matrix res = matrix(a.n, a.m);
  for (int i = 0; i < a.n; i++) res.a[i][i] = 1;
  for (; b; b = b >> 1) {
    if (b & 1) res = res * a;
    a = a * a;
  }
  return res;
}
int a[xm], dp[xn][xm][2], last[xn], pt1 = 7, pt2 = -1;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  for (int i = 0; i < 7; ++i) cin >> a[i];
  for (int i = 0; i < 7; ++i) {
    if (!a[i]) continue;
    pt1 = min(pt1, i);
    pt2 = max(pt2, i);
  }
  for (int mask = 0; mask < 128; ++mask) {
    dp[mask][0][1] = 1;
    for (int i = 1; i < xm; ++i) {
      dp[mask][i][0] = dp[mask][i][1] = dp[mask][i - 1][0] + dp[mask][i - 1][1];
      if ((mask & (1 << (i - 1)))) dp[mask][i][1] -= dp[mask][i - 1][1];
    }
  }
  last[(1 << pt1) - 1] = 1;
  for (int i = pt1; i <= pt2; ++i) {
    int n = 1 << (i + 1);
    matrix m(n, 1), c(n, n);
    for (int mask = 0; mask < 1 << i; ++mask)
      swap(last[mask], last[mask | (1 << i)]);
    for (int mask = 0; mask < n; ++mask)
      for (int mask2 = 0; mask2 < n; ++mask2)
        c.a[mask][mask2] = dp[(mask & mask2)][i + 1][1];
    for (int mask = 0; mask < n; ++mask) m.a[mask][0] = last[mask];
    m = Pow(c, a[i]) * m;
    for (int mask = 0; mask < n; ++mask) last[mask] = m.a[mask][0];
  }
  cout << last[(1 << (pt2 + 1)) - 1] << '\n';
  return 0;
}