#include <bits/stdc++.h>
using namespace std;
const int N = 130;
const int MOD = 1e9 + 7;
inline void add(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
struct matrix {
  int n, m;
  int a[N][N];
  matrix operator*(const matrix &x) const {
    matrix ret;
    ret.n = n;
    ret.m = x.m;
    memset(ret.a, 0, sizeof(ret.a));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < ret.m; j++)
        for (int k = 0; k < m; k++)
          add(ret.a[i][j], 1ll * a[i][k] * x.a[k][j] % MOD);
    return ret;
  }
  void show() {
    puts("-----show-----");
    printf("n:%d  m:%d\n", n, m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) printf("%d ", a[i][j]);
      puts("");
    }
    puts("");
  }
};
int a[8];
int v[8][N][N];
int ans;
matrix one, dp, tran;
matrix Pow(matrix x, int y) {
  matrix mult = x, ret = one;
  ret.n = x.n;
  ret.m = x.m;
  while (y) {
    if (y & 1) ret = ret * mult;
    mult = mult * mult;
    y >>= 1;
  }
  return ret;
}
int main() {
  one.n = 128;
  one.m = 128;
  memset(one.a, 0, sizeof(one.a));
  for (int i = 0; i < 128; i++) one.a[i][i] = 1;
  for (int i = 1; i <= 7; i++) scanf("%d", a + i);
  for (int i = 1; i <= 7; i++)
    for (int j = 0; j < (1 << i); j++)
      for (int k = 0; k < (1 << i); k++)
        for (int l = 0; l < (1 << i - 1); l++) {
          int m = (l << 1) ^ 1 ^ (1 << i);
          int add = 1;
          for (int x = 0; x < i; x++)
            if ((j & (1 << x)) && (k & (1 << x)) && (m & (1 << x)) &&
                (m & (1 << x + 1)))
              add = 0;
          v[i][j][k] += add;
        }
  dp.n = 1;
  dp.m = 1;
  memset(dp.a, 0, sizeof(dp.a));
  dp.a[0][0] = 1;
  for (int i = 1; i <= 7; i++) {
    for (int j = 0; j < dp.m; j++) {
      dp.a[0][j + dp.m] = dp.a[0][j];
      dp.a[0][j] = 0;
    }
    dp.m *= 2;
    tran.n = dp.m;
    tran.m = dp.m;
    memset(tran.a, 0, sizeof(tran.a));
    for (int j = 0; j < (1 << i); j++)
      for (int k = 0; k < (1 << i); k++) tran.a[k][j] = v[i][j][k];
    tran = Pow(tran, a[i]);
    dp = dp * tran;
  }
  printf("%d\n", dp.a[0][127]);
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 130;
const int MOD = 1e9 + 7;
inline void add(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
struct matrix {
  int n, m;
  int a[N][N];
  matrix operator*(const matrix &x) const {
    matrix ret;
    ret.n = n;
    ret.m = x.m;
    memset(ret.a, 0, sizeof(ret.a));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < ret.m; j++)
        for (int k = 0; k < m; k++)
          add(ret.a[i][j], 1ll * a[i][k] * x.a[k][j] % MOD);
    return ret;
  }
  void show() {
    puts("-----show-----");
    printf("n:%d  m:%d\n", n, m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) printf("%d ", a[i][j]);
      puts("");
    }
    puts("");
  }
};
int a[8];
int v[8][N][N];
int ans;
matrix one, dp, tran;
matrix Pow(matrix x, int y) {
  matrix mult = x, ret = one;
  ret.n = x.n;
  ret.m = x.m;
  while (y) {
    if (y & 1) ret = ret * mult;
    mult = mult * mult;
    y >>= 1;
  }
  return ret;
}
int main() {
  one.n = 128;
  one.m = 128;
  memset(one.a, 0, sizeof(one.a));
  for (int i = 0; i < 128; i++) one.a[i][i] = 1;
  for (int i = 1; i <= 7; i++) scanf("%d", a + i);
  for (int i = 1; i <= 7; i++)
    for (int j = 0; j < (1 << i); j++)
      for (int k = 0; k < (1 << i); k++)
        for (int l = 0; l < (1 << i - 1); l++) {
          int m = (l << 1) ^ 1 ^ (1 << i);
          int add = 1;
          for (int x = 0; x < i; x++)
            if ((j & (1 << x)) && (k & (1 << x)) && (m & (1 << x)) &&
                (m & (1 << x + 1)))
              add = 0;
          v[i][j][k] += add;
        }
  dp.n = 1;
  dp.m = 1;
  memset(dp.a, 0, sizeof(dp.a));
  dp.a[0][0] = 1;
  for (int i = 1; i <= 7; i++) {
    for (int j = 0; j < dp.m; j++) {
      dp.a[0][j + dp.m] = dp.a[0][j];
      dp.a[0][j] = 0;
    }
    dp.m *= 2;
    tran.n = dp.m;
    tran.m = dp.m;
    memset(tran.a, 0, sizeof(tran.a));
    for (int j = 0; j < (1 << i); j++)
      for (int k = 0; k < (1 << i); k++) tran.a[k][j] = v[i][j][k];
    tran = Pow(tran, a[i]);
    dp = dp * tran;
  }
  printf("%d\n", dp.a[0][127]);
  return 0;
}

```