#include <bits/stdc++.h>
using namespace std;
void factorarr(int l, int primes[]) {
  iota(primes, primes + l, 0);
  for (long long i = 2; i * i < l + 5; i++) {
    if (primes[i] == i) {
      for (long long j = i * i; j <= l; j += i) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
        primes[j] = i;
#pragma clang diagnostic pop
      }
    }
  }
}
vector<int> primevec(int l) {
  int flist[l];
  vector<int> plist = {};
  factorarr(l, flist);
  for (int(i) = (2); (i) < (l); (i)++) {
    if (flist[i] == i) {
      plist.push_back(i);
    }
  }
  return plist;
}
long long modpow(long long base, long long exp, int mod) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2) res = (res * base) % mod;
    exp >>= 1;
    base = (base * base) % mod;
  }
  return res;
}
long long modinverse(long long a, long long m) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m;
    a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
class llpmat {
 public:
  unsigned m_colsize;
  unsigned m_rowsize;
  unsigned m_modulo;
  vector<vector<long long> > m_matrix;
  llpmat(unsigned, unsigned, unsigned, long long);
  llpmat(const llpmat &);
  llpmat(unsigned, unsigned, unsigned, string);
  llpmat(vector<vector<long long> >, unsigned);
  llpmat operator+(long long);
  llpmat operator-(long long);
  llpmat operator*(long long);
  llpmat operator/(long long);
  llpmat operator+(llpmat &);
  llpmat operator-(llpmat &);
  llpmat operator*(llpmat &);
  llpmat transpose();
  long long &operator()(const unsigned &, const unsigned &);
  unsigned collen() const;
  unsigned rowlen() const;
  unsigned modp() const;
  void print() const;
};
llpmat::llpmat(unsigned m, unsigned n, unsigned p, long long entry) {
  m_colsize = m;
  m_rowsize = n;
  m_modulo = p;
  m_matrix.resize(m);
  for (int i = 0; i < m; i++) {
    m_matrix[i].resize(n, entry % p);
  }
}
llpmat::llpmat(unsigned m, unsigned n, unsigned p, string mat_type) {
  m_colsize = m;
  m_rowsize = n;
  m_modulo = p;
  m_matrix.resize(m);
  if (mat_type == "identity") {
    for (int i = 0; i < m; i++) {
      m_matrix[i].resize(n, 0);
    }
    for (int i = 0; i < min(m, n); i++) {
      m_matrix[i][i] = 1;
    }
  } else {
    cout << "Not a valid type.\n";
  }
}
llpmat::llpmat(const llpmat &M) {
  this->m_colsize = M.collen();
  this->m_rowsize = M.rowlen();
  this->m_modulo = M.modp();
  this->m_matrix = M.m_matrix;
}
llpmat::llpmat(vector<vector<long long> > v, unsigned p) {
  m_matrix = v;
  m_modulo = p;
  m_colsize = v.size();
  m_rowsize = v[0].size();
}
llpmat llpmat::operator+(long long scalar) {
  llpmat result(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      result(i, j) = (this->m_matrix[i][j] + scalar) % m_modulo;
    }
  }
  return result;
}
llpmat llpmat::operator-(long long scalar) {
  llpmat result(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      result(i, j) = (this->m_matrix[i][j] - scalar) % m_modulo;
    }
  }
  return result;
}
llpmat llpmat::operator*(long long scalar) {
  llpmat result(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      result(i, j) = (this->m_matrix[i][j] * scalar) % m_modulo;
    }
  }
  return result;
}
llpmat llpmat::operator/(long long scalar) {
  llpmat result(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      result(i, j) =
          (this->m_matrix[i][j] * modinverse(scalar, m_modulo)) % m_modulo;
    }
  }
  return result;
}
llpmat operator+(long long scalar, llpmat &M) { return (M + scalar); }
llpmat operator-(long long scalar, llpmat &M) { return (M - scalar); }
llpmat operator*(long long scalar, llpmat &M) { return (M * scalar); }
llpmat operator/(long long scalar, llpmat &M) { return (M / scalar); }
llpmat llpmat::operator+(llpmat &M) {
  llpmat sum(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      sum(i, j) = (this->m_matrix[i][j] + M(i, j)) % m_modulo;
    }
  }
  return sum;
}
llpmat llpmat::operator-(llpmat &M) {
  llpmat diff(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      diff(i, j) = (this->m_matrix[i][j] - M(i, j)) % m_modulo;
    }
  }
  return diff;
}
llpmat llpmat::operator*(llpmat &M) {
  llpmat prod(m_colsize, M.rowlen(), m_modulo, 0);
  if (M.collen() == m_rowsize) {
    int i, j, k;
    long long temp = 0;
    for (i = 0; i < m_colsize; i++) {
      for (j = 0; j < M.rowlen(); j++) {
        temp = 0;
        for (k = 0; k < m_rowsize; k++) {
          temp = (temp + m_matrix[i][k] * M(k, j)) % m_modulo;
        }
        prod(i, j) = temp;
      }
    }
    return prod;
  } else {
    throw invalid_argument("matrix sizes not compatible");
  }
}
long long &llpmat::operator()(const unsigned &rowNo, const unsigned &colNo) {
  return this->m_matrix[rowNo][colNo];
}
unsigned llpmat::rowlen() const { return this->m_rowsize; }
unsigned llpmat::collen() const { return this->m_colsize; }
unsigned llpmat::modp() const { return this->m_modulo; }
llpmat llpmat::transpose() {
  llpmat Transpose(m_rowsize, m_colsize, m_modulo, 0);
  for (unsigned i = 0; i < m_rowsize; i++) {
    for (unsigned j = 0; j < m_colsize; j++) {
      Transpose(i, j) = this->m_matrix[j][i];
    }
  }
  return Transpose;
}
void llpmat::print() const {
  cout << "Matrix:\n";
  for (unsigned i = 0; i < m_colsize; i++) {
    for (unsigned j = 0; j < m_rowsize; j++) {
      cout << "[" << m_matrix[i][j] << "] ";
    }
    cout << '\n';
  }
}
llpmat llppow(llpmat base, long long exp) {
  llpmat res = llpmat(base.collen(), base.rowlen(), base.m_modulo, "identity");
  while (exp > 0) {
    if (exp % 2) res = res * base;
    exp >>= 1;
    base = base * base;
  }
  return res;
}
int main(int argc, const char *argv[]) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int p = pow(10, 9) + 7;
  vector<int> w;
  for (int(i) = (0); (i) < (7); (i)++) {
    int temp;
    cin >> temp;
    w.push_back(temp);
  }
  llpmat A({{1}}, p);
  int num = 7;
  for (int(i) = (0); (i) < (num); (i)++) {
    llpmat B(1 << (i + 1), 1, p, 0);
    for (int(j) = (0); (j) < (1 << i); (j)++) {
      B((1 << i) + j, 0) = A(j, 0);
    }
    llpmat M(1 << (i + 1), 1 << (i + 1), p, 0);
    if (i == 0) {
      M.m_matrix = {{1, 1}, {1, 0}};
    } else {
      for (int(x) = (0); (x) < (1 << (i + 1)); (x)++) {
        for (int(y) = (0); (y) < (1 << (i + 1)); (y)++) {
          int ent = 0;
          for (int(z) = (0); (z) < (1 << i); (z)++) {
            int t = 1 << (i + 1) | (z << 1) | 1;
            t = t & (t >> 1);
            if ((t & x & y) == 0) {
              ent++;
            }
          }
          M(x, y) = ent;
        }
      }
    }
    M = llppow(M, w[i]);
    A = M * B;
  }
  cout << A((1 << num) - 1, 0);
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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>
using namespace std;
void factorarr(int l, int primes[]) {
  iota(primes, primes + l, 0);
  for (long long i = 2; i * i < l + 5; i++) {
    if (primes[i] == i) {
      for (long long j = i * i; j <= l; j += i) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
        primes[j] = i;
#pragma clang diagnostic pop
      }
    }
  }
}
vector<int> primevec(int l) {
  int flist[l];
  vector<int> plist = {};
  factorarr(l, flist);
  for (int(i) = (2); (i) < (l); (i)++) {
    if (flist[i] == i) {
      plist.push_back(i);
    }
  }
  return plist;
}
long long modpow(long long base, long long exp, int mod) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2) res = (res * base) % mod;
    exp >>= 1;
    base = (base * base) % mod;
  }
  return res;
}
long long modinverse(long long a, long long m) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m;
    a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
