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;
const int maxn = (5e5) + 10, maxm = (1 << 7) + 10, mod = 1e9 + 7;
int w[8];
struct mat {
  int n, m;
  int M[maxm][maxm];
  mat() { memset(M, 0, sizeof M); }
  int* operator[](int x) { return M[x]; }
};
mat emp, iden, A[8], b;
mat zar(mat a, mat b, int x) {
  int somenum = 0;
  for (int i = x; i < 7; i++) somenum += (1 << i);
  mat ans;
  ans.n = a.n, ans.m = b.m;
  int r = a.m;
  for (int i = 0; i < (1 << x); i++)
    for (int j = 0; j < (1 << x); j++)
      for (int k = 0; k < (1 << x); k++)
        ans[i + somenum][j + somenum] =
            (ans[i + somenum][j + somenum] +
             (1ll * a[i + somenum][k + somenum] * b[k + somenum][j + somenum]) %
                 mod) %
            mod;
  return ans;
}
mat tav(mat a, int r, int z) {
  iden.n = a.n;
  iden.m = a.m;
  if (r == 0) return iden;
  mat ans = iden;
  ans.n = a.n;
  ans.m = a.m;
  ans = tav(a, (r >> 1), z);
  ans = zar(ans, ans, z);
  if (r % 2) ans = zar(ans, a, z);
  return ans;
}
bool check(int x, int y, int z, int h) {
  for (int i = 0; i < h; i++) {
    int r1 = x & (1 << i), r2 = y & (1 << i), r3 = z & (1 << i),
        r4 = z & (1 << (max(i - 1, (int)0)));
    if (i == 0) r4 = 1;
    if (i == h - 1) r3 = 1;
    if (r1 && r2 && r3 && r4) return 0;
  }
  for (int i = h; i < 7; i++)
    if (!(((1 << i)) & x) || (!((1 << i) & y))) return 0;
  return 1;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  for (int i = 1; i <= 7; i++) scanf("%d", &w[i]);
  for (int i = 0; i < maxm; i++) iden[i][i] = 1;
  iden.n = maxm;
  iden.m = maxm;
  b.n = (1 << 7), b.m = 1;
  b[(1 << 7) - 1][0] = 1;
  for (int i = 1; i <= 7; i++)
    for (int x = 0; x < (1 << 7); x++)
      for (int y = 0; y < (1 << 7); y++)
        for (int z = 0; z < (1 << (i - 1)); z++)
          if (check(x, y, z, i)) A[i][x][y] = (A[i][x][y] + 1) % mod;
  for (int i = 1; i <= 7; i++) A[i].n = (1 << 7), A[i].m = (1 << 7);
  for (int i = 1; i <= 7; i++) A[i] = tav(A[i], w[i], i);
  iden.n = A[1].n, iden.m = A[1].m;
  mat ans = iden;
  for (int i = 1; i <= 7; i++) ans = zar(A[i], ans, i);
  ans = zar(ans, b, 7);
  printf("%d\n", ans[(1 << 7) - 1][0]);
  return 0;
}