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>
const long long N = 2e5 + 5;
const long long p = 1e9 + 7;
template <class T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
long long to[128][128], all = 127;
struct matrix {
  long long a[128][128];
  matrix() { memset(a, 0, sizeof(a)); }
  inline void init() {
    for (long long i = 0; i <= all; i++) a[i][i] = 1;
  }
} nt;
inline matrix operator*(matrix a, matrix b) {
  matrix c;
  for (long long i = 0; i <= all; i++)
    for (long long j = 0; j <= all; j++)
      for (long long k = 0; k <= all; k++)
        (c.a[i][j] += a.a[i][k] * b.a[k][j] % p) %= p;
  return c;
}
inline matrix ksm(matrix a, long long b) {
  matrix ans;
  ans.init();
  for (; b; b >>= 1, a = a * a)
    if (b & 1) ans = ans * a;
  return ans;
}
long long n, ad, AD, f[128], g[128], h[8], al, lst, nw, st, vis[128], Ans;
inline void solve() {
  for (long long i = 1; i <= 7; i++) read(h[i]);
  for (long long i = 1; i <= 7; i++) {
    if (!h[i]) continue;
    f[(1 << i) - 1] = 1;
    lst = i;
    break;
  }
  for (long long as = 1; as <= 7; as++) {
    if (!h[as]) continue;
    al = (1 << as) - 1;
    memset(to, 0, sizeof(to));
    for (long long i = 0; i <= (1 << (as + 1)) - 1; i++)
      if ((i & 1) && (i & (1 << as))) {
        for (long long a = 0; a <= (1 << as) - 1; a++)
          for (long long b = 0; b <= (1 << as) - 1; b++) {
            long long tag = 0;
            for (long long c = 0; c <= as - 1; c++)
              if ((a & b & (1 << c)) && (i & (1 << c)) && (i & (1 << (c + 1))))
                tag = 1;
            to[a][b] += (tag ^ 1);
          }
      }
    for (long long i = 0; i <= al; i++)
      for (long long j = 0; j <= al; j++) nt.a[i][j] = to[i][j];
    all = al;
    nt = ksm(nt, h[as] - 1);
    st = (1 << as) - (1 << lst);
    memset(g, 0, sizeof(g));
    for (long long i = 0; i <= (1 << lst) - 1; i++) {
      long long rel = (i | st);
      for (long long j = 0; j <= al; j++) (g[j] += to[rel][j] * f[i] % p) %= p;
    }
    for (long long i = 0; i <= al; i++) f[i] = g[i];
    memset(g, 0, sizeof(g));
    for (long long i = 0; i <= al; i++)
      for (long long j = 0; j <= al; j++) (g[j] += f[i] * nt.a[i][j] % p) %= p;
    for (long long i = 0; i <= al; i++) f[i] = g[i];
    lst = as;
  }
  printf("%lld\n", f[(1 << lst) - 1]);
}
signed main() { solve(); }