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>
const int N = 7;
int wide[N + 1];
const unsigned int mod = 1000000007u;
class TransMat {
 public:
  unsigned int num[1 << N][1 << N];
  int n;

 public:
  void clear();
};
void TransMat ::clear() { memset(num, 0, sizeof num); }
class AnsMat {
 public:
  unsigned int num[1 << N];
  int n;

 public:
  void clear();
};
void AnsMat ::clear() { memset(num, 0, sizeof num); }
TransMat operator*(const TransMat &a, const TransMat &b) {
  TransMat c;
  c.clear();
  c.n = a.n;
  int S = 1 << c.n;
  for (int i = 0; i < S; ++i)
    for (int j = 0; j < S; ++j)
      for (int k = 0; k < S; ++k)
        c.num[i][j] =
            (c.num[i][j] + (unsigned long long)a.num[i][k] * b.num[k][j]) % mod;
  return c;
}
AnsMat operator*(const TransMat &a, const AnsMat &b) {
  AnsMat c;
  c.clear();
  c.n = b.n;
  int S = 1 << c.n;
  for (int i = 0; i < S; ++i)
    for (int k = 0; k < S; ++k)
      c.num[i] = (c.num[i] + (unsigned long long)a.num[i][k] * b.num[k]) % mod;
  return c;
}
TransMat Trans;
AnsMat f;
void read() {
  for (int i = 1; i <= N; ++i) scanf("%d", &wide[i]);
}
void GetTrans(int n) {
  Trans.clear();
  Trans.n = n;
  int S = 1 << n;
  for (int t = 0; t < S; ++t)
    for (int s = 0; s < S; ++s)
      for (int mid = S >> 1; mid < S; ++mid)
        Trans.num[t][s] += !(t & s & mid & (mid << 1) || (t & s & mid & 1));
}
void fupdate(int n) {
  f.n = n;
  int S = 1 << n, hS = S >> 1;
  for (int s = hS; s < S; ++s) f.num[s] = f.num[s - hS], f.num[s - hS] = 0;
}
void qpower(int b) {
  for (; b; Trans = Trans * Trans, b >>= 1)
    if (b & 1) f = Trans * f;
}
void chief() {
  f.num[0] = 1;
  f.n = 0;
  for (int i = 1; i <= N; ++i) {
    GetTrans(i);
    fupdate(i);
    qpower(wide[i]);
  }
}
void write() { printf("%u\n", f.num[(1 << N) - 1]); }
int main() {
  read();
  chief();
  write();
  return 0;
}