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;
namespace SHENZHEBEI {
const int L = 2333333;
char SZB[L], *S = SZB, *T = SZB;
inline char gc() {
  if (S == T) {
    T = (S = SZB) + fread(SZB, 1, L, stdin);
    if (S == T) return '\n';
  }
  return *S++;
}
inline long long readint() {
  long long x = 0;
  char ch = gc();
  for (; !isdigit(ch); ch = gc())
    ;
  for (; isdigit(ch); ch = gc()) x = x * 10 - 48 + ch;
  return x;
}
inline void write(long long x) {
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline char readchar() {
  char ch = gc();
  for (; isspace(ch); ch = gc())
    ;
  return ch;
}
inline long long readstr(char *s) {
  char ch = gc();
  int cur = 0;
  for (; isspace(ch); ch = gc())
    ;
  for (; !isspace(ch); ch = gc()) s[cur++] = ch;
  s[cur] = '\0';
  return cur;
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
}  // namespace SHENZHEBEI
using namespace SHENZHEBEI;
const long long mod = 1e9 + 7;
struct data {
  long long m[130][130];
} st, zy, tmp;
long long bin[10], a[10], b[10], m, ck = 0;
void add(long long &x, long long y) { x = (x + y) % mod; }
data operator*(data a, data b) {
  memset(tmp.m, 0, sizeof tmp.m);
  for (long long i = 0; i <= m; ++i)
    for (long long k = 0; k <= m; ++k)
      for (long long j = 0; j <= m; ++j)
        add(tmp.m[i][j], a.m[i][k] * b.m[k][j]);
  return tmp;
}
inline long long work(long long l, long long r, long long n) {
  if (!n) return l | r;
  long long sum = 0;
  for (long long i = 0; i <= (1 << n) - 1; ++i) {
    long long ans = 1;
    for (long long j = 0; j <= n; ++j)
      ans &= (j == 0 ? 0 : (i >> (j - 1) & 1)) || (j == n ? 0 : (i >> j & 1)) ||
             (l >> j & 1) || (r >> j & 1);
    sum += ans;
  }
  return sum % mod;
}
int main() {
  for (long long i = 0; i <= 6; ++i) b[i] = a[i] = readint();
  st.m[0][0] = 1;
  for (long long i = 0; i <= 6; ++i)
    if (a[i]) {
      memset(zy.m, 0, sizeof zy.m);
      m = (1 << (i + 1)) - 1;
      for (long long S = 0; S <= (1 << (i + 1)) - 1; ++S)
        for (long long T = 0; T <= (1 << (i + 1)) - 1; ++T)
          zy.m[S][T] = work(S, T, i);
      while (a[i]) {
        if (a[i] & 1) st = st * zy;
        zy = zy * zy;
        a[i] >>= 1;
      }
    }
  for (long long i = 6; i >= 0; --i)
    if (b[i]) return writeln(st.m[0][0]), 0;
}