Description

Undergrad C program that can be able to add a friend ship, remove a friendship, and print out the friend(s) for a particular user. You can assume that friendships go both ways, i.e. if A is friends with B, then B is also friends with A.

Input

The input will begin with an integer q (q <= 500,000), number of queries to your webpage. The next q lines will each contain 1 server query. There are 3 query types. The first query type is the add query. The add query will begin with the word "ADD" followed by two names, a and b. The word ADD and the names will all be separated by a single space. This query implies the people named a and b have become friends. The second query is the remove query. The remove query will begin with the word REMOVE followed by two names, a and b. The word REMOVE and the two names will be separated by a single space. The remove query will denote that user a and b are no longer friends. The last query type is the list query. The list query will begin with the word LIST followed by one name, a, representing the user we wish to list the friends of. Each name will be at most 100 lower case characters and will contain no whitespace. No user will become a friend of themselves. No user will remove themselves as a friend. If a friendship is added, it will be between two users that are currently not friends. If a friendship is removed, it will be between two users that are currently friends.

Output

For each list query print out on a line by itself the number of friends the user has. After which print out the names of each friend of the given user (in any order) each on their own line.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.