t = int(input())

for i in range(t):
    a, b, c = list(map(int, input().split()))

    total = 0
    fst = min(b, c//2)
    total += 3 * fst
    b -= fst
    snd = min(a, b // 2)
    total += 3 * snd
    print(total)