t = int(input())
for _ in range(t):
  a1, b1, c1 = map(int, input().split())
  a2, b2, c2 = a1, b1, c1
  ans1 = min(a1, b1 // 2)
  b1 -= 2 * ans1
  ans1 += min(b1, c1 // 2)

  ans2 = min(b2, c2 // 2)
  b2 -= ans2
  ans2 += min(a2, b2 // 2)
  print(max(ans1, ans2) * 3)