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 S = 7, sol;
long long W[257];
void inc(long long& x, long long y) { x = (x + y) % 1000000007; }
struct mat {
  long long N, d[257][257];
  mat() { memset(d, 0, sizeof(d)); }
  mat(long long n, bool one = false) : N(n) {
    memset(d, 0, sizeof(d));
    if (one)
      for (long long I = 0; I < N; I++) d[I][I] = 1;
  }
  mat operator*(mat& o) {
    assert(N == o.N);
    mat ret = mat(N);
    for (long long I = 0; I < N; I++)
      for (long long K = 0; K < N; K++)
        for (long long p = 0; p < N; p++) inc(ret.d[I][K], d[I][p] * o.d[p][K]);
    return ret;
  }
  mat operator^(long long b) {
    mat ret(N, true);
    mat a = *this;
    while (b > 0) {
      if (b & 1) ret = ret * a;
      a = a * a;
      b = b / 2;
    }
    return ret;
  }
} C, M, R;
mat magic(long long n) {
  long long all = (1 << n);
  mat ret = mat(all);
  for (long long first = 0; first < all; first++)
    for (long long last = 0; last < all; last++)
      for (long long hor = 0; hor < all / 2; hor++) {
        long long truehor = hor * 2 + 1 + (1 << n);
        if (!(first & last & truehor & (truehor / 2))) ret.d[first][last]++;
      }
  return ret;
}
int main() {
  for (long long I = 0; I < S; I++) cin >> W[I];
  C = mat(2, true);
  for (long long I = 0; I < S; I++) {
    M = magic(I + 1);
    R = M ^ W[I];
    C = C * R;
    for (long long first = 0; first < C.N; first++)
      for (long long last = 0; last < C.N; last++) {
        C.d[first][last + C.N] = C.d[first][last];
        C.d[first][last] = 0;
      }
    C.N *= 2;
  }
  sol = C.d[1][C.N - 1];
  cout << sol << endl;
}