‘POST’(USERID, TWEETID) tells that a user having ID as USERID has posted a tweet having ID as TWEETID.
‘GET_FEED’( ‘USERID’ ) returns the list of 10 most recent tweet IDs in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user themself. Tweets must be ordered from most recent to least recent.
‘FOLLOW(USERID, FOLLOWERID) tells that user is followed by the user having ID as ‘FOLLOWERID’.
UNFOLLOW(USERID, FOLLOWERID) tells that the user ‘FOLLOWERID’ has unfollowed the user.
The first line of the input contains an integer, 'T,’ denoting the number of test cases.
The first line of each test case contains a single integer, 'N’, denoting the number of function calls.
Next ‘N’ lines of each test case contain an integer denoting the function type followed by the parameter list.
Type 1 denotes POST().
Type 2 denotes GET_FEED().
Type 3 denotes FOLLOW().
Type 4 denotes UNFOLLOW().
For each test case, output the lists returned by the GET_FEED() function.
Print the output of each test case in a separate line.
Note:
You do not need to print anything. It has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 10
1 <= N <= 10000.
1 <= ‘USERID’ <= 500 .
Time limit: 1 sec
Sample Input 1:
2
5
1 1 100
1 2 200
3 1 2
2 2
2 1
3
1 1 100
1 1 110
2 1
Sample Output 1:
200 100
100
110 100
Explanation of sample input 1:
For the first test case,
User 1 posted a tweet with ID as 100.
User 2 posted a tweet with ID as 200.
User 2 followed user 1.
Now, the get_Feed for user 2 will show his own posts and user 1’s posts.So,the posts will be [200,100].
get_Feed for user 1 will show only his own posts as he didn’t follow any other user. So, the posts will be [100].
For the second test case:
User 1 posted a tweet with ID as 100.
User 1 posted a tweet with ID as 110.
get_Feed for user 1 will show only his own posts as he didn’t follow any other user.So, the posts will be [110, 100].
Sample Input 2:
2
8
1 1 1
3 1 2
4 1 2
2 1
1 1 2
1 1 3
1 2 4
2 1
9
1 1 1
2 1
1 3 2
3 1 3
4 1 3
1 3 3
1 1 4
3 3 1
2 1
Sample Output 2:
1
3 2 1
1
4 3 2 1