#!/usr/bin/ruby N=gets.to_i A=[*1..N] gets.to_i.times{ a=gets.to_i A[a-1],A[a]=A[a],A[a-1] } B=gets.split.map(&:to_i) R=[] (N-1).downto(1){|i| t=B[i] 1.upto(i){|j| if A[j-1]==t R<<[j,j+1] A[j-1],A[j]=A[j],A[j-1] end } } p R.size puts R.map{|e|'%d %d'%e}