for _ in range(int(input())):
    a1,b1,c1 = list(map(int, input().split()))
    ans1, ans2 = 0, 0
    a,b,c = a1,b1,c1
    k = min(a, b//2)
    a -= k
    b -= 2*k
    ans1 += 3*k
    k = min(b, c//2)
    b -= k
    c -= 2*k
    ans1 += 3*k
    a,b,c = a1,b1,c1
    k = min(b, c//2)
    b -= k
    c -= 2*k
    ans2 += 3*k
    k = min(a, b//2)
    a -= k
    b -= 2*k
    ans2 += 3*k
    print(max(ans1, ans2))