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 mod = 1e9 + 7;
int n = 7, w[9];
struct mat {
  int a[135][135];
  int len;
  mat() { memset(a, 0, sizeof a); }
  void print() {
    for (int i = 0; i <= len - 1; i++)
      for (int j = 0; j <= len - 1; j++) {
        printf("%d%c", a[i][j], (j == len - 1) ? '\n' : ' ');
      }
    printf("\n");
  }
  int *operator[](int i) { return a[i]; }
  mat operator*(mat lhs) const {
    mat t;
    for (int i = 0; i <= len - 1; i++)
      for (int j = 0; j <= len - 1; j++)
        for (int k = 0; k <= len - 1; k++)
          t[i][k] = (t[i][k] + (1ll * a[i][j] * lhs[j][k]) % mod) % mod;
    return t;
  }
} base[9], cur;
void init(int x) {
  base[x].len = (1 << x);
  int all = (1 << x) - 1, All = (1 << (x + x + 1)) - 1;
  for (int s = 0; s <= All; s++) {
    if (!(s & 1) || !((s >> (x + x)) & 1)) continue;
    for (int ss = 0; ss <= all; ss++) {
      bool flag = 1;
      for (int i = 1; i <= x; i++)
        if ((1 << (i - 1)) & ss) {
          if ((1 << (i + i - 1)) & s) {
            flag = 0;
            break;
          }
        }
      if (!flag) continue;
      int ts = 0;
      for (int i = 1; i <= x; i++)
        if (((s >> (i + i - 2)) & 1) && ((s >> (i + i - 1)) & 1) &&
            ((s >> (i + i)) & 1))
          ts += (1 << (i - 1));
      base[x][ss][ts]++;
    }
  }
}
mat qpow(mat a, int b) {
  mat res;
  int len = a.len;
  res.len = len;
  for (int i = 0; i <= len - 1; i++) res[i][i] = 1;
  while (b) {
    if (b & 1) res = a * res, res.len = len;
    a = a * a;
    a.len = len;
    b >>= 1;
  }
  return res;
}
void trans(mat &X, int x, mat &Y, int y) {
  int ax = (1 << x) - 1, ay = (1 << (y + y + 1)) - 1;
  for (int sy = 0; sy <= ay; sy++) {
    bool flag = 1;
    flag &= (sy & 1) && ((sy >> (y + y)) & 1);
    for (int i = x + 1; i <= y; i++) flag &= ((sy >> (i + i - 1)) & 1);
    if (!flag) continue;
    for (int sx = 0; sx <= ax; sx++) {
      bool Flag = 1;
      for (int i = 1; i <= x; i++)
        if ((1 << (i - 1)) & sx) {
          if ((1 << (i + i - 1) & sy)) {
            Flag = 0;
            break;
          }
        }
      if (!Flag) continue;
      int ty = 0;
      for (int i = 1; i <= y; i++)
        if ((sy >> (i + i - 2) & 1) && ((sy >> (i + i - 1)) & 1) &&
            ((sy >> (i + i)) & 1))
          ty += (1 << (i - 1));
      Y[0][ty] = (Y[0][ty] + X[0][sx]) % mod;
    }
  }
}
int main() {
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= n; i++) init(i);
  int lst = 0;
  cur[0][0] = cur[0][1] = 1;
  for (int i = 1; i <= n; i++) {
    if (w[i] > 0) {
      mat tmp;
      trans(cur, lst, tmp, i);
      lst = i;
      cur = tmp;
      cur.len = (1 << i);
      if (w[i] > 1) {
        assert(cur.len == base[i].len);
        cur = cur * qpow(base[i], w[i] - 1);
        cur.len = (1 << i);
      }
    }
  }
  printf("%d\n", cur[0][0]);
  return 0;
}