import std.stdio, std.string, std.array, std.conv, std.range, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] a = new int[n], b = new int[n];
    foreach (i; 0 .. n) {
        int[] tmp = readln.chomp.split.to!(int[]);
        a[i] = tmp[0], b[i] = tmp[1];
    }
    zip(a, b).sort!((t1, t2) => t1 < t2);
    foreach (i; 0 .. n) {
        writeln(a[i], " ", b[i]);
    }
}
