while(1>0){val b=readLine.split(" ")map(BigInt(_)) println(b(0)modInverse(b(1)))}