gets.to_i.times{ a,b=gets.split(" ").map{|e| e.to_i} puts b*a+b }