import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc=new Scanner(System.in);
long test_case=sc.nextLong();
while(test_case>0){
System.out.println(xyBits(sc.nextLong(),sc.nextLong()));
test_case--;
}
}
private static long xyBits(long x_bit,long y_bit){
long tot_bits=(x_bit+y_bit-1)%1000000007;
long num=0;
for(long i=tot_bits;i>tot_bits-x_bit;i--){
// num+=(1<<i)%1000000007;
num+=powof2(2,i);
}
return num%1000000007;
}
private static long powof2(long x,long y){
if(x==0 & y==0){
return 1;
}else if(y==0){
return 1;
}else if(x==0){
return 0;
}else{
long ans=1;
while(y>0){
if((y&1)==1){
ans=(ans*x)%1000000007;
}
x=(x*x)%1000000007;
y=y/2;
}
return ans;
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}