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 BASE = 1e9 + 7;
const int N = 8;
int n = 7;
int w[N];
long long dp[N][1 << N], f[N][1 << N];
struct Matrix {
  static const int N = (1 << 7) + 10;
  int n;
  long long a[N][N];
  void Init(int _n) {
    n = _n;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) a[i][j] = 0;
  }
  Matrix operator*(const Matrix &that) const {
    Matrix ans;
    ans.Init(n);
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        for (int k = 0; k < n; ++k)
          ans.a[i][j] = (ans.a[i][j] + a[i][k] * that.a[k][j]) % BASE;
    return ans;
  }
};
void Add(long long &a, long long b) {
  a += b;
  a %= BASE;
}
long long Compute(int n, int mask1, int mask2) {
  static long long ways[N][2];
  memset(ways, 0, sizeof ways);
  ways[0][1] = 1;
  for (int i = 1; i <= n; ++i) {
    int bit1 = mask1 >> (i - 1) & 1, bit2 = mask2 >> (i - 1) & 1;
    if (bit1 == 1 && bit2 == 1) {
      Add(ways[i][1], ways[i - 1][0]);
      Add(ways[i][0], ways[i - 1][0]);
      Add(ways[i][0], ways[i - 1][1]);
    } else {
      for (int x = 0; x <= 1; ++x)
        for (int y = 0; y <= 1; ++y) Add(ways[i][x], ways[i - 1][y]);
    }
  }
  return ways[n][1];
}
Matrix Pow(Matrix a, long long p) {
  Matrix ans;
  ans = a;
  --p;
  while (p) {
    if (p & 1) ans = ans * a;
    a = a * a;
    p >>= 1;
  }
  return ans;
}
Matrix BuildMatrix(int n) {
  Matrix ans;
  ans.Init(1 << n);
  for (int i = 0; i < 1 << n; ++i)
    for (int j = 0; j < 1 << n; ++j) {
      ans.a[i][j] = Compute(n, i, j);
    }
  return ans;
}
int main() {
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int preMask = 0; preMask < 1 << (i - 1); ++preMask)
      Add(f[i][preMask | (1 << (i - 1))], dp[i - 1][preMask]);
    if (w[i] == 0) {
      for (int mask = 0; mask < 1 << i; ++mask) dp[i][mask] = f[i][mask];
    } else {
      Matrix a = BuildMatrix(i);
      a = Pow(a, w[i]);
      for (int mask1 = 0; mask1 < 1 << i; ++mask1)
        for (int mask2 = 0; mask2 < 1 << i; ++mask2) {
          Add(dp[i][mask1], f[i][mask2] * a.a[mask2][mask1]);
        }
    }
  }
  printf("%I64d", dp[n][(1 << n) - 1]);
  return 0;
}