#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<> typedef long long ll; using namespace std; const ll mod= 1e9; int main(){ int N,K; int S[110],A[110]; vector> ans; cin>>N>>K; REP(i,0,N){ S[i]=i+1; } REP(i,0,K){ int x,y; cin>>x>>y; x--;y--; swap(S[x],S[y]); } REP(i,0,N) cin>>A[i]; REP(i,0,N){ RREP(j,i+1,N){ if(S[i]!=A[j]) continue; RREP(k,i+1,j+1) { swap(A[k - 1], A[k]); ans.emplace_back(k - 1, k); } } } reverse(ALL(ans)); p(ans.size()); for(auto a:ans){ p2(a.first+1, a.second+1); } return 0; }