n,k,x,*t=`dd`.split.map &:to_i c=0,*t.pop(n) f=->v,m{m.times{a,b=t.pop 2;v[a],v[b]=v[b],v[a]}} f[c,k-x] s=*0..n t.reverse! f[s,x-1] $><<(1..n).select{|i|c[i]!=s[i]}*' '