# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

for _ in range(int(input())):
    a,b,c=map(int,input().split())
    solution=0
    while True:
        if a>=1 and b>=2:
            solution+=3
        else:
            break
        a=a-1
        b=b-2
        if b>=1 and c>=2:
            solution+=3
        else:
            break
    print(solution)            
    