from collections import defaultdict
from math import ceil
t = int(input())
for _ in range(t):
    a,b,c = map(int,input().split())
    total = min(c//2,b)*3
    b-= total//3
    total += min(b//2,a)*3
    print (total)

    
