https://www.acmicpc.net/problem/15953
import java.util.*
import java.lang.String.format
fun main(args: Array<String>) {
val s=Scanner(System.`in`)
var n=s.nextInt()
for(i in 0 until n){
var a=s.nextInt()
var b=s.nextInt()
var na=0
var 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
println(na+nb)
}
}