# -*- coding: utf-8 -*-
"""Untitled64.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1zA8FWwgFqsNBhUVzwcHCFdtRPCg4FF0G
"""

for _ in range(int(input())):
  a,b,c=input().split()
  a=int(a)
  b=int(b)
  c=int(c)
  count=0
  while c>=2 and b>=1:
    count+=3
    c=c-2
    b=b-1
  while b>=2 and a>=1:
    count+=3
    b=b-2
    a=a-1
  print(count)



