t = int(input())
for i in range(t):
    a, b, c = [int(x) for x in input().split()]
    sum = 0
    if(c // 2 > b):
        sum += b*3
    else:
        sum += (c//2) * 3
        b -= c//2;
        if(b//2 > a):
            sum += a * 3
        else:
            sum += (b//2) * 3
            
    print(sum)