querries=int(input())
for querrie in range(querries):
  abc=input().split()
  total=0
  a=int(abc[0])
  b=int(abc[1])
  c=int(abc[2])
  while c>1 and b>0:
    total=total+3
    c=c-2
    b=b-1
  while a>0 and b>1:
    total=total+3
    b=b-2
    a=a-1
  print(total)