#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c b(t); for(ll i=0;i<64;i++){ if(b[i]) { if(flag) flag = false, s = A; else s = dot(A, s); } A = dot(A, A); } return s; } int main(int argc, char const *argv[]) { ll k, m, n;std::cin >> k >> m >> n; vvl a = VV(k*k, k*k, 0, ll); vvl d = VV(m, 3, 0, ll); re(i, m) { scanf("%lld %lld %lld", &d[i][0],&d[i][1],&d[i][2]); d[i][0]--, d[i][1]--, d[i][2]--; } for(int i=0;i j, 1 for(int j=0;j