for i in range(int(input(""))):
    a,b,c = input("").split()
    a = int(a)
    b = int(b)
    c = int(c)
    count = 0
    while 1:
        if b >= 1 and c >=2:
            b = b - 1
            c = c - 2
            count = count + 3
        else:
            break
    while 1:
        if a >= 1 and b >=2:
            a = a - 1
            b = b - 2
            count = count + 3
        else:
            break
    print(count)