import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void solve() { Scanner sc=new Scanner(System.in); PrintWriter pw=new PrintWriter(System.out); HashMap points=new HashMap<>(); int N=sc.nextInt(); if (!(1 <= N && N <= 2e5)) throw new AssertionError(); int[] X=new int[N]; int[] Y=new int[N]; for (int i=0;i que=new ArrayDeque<>(); for (int i=0;i= 0 && !que.isEmpty()){ State state = que.pollFirst(); if (points.containsKey(time)) { if (state.col != -1) { System.out.println(-1); return; } int[] xi=points.get(time); state.col = xi[1]; state.height = xi[0]; } else { if (state.col != -1) state.height--; } if (state.height == 0) { ans[state.col] = time; } else { que.addLast(state); } --time; } if (!que.isEmpty() || (time > 0 && que.isEmpty())) { System.out.println(-1); return; } for (int i=0;i