#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;
using ld = long double;
using pr = pair<int, int>;
const int MOD = 1e9+7, MAXA = 1e6;
int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
vector<int> cur(n);
for (int i = 0; i < n; i++) cur[i] = i;
vector<vector<int>> srt(n), poss(n, vector<int>(n));
for (int i = n-1; i >= 0; i--) {
swap(cur[x[i]], cur[y[i]]);
srt[i] = cur;
for (int j = 0; j < n; j++) {
poss[i][cur[j]] = j;
}
}
vector<int> pos(n), curr(n);
for (int i = 0; i < n; i++) {
pos[s[i]] = i; // where a color resides
curr[i] = s[i]; // holds the color of a point
}
for (int i = 0; i < n; i++) {
p[i] = pos[i];
q[i] = poss[i][i];
swap(pos[i], pos[curr[poss[i][i]]]);
swap(curr[p[i]], curr[q[i]]);
}
return n;
}