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>

Solution (in JAVA):

Solution:
import java.util.*;

public class E {

    final int N = 100_000;
    final int W = 7;
    final int MOD = 1_000_000_007;

    int[][] mem;
    long[][][] memG;
    int[] w;
    int ans;

    void read() {
        Scanner scanner = new Scanner(System.in);

        w = new int[W];

        for (int i = 0; i < w.length; i++) {
            w[i] = scanner.nextInt();
        }

        scanner.close();
    }

    boolean good(int a, int b, int c) {
        return (a & b & c & (c >> 1)) == 0;
    }

    long[][] mul(long [][] a, long[][] b) {
        long[][] t = new long[a.length][a.length];

        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a.length; j++) {
                for (int k = 0; k < a.length; k++) {
                    t[i][j] = (t[i][j] + a[i][k] * b[k][j]) % MOD;
                }
            }
        }

        return t;
    }

    long[][] pow(long[][] base, int p) {
        long[][] ans = new long[base.length][base.length];
        for (int i = 0; i < ans.length; i++) {
            ans[i][i] = 1;
        }
        for (; p > 0; p >>= 1) {
            if ((p & 1) > 0) {
                ans = mul(ans, base);
            }
            base = mul(base, base);
        }
        return ans;
    }

    long f(int mask, int pos) {
        if (mem[pos][mask] == 0) {
            int realMask = 1 << pos | mask;
            long res = 0;
            int lastMask = 1 << (pos + 1);

            if (pos == w.length - 1) {
                res = memG[pos][realMask][lastMask - 1];
            } else {
                for (int i = 0; i < lastMask; i++) {
                    res = (res + memG[pos][realMask][i] * f(i, pos + 1)) % MOD;
                }
            }

            mem[pos][mask] = (int) res + 1;
        }
        return mem[pos][mask] - 1;
    }

    void solve() {
        mem = new int[W][1 << W];
        memG = new long[W][][];

        for (int w = 0; w < W; w++) {
            int m = 1 << w + 1;
            long[][] t = new long[m][m];

            for (int i = 0; i < m; i++) {
                for (int j = 0; j < m; j++) {
                    int res = 0;
                    int n = 1 << w;
                    for (int k = 0; k < n; k++) {
                        if (good(i, j, ((n | k) << 1) | 1)) {
                            res++;
                        }
                    }
                    t[i][j] = res;
                }
            }

            memG[w] = pow(t, this.w[w]);
        }

        ans = (int) f(0, 0);
    }

    void write() {
        System.out.println(ans);
    }

    public static void main(String[] args) {
        //long time = System.currentTimeMillis();
        E e = new E();
        e.read();
        e.solve();
        e.write();
        //System.out.println(System.currentTimeMillis() - time);
    }

}