const MOD: usize = 998244353; fn power_mat(target: &Vec>, times: usize) -> Vec> { let n = target.len(); if times == 0 { let mut ret = vec![vec![0usize; n]; n]; for i in 0..n { ret[i][i] = 1; } return ret; } if times == 1 { return target.clone(); } let temp = power_mat(target, times/2); if times % 2 == 1 { calc_mat(&calc_mat(&temp, &temp), target) } else { calc_mat(&temp, &temp) } } fn calc_mat(left: &Vec>, right: &Vec>) -> Vec> { let sizei = left.len(); let sizej = right[0].len(); let sizek = left[0].len(); let mut ret = vec![vec![0usize; sizej]; sizei]; for i in 0..sizei { for j in 0..sizej { ret[i][j] = (0..sizek).map(|k| left[i][k] * right[k][j] % MOD).sum::() % MOD; } } ret } fn main() { let mut nmt = String::new(); std::io::stdin().read_line(&mut nmt).ok(); let nmt: Vec = nmt.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nmt[0]; let m = nmt[1]; let t = nmt[2]; let mut op = vec![vec![0usize; n]; n]; for _ in 0..m { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let u = temp[0]; let v = temp[1]; op[u][v] += 1; op[v][u] += 1; } let op = power_mat(&op, t); println!("{}", op[0][0]); }