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 INF = 1e9;
const long long int INFLL = 1e18;
const double EPS = 1e-8;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
const long long int MOD = 1e9 + 7;
struct Mod {
  long long int n;
  Mod() {}
  Mod(long long int x) {
    if (x < 0)
      n = x % MOD + MOD;
    else
      n = x % MOD;
  }
};
Mod operator+(Mod a, Mod b) { return Mod((a.n + b.n) % MOD); }
Mod operator+=(Mod &a, Mod b) { return a = a + b; }
Mod operator-(Mod a, Mod b) { return Mod((a.n - b.n + MOD) % MOD); }
Mod operator-=(Mod &a, Mod b) { return a = a - b; }
Mod operator*(Mod a, Mod b) { return Mod((a.n * b.n) % MOD); }
Mod operator*=(Mod &a, Mod b) { return a = a * b; }
Mod modpow(Mod x, long long int k) {
  Mod res = 1;
  while (k) {
    if (k & 1) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
Mod inv(Mod a) { return modpow(a, MOD - 2); }
Mod operator/(Mod a, Mod b) { return Mod((a.n * inv(b).n) % MOD); }
Mod operator/=(Mod &a, Mod b) { return a = a / b; }
vector<vector<Mod> > mul(vector<vector<Mod> > a, vector<vector<Mod> > b) {
  vector<vector<Mod> > c =
      vector<vector<Mod> >(a.size(), vector<Mod>(b[0].size(), 0));
  for (int i = (0); i < (int)(c.size()); i++)
    for (int j = (0); j < (int)(c[i].size()); j++)
      for (int k = (0); k < (int)(a[i].size()); k++)
        c[i][j] = c[i][j] + a[i][k] * b[k][j];
  return c;
}
vector<vector<Mod> > pow(vector<vector<Mod> > a, long long int k) {
  vector<vector<Mod> > res =
      vector<vector<Mod> >(a.size(), vector<Mod>(a.size(), 0));
  for (int i = (0); i < (int)(res.size()); i++) res[i][i] = 1;
  while (k > 0) {
    if (k % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    k /= 2;
  }
  return res;
}
Mod nx[1 << 7];
Mod x[1 << 7];
int a;
int main() {
  for (int i = (0); i < (int)(1 << 7); i++) nx[i] = x[i] = 0;
  nx[0] = 1;
  bool st = false;
  for (int i = (0); i < (int)(7); i++) {
    cin >> a;
    for (int j = (1 << i) - 1; j >= 0; j--) x[j + (1 << i)] = nx[j];
    vector<vector<Mod> > A(1 << (i + 1), vector<Mod>(1 << (i + 1), 0));
    for (int j = (0); j < (int)(1 << (i + 1)); j++)
      for (int k = (0); k < (int)(1 << (i + 1)); k++) {
        for (int l = (0); l < (int)(1 << i); l++) {
          bool ok = true;
          int o = 1 + l * 2 + (1 << (i + 1));
          for (int m = (0); m < (int)(i + 1); m++)
            if ((j & (1 << m)) && (k & (1 << m)) && (o & (1 << m)) &&
                (o & (1 << (m + 1))))
              ok = false;
          if (ok) A[j][k] += 1;
        }
      }
    A = pow(A, a);
    for (int j = (0); j < (int)((1 << (i + 1))); j++) nx[j] = 0;
    for (int j = (0); j < (int)((1 << (i + 1))); j++)
      for (int k = ((1 << i)); k < (int)((1 << (i + 1))); k++)
        nx[j] += A[j][k] * x[k];
  }
  cout << nx[(1 << 7) - 1].n << endl;
  return 0;
}