package main import . "fmt" import . "os" import bf "bufio" func main() { rd:=bf.NewReader(Stdin) var t int Fscan(rd,&t) for ;t>0;t-- { var n,m,k int Fscan(rd,&n,&m,&k) k%=m if k>=m-n { Println(0) } else { Println(k) } } }