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 mod = 1000000007;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
int n;
bool mset(int mask, int i) { return mask & (1 << i); }
bool sparse(int k, int left, int horizontal, int right) {
  for (int i = (0); i < (k); ++i)
    if (mset(left, i) && mset(right, i) && mset(horizontal, i) &&
        mset(horizontal, i + 1))
      return 0;
  return 1;
}
int ways(int k, int left, int right) {
  int c = 0;
  for (int horizontal = (0); horizontal < ((1 << (k - 1))); ++horizontal)
    if (sparse(k, left, 2 * horizontal + 1 + (1 << k), right)) ++c;
  return c;
}
int dp[133];
int tmp[133];
int size;
int matrix[7][128][128];
void diag(int a, int s = 1) {
  for (int i = (0); i < (size); ++i)
    for (int j = (0); j < (size); ++j) matrix[a][i][j] = (i == j ? s : 0);
}
void mov(int a, int b) {
  for (int i = (0); i < (size); ++i)
    for (int j = (0); j < (size); ++j) matrix[b][i][j] = matrix[a][i][j];
}
void mul(int a, int b, int c) {
  diag(c, 0);
  for (int i = (0); i < (size); ++i)
    for (int k = (0); k < (size); ++k)
      for (int j = (0); j < (size); ++j)
        matrix[c][i][j] =
            (matrix[c][i][j] + (long long)matrix[a][i][k] * matrix[b][k][j]) %
            mod;
}
void pow(int k) {
  diag(1);
  while (k) {
    if (k & 1) {
      mul(0, 1, 2);
      mov(2, 1);
    }
    mul(0, 0, 2);
    mov(2, 0);
    k /= 2;
  }
}
void process(int k, int w) {
  size = (1 << k);
  for (int i = (0); i < (size / 2); ++i) {
    dp[i + size / 2] = dp[i];
    dp[i] = 0;
  }
  for (int i = (0); i < (size); ++i)
    for (int j = (0); j < (size); ++j) matrix[0][i][j] = ways(k, i, j);
  pow(w);
  for (int i = (0); i < (size); ++i) tmp[i] = 0;
  for (int i = (0); i < (size); ++i)
    for (int j = (0); j < (size); ++j)
      tmp[j] = (tmp[j] + (long long)dp[i] * matrix[1][i][j]) % mod;
  for (int i = (0); i < (size); ++i) dp[i] = tmp[i];
}
int main() {
  dp[0] = 1;
  for (int k = (1); k < (8); ++k) {
    int w;
    scanf("%d", &w);
    process(k, w);
  }
  printf("%d\n", dp[127]);
  return 0;
}