q = int(input())
Ans = []
for i in range(q):
    a, b, c = map(int,input().split())
    operbc = min(b, c // 2)
    b -= operbc
    operab = min(a, b // 2)
    Ans.append((operbc + operab) * 3)
for i in range(q):
    print(Ans[i])
