elem = int(input())
for x in range(elem):
    ar = []
    for x in input().split(' '):
        ar.append(int(x))
    count = 0
    while ar[1]>0:
        if ar[2]>1:
            count = count + 3
            ar[2]=ar[2]-2
            ar[1]=ar[1]-1
        else:
            break
    while ar[0]>0:
        if ar[1]>1:
            count = count + 3
            ar[1]=ar[1]-2
            ar[0]=ar[0]-1
        else:
            break
    print(count)