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