In a social network, a person can invite friends of his/her friend. John
wants to invite and add new friends. Complete the program below so that it
prints the names of the persons to whom John can send a friend request.
Input Format:
The first line contains the value of the N which represent the number of
friends. Next N lines contain the name of the friend F followed by the number
of friends of F and finally their names separated by space.
Boundary Conditions: 2 <= N
<= 10
Output Format:
The names to which John can send a friend request.
Example Input/Output 1:
Input:
3
Mani 3 Ram Raj Guna
Ram 2 Kumar Kishore
Mughil 3 Praveen Naveen Ramesh
Output:
Raj Guna Kumar Kishore Praveen Naveen Ramesh
Explanation:
Ram is not present in the output as Ram is already John's friend.
Solution:
n = int(input())
already_friend,
be_friend, soln = [], [], []
for _ in range(n):
x, y, *z = input().strip().split()
already_friend.append(x)
for j in z:
be_friend.append(j)
for i in be_friend:
if i not in already_friend:
soln.append(i)
print(*soln)