import java.math.BigInteger; import java.util.Scanner; public class Main{ static BigInteger mod=BigInteger.valueOf(129402307); static long pow(long a,long x,long m){ if(a==0) return 0; else if(x==0) return 1; else if(x%2==0) return pow((a*a)%m,x/2,m)%m; else return (a*pow((a*a)%m,x/2,m))%m; } public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ BigInteger n=sc.nextBigInteger(); BigInteger m=sc.nextBigInteger(); n=n.remainder(mod); m=m.remainder(mod.subtract(BigInteger.ONE)); long nn=n.longValue(),mm=m.longValue(); System.out.println(pow(nn,mm,mod.longValue())); } } }