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