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