#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define in(T,V) T V;cin>>V;

int X[6666],Y[6666];
int A[111];

int main(){
    in(int,N);
    in(int,K);
    REP(i,K){
        cin >> X[i] >> Y[i]; X[i]--, Y[i]--;
    }
    REP(i,N){
        cin >> A[i]; A[i]--;
    }

    int a[111];
    REP(i,N) a[i] = A[i];
    REP(i,K){
        swap(a[X[i]],a[X[i]+1]);
    }

    VI res;
    REP(i,N) REP(j,N-1){
        if(a[j] > a[j+1]){
            swap(a[j], a[j+1]);
            res.push_back(j);
        }
    }
    cout << res.size() << endl;
    for(auto &v : res){
        cout << v+1 << " " << v+2 << endl;
    }
}