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