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

    ans = 0
    while c >= 2 and b >= 1:
        ans += 3
        c -= 2
        b -= 1
    while b >= 2 and a >= 1:
        ans += 3
        b -= 2
        a -= 1

    print(ans)
