""" 包除原理で解きそう 全部0で埋める行・列の個数によって変化してしまうな… まず、行か列の片方だけ求める? 少なくともX個列が0で埋まっている時、少なくともY個行が0で埋まっている場合の数 O(HW)解は Σ nCr(H,x) * nCr(W,y) * pow( 2 , H*W-x*W-H*y+x*y , mod ) * pow(-1,x+y,mod) で求まる 分離できないか? H*W - x*W - H*y + x*y = (H-x)*(W-y) 分離できてないじゃん 採用 = 2^k 不採用 = -1 A[i+1] = A[i] * ( 2^k-1 ) """ import sys from sys import stdin def modfac(n, MOD): f = 1 factorials = [1] for m in range(1, n + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (n + 1) invs[n] = inv for m in range(n, 1, -1): inv *= m inv %= MOD invs[m - 1] = inv return factorials, invs def modnCr(n,r): return fac[n] * inv[n-r] * inv[r] % mod mod = 10**9+7 fac,inv = modfac(10**6+100,mod) p2 = [1] for i in range(10**6+100): p2.append(p2[-1]*2 % mod) H,W = map(int,stdin.readline().split()) ans = 0 for unpick in range(0,H+1): pick = H-unpick bi = p2[pick] now = pow(bi-1,W,mod) ans += now * modnCr(H,unpick) * ( (-1)**(unpick%2) ) ans %= mod print (ans % mod) """ A = 0 for x in range(0,H+1): now = modnCr(H,x) * p2[H-x] if now % 2 == 0: A += now else: A -= now B = 0 for y in range(0,W+1): now = modnCr(W,y) * p2[W-y] if now % 2 == 0: B += now else: B -= now print (A,B) print (A*B%mod) """