import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } final long MOD=(long)1e9+7; long ADD(long a,long b) { return a+b>=MOD?a+b-MOD:a+b; } long[][] mul(long[][] a,long[][] b){ long[][] ret=new long[a.length][b[0].length]; for(int i=0;i0;n>>=1,a=mul(a,a))if(n%2==1)ret=mul(ret,a); return ret; } long pow(long a,long n) { long ret=1; for(;n>0;n>>=1,a=a*a%MOD)if(n%2==1)ret=ret*a%MOD; return ret; } long fib(long c) { long[][] mat= {{1,1},{1,0}}; mat=pow(mat,c-1); return mat[0][0]; } void run() { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); long ans=1; BigInteger MODIDX=BigInteger.valueOf(MOD-1); while(N-->0) { long C=sc.nextLong(); long D=new BigInteger(sc.next()).remainder(MODIDX).longValue(); ans=ans*pow(fib(C+2),D)%MOD; } System.out.println(ans); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }