t = int(input())
for k in range(t):
    s = 0
    a, b, c = [int(i) for i in input().split()]
    k = min(b, c // 2)
    s += 3 * k
    b -= k
    c -= 2 * k
    k = min(a, b // 2)
    s += 3 * k
    print(s)
