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;
template <typename T, typename U>
inline void amin(T& x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T& x, U y) {
  if (x < y) x = y;
}
template <int MOD>
struct ModInt {
  static const int Mod = MOD;
  unsigned x;
  ModInt() : x(0) {}
  ModInt(signed sig) {
    int sigt = sig % MOD;
    if (sigt < 0) sigt += MOD;
    x = sigt;
  }
  ModInt(signed long long sig) {
    int sigt = sig % MOD;
    if (sigt < 0) sigt += MOD;
    x = sigt;
  }
  int get() const { return (int)x; }
  ModInt& operator+=(ModInt that) {
    if ((x += that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt& operator-=(ModInt that) {
    if ((x += MOD - that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt& operator*=(ModInt that) {
    x = (unsigned long long)x * that.x % MOD;
    return *this;
  }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
struct Matrix {
  static const int MaxN = 1 << 7;
  int hei, wid;
  ModInt<1000000007> v[MaxN][MaxN];
  Matrix() {}
  Matrix(int n, int m) : hei(n), wid(m) { memset(v, 0, sizeof(v)); }
  inline int height() const { return hei; }
  inline int width() const { return wid; }
  inline ModInt<1000000007>& at(int i, int j) { return v[i][j]; }
  inline const ModInt<1000000007>& at(int i, int j) const { return v[i][j]; }
  static Matrix identity(int n) {
    Matrix A(n, n);
    for (int(i) = 0; (i) < (int)(n); ++(i)) A.at(i, i) = 1;
    return A;
  }
  inline static Matrix identity(const Matrix& A) {
    return identity(A.height());
  }
  Matrix& operator*=(const Matrix& B) {
    int n = height(), m = B.width(), p = B.height();
    assert(p == width());
    const unsigned(*b)[MaxN] = reinterpret_cast<const unsigned(*)[MaxN]>(B.v);
    ModInt<1000000007> w[MaxN][MaxN];
    unsigned long long pp = (1ULL << 32) % ModInt<1000000007>::Mod;
    for (int(i) = 0; (i) < (int)(n); ++(i)) {
      const unsigned* ai = reinterpret_cast<const unsigned*>(v[i]);
      for (int(j) = 0; (j) < (int)(m); ++(j)) {
        unsigned x0 = 0;
        unsigned long long x1 = 0;
        for (int(k) = 0; (k) < (int)(p); ++(k)) {
          unsigned long long y = (unsigned long long)ai[k] * b[k][j];
          unsigned long long t = x0 + y;
          x1 += t >> 32;
          x0 = t & 0xffffffff;
        }
        w[i][j].x =
            (x0 + x1 % ModInt<1000000007>::Mod * pp) % ModInt<1000000007>::Mod;
      }
    }
    memcpy(v, w, sizeof(v));
    return *this;
  }
};
Matrix operator^(const Matrix& t, long long k) {
  Matrix A = t, B = Matrix::identity(t);
  while (k) {
    if (k & 1) B *= A;
    A *= A;
    k >>= 1;
  }
  return B;
}
int main() {
  int K = 7;
  vector<int> w(K);
  for (int(i) = 0; (i) < (int)(K); ++(i)) scanf("%d", &w[i]);
  Matrix b(1, 1 << K);
  b.at(0, 1) = 1;
  for (int(h) = (int)(1); (h) <= (int)(K); ++(h)) {
    Matrix A(1 << K, 1 << K);
    for (int(j) = 0; (j) < (int)(1 << K); ++(j)) {
      for (int(k) = 0; (k) < (int)(1 << K); ++(k)) {
        for (int(l) = 0; (l) < (int)(1 << (h - 1)); ++(l)) {
          int l2 = 1 | l << 1 | 1 << h;
          bool ok = true;
          for (int(y) = 0; (y) < (int)(K); ++(y)) {
            ok &= !((j >> y & 1) && (k >> y & 1) && (l2 >> y & 3) == 3);
            ok &= !(y >= h && (k >> y & 1));
          }
          if (ok) A.at(j, k) += 1;
        }
      }
    }
    b *= A ^ w[h - 1];
    if (h < K) {
      Matrix B(1 << K, 1 << K);
      for (int(j) = 0; (j) < (int)(1 << K); ++(j)) B.at(j, j | 1 << h) = 1;
      b *= B;
    }
  }
  ModInt<1000000007> ans = b.at(0, (1 << K) - 1);
  printf("%d\n", ans.get());
  return 0;
}