import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class P1248C {

    private static final long MOD = 1_000_000_007;

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Matrix fibInit = new Matrix(new long[][]{{2, 1}});
        Matrix fibTrans = new Matrix(new long[][]{
                {1, 1},
                {1, 0},
        });
        fibTrans = fibTrans.pow(n - 1);
        Matrix subInit = new Matrix(new long[][]{{1, 0, 1}});
        Matrix subTrans = new Matrix(new long[][]{
                {1, 1, 0},
                {1, 0, 0},
                {1, 0, 1}
        });
        subTrans = subTrans.pow(n - 1);
        long a = fibInit.multiply(fibTrans).matrix[0][1];
        long b = (a + 1) % MOD;
        long sub = subInit.multiply(subTrans).matrix[0][1];
        Matrix rowInit = new Matrix(new long[][]{{b, a, sub}});
        Matrix rowTrans = new Matrix(new long[][]{
                {1, 1, 0},
                {1, 0, 0},
                {-1, 0, 1}
        });
        rowTrans = rowTrans.pow(m - 1);
        writer.println(2 * rowInit.multiply(rowTrans).matrix[0][1] % MOD);

        writer.close();
    }

    private static class Matrix {
        private int m, n;
        private long[][] matrix;

        Matrix(int m, int n) {
            if (m <= 0 || n <= 0)
                throw new IllegalArgumentException();
            this.m = m;
            this.n = n;
            this.matrix = new long[m][n];
        }

        Matrix(long[][] matrix) {
            if (matrix.length <= 0)
                throw new IllegalArgumentException();
            for (long[] row : matrix)
                if (row.length != matrix[0].length)
                    throw new IllegalArgumentException();
            this.matrix = matrix;
            this.m = matrix.length;
            this.n = matrix[0].length;
        }

        Matrix multiply(Matrix other) {
            if (other.m != this.n)
                throw new IllegalArgumentException();
            long[][] t = new long[this.m][other.n];
            for (int i = 0; i < this.m; ++i)
                for (int j = 0; j < other.n; ++j)
                    for (int k = 0; k < this.n; ++k) {
                        t[i][j] = (t[i][j] + this.matrix[i][k] * other.matrix[k][j] % MOD + MOD) % MOD;
                    }
            return new Matrix(t);
        }

        Matrix pow(long k) {
            if (this.m != this.n)
                throw new UnsupportedOperationException();
            Matrix t = new Matrix(n, n), temp = this;
            for (int i = 0; i < n; ++i)
                t.matrix[i][i] = 1;
            for (int i = 0; (1L << i) <= k; ++i) {
                if (((1L << i) & k) > 0) {
                    t = t.multiply(temp);
                }
                temp = temp.multiply(temp);
            }
            return t;
        }
    }


    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        private SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
