t = int(input())

for i in range(t):
    e = input().split()
    a = int(e[0])
    b = int(e[1])
    c = int(e[-1])
    s = 0
    if a > 0 or c > 0:
        while c > 1 and b > 0:
            try:
                b -= 1
                s += 1
                c -= 2
                s += 2
            except:
                pass
        while a >= 0 and b > 1:
            try:
                a -= 1
                s += 1
                b -= 2
                s += 2
            except:
                pass

    print(s)
