def recur(a,b,c,maxi):
    if a >=1 and b >= 2 and c >= 2:
        return recur(a,b-1,c-2,maxi +3)
    if a >= 1 and b >= 2:
        return recur(a-1,b-2,c,maxi+3)
    if b >= 1 and c >= 2:
        return recur(a,b-1,c-2,maxi+3)
    return(maxi)



n = int(input())
for i in range(n):
    l = list(map(int,input().split(" ")))
    maxi = recur(l[0],l[1],l[2],0)
    print(maxi)
