def f(a,b,c):
  s=0
  while (b>0 and c>1):
    b=b-1
    c=c-2
    s=s+3
  while (a>0 and b>1):
    a=a-1
    b=b-2
    s=s+3
  print(s)

t=int(input())
for i in range(0,t):
  a,b,c=map(int,input().split())
  f(a,b,c)