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 N = 7;
const int MOD = (int)1e9 + 7;
void add_to(int& a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int mul(int a, int b) {
  long long c = (long long)a * b;
  return (int)(c % MOD);
}
struct Matrix {
  int SZ;
  int a[1 << N][1 << N];
  explicit Matrix(int size, int e = 0) : a() {
    SZ = size;
    for (int i = 0; i < SZ; i++) a[i][i] = e;
  }
  int* operator[](int p) { return a[p]; }
  const int* operator[](int p) const { return a[p]; }
  Matrix operator*(const Matrix& b) {
    Matrix c(SZ);
    for (int i = 0; i < SZ; i++)
      for (int j = 0; j < SZ; j++)
        for (int k = 0; k < SZ; k++) add_to(c[i][j], mul(a[i][k], b[k][j]));
    return c;
  }
};
Matrix bin_pow(Matrix a, int b) {
  Matrix c(a.SZ, 1);
  while (b > 0) {
    if (b % 2 == 1) c = c * a;
    a = a * a;
    b /= 2;
  }
  return c;
}
int width[N];
int dp[1 << N];
int loc[N + 1][2];
bool bit(int a, int b) { return (a & (1 << b)) != 0; }
int get_ways(int lvl, int left, int right) {
  memset(loc, 0, sizeof(loc));
  loc[0][1] = 1;
  for (int i = 0; i < lvl; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) {
        if (bit(left, i) && bit(right, i) && j == 1 && k == 1) continue;
        add_to(loc[i + 1][k], loc[i][j]);
      }
  return loc[lvl][1];
}
void solve() {
  for (int i = 0; i < N; i++) scanf("%d", &width[i]);
  dp[0] = 1;
  int prev_lvl = 0;
  for (int lvl = 1; lvl <= N; lvl++) {
    if (width[lvl - 1] == 0) continue;
    Matrix vec(1 << lvl);
    for (int mask = 0; mask < (1 << prev_lvl); mask++) {
      int new_mask = mask;
      for (int i = prev_lvl; i < lvl; i++) new_mask |= (1 << i);
      vec[0][new_mask] = dp[mask];
    }
    Matrix mat(1 << lvl);
    for (int from = 0; from < (1 << lvl); from++)
      for (int to = 0; to < (1 << lvl); to++)
        mat[from][to] = get_ways(lvl, from, to);
    mat = bin_pow(mat, width[lvl - 1]);
    vec = vec * mat;
    for (int mask = 0; mask < (1 << lvl); mask++) dp[mask] = vec[0][mask];
    prev_lvl = lvl;
  }
  int ans = dp[(1 << prev_lvl) - 1];
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}