export {};
const input: string[] = require("fs").readFileSync(0,"utf8").toString().trim().split('\n');
let arr:[number, number][] = [];
for(let i=1; i<=Number(input[0]); i++){
    let [x, y] = input[i].split(' ').map(Number);
    arr.push([x,y]);
}
arr.sort((a,b)=>{
    if(a[0]!==b[0]) return a[0] - b[0];
    else return a[1]-b[1];
})

arr.forEach(v => console.log(v[0],v[1]));