fork download
  1. s=$3{for(y=0;(x=y*$2+1)%s||($1>=x/=s)&&(y<=$1);y++);print x-$2,y-s}
Success #stdin #stdout 0.01s 5308KB
stdin
5
5 2 5
5 3 4
50 48 49
4 1 1
4 0 1
4 3 2
stdout
1 2
4 5
49 50
4 3
1 4
2 1