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