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