ntest = int(input())
for i in range(ntest):
    a, b, c = map(int, input().split())
    ans = 0
    for j in range(min(a, b // 2) + 1):
        newb = b - j * 2
        ans = max(ans, j + min(newb, c // 2))
    print(ans * 3)

