Money Mismanagement
Indra is not very good at managing their money. They try to purchase items without checking their bank account, and don't know which purchase went through, or which ones failed. Could you write a program to help them?
Indra begins with n dollars, and there are m events that occur in order: either Indra receives their paycheck of x dollars, or tries to purchase an item worth x dollars. If Indra has less than x dollars in their account, the purchase fails, and Indra loses no money.
Input
The first line contains integers n and m, the starting money and the number of events respectively. The following m lines contain each event, of the following form:
1 x, which represents Indra receiving x dollars2 x, which represents Indra attempting to purchase an item worth x.
Output
For each purchase attempt, output a line containing SUCCEED or FAIL.
Constraints
- 1≤n,m,x≤1000
Example 1
3 10
1 5
1 4
2 6
1 1
2 3
2 4
2 9
2 9
1 4
1 4
SUCCEED
SUCCEED
SUCCEED
FAIL
FAIL
Example 2
1 10
2 3
1 5
1 2
1 5
1 5
2 5
2 9
1 2
1 2
1 2
FAIL
SUCCEED
SUCCEED
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.