fork(1) download
  1. s=$3{for(y=s-1;(x=y*$2-1)%s;y--);print x/s,s-y}
Success #stdin #stdout 0.01s 5304KB
stdin
3
1 1 1
5 2 5
5 3 2
50 48 49
6 0 1
5 1 2
stdout
-1 1
1 2
1 1
47 1
-1 1
0 1