def process(s): try: if len([i for i in s.split('.') if int(i)<=255 and int(i) >= 0])==4: return True except: return False return False while True: try: if process(raw_input()): print "YES" else: print "NO" ...