from copy import deepcopy

class st:
  pass
  
def take1(st):
  f=min(st.a, st.b//2)
  st.a -= f
  st.b -= 2*f
  return f*3
  
def take2(st):
  f=min(st.b, st.c//2)
  st.b -= f
  st.c -= 2*f
  return f*3

def solve(I):
  st = deepcopy(I)
  res1 = take1(st) + take2(st)
  st = deepcopy(I)
  res2 = take2(st) + take1(st)
  return max(res1, res2)

for i in range(int(input())):
   s = st()
   s.a,s.b,s.c=map(int, input().split())
   print(solve(s))
