package main import ( "bufio" "fmt" "os" ) func main() { solve() } func solve() { N := readLine() M := readLine() //fmt.Println(pow(N, M)) n := []rune(N) m := []rune(M) if N == "0" { fmt.Println("0") return } if M == "0" { fmt.Println("1") return } var n1, m1 int for _, v := range n { n1 = (n1*10 + (int(v) - int('0'))) % MOD } for _, v := range m { m1 = (m1*10 + (int(v) - int('0'))) % (MOD - 1) } fmt.Println(pow(n1, m1)) return } // 繰り返し二乗法 // http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=NTL_1_B // O(log(2)n) const MOD = 129402307 func pow(x, n int)int{ if n == 0{ return 1 }else if n%2==0{ return pow(x*x%MOD, n/2) }else{ return pow(x*x%MOD, n/2)*x%MOD } } /////////////////////////////////////////////////// var rdr = bufio.NewReaderSize(os.Stdin, 1000000) func readLine() string { buf := make([]byte, 0) for { l, p, e := rdr.ReadLine() if e != nil { panic(e) } buf = append(buf, l...) if !p { break } } return string(buf) }