use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let v: Vec = s.split_whitespace().skip(1).flat_map(str::parse).collect(); for n in v.chunks(3) { let a = n[2] % n[1]; println!("{}", if a < n[1] - n[0] { a } else { 0 }) } }