package boj;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class boj_11650 {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
int count = Integer.parseInt(r.readLine());
List<List<Integer>> points = new ArrayList<>();
put(r, count, points);
List<List<Integer>> collect = sorted(points);
print(w, collect);
w.flush();
}
private static void put(BufferedReader r, int count, List<List<Integer>> points) throws IOException {
for (int i = 0; i < count; i++) {
List<Integer> point = Arrays.stream(r.readLine().split(" "))
.map(Integer::parseInt)
.collect(Collectors.toList());
points.add(point);
}
}
private static List<List<Integer>> sorted(List<List<Integer>> points) {
List<List<Integer>> collect = points.stream()
.sorted(Comparator.comparingInt((List<Integer> point) -> point.get(0))
.thenComparingInt(point -> point.get(1))).collect(Collectors.toList());
return collect;
}
private static void print(BufferedWriter w, List<List<Integer>> collect) throws IOException {
for (List<Integer> i : collect) {
w.write(i.get(0) + " " + i.get(1));
w.newLine();
}
}
}