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

        if b >= 2 and a > 0:
            b = b-2
            a = a-1
            cnt = cnt+3
            continue

        if a == 0:
            break

        if c <= 1:
            break


    print(cnt)