import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); PriorityQueue que = new PriorityQueue<>((o1, o2) -> { if (o1.x != o2.x) { return o1.x - o2.x; } return o1.y - o2.y; }); for (int i = 0; i < n; i++) { String[] sa = br.readLine().split(" "); Obj o = new Obj(); o.i = i; o.x = Integer.parseInt(sa[0]); o.y = Integer.parseInt(sa[1]); que.add(o); } br.close(); PrintWriter pw = new PrintWriter(System.out); pw.println(n / 2); while (que.size() >= 2) { Obj o1 = que.poll(); Obj o2 = que.poll(); pw.println((o1.i + 1) + " " + (o2.i + 1)); } pw.flush(); } static class Obj { int i, x, y; } }