from sys import stdin

def scal(typ=int):
  return typ(stdin.readline())

def vec(typ=int):
  if isinstance(typ, list):
    inp = stdin.readline().split()
    return [typ[i](inp[i]) for i in range(len(inp))]
  else:
    return list(map(typ, stdin.readline().split()))

t = scal()
for _ in range(t):
  a, b, c = vec()
  n = min(b, c // 2)
  b -= n
  n += min(a, b // 2)
  print(3 * n)
