'''     ***Author RtS***
'''
b = int(input())
a = []
for i in range(b):
    a.append([int(j) for j in input().split()])
for i in a:
    if int(i[2]/2) >= i[1]: 
        print(int(i[1]*3))
    else:
        c = int(i[1] - int(i[2]/2))
        if int(c/2) <= i[0]:
            print(int(i[2]/2)*3 + int(c/2)*3)
        else:
            print(int(i[2]/2)*3 + i[0]*3)