CCCPaste

Flowers Finder

from collections import deque

vowels = deque(x for x in input().split())
consonants = [x for x in input().split()]

searched_words = ['rose', 'tulip', 'lotus', 'daffodil']
found_word = set()

while True:
    if len(vowels) == 0:
        break
    if len(consonants) == 0:
        break
    
    first_vowel = vowels.popleft()
    last_consonant = consonants.pop()
    
    for word in searched_words:
        for letter in word:
            if first_vowel == letter:
                found_word.add(letter)
            
            if last_consonant == letter:
                found_word.add(letter)
            
print(found_word)