import os, sys

# zeilen = [l.strip() for l in sys.stdin.readlines()]

t = int(sys.stdin.readline().strip())

for _ in range(t):
  a, b, c = map(int, sys.stdin.readline().strip().split())
  anz2 = min(b, c//2)
  anz1 = min(a, (b-anz2) // 2)
  print(3*(anz1 + anz2))

