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 a[7];
int pre[128];
int curr[128];
int last;
int n;
int h, base;
long long f[128][128];
int fdp[8][2][128][128];
const int MAXPOW = 1024;
int ok[MAXPOW + 1];
long long pw[MAXPOW + 1][128][128];
int lo, hi;
void rundfs() {
  for (unsigned int(b) = (0); (b) < (2); (b)++)
    for (unsigned int(msk) = (0); (msk) < (128); (msk)++)
      for (unsigned int(tg) = (0); (tg) < (128); (tg)++)
        fdp[h][b][msk][tg] = (msk == tg);
  for (int j = h - 1; j >= 0; j--) {
    int top = (j == (h - 1));
    for (unsigned int(b) = (0); (b) < (2); (b)++) {
      for (unsigned int(msk) = (0); (msk) < (128); (msk)++) {
        int rem = 4 - b - top - last - ((msk & 1 << j) != 0);
        if (rem == 0) {
          for (unsigned int(i) = (0); (i) < (128); (i)++) fdp[j][b][msk][i] = 0;
          continue;
        }
        for (unsigned int(i) = (0); (i) < (128); (i)++)
          fdp[j][b][msk][i] = fdp[j + 1][0][msk & ~(1 << j)][i];
        if (rem > 1 && !last)
          for (unsigned int(i) = (0); (i) < (128); (i)++)
            fdp[j][b][msk][i] =
                ((fdp[j][b][msk][i]) + (fdp[j + 1][0][msk | (1 << j)][i])) %
                MOD;
        ;
        if (rem > 1 && !top)
          for (unsigned int(i) = (0); (i) < (128); (i)++)
            fdp[j][b][msk][i] =
                ((fdp[j][b][msk][i]) + (fdp[j + 1][1][msk & ~(1 << j)][i])) %
                MOD;
        ;
        if (rem > 2 && !top && !last)
          for (unsigned int(i) = (0); (i) < (128); (i)++)
            fdp[j][b][msk][i] =
                ((fdp[j][b][msk][i]) + (fdp[j + 1][1][msk | (1 << j)][i])) %
                MOD;
        ;
      }
    }
  }
  for (unsigned int(msk) = (0); (msk) < (128); (msk)++)
    for (unsigned int(tg) = (0); (tg) < (128); (tg)++)
      f[msk][tg] = fdp[0][1][msk][tg];
}
long long act[128][128];
long long aux[128][128];
void makepw(int p) {
  if (ok[p]) return;
  makepw(p / 2);
  for (unsigned int(i) = (base); (i) < (128); (i)++)
    for (unsigned int(j) = (base); (j) < (128); (j)++)
      aux[i][j] = pw[p / 2][i][j];
  for (unsigned int(i) = (base); (i) < (128); (i)++)
    for (unsigned int(j) = (base); (j) < (128); (j)++) {
      act[i][j] = 0;
      for (unsigned int(k) = (base); (k) < (128); (k)++)
        act[i][j] = ((act[i][j]) + (aux[i][k] * aux[k][j])) % MOD;
      ;
    }
  if (p % 2) {
    for (unsigned int(i) = (base); (i) < (128); (i)++)
      for (unsigned int(j) = (base); (j) < (128); (j)++) {
        aux[i][j] = 0;
        for (unsigned int(k) = (base); (k) < (128); (k)++)
          aux[i][j] = ((aux[i][j]) + (act[i][k] * f[k][j])) % MOD;
        ;
      }
    for (unsigned int(i) = (base); (i) < (128); (i)++)
      for (unsigned int(j) = (base); (j) < (128); (j)++) act[i][j] = aux[i][j];
  }
  for (unsigned int(i) = (base); (i) < (128); (i)++)
    for (unsigned int(j) = (base); (j) < (128); (j)++) pw[p][i][j] = act[i][j];
  ok[p] = 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  lo = -1;
  for (unsigned int(i) = (0); (i) < (7); (i)++) {
    cin >> a[i];
    if (a[i]) {
      if (lo == -1) lo = i;
      hi = i;
    }
  }
  for (unsigned int(i) = (0); (i) < (128); (i)++) curr[i] = 1;
  int id = hi;
  last = 1;
  while (id >= lo) {
    n = a[id];
    h = id + 1;
    base = 128 - (1 << h);
    rundfs();
    for (unsigned int(msk) = (0); (msk) < (128); (msk)++) pre[msk] = curr[msk];
    if (last) {
      for (unsigned int(msk) = (0); (msk) < (128); (msk)++) {
        curr[msk] = 0;
        for (unsigned int(tg) = (0); (tg) < (128); (tg)++)
          curr[msk] = ((curr[msk]) + (f[msk][tg] * pre[tg])) % MOD;
        ;
      }
      last = 0;
      n--;
      rundfs();
      for (unsigned int(msk) = (0); (msk) < (128); (msk)++)
        pre[msk] = curr[msk];
    }
    for (unsigned int(i) = (0); (i) < (MAXPOW + 1); (i)++) ok[i] = 0;
    ok[0] = ok[1] = 1;
    for (unsigned int(i) = (base); (i) < (128); (i)++)
      for (unsigned int(j) = (base); (j) < (128); (j)++) pw[0][i][j] = (i == j);
    for (unsigned int(i) = (base); (i) < (128); (i)++)
      for (unsigned int(j) = (base); (j) < (128); (j)++) pw[1][i][j] = f[i][j];
    makepw(MAXPOW);
    makepw(n % MAXPOW);
    for (unsigned int(i) = (0); (i) < (n / MAXPOW); (i)++) {
      for (unsigned int(msk) = (base); (msk) < (128); (msk)++) {
        curr[msk] = 0;
        for (unsigned int(tg) = (base); (tg) < (128); (tg)++)
          curr[msk] = ((curr[msk]) + (pw[MAXPOW][msk][tg] * pre[tg])) % MOD;
        ;
      }
      for (unsigned int(msk) = (base); (msk) < (128); (msk)++)
        pre[msk] = curr[msk];
    }
    for (unsigned int(msk) = (base); (msk) < (128); (msk)++) {
      curr[msk] = 0;
      for (unsigned int(tg) = (base); (tg) < (128); (tg)++)
        curr[msk] = ((curr[msk]) + (pw[n % MAXPOW][msk][tg] * pre[tg])) % MOD;
      ;
    }
    for (unsigned int(msk) = (base); (msk) < (128); (msk)++)
      pre[msk] = curr[msk];
    id--;
    while (id && !a[id]) id--;
  }
  cout << curr[127] << endl;
  return 0;
}