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>
inline int read() {
  int ret;
  scanf("%d", &ret);
  return ret;
}
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
using namespace std;
inline void add(long long &x, long long y) { x = (x + y) % 1000000007ll; }
struct Matrix {
  long long a[130][130];
  void toZero() { memset(a, 0, sizeof a); }
  void toE(int n) {
    toZero();
    for (int i = 0; i < int(n); i++) a[i][i] = 1;
  }
};
Matrix mul(Matrix a, Matrix b, int r) {
  Matrix ret;
  ret.toZero();
  for (int i = 0; i < int(r); i++)
    for (int j = 0; j < int(r); j++)
      for (int k = 0; k < int(r); k++) add(ret.a[i][j], a.a[i][k] * b.a[k][j]);
  return ret;
}
Matrix pow(Matrix a, int n, int r) {
  Matrix ret;
  ret.toE(r);
  while (n) {
    if (n & 1) ret = mul(ret, a, r);
    a = mul(a, a, r);
    n >>= 1;
  }
  return ret;
}
int width[8];
long long way[1 << 8];
long long wayto[1 << 8];
int Main() {
  ios_base::sync_with_stdio(0);
  for (int i = 1; i <= int(7); i++) cin >> width[i];
  way[1] = 1;
  for (int i = 1; i <= int(7); i++) {
    Matrix a;
    a.toZero();
    for (int s1 = 0; s1 < int(1 << i); s1++)
      for (int s2 = 0; s2 < int(1 << i); s2++) {
        for (int k = 0; k < int(1 << (i - 1)); k++) {
          int sk = 1 + (k << 1) + (1 << i);
          if ((sk & s1 & s2 & (sk >> 1)) == 0) a.a[s1][s2]++;
        }
      }
    a = pow(a, width[i], 1 << i);
    memset(wayto, 0, sizeof wayto);
    for (int s = 0; s < int(1 << i); s++) {
      for (int j = 0; j < int(1 << i); j++) add(wayto[s], a.a[s][j] * way[j]);
    }
    memset(way, 0, sizeof way);
    for (int s = 0; s < int(1 << i); s++) way[(1 << i) + s] = wayto[s];
  }
  cout << wayto[127] << endl;
  return 0;
}
int main() { return Main(); }