open Int64 let rec(!)_=Scanf.scanf"%Ld %Ld %Ld "(f one)and f s a b c=b>zero&f[|s;rem(mul s a)c|].(to_int(logand b one))(rem(mul a a)c)(shift_right b 1)c;Printf.printf"%Ld "s;!0;;!0