($N,$K,$X)=glob<>; @N=0..$N; <>=~$",@N[$`,$']=@N[$',$`]for 1..$X; @AB=reverse<>; @C=(0,glob shift@AB); / /,@C[$`,$']=@C[$',$`]for@AB; $N[$_]!=$C[$_]and($a?$b:$a)=$_ for 1..$N; print"$a $b\n"