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 int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;
int w[10];
namespace {
inline int add(int x) { return x >= MOD ? x - MOD : x; }
}  // namespace
namespace solver1 {
struct Matrix {
  static const int MAXN = (1 << 7) | 10;
  static const int N = 1 << 7;
  int a[MAXN][MAXN];
  void init() { memset(a, 0, sizeof a); }
  void set() {
    init();
    for (int i = 0; i < N; i++) {
      a[i][i] = 1;
    }
  }
  Matrix operator*(const Matrix& rhs) const {
    Matrix ans;
    static long long tmp[MAXN][MAXN];
    static const long long MODLL = (long long)MOD * MOD;
    for (int i = 0; i < N; i++) {
      for (int k = 0; k < N; k++) {
        for (int j = 0; j < N; j++) {
          tmp[i][j] += (long long)a[i][k] * rhs.a[k][j];
          if (tmp[i][j] >= MODLL) tmp[i][j] -= MODLL;
        }
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        ans.a[i][j] = tmp[i][j] % MOD;
        tmp[i][j] = 0;
      }
    }
    return ans;
  }
};
Matrix pwr(Matrix a, int b) {
  Matrix ans;
  ans.set();
  for (; b; b >>= 1, a = a * a) {
    if (b & 1) ans = ans * a;
  }
  return ans;
}
int calc(int mask1, int mask2, int n) {
  int f[10][2];
  memset(f, 0, sizeof f);
  f[0][1] = 1;
  for (int i = 0; i < n; i++) {
    f[i + 1][0] = add(f[i][0] + f[i][1]);
    f[i + 1][1] = f[i][0];
    if (!(mask1 >> i & 1) || !(mask2 >> i & 1)) {
      f[i + 1][1] = add(f[i + 1][1] + f[i][1]);
    }
  }
  return f[n][1];
}
Matrix get(int x, int y) {
  Matrix ans;
  ans.init();
  int t = 0;
  for (int i = x; i < y; i++) {
    t |= 1 << i;
  }
  for (int i = 0; i < (1 << x); i++) {
    for (int j = 0; j < (1 << y); j++) {
      ans.a[j][i] = calc(i | t, j, y);
    }
  }
  return ans;
}
void main() {
  Matrix ans;
  ans.set();
  int last = 1;
  if (w[1]) {
    ans = pwr(get(1, 1), w[1]) * ans;
  }
  for (int i = 2; i <= 7; i++) {
    if (w[i]) {
      ans = get(last, i) * ans;
      ans = pwr(get(i, i), w[i] - 1) * ans;
      last = i;
    }
  }
  printf("%d\n", ans.a[(1 << last) - 1][1]);
}
}  // namespace solver1
int main() {
  for (int i = 1; i <= 7; i++) {
    scanf("%d", w + i);
  }
  solver1::main();
}