#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;
}
