for _ in range(input()):
    a, b, c = map(int, raw_input().split())
    k = min(a, b / 2)
    x = 3 * (k + min(b - k * 2, c / 2))
    k = min(b, c / 2)
    y = 3 * (k + min(a, b - k >> 1))
    print max(x, y)
