fork download
  1. s=$3{for(y=$1;(x=y*$2+1)%s||$1<x/=s;y--);$0=x y}s
Success #stdin #stdout 0s 5316KB
stdin
6
1 1 1
5 2 5
50 48 49
6 0 1
5 3 2
stdout
10
12
4950
16
53