function Main(input) {

    input = input.split("\n")
    var n = parseInt(input[0],10);
    var list = new Array(n);
    var list2 = new Array(n);

    for(var i = 1; i < n+1; i++){
        var a = input[i].split(" ")
        list[i-1] = a[0];
        list2[i-1] = a[1];
    }
    list.sort()
    console.log(list);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));