from sys import stdin, stdout

for _ in range(int(stdin.readline())):

    cont = 0
    cont1 = 0
    a = stdin.readline().split()
    ent = list(map(int,a))
    lis = list(map(int,a))

    if ent[1]==0:
        stdout.write('0\n')
        continue
    while ent[1]>0 and ent[2]>=2:
        ent[1]-=1
        ent[2]-=2
        cont+=3
    while ent[0]>0 and ent[1]>=2:
        ent[0]-=1
        ent[1]-=2
        cont+=3

    while lis[0]>0 and lis[1]>=2:
        lis[0]-=1
        lis[1]-=2
        cont1+=3
    while lis[1]>0 and lis[2]>=2:
        lis[1]-=1
        lis[2]-=2
        cont1+=3

    if cont>cont1:
        stdout.write(str(cont)+'\n')
    else:
        stdout.write(str(cont1)+'\n')