package main import ( "fmt" "math/big" ) func pow(x, y *big.Int) int{ x = x.Mod(x, big.NewInt(10)) xx := int(x.Uint64()) zero := big.NewInt(0) z := 1 for ; y.Cmp(zero) != 0 ; { if y.Bit(0) == 1 { z = z * xx % 10 } xx = xx * xx % 10 y = y.Rsh(y, 1) } return z } func main() { var sx, sy string fmt.Scan(&sx) fmt.Scan(&sy) x := big.NewInt(1) y := big.NewInt(1) x.SetString(sx, 10) y.SetString(sy, 10) z := pow(x, y) fmt.Println(z) }