def func(a,b,c):
    m = min(b,(c-c%2)/2)
    if(m == b):
        return int(3*m)
    else:
        b = b-m
        n = min(a,(b-b%2)/2)
        return int(3*(m+n))


t = int(input())
for _ in range(t):
    a,b,c = map(int,input().split())
    ans = func(a,b,c)
    print(ans)
