#include #include using namespace std; typedef long long ll; typedef vector> vvl; ll mod = 1000000007; vvl mul(const vvl &a,const vvl &b){ int i,j,k,n = a.size(); vvl c(n,vector(n,0)); for(i=0;i mul2(vvl &a,vector b){ int i,j,n = a.size(); vector c(n); for(i=0;i(n,0)); for(i=0;i mat_pw2(vvl &a, ll x, vector v){ int i,j,k,n = a.size(); while(x){ if(x&1) v = mul2(a,v); a = mul(a,a); x /= 2; } return v; } bool ok[6][6][6]; int main(){ ll i,j,l,r,k,m,n; cin >> k >> m >> n; for(i=0;i> p >> q >> r; p--; q--; r--; ok[p][q][r] = true; } int sz = k*k; vvl mat(sz); for(i=0;i v(sz); for(i=0;i<1;i++){ for(j=0;j