#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef complex P; typedef pair pii; #define REP(i,n) for(ll i=0;i>n>>k; vi mp(n); REP(i,n)mp[i]=i; REP(i,k){ int x,y; cin>>x>>y; --x; --y; swap(mp[x],mp[y]); } // { // vi rev(n); // REP(i,n)rev[mp[i]]=i; // mp = rev; // } vi to(n); vector res; REP(i,n){ cin>>to[i]; --to[i]; int id = 0; FOR(j,i,n){ id = j; if(mp[j]==to[i])break; } FOR(j,i,id){ ll t = id-1-j+i-1; res.push_back(make_pair(t+1,t+2)); swap(mp[t],mp[t+1]); } } cout<