if __name__ == '__main__' :
    for i in range(int(input())) :
        a, b, c = map(int, input().split())
        count = 0
        if c>a :
            while b>0 and c>1 :
                b = b-1
                c = c-2
                count = count+3
            while b>1 and a>0 :
                b = b-2
                a = a-1
                count = count+3
        elif c<=a :
            while a>0 and b>1 :
                a = a-1
                b = b-2
                count = count+3
            while b>0 and c>1 :
                c = c-2
                b = b-1
                count = count+3

        print(count)
