t = int(input())

while t > 0:
  t -= 1
  a,b,c = input().split(' ')
  a = int(a)
  b = int(b)
  c = int(c)
  x = min(a,b//2)
  y = min(b,c//2)
  res1 = x * 3 + min((b-2 * x),c//2)*3
  res2 = y * 3 + min((b-y)//2,a)*3
  print(max(res1,res2))


