t = int(input())

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

    p = min(a, b // 2)
    v = min(b, c // 2)
    s1 = 3 * p + min(b - p * 2, c // 2) * 3
    s2 = 3 * v + min(a, (b - v) // 2) * 3
    print(max(s1, s2))
