t = int(input())

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