import math
n = int(input())
for i in range(n):
    count = 0
    ele = list(map(int,input().rstrip().split( )))
    if(ele[1]>0):
        k = math.floor(ele[2]/2)
        x = min(k,ele[1])
        if(x==ele[1]):
            count = count + ele[1]*3
        else:
            count = count + k*3
            ele[1] = ele[1] -k
            j = math.floor(ele[1]/2)
            y = min(ele[0],j)
            if(j==ele[0]):
                count = count + ele[0] * 3
            else:
                count = count + j *3
        print(count,end = "\n")
    else:
        print(0,end = "\n")