Problem:
Power

For given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.

Input

m n

Two integers m and n are given in a line.

Output

Print mn (mod 1,000,000,007) in a line.

Constraints

1 ≤ m ≤ 100

1 ≤ n ≤ 109

Sample Input 1

2 3

Sample Output 1

8

Sample Input 2

5 8

Sample Output 2

390625

Solution in JAVA (judge verdict: Wrong Answer)

public class Main{
  static long mod = 1000000007;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    long m, n;

    m = sc.nextInt();
    n = sc.nextInt();
    System.out.println(power(m, n));

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static long power(long m, long n){
    long q, r;

    if(n == 1)return m;
    else{
      q = n / 2;
      r = n % 2;
      return (power(((m * m) % mod), q) + m * r) % mod;
    }

  }
}