"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const cities = arg.slice(1, M + 1);
    let data = [];
    
    for(let i in cities) {
        let tempPrefecture = parseInt(cities[i].split(" ")[0]);
        let tempBirth      = parseInt(cities[i].split(" ")[1]);
        
        data.push({
            prefecture: tempPrefecture,
            birth:      tempBirth,
            index:      i
        })
    }
    
    data.sort((a,b)=>a.prefecture - b.prefecture);
    data.sort((a,b)=>a.birth - b.birth);
    
    console.log(JSON.stringify(data));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));