If we put type-c monkeys first, type-a monkeys or type-b monkeys may not be able to have seats.
for _ in range(int(input())):
m, a, b, c = map(int, input().split())
a_seated: int = min(a, m)
b_seated: int = min(b, m)
ans: int = a_seated + b_seated + min(c, 2 * m - a_seated - b_seated)
print(ans)_ lb
TODO: