import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
  a, b, c = map(int, input().split())
  resl = 0
  if b >= c // 2:
    resl += c // 2 * 3
    b -= c // 2
  else:
    resl += b * 3
    b = 0
  if a >= b // 2:
    resl += b // 2 * 3
  else:
    resl += a * 3
  resr = 0
  if a >= b // 2:
    resr += b // 2 * 3
    b = b % 2
  else:
    resr += a * 3
    a = 0
  if b >= c // 2:
    resr += c // 2 * 3
  else:
    resr += b * 3
  print(max(resl, resr))