fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let v: Vec = s.split_whitespace().flat_map(str::parse).collect(); if v[0] >= v[2] { println!("0"); return; } let (mut a, mut b, mut c) = (1, 1, 0); for i in 1..v[0] { a = a * i % v[2]; b = b * a % v[2]; } for i in v[0]..=v[2].min(v[1]) { a = a * i % v[2]; b = b * a % v[2]; c += b; } println!("{}", c % v[2]); }