from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
#from random import randint

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

m,n = multi_int_input()

if m==2 and n == 2:
    print(6)
elif(m == 1 and n ==1 ):
    print(1)
elif (m== 1):
    print(2*n)
elif((n == 1)):
    print(2*m)
else:
    print((((m-1)**2)*((n-1)**2)*2)%MOD)