for _ in range(int(input())):
    a, b, c = map(int, input().split())
    stones = 0
    while (b and (a or c)):
        if b >= 1 and c >= 2:
            b -= 1
            c -= 2
            stones += 3
        elif a >= 1 and b >= 2:
            a -= 1
            b -= 2
            stones += 3
        else:
            b = 0
            stones += 0
    print(stones)   