def stones(a, b, c):
    stone_count = 0
    first_take = min(b, c // 2)
    stone_count += 3*first_take
    b -= first_take
    second_take = min(a, b //2)
    return stone_count + 3*second_take
    
for _ in range(int(input())):
    a, b, c = map(int, input().split())
    print(stones(a, b, c))