for _ in range(int(input())):
    a,b,c = map(int,input().split())
    summ = a+b+c
    while b>=1 and c >= 2:
        b -= 1
        c -= 2

    while a >= 1 and b >= 2:
        a -= 1
        b -= 2
    print(summ-(a+b+c))