t = int(input())
for it in range(t):
    a, b, c = list(map(int, input().split()))
    t1 = min(c // 2, b)
    b -= t1
    c -= 2 * t1
    t2 = min(b // 2, a)
    a -= t2
    b -= 2 * t2
    ms = 3 * (t1 + t2)
    print(ms)
