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 Maxn = 128;
const int Mod = 1e9 + 7;
long long mat[Maxn][Maxn][Maxn];
long long c[Maxn][Maxn];
long long adj[Maxn][Maxn];
int p[Maxn + 1];
int s[Maxn + 1];
long long cur[Maxn][Maxn];
long long st[Maxn];
long long nst[Maxn];
long long w[Maxn];
void mul(long long a[Maxn][Maxn], long long b[Maxn][Maxn], int to) {
  memset(c, 0, sizeof c);
  for (int i = 0; i < Maxn; i++)
    if (i % 9 == 0) p[i] = 1;
  for (int i = 0; i < to; i++) s[i] = 1;
  s[Maxn] = 0;
  for (int i = 0; i != to; i++)
    for (int j = 0; j != to; j++) {
      for (int k = 0; k != to; k++) {
        c[i][j] = c[i][j] + (a[i][k] * b[k][j]);
        if (p[k]) c[i][j] %= Mod;
      }
      c[i][j] %= Mod;
    }
  return;
}
int main() {
  int n = 7;
  st[0] = 1;
  for (int i = 1; i <= 7; i++) cin >> w[i];
  int last = 0;
  for (int lvl = 1; lvl <= 7; lvl++) {
    if (!w[lvl]) continue;
    int pmask = 0;
    for (int i = last + 1; i <= lvl; i++) pmask += (1 << i - 1);
    for (int i = 0; i < pmask; i++) st[i + pmask] = st[i], st[i] = 0;
    for (int mask1 = 0; mask1 < (1 << lvl); mask1++) {
      for (int mask2 = 0; mask2 < (1 << lvl); mask2++) {
        adj[mask1][mask2] = 0;
        for (int mask3 = (1 << lvl) + 1; mask3 < (1 << lvl + 1); mask3 += 2) {
          int f = 1;
          for (int i = lvl - 1; i + 1; --i) {
            if (((1 << i) & mask1) && ((1 << i) & mask2) &&
                ((1 << (i + 1)) & mask3) && ((1 << i) & mask3))
              f = 0;
          }
          adj[mask1][mask2] += f;
        }
      }
    }
    for (int i = 0; i < Maxn; i++)
      for (int j = 0; j < Maxn; j++) mat[0][i][j] = adj[i][j];
    memset(cur, 0, sizeof cur);
    for (int i = 0; i < Maxn; i++) cur[i][i] = 1;
    for (int i = 1; i < 17; i++) {
      mul(mat[i - 1], mat[i - 1], (1 << lvl));
      for (int j = 0; j < Maxn; j++)
        for (int k = 0; k < Maxn; k++) mat[i][j][k] = c[j][k];
    }
    for (int k = 0; k < 17; k++)
      if ((1 << k) & w[lvl]) {
        mul(cur, mat[k], (1 << lvl));
        for (int i = 0; i < Maxn; i++)
          for (int j = 0; j < Maxn; j++) cur[i][j] = c[i][j];
      }
    for (int i = 0; i < Maxn; i++) nst[i] = st[i], st[i] = 0;
    for (int i = 0; i < Maxn; i++)
      for (int j = 0; j < Maxn; j++) st[i] += nst[j] * cur[j][i], st[i] %= Mod;
    last = lvl;
  }
  cout << st[(1 << last) - 1] << endl;
  return 0;
}