#include #include #include int main(){ int n, k; std::cin >> n >> k; int amida[100]; for(int i = 0; i < n; ++i) amida[i] = i; for(int i = 0; i < k; ++i){ int from, to; std::cin >> from >> to; std::swap(amida[from - 1], amida[to - 1]); } int result[100]; for(int i = 0; i < n; ++i){ int num; std::cin >> num; result[num - 1] = i; } std::vector > v; for(int i = 0; i < n; ++i){ int j = 0; while(result[i] != amida[j]) j++; while(result[i] != amida[i]){ std::swap(amida[j], amida[j - 1]); v.push_back(std::make_pair(j - 1, j)); j--; } } std::cout << v.size() << std::endl; for(int i = 0; i < v.size(); ++i){ std::cout << v[i].first + 1<< " " << v[i].second + 1 << std::endl; } return 0; }