for _ in range(int(input())):
    a, b, c = map(int, input().split())
    ans = 0
    for i in range(a + 1):
        if i * 2 <= b:
            ans = max(ans, i * 3 + min(b - i * 2, c // 2) * 3)
    print(ans)
