let pow x y z =
  let mult x1 y1 = ((x1 mod z)*(y1 mod z)) mod z in
  let rec f m n b = match n with
      0 -> 1
    | 1 -> mult m b
    | _ -> f (mult m m) (n/2) (mult b (if n mod 2 = 0 then 1 else x))
  in f x y 1;;

let () =
  let f x y = pow x y 1000000007 |> Printf.printf "%d\n"
  in Scanf.scanf "%d %d\n" f;;