Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.
There are n
kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different kinds are distinguishable). The number of presents of each kind, that Alice has is very big, so we can consider Alice has an infinite number of gifts of each kind.
Also, there are m
boxes. All of them are for different people, so they are pairwise distinct (consider that the names of m
friends are written on the boxes). For example, putting the first kind of present into the first box but not into the second box, is different from putting the first kind of present into the second box but not into the first box.
Alice wants to pack presents with the following rules:
- She won't pack more than one present of each kind into the same box, so each box should contain presents of different kinds (i.e. each box contains a subset of n
- kinds, empty boxes are allowed);
- For each kind at least one present should be packed into some box.
Now Alice wants to know how many different ways to pack the presents exists. Please, help her and calculate this number. Since the answer can be huge, output it by modulo 109+7
.
See examples and their notes for clarification.
Input
The first line contains two integers n
and m, separated by spaces (1≤n,m≤109
) — the number of kinds of presents and the number of boxes that Alice has.
Output
Print one integer — the number of ways to pack the presents with Alice's rules, calculated by modulo 109+7
Examples
Input
Copy
1 3
Output
Copy
7
Input
Copy
2 2
Output
Copy
9
Note
In the first example, there are seven ways to pack presents:
{1}{}{}
{}{1}{}
{}{}{1}
{1}{1}{}
{}{1}{1}
{1}{}{1}
{1}{1}{1}
In the second example there are nine ways to pack presents:
{}{1,2}
{1}{2}
{1}{1,2}
{2}{1}
{2}{1,2}
{1,2}{}
{1,2}{1}
{1,2}{2}
{1,2}{1,2}
For example, the way {2}{2}
is wrong, because presents of the first kind should be used in the least one box.
题意:这些天爱丽丝收到了很多礼物。所以她决定把它们装进盒子寄给她的朋友们。有n种礼物。一种礼物是相同的(即无法区分两种相同的礼物)。不同种类的礼物是不同的(也就是说,两种不同的礼物是可以区分的)。爱丽丝收到的每一种礼物的数量都非常大,所以我们可以认为爱丽丝收到的每一种礼物的数量是无限的。还有m个盒子。他们都是为不同的人,所以他们是两两不同的(考虑到m个朋友的名字写在盒子上)。例如,把第一种礼物放在第一个盒子里而不是放在第二个盒子里,这与把第一种礼物放在第二个盒子里而不是放在第一个盒子里是不同的。爱丽斯想要用以下规则来包装礼物:她不会在同一个盒子里装超过一件不同种类的礼物,所以每个盒子应该包含不同种类的礼物(即每个盒子包含n个种类的子集,允许有空盒子);每一种礼物至少应装入一个盒子。现在爱丽丝想知道有多少种包装礼物的不同方法。请帮她计算一下这个数字。因为答案可能很大,所以输出109+7的模。参见示例及其注释以获得澄清。输入第一行包含两个整数n和m,用空格(1n, m109)隔开,表示礼物的种类和Alice拥有的盒子的数量。输出打印一个整数的方式来包装的礼物与爱丽丝的规则,计算出的模块109+7
思路:(2^m-1)^n;
#include <cstdio>
#include<iostream>
#include <cstring>
#include <algorithm>
#include <stack>
#include<set>
using namespace std;
#define ll long long
const int maxn=2e4;
#define mod 1000000007
ll qpow(ll base, ll n)
{
ll ans = 1;
while(n)
{
if(n&1) ans=(ans%mod)*(base%mod)%mod;
base = (base%mod) * (base%mod)%mod;
n/=2;
}
return ans%mod;
}
int main()
{
ll n,m;
scanf("%lld %lld",&n,&m);
ll sum=(qpow(2LL,m)+mod-1)%mod;
sum=qpow(sum,n)%mod;
printf("%lld\n",sum);
}