class llpmat {
 public:
  unsigned m_colsize;
  unsigned m_rowsize;
  unsigned m_modulo;
  vector<vector<long long> > m_matrix;
  llpmat(unsigned, unsigned, unsigned, long long);
  llpmat(const llpmat &);
  llpmat(unsigned, unsigned, unsigned, string);
  llpmat(vector<vector<long long> >, unsigned);
  llpmat operator+(long long);
  llpmat operator-(long long);
  llpmat operator*(long long);
  llpmat operator/(long long);
  llpmat operator+(llpmat &);
  llpmat operator-(llpmat &);
  llpmat operator*(llpmat &);
  llpmat transpose();
  long long &operator()(const unsigned &, const unsigned &);
  unsigned collen() const;
  unsigned rowlen() const;
  unsigned modp() const;
  void print() const;
};
llpmat::llpmat(unsigned m, unsigned n, unsigned p, long long entry) {
  m_colsize = m;
  m_rowsize = n;
  m_modulo = p;
  m_matrix.resize(m);
  for (int i = 0; i < m; i++) {
    m_matrix[i].resize(n, entry % p);
  }
}
llpmat::llpmat(unsigned m, unsigned n, unsigned p, string mat_type) {
  m_colsize = m;
  m_rowsize = n;
  m_modulo = p;
  m_matrix.resize(m);
  if (mat_type == "identity") {
    for (int i = 0; i < m; i++) {
      m_matrix[i].resize(n, 0);
    }
    for (int i = 0; i < min(m, n); i++) {
      m_matrix[i][i] = 1;
    }
  } else {
    cout << "Not a valid type.\n";
  }
}
llpmat::llpmat(const llpmat &M) {
  this->m_colsize = M.collen();
  this->m_rowsize = M.rowlen();
  this->m_modulo = M.modp();
  this->m_matrix = M.m_matrix;
}
llpmat::llpmat(vector<vector<long long> > v, unsigned p) {
  m_matrix = v;
  m_modulo = p;
  m_colsize = v.size();
  m_rowsize = v[0].size();
}
llpmat llpmat::operator+(long long scalar) {
  llpmat result(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      result(i, j) = (this->m_matrix[i][j] + scalar) % m_modulo;
    }
  }
  return result;
}
llpmat llpmat::operator-(long long scalar) {
  llpmat result(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      result(i, j) = (this->m_matrix[i][j] - scalar) % m_modulo;
    }
  }
  return result;
}
llpmat llpmat::operator*(long long scalar) {
  llpmat result(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      result(i, j) = (this->m_matrix[i][j] * scalar) % m_modulo;
    }
  }
  return result;
}
llpmat llpmat::operator/(long long scalar) {
  llpmat result(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      result(i, j) =
          (this->m_matrix[i][j] * modinverse(scalar, m_modulo)) % m_modulo;
    }
  }
  return result;
}
llpmat operator+(long long scalar, llpmat &M) { return (M + scalar); }
llpmat operator-(long long scalar, llpmat &M) { return (M - scalar); }
llpmat operator*(long long scalar, llpmat &M) { return (M * scalar); }
llpmat operator/(long long scalar, llpmat &M) { return (M / scalar); }
llpmat llpmat::operator+(llpmat &M) {
  llpmat sum(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      sum(i, j) = (this->m_matrix[i][j] + M(i, j)) % m_modulo;
    }
  }
  return sum;
}
llpmat llpmat::operator-(llpmat &M) {
  llpmat diff(m_colsize, m_rowsize, m_modulo, 0);
  int i, j;
  for (i = 0; i < m_colsize; i++) {
    for (j = 0; j < m_rowsize; j++) {
      diff(i, j) = (this->m_matrix[i][j] - M(i, j)) % m_modulo;
    }
  }
  return diff;
}
llpmat llpmat::operator*(llpmat &M) {
  llpmat prod(m_colsize, M.rowlen(), m_modulo, 0);
  if (M.collen() == m_rowsize) {
    int i, j, k;
    long long temp = 0;
    for (i = 0; i < m_colsize; i++) {
      for (j = 0; j < M.rowlen(); j++) {
        temp = 0;
        for (k = 0; k < m_rowsize; k++) {
          temp = (temp + m_matrix[i][k] * M(k, j)) % m_modulo;
        }
        prod(i, j) = temp;
      }
    }
    return prod;
  } else {
    throw invalid_argument("matrix sizes not compatible");
  }
}
long long &llpmat::operator()(const unsigned &rowNo, const unsigned &colNo) {
  return this->m_matrix[rowNo][colNo];
}
unsigned llpmat::rowlen() const { return this->m_rowsize; }
unsigned llpmat::collen() const { return this->m_colsize; }
unsigned llpmat::modp() const { return this->m_modulo; }
llpmat llpmat::transpose() {
  llpmat Transpose(m_rowsize, m_colsize, m_modulo, 0);
  for (unsigned i = 0; i < m_rowsize; i++) {
    for (unsigned j = 0; j < m_colsize; j++) {
      Transpose(i, j) = this->m_matrix[j][i];
    }
  }
  return Transpose;
}
void llpmat::print() const {
  cout << "Matrix:\n";
  for (unsigned i = 0; i < m_colsize; i++) {
    for (unsigned j = 0; j < m_rowsize; j++) {
      cout << "[" << m_matrix[i][j] << "] ";
    }
    cout << '\n';
  }
}
llpmat llppow(llpmat base, long long exp) {
  llpmat res = llpmat(base.collen(), base.rowlen(), base.m_modulo, "identity");
  while (exp > 0) {
    if (exp % 2) res = res * base;
    exp >>= 1;
    base = base * base;
  }
  return res;
}
int main(int argc, const char *argv[]) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int p = pow(10, 9) + 7;
  vector<int> w;
  for (int(i) = (0); (i) < (7); (i)++) {
    int temp;
    cin >> temp;
    w.push_back(temp);
  }
  llpmat A({{1}}, p);
  int num = 7;
  for (int(i) = (0); (i) < (num); (i)++) {
    llpmat B(1 << (i + 1), 1, p, 0);
    for (int(j) = (0); (j) < (1 << i); (j)++) {
      B((1 << i) + j, 0) = A(j, 0);
    }
    llpmat M(1 << (i + 1), 1 << (i + 1), p, 0);
    if (i == 0) {
      M.m_matrix = {{1, 1}, {1, 0}};
    } else {
      for (int(x) = (0); (x) < (1 << (i + 1)); (x)++) {
        for (int(y) = (0); (y) < (1 << (i + 1)); (y)++) {
          int ent = 0;
          for (int(z) = (0); (z) < (1 << i); (z)++) {
            int t = 1 << (i + 1) | (z << 1) | 1;
            t = t & (t >> 1);
            if ((t & x & y) == 0) {
              ent++;
            }
          }
          M(x, y) = ent;
        }
      }
    }
    M = llppow(M, w[i]);
    A = M * B;
  }
  cout << A((1 << num) - 1, 0);
}

```