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;
struct mat {
  long long a[128][128];
};
struct vec {
  long long a[128];
};
vec V;
int w[8];
mat I, M[8];
bool check(int l, int u, int v, int w) {
  w = 2 * w + 1 + (1 << l);
  for (int i = 0; i < l; i++) {
    if (((1 << i) & u) && ((1 << i) & v) && ((1 << i) & w) &&
        ((1 << (i + 1)) & w)) {
      return false;
    }
  }
  return true;
}
long long trans(int l, int u, int v) {
  long long ok = 0;
  for (int i = 0; i < (1 << (l - 1)); i++) {
    ok += check(l, u, v, i);
  }
  return ok;
}
vec mult(mat m, vec v, int b) {
  vec w;
  for (int i = 0; i < b; i++) {
    w.a[i] = 0;
    for (int j = 0; j < b; j++) {
      w.a[i] += (m.a[i][j] * v.a[j]) % 1000000007LL;
    }
    w.a[i] %= 1000000007LL;
  }
  return w;
}
mat mult(mat m1, mat m2, int b) {
  mat m3;
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < b; j++) {
      m3.a[i][j] = 0;
      for (int k = 0; k < b; k++) {
        m3.a[i][j] += (m1.a[i][k] * m2.a[k][j]) % 1000000007LL;
      }
      m3.a[i][j] %= 1000000007LL;
    }
  }
  return m3;
}
mat pow(mat m, int b, int B) {
  if (b == 0) return I;
  if (b == 1) return m;
  mat MM = pow(m, b / 2, B);
  MM = mult(MM, MM, B);
  if (b % 2 == 0) return MM;
  return mult(MM, m, B);
}
int main() {
  for (int i = 0; i < 128; i++) {
    I.a[i][i] = 1;
  }
  V.a[0] = 1;
  for (int i = 1; i <= 7; i++) {
    scanf("%d", &w[i]);
    for (int j = 0; j < (1 << (i - 1)); j++) {
      V.a[j + (1 << (i - 1))] = V.a[j];
      V.a[j] = 0;
    }
    for (int j = 0; j < (1 << i); j++) {
      for (int k = 0; k < (1 << i); k++) {
        M[i].a[j][k] = trans(i, j, k);
      }
    }
    V = mult(pow(M[i], w[i], (1 << i)), V, (1 << i));
  }
  printf("%lld\n", V.a[127]);
}