


Let's say the pet shop's oldest dog’s uID that has not yet been adopted is 4 and that of the oldest cat is 3.
If operation 2 0 is performed then the oldest dog will be adopted i.e uID 4.
If operation 2 1 is performed then the oldest cat will be adopted i.e uID 3.
If operation 2 2 is performed then the animal older among them will be adopted.
The first line contains a single integer ‘T' representing the number of test cases.
The first line of each test case contains a single integer ‘N’ representing the number of operations.
Next ‘N' lines contain operations that have to be performed on the shop. Each operation is either of type 1 or 2.
For each test case print a vector/list that contains the unique identification number of pets that are adopted in the order they are adopted.
1. All the operations are valid.
2. You do not need to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 1000
1 <= uID <= 10^6
0 <= type1 <= 1
0 <= type2 <= 2
Time Limit: 1sec
We can maintain a list of pets in the order they arrive at the shop. The list must contain 3 parameters unique ID of each pet, whether the pet is a dog or cat, and whether it has been adopted or not.
We can declare a list ‘pets’ which contains all the above details. Declare a list ‘ans’ that is initially empty and stores the unique ID in the order in which they are adopted.
We perform each query as follows:-
We can maintain a list of pets in the order they arrive at the shop. The list must contain 3 parameters unique ID of each pet, whether the pet is dog or cat, and the position of the next dog in the list if this animal is a dog or the position of the next cat in the list if this animal is a cat.
We can declare a list ‘pets’ which contains all the above details. Declare a list ‘ans’ that is initially empty and stores the unique ID in the order in which they are adopted.
We will declare variables ‘firstCat’, ‘lastCat’, ‘firstDog’, and ‘lastDog’.
We perform each query as follows:-