program main
    implicit none
    
    integer(8) :: n
    integer(8) :: i
    
    character(20), allocatable :: cheaters(:)
    character(20), allocatable :: students(:)
    
    read *, n
    
    allocate(cheaters(n))
    allocate(students(n))
    
    do i = 1, n
        read *, cheaters(i), students(i)
    end do
    
    do i = 1, n
        if (count(cheaters == students(i)) == 0 .and. count(students(: i-1) == students(i)) == 0) print *, students(i)
    end do
end program main