Challenge: Common Friends

Lab Python Beginner 10 points

Two people list their friends. Print the friends they have in common, sorted alphabetically. If there are none, print No common friends.

Input

Two lines, each a list of names separated by spaces.

Output

The common names in alphabetical order separated by spaces, or No common friends.

Example

Input

ravi asha meena kabir
kabir zoya asha

Output

asha kabir
Sample input available Sample output available
Editor
Python

Hints

Turn each line into a set.

& gives the items in both sets.

sorted() turns a set into a sorted list.

Solution explanation

Sets make this a one-liner: a & b is everything in both. Sort it and join it into a line.

Show solution
a = set(input().split())
b = set(input().split())
common = sorted(a & b)
print(" ".join(common) if common else "No common friends")
Output
Answer
HOME LEARN COMMUNITY DASHBOARD