for _ in range(int(input())):
    a,b,c = map(int,input().split())
    
    res = 0
    temp = min(b,c//2)
    res += temp*3
    b-=temp
    c-=temp*2
    temp=min(a,b//2)
    res += temp*3
    print(res)