#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
template <typename T>
inline T Abs(T x) {
  return (x >= 0) ? x : -x;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline string toStr(T x) {
  stringstream st;
  st << x;
  string s;
  st >> s;
  return s;
}
template <typename T>
inline int bit(T mask, int b) {
  return (b >= 0 && (mask & (T(1) << b)) != 0) ? 1 : 0;
}
inline int nextInt() {
  int x;
  if (scanf("%d", &x) != 1) throw;
  return x;
}
inline long long nextInt64() {
  long long x;
  if (scanf("%lld", &x) != 1) throw;
  return x;
}
inline double nextDouble() {
  double x;
  if (scanf("%lf", &x) != 1) throw;
  return x;
}
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const long long MOD = INF + 7;
const int MAXN = 8;
long long d[MAXN][1 << MAXN], D[MAXN][1 << MAXN][1 << MAXN];
vector<pair<int, int> > a;
bool used[MAXN];
void mul(int n, long long a[1 << MAXN][1 << MAXN],
         long long b[1 << MAXN][1 << MAXN]) {
  static long long res[1 << MAXN][1 << MAXN];
  memset(res, 0, sizeof res);
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      for (int k = 0; k < (int)(n); k++) {
        res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % MOD;
      }
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      a[i][j] = res[i][j];
    }
  }
}
void binPow(long long a[1 << MAXN][1 << MAXN], int n, long long b) {
  static long long res[1 << MAXN][1 << MAXN];
  memset(res, 0, sizeof res);
  for (int i = 0; i < (int)(n); i++) {
    res[i][i] = 1;
  }
  while (b > 0) {
    if (b % 2 == 0) {
      mul(n, a, a);
      b /= 2;
    } else {
      mul(n, res, a);
      b--;
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      a[i][j] = res[i][j];
    }
  }
}
void calcMoves(int n, long long a[1 << MAXN][1 << MAXN], bool first) {
  for (int deprLeft = 0; deprLeft < (int)(1 << n); deprLeft++) {
    for (int realLeft = 0; realLeft < (int)(1 << n); realLeft++) {
      if ((deprLeft & realLeft) != 0) {
        continue;
      }
      if (first && realLeft + 1 != 1 << n) {
        continue;
      }
      for (int mid = 0; mid < (int)(1 << (n - 1)); mid++) {
        int realMid = 1 + (mid << 1) + (1 << n);
        int deprRight = 0;
        for (int i = 0; i < (int)(n); i++) {
          if (bit(realMid, i) && bit(realMid, i + 1) && bit(realLeft, i)) {
            deprRight += 1 << i;
          }
        }
        a[deprLeft][deprRight]++;
      }
    }
  }
}
long long move(int h, int w, int start, int finish, int pos) {
  if (!used[pos]) {
    used[pos] = true;
    static long long a[1 << MAXN][1 << MAXN];
    memset(a, 0, sizeof a);
    calcMoves(h, a, pos == 0);
    binPow(a, 1 << h, w);
    for (int i = 0; i < (int)(1 << h); i++) {
      for (int j = 0; j < (int)(1 << h); j++) {
        D[pos][i][j] = a[i][j];
      }
    }
  }
  return D[pos][start][finish];
}
long long get(int v, int mask) {
  if (v == int(a.size())) return (mask == 0) ? 1 : 0;
  if (mask >= (1 << a[v].first)) return 0;
  long long &ans = d[v][mask];
  if (ans != -1) return ans;
  ans = 0;
  int h = a[v].first, w = a[v].second;
  for (int nmask = 0; nmask < (int)(1 << h); nmask++) {
    ans = (ans + move(h, w, mask, nmask, v) * get(v + 1, nmask)) % MOD;
  }
  return ans;
}
int main() {
  cout.setf(ios::fixed);
  cout.precision(10);
  double _startTime = clock();
  for (int i = 0; i < (int)(7); i++) {
    int w = nextInt();
    if (w != 0) {
      a.push_back(make_pair(i + 1, w));
    }
  }
  reverse((a).begin(), (a).end());
  if (a[0].second > 1) {
    a.insert(a.begin(), make_pair(a[0].first, 1));
    a[1].second--;
  }
  memset(d, 255, sizeof d);
  cout << get(0, 0) << endl;
  cerr << "Elapsed " << (clock() - _startTime) / 1000 << " ms" << endl;
  return 0;
}

### Prompt

