Codeforces Round #593 (Div. 2) B. Alice and the List of Presents

B. Alice and the List of Presents

time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

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

1 3

output

7

input

2 2

output

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.

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}

const ll maxn = 1e9 + 7;
ll _power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2,判断b的奇偶性
			ans = ans * a % p; //如果为奇数,证明该位为1,需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
int main() {
	ll n, i, j, m;
	while (cin >> n >> m) {
		ll total = _power(2, m, maxn);
		total--;
		total = _power(total, n, maxn);
		cout << total << endl;
	}
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GUESSERR

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值