#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> exm;
vector<vector<long long>> mult(vector<vector<long long>> a,
                               vector<vector<long long>> b) {
  vector<vector<long long>> x = a;
  int m1, m2, m3;
  for (m1 = 0; m1 < x.size(); m1++)
    for (m2 = 0; m2 < x.size(); m2++) x[m1][m2] = 0;
  for (m1 = 0; m1 < x.size(); m1++)
    for (m2 = 0; m2 < x.size(); m2++)
      for (m3 = 0; m3 < x.size(); m3++) {
        x[m1][m2] += (a[m1][m3] * b[m3][m2]) % 1000000007ll;
        x[m1][m2] %= 1000000007ll;
      }
  return x;
}
vector<vector<long long>> binpow(vector<vector<long long>> a, int n) {
  vector<vector<long long>> res = a;
  n--;
  while (n > 0)
    if (n & 1) {
      res = mult(res, a);
      --n;
    } else {
      a = mult(a, a);
      n /= 2;
    }
  return res;
}
int n = 7;
long long a[10], best, dp[10][(1 << 8) + 5];
vector<vector<long long>> nxt, now;
vector<pair<long long, int>> v;
long long comb(int m1, int m2, int n) {
  vector<long long> c(2);
  c[1] = 1;
  for (int i = 1; i <= n; i++) {
    int bit = 1 << (i - 1);
    if ((bit & m1) && (bit & m2)) {
      c[0] = c[1] + c[0];
      c[1] = c[0] - c[1];
    } else {
      c[0] = c[0] + c[1];
      c[1] = c[0];
    }
  }
  return c[1] % 1000000007ll;
}
int main() {
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] && v.empty()) v.push_back(make_pair(0, i));
    if (a[i]) v.push_back(make_pair(a[i], i));
  }
  exm.resize((1 << 7));
  for (int m1 = 0; m1 < (1 << 7); m1++) exm[m1].resize((1 << 7));
  dp[0][(1 << (v[0].second)) - 1] = 1;
  for (int i = 1; i < v.size(); i++) {
    nxt.resize(1 << v[i].second);
    for (int m1 = 0; m1 < (1 << v[i].second); m1++) {
      nxt[m1].resize(1 << v[i].second);
      for (int m2 = 0; m2 < (1 << v[i].second); m2++)
        nxt[m1][m2] = comb(m1, m2, v[i].second);
    }
    vector<vector<long long>> upd = binpow(nxt, v[i].first);
    vector<long long> res((1 << 7) + 2);
    for (int j = 0; j < (1 << v[i - 1].second); j++) {
      int m1 =
          (((1 << (v[i].second - v[i - 1].second)) - 1) << v[i - 1].second) + j;
      res[m1] += dp[i - 1][j] % 1000000007ll;
      res[m1] %= 1000000007ll;
    }
    for (int m1 = 0; m1 < (1 << v[i].second); m1++)
      for (int m2 = 0; m2 < (1 << v[i].second); m2++) {
        dp[i][m2] += (res[m1] * upd[m1][m2]) % 1000000007ll;
        dp[i][m2] %= 1000000007ll;
      }
  }
  cout << dp[v.size() - 1][(1 << v.back().second) - 1] << endl;
  return 0;
}
