#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

soundness = [     [["∀", "Day", "Corrupt", "TestPositive"]]
                , ["BLErd"]
                , ["!KU( ~t"]
                , ["!KU( ~x"]
                , ["!KU( sk(x"]
                , ["!KU( sk(~x"]
                , ["!Phone(", "!BackendPubKey(", "!HAPubKey"]
                , ["!PhoneReceive"]
                , ["!KU( tan"]
                , [["!KU( ~n ", "Corrupt"]]
                , ["!KU( sign", "!KU( hkdf"]
                , ["!KU( aes"]
                , [["!KU( ~", "Corrupt"], "!KU( reg", "!KU( h"]
                , ["!Chan"]
                , ["!Backend("]
                , [["!KU( ", "Corrupt"]]
                , ["!FTested("]
                , ["($dayClose", "($dayContag"]
                , [["∀", "Day"]]
                , ["$dTest"]
                , ["#t1 ="]
                , ["($d"]
                , [" = "]
                , ["Day"]]


oracles = {
    "default": [ ["!KU( sk(", "!KU( prg(", "!KU( prf("]
               , ["!Phone( "]
               , ["!PhoneKey( "]
               , ["!Positive"]
               , ["!HA", "!BackendKey", "!BackendPubKey", "!PhoneTestDB( "]
               , ["!PhoneReceived( "]
               , ["!KU"]
               , ["!Chan( "]
               , ["!Backend( "]
               , ["Corrupt"]
               , ["Earlier"]
               , ["IsAt", "!SpaceTime"]],
    "soundness": soundness
}

lines = sys.stdin.readlines()
lemma = sys.argv[1]
oracle = oracles[lemma] if lemma in oracles else oracles["default"]

results = []
for current in oracle:
    for line in list(lines): # local copy
        for guess in current:
            if isinstance(guess, list):
                matched = guess[0] in line and not any(x in line for x in guess[1:])
            else:
                matched = guess in line
            if matched:
                num = line.split(":")[0]
                results.append(num)
                lines.remove(line)
                break

not_matched = [l.split(":")[0] for l in lines if l.split(":")[0] not in results]

for num in results:
    print(num)
for num in reversed(not_matched):
   print(num)