#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include //#include //using Modint = atcoder::modint998244353; using namespace std; typedef long long ll; void ex_gcd(ll a, ll b, ll &d, ll &x, ll &y) { if (!b) { d = a; x = 1; y = 0; } else { ex_gcd(b, a % b, d, y, x); y -= a / b * x; } } ll inv(ll a, ll n) { ll d, x, y; ex_gcd(a, n, d, x, y); return d == 1 ? (x % n + n) % (n / d) : -1; } ll gcd(ll x, ll y) { if (y == 0) return x; return gcd(y, x % y); } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } inline void scan_d(int &ret) { char c; ret=0; while((c=getchar())<'0'||c>'9'); while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar(); } const int maxn = 105; const int mod = 998244353; // https://www.kancloud.cn/digest/acarthur/166627 typedef vector vec; typedef vector mat; mat mul(mat &a, mat &b) { int n = a.size(); int m = a[0].size(); int mm = b[0].size(); mat c(n, vec(mm)); for(int i=0;i 0) { if(k & 1) b = mul(b, a); a = mul(a, a); k >>= 1; } return b; } int e[maxn][maxn]; int main() { #ifdef suiyuan2009 freopen("/Users/suiyuan2009/CLionProjects/icpc/input.cpp", "r", stdin); freopen("/Users/suiyuan2009/CLionProjects/icpc/output.cpp", "w", stdout); #endif int T; scan_d(T); while(T--){ int n,m,K; scan_d(n); scan_d(m); scan_d(K); memset(e, -1, sizeof(e)); for(int i=0;i