This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_5_C"
#include "../Number/modint.hpp"
#include "../Number/combination.hpp"
constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
const Combination<mint> C(1000);
int main() {
std::cin.tie();
std::ios::sync_with_stdio(false);
int n, k;
std::cin >> n >> k;
mint ans = 0;
for (int i = 0; i <= k; ++i) {
ans += mint(-1).pow(k - i) * C.binom(k, i) * mint(i).pow(n);
}
std::cout << ans << "\n";
return 0;
}#line 1 "Verify/combination.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_5_C"
#line 2 "Number/modint.hpp"
#include <iostream>
template <int MOD>
struct ModInt {
using lint = long long;
int val;
// constructor
ModInt(lint v = 0) : val(v % MOD) {
if (val < 0) val += MOD;
};
// unary operator
ModInt operator+() const { return ModInt(val); }
ModInt operator-() const { return ModInt(MOD - val); }
ModInt& operator++() { return *this += 1; }
ModInt& operator--() { return *this -= 1; }
// functions
ModInt pow(lint n) const {
auto x = ModInt(1);
auto b = *this;
while (n > 0) {
if (n & 1) x *= b;
n >>= 1;
b *= b;
}
return x;
}
ModInt inv() const {
int s = val, t = MOD,
xs = 1, xt = 0;
while (t != 0) {
auto div = s / t;
s -= t * div;
xs -= xt * div;
std::swap(s, t);
std::swap(xs, xt);
}
return xs;
}
// arithmetic
ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
ModInt& operator+=(const ModInt& x) {
if ((val += x.val) >= MOD) val -= MOD;
return *this;
}
ModInt& operator-=(const ModInt& x) {
if ((val -= x.val) < 0) val += MOD;
return *this;
}
ModInt& operator*=(const ModInt& x) {
val = lint(val) * x.val % MOD;
return *this;
}
ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
// comparator
bool operator==(const ModInt& b) const { return val == b.val; }
bool operator!=(const ModInt& b) const { return val != b.val; }
// I/O
friend std::istream& operator>>(std::istream& is, ModInt& x) {
lint v;
is >> v;
x = v;
return is;
}
friend std::ostream& operator<<(std::ostream& os, const ModInt& x) {
return os << x.val;
}
};
using modint1000000007 = ModInt<1000000007>;
using modint998244353 = ModInt<998244353>;
#line 2 "Number/combination.hpp"
#include <vector>
template <class T>
struct Combination {
int max_n;
std::vector<T> f, invf;
explicit Combination(int n)
: max_n(n), f(n + 1), invf(n + 1) {
f[0] = 1;
for (int i = 1; i <= n; ++i) {
f[i] = f[i - 1] * i;
}
invf[max_n] = f[max_n].inv();
for (int i = max_n - 1; i >= 0; --i) {
invf[i] = invf[i + 1] * (i + 1);
}
}
T fact(int n) const { return n < 0 ? T(0) : f[n]; }
T invfact(int n) const { return n < 0 ? T(0) : invf[n]; }
T perm(int a, int b) const {
return a < b || b < 0 ? T(0) : f[a] * invf[a - b];
}
T binom(int a, int b) const {
return a < b || b < 0 ? T(0) : f[a] * invf[a - b] * invf[b];
}
};
#line 5 "Verify/combination.test.cpp"
constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
const Combination<mint> C(1000);
int main() {
std::cin.tie();
std::ios::sync_with_stdio(false);
int n, k;
std::cin >> n >> k;
mint ans = 0;
for (int i = 0; i <= k; ++i) {
ans += mint(-1).pow(k - i) * C.binom(k, i) * mint(i).pow(n);
}
std::cout << ans << "\n";
return 0;
}