#include #include #include #include #include #include #include using namespace std; using ll = long long; using pii = pair; using vi = vector; using vvi = vector; // #define rep(i,n) for(int i=0;i<(n);++i) #define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c)) #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) for(int i=0;i<(n);++i) #define repi(i,a,b) for(int i=(a);i<(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define _fromto2(i,n) for(int i=0;i<=(n);++i) #define _fromto3(i,a,b) for(int i=(a);i<=(b);++i) #define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__) #define rrep(i,n) for(int i=(n);i>=0;--i) const int MOD = 1e9+7; const int INF = 1e9; const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1}; templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(bostream& operator<<(ostream& os,const vector& vec){os<<"{";for(int i=0;iostream& operator<<(ostream& os,const pair& rhs){os<<"("< void debug(const First& first) {cerr< void debug(const First& first, const Rest&... rest) {cerr<> a >> b >> n; Matrix m(0, 1, b, a); m = pow(m, n-1); cout << m.d << endl; return 0; }