n = int(input())
for i in range(n):
  cnt = 0
  a, b, c = [int(x) for x in input().split(' ')]
  f = min(b, c // 2)
  cnt += f + f * 2
  b -= f
  c -= f * 2
  d = min(a, b // 2)
  cnt += d + d * 2
  a -= d
  b -= d * 2
  print(cnt)
