for i in range(int(input())):
    a, b, c = map(int,input().split())
    d = 0
    while b > 0 and c > 1:
        c -= 2
        b -= 1
        d += 3
    while a > 0 and b > 1:
        b -= 2
        a -= 1
        d += 3
    print(d)
