t = gets.to_i results = [] t.times{ a,b,c = gets.split.map &:to_i result = 0 if c > a then result += a * 2 c -= a result += c / 2 result += b / 2 * 2 else result += c * 2 a = a - c result += b / 2 * 2 if b % 2 == 1 && a>0 then result += 1 end end results << result } puts results