n,k,x = gets.chomp.split(" ").map{|u|u.to_i} a = [] n.times do|i| a.push(i+1) end b =[] (x-1).times do d = (gets.chomp.split(" ").map{|u|u.to_i}) a[d[0]-1],a[d[1]-1] = a[d[1]-1],a[d[0]-1] end gets (k-x).times do b.push(gets.chomp.split(" ").map{|u|u.to_i}) end c = gets.chomp.split(" ").map{|u|u.to_i} (0..(b.size-1)).reverse_each do |i| c[b[i][0]-1],c[b[i][1]-1] = c[b[i][1]-1],c[b[i][0]-1] end ans = [] n.times do |i| ans.push(i+1) if a[i] != c[i] end puts "#{ans[0]} #{ans[1]}"