t=int(input())
for _ in range (t):
    a,b,c=map(int,input().split())
    count=0

    while c != 0:
        if b >= 1 and c >= 2:
            count += 3
        else:
            break
        b -= 1
        c -= 2
    while a != 0:
        if b >= 2 and a >= 1:
            count += 3
        else:
            break
        b -= 2
        a -= 1
    print(count)