Your challenge is to write 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 comment(linker, "/STACK:200000000")
using namespace std;
template <typename T>
inline T Abs(T x) {
  return (x >= 0) ? x : -x;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline string toStr(T x) {
  stringstream st;
  st << x;
  string s;
  st >> s;
  return s;
}
template <typename T>
inline int bit(T mask, int b) {
  return (b >= 0 && (mask & (T(1) << b)) != 0) ? 1 : 0;
}
inline int nextInt() {
  int x;
  if (scanf("%d", &x) != 1) throw;
  return x;
}
inline long long nextInt64() {
  long long x;
  if (scanf("%lld", &x) != 1) throw;
  return x;
}
inline double nextDouble() {
  double x;
  if (scanf("%lf", &x) != 1) throw;
  return x;
}
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const long long MOD = INF + 7;
const int MAXN = 8;
long long d[MAXN][1 << MAXN], D[MAXN][1 << MAXN][1 << MAXN];
vector<pair<int, int> > a;
bool used[MAXN];
void mul(int n, long long a[1 << MAXN][1 << MAXN],
         long long b[1 << MAXN][1 << MAXN]) {
  static long long res[1 << MAXN][1 << MAXN];
  memset(res, 0, sizeof res);
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      for (int k = 0; k < (int)(n); k++) {
        res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % MOD;
      }
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      a[i][j] = res[i][j];
    }
  }
}
void binPow(long long a[1 << MAXN][1 << MAXN], int n, long long b) {
  static long long res[1 << MAXN][1 << MAXN];
  memset(res, 0, sizeof res);
  for (int i = 0; i < (int)(n); i++) {
    res[i][i] = 1;
  }
  while (b > 0) {
    if (b % 2 == 0) {
      mul(n, a, a);
      b /= 2;
    } else {
      mul(n, res, a);
      b--;
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      a[i][j] = res[i][j];
    }
  }
}
void calcMoves(int n, long long a[1 << MAXN][1 << MAXN], bool first) {
  for (int deprLeft = 0; deprLeft < (int)(1 << n); deprLeft++) {
    for (int realLeft = 0; realLeft < (int)(1 << n); realLeft++) {
      if ((deprLeft & realLeft) != 0) {
        continue;
      }
      if (first && realLeft + 1 != 1 << n) {
        continue;
      }
      for (int mid = 0; mid < (int)(1 << (n - 1)); mid++) {
        int realMid = 1 + (mid << 1) + (1 << n);
        int deprRight = 0;
        for (int i = 0; i < (int)(n); i++) {
          if (bit(realMid, i) && bit(realMid, i + 1) && bit(realLeft, i)) {
            deprRight += 1 << i;
          }
        }
        a[deprLeft][deprRight]++;
      }
    }
  }
}
long long move(int h, int w, int start, int finish, int pos) {
  if (!used[pos]) {
    used[pos] = true;
    static long long a[1 << MAXN][1 << MAXN];
    memset(a, 0, sizeof a);
    calcMoves(h, a, pos == 0);
    binPow(a, 1 << h, w);
    for (int i = 0; i < (int)(1 << h); i++) {
      for (int j = 0; j < (int)(1 << h); j++) {
        D[pos][i][j] = a[i][j];
      }
    }
  }
  return D[pos][start][finish];
}
long long get(int v, int mask) {
  if (v == int(a.size())) return (mask == 0) ? 1 : 0;
  if (mask >= (1 << a[v].first)) return 0;
  long long &ans = d[v][mask];
  if (ans != -1) return ans;
  ans = 0;
  int h = a[v].first, w = a[v].second;
  for (int nmask = 0; nmask < (int)(1 << h); nmask++) {
    ans = (ans + move(h, w, mask, nmask, v) * get(v + 1, nmask)) % MOD;
  }
  return ans;
}
int main() {
  cout.setf(ios::fixed);
  cout.precision(10);
  double _startTime = clock();
  for (int i = 0; i < (int)(7); i++) {
    int w = nextInt();
    if (w != 0) {
      a.push_back(make_pair(i + 1, w));
    }
  }
  reverse((a).begin(), (a).end());
  if (a[0].second > 1) {
    a.insert(a.begin(), make_pair(a[0].first, 1));
    a[1].second--;
  }
  memset(d, 255, sizeof d);
  cout << get(0, 0) << endl;
  cerr << "Elapsed " << (clock() - _startTime) / 1000 << " ms" << endl;
  return 0;
}

```