import java.io.*; import java.util.*; public class BB { public static void main(String[] args)throws Throwable { MyScanner sc=new MyScanner(); PrintWriter pw=new PrintWriter(System.out); mod=(int)1e9+7; int max=(int)(1e5+5); int [] fac=new int [max]; int [] inv=new int [max]; fac[0]=1; for(int i=1;i0){ int l=sc.nextInt()-1; int r=sc.nextInt()-1; int cntOne=0; int cntTwo=0; int [] c=new int [26]; long ans=1; for(int i=0;i<26;i++){ c[i]=cum[r][i]; if(l>0) c[i]-=cum[l-1][i]; if(c[i]%2==1){ cntOne++; c[i]--; } c[i]/=2; ans=(ans*inv[c[i]])%mod; cntTwo+=c[i]; } ans=(ans*fac[cntTwo])%mod; if(cntOne>0) ans*=cntOne; ans%=mod; pw.println(ans); } pw.flush(); pw.close(); } static int mod; public static long inv(long x){ long r,y; for(r=1,y=mod-2;y!=0;x=x*x%mod,y>>=1) if((y&1)==1) r=r*x%mod; return r; } static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() {while (st == null || !st.hasMoreElements()) { try {st = new StringTokenizer(br.readLine());} catch (IOException e) {e.printStackTrace();}} return st.nextToken();} int nextInt() {return Integer.parseInt(next());} long nextLong() {return Long.parseLong(next());} double nextDouble() {return Double.parseDouble(next());} String nextLine(){String str = ""; try {str = br.readLine();} catch (IOException e) {e.printStackTrace();} return str;} } }