#include <bits/stdc++.h>
#pragma gcc optimze("Ofast", "unroll-loops")
using namespace std;
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}
pair<int, int>& operator+=(pair<int, int>& a, pair<int, int> b) {
  return a.first += b.first, a.second += b.second, a;
}
template <typename Iter>
ostream& outIt(ostream& out, Iter b, Iter e) {
  for (Iter i = b; i != e; i++) out << *i << " ";
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> v) {
  return outIt(out << '[', (v).begin(), (v).end()) << ']';
}
template <typename T, size_t N>
ostream& operator<<(ostream& out, array<T, N> v) {
  return outIt(out << '[', (v).begin(), (v).end()) << ']';
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ", " << p.second << ')';
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  return in >> p.first >> p.second;
}
array<array<array<int, 1 << 8>, 1 << 8>, 8> mt;
const int mod = 1000000007;
template <size_t N>
using matrix = array<array<int, N>, N>;
template <size_t _N>
void timesref(matrix<_N>& ans, const matrix<_N>& b, int N) {
  matrix<_N> a = {};
  swap(a, ans);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        ans[i][k] = (ans[i][k] + (int64_t)a[i][j] * b[j][k]) % mod;
}
template <size_t _N>
void times(matrix<_N>& ans, const matrix<_N> b, int N) {
  matrix<_N> a = {};
  swap(a, ans);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        ans[i][k] = (ans[i][k] + (int64_t)a[i][j] * b[j][k]) % mod;
}
void fpow(matrix<256>& a, int b, matrix<256>& ans, int N) {
  do
    if (b & 1) timesref(ans, a, N);
  while (times(a, a, N), b >>= 1);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int t = 1; t <= 7; t++)
    for (int i = 0; i < (1 << t); i++)
      for (int j = 0; j < (1 << t); j++)
        for (int k = 0; k < (1 << t); k += 2) {
          for (int x = 0; x < t; x++)
            if (k & 1 << x | k & 1 << x + 1 | i & 1 << x | j & 1 << x)
              ;
            else
              goto no;
          mt[t][i][j]++;
        no:;
        }
  matrix<256> ans;
  for (int i = 0; i < 256; i++)
    for (int j = 0; j < 256; j++) ans[i][j] = i == j;
  for (int i = 1, a; i <= 7; i++) cin >> a, fpow(mt[i], a, ans, 1 << i);
  cout << ans[0][0] << endl;
}

### Prompt

Please formulate a cpp solution to the following 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>

### Response

```cpp
#include <bits/stdc++.h>
#pragma gcc optimze("Ofast", "unroll-loops")
using namespace std;
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}
pair<int, int>& operator+=(pair<int, int>& a, pair<int, int> b) {
  return a.first += b.first, a.second += b.second, a;
}
template <typename Iter>
ostream& outIt(ostream& out, Iter b, Iter e) {
  for (Iter i = b; i != e; i++) out << *i << " ";
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> v) {
  return outIt(out << '[', (v).begin(), (v).end()) << ']';
}
template <typename T, size_t N>
ostream& operator<<(ostream& out, array<T, N> v) {
  return outIt(out << '[', (v).begin(), (v).end()) << ']';
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ", " << p.second << ')';
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  return in >> p.first >> p.second;
}
array<array<array<int, 1 << 8>, 1 << 8>, 8> mt;
const int mod = 1000000007;
template <size_t N>
using matrix = array<array<int, N>, N>;
template <size_t _N>
void timesref(matrix<_N>& ans, const matrix<_N>& b, int N) {
  matrix<_N> a = {};
  swap(a, ans);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        ans[i][k] = (ans[i][k] + (int64_t)a[i][j] * b[j][k]) % mod;
}
template <size_t _N>
void times(matrix<_N>& ans, const matrix<_N> b, int N) {
  matrix<_N> a = {};
  swap(a, ans);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        ans[i][k] = (ans[i][k] + (int64_t)a[i][j] * b[j][k]) % mod;
}
void fpow(matrix<256>& a, int b, matrix<256>& ans, int N) {
  do
    if (b & 1) timesref(ans, a, N);
  while (times(a, a, N), b >>= 1);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int t = 1; t <= 7; t++)
    for (int i = 0; i < (1 << t); i++)
      for (int j = 0; j < (1 << t); j++)
        for (int k = 0; k < (1 << t); k += 2) {
          for (int x = 0; x < t; x++)
            if (k & 1 << x | k & 1 << x + 1 | i & 1 << x | j & 1 << x)
              ;
            else
              goto no;
          mt[t][i][j]++;
        no:;
        }
  matrix<256> ans;
  for (int i = 0; i < 256; i++)
    for (int j = 0; j < 256; j++) ans[i][j] = i == j;
  for (int i = 1, a; i <= 7; i++) cin >> a, fpow(mt[i], a, ans, 1 << i);
  cout << ans[0][0] << endl;
}

```