import re import fileinput C = set(['digi', 'petit', 'rabi', 'gema', 'piyo']) for line in fileinput.input(): a = line.rstrip('\n').split(' ', 1) if len(a) < 2: print 'WRONG!' continue name, line = a line = line[-1].lower() if not name in C: print 'WRONG!' if name == 'digi' and re.search('nyo\W{0,3}$', line): print 'CORRECT (maybe)' elif name == 'petit' and re.search('nyu\W{0,3}$', line): print 'CORRECT (maybe)' elif name == 'rabi' and re.search('\w', line): print 'CORRECT (maybe)' elif name == 'gema' and re.search('gema\W{0,3}$', line): print 'CORRECT (maybe)' elif name == 'digi' and re.search('pyo\W{0,3}$', line): print 'CORRECT (maybe)' else: print 'WRONG!'