#include <vector>
#include <utility>

void solve(int N, int M, std::vector<std::pair<int, int>> moves);
std::pair<int, int> move(int i, int j);