for _ in range(int(input())):
    a, b, c = map(int, input().split())

    TotalStones = 0
    if b == 0:
        pass
    else:
        if c != 0:
            while (b >= 1 and c >= 2):
                b -= 1
                c -= 2
                TotalStones += 3

        if a != 0:
            while ( a >= 1 and b >= 2 ):
                a -= 1
                b -= 2
                TotalStones += 3

    print(TotalStones)
