def main():
    T = int(input())
    for _ in range(T):
        A, B, C = map(int, input().split())
        y = min(B, C // 2)
        B -= y
        C -= 2 * y
        x = min(A, B // 2)
        print(3 * (x + y))


if __name__ == "__main__":
    main()
