https://www.acmicpc.net/problem/15953
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
for(int i=0;i<n;i++){
int a=s.nextInt();
int b=s.nextInt();
int na=0;
int nb=0;
if(a==0) na=0;
else if(a==1) na=5000000;
else if(a<=3) na=3000000;
else if(a<=6) na=2000000;
else if(a<=10) na=500000;
else if(a<=15) na=300000;
else if(a<=21) na=100000;
if(b==0) nb=0;
else if(b==1) nb=5120000;
else if(b<=3) nb=2560000;
else if(b<=7) nb=1280000;
else if(b<=15) nb=640000;
else if(b<=31) nb=320000;
System.out.println(na+nb);
}
}
}