#include using namespace std; using ll = long long; #define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++) // Ref: https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac #define dump(var) do{std::cerr << #var << " : ";view(var);}while(0) template void view(T e){std::cerr << e << "\n";} template void view(const std::vector& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << "\n";} template void view(const std::vector >& vv){ std::cerr << "\n"; for(const auto& v : vv){ view(v); } } template void dump_cout(const T& v) { for(long long i = 0; i < v.size(); i++) std::cout << v[i] << (i == v.size()-1 ? "\n" : " "); } #include using mint = atcoder::modint1000000007; namespace mm { template using matrix = std::vector>; template matrix E(int n) { matrix res(n, std::vector(n, 0)); for(int i = 0; i < n; i++) res[i][i] = 1; return res; } template matrix matMul(matrix a, matrix b) { assert(a.size() && b.size()); assert(a[0].size() == b.size()); matrix res(a.size(), std::vector(b[0].size(), 0)); for(int i = 0; i < a.size(); i++) { for(int j = 0; j < b[0].size(); j++) { for(int k = 0; k < b.size(); k++) { res[i][j] += a[i][k] * b[k][j]; } } } return res; } template std::vector vecMul(matrix a, std::vector b) { assert(a.size() && b.size()); assert(a[0].size() == b.size()); std::vector res(b.size(), 0); for(int i = 0; i < a.size(); i++) { for(int j = 0; j < b.size(); j++) { res[i] += a[i][j] * b[j]; } } return res; } template matrix matPow(matrix a, long long p) { assert(a.size() && a.size() == a[0].size()); matrix res(a.size(), std::vector(a.size(), 0)); for(int i = 0; i < a.size(); i++) res[i][i] = 1; while(p) { if(p & 1) res = matMul(res, a); a = matMul(a, a); p /= 2; } return res; } } using namespace mm; void F(ll c, ll n, ll m) { double a = 1. / c; double b = 1. - a; matrix M = { {a, 0, 0, a}, {0, b, b, 0}, {1, 0, 0, 0}, {0, 1, 0, 0} }; vector V = {a, 0, 1, 0}; auto RM = matPow(M, n); auto RV = vecMul(RM, V); dump(RV); } void solve() { ll c, n, m; cin >> c >> n >> m; mint a = mint(c).inv(); mint b = 1 - a; matrix M = { {a, 0, 0, a}, {0, b, b, 0}, {1, 0, 0, 0}, {0, 1, 0, 0} }; vector V = {a, 0, 1, 0}; auto RM = matPow(M, n); auto RV = vecMul(RM, V); mint ans = 1 - (1 - RV[2]).pow(m); cout << ans.val() << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }