#include #include #include #include using namespace std; int main(){ int n, a, b; cin >> n; for(int i = 0; i < n - 1; ++i){ cin >> a >> b; } vector< pair, int > > p; for(int i = 0; i < n; ++i){ cin >> a >> b; p.push_back(make_pair(make_pair(a, b), i)); } cout << p.size() << endl; sort(p.begin(), p.end(), [](const pair,int>& a, const pair,int> & b) { if (a.first.first < b.first.first) { return true; } else { return a.first.second < b.first.second; } }); for(int i = 0; i < n - 1; ++i){ cout << p.at(i).second << " " << p.at(i + 1).second << endl; //if(i == n - 2) // cout << endl; //else // cout << " "; } return 0; }