'use strict'
function main(input) {
  input = input.trim().split('\n')
  input.shift()
  let count = []
  let aMap = new Map
  input = input
    .map(c => {
      let arr = c.split(' ').map(w => w - 0)
      if (count[arr[0]] === undefined) count[arr[0]] = []
      count[arr[0]].push(arr[1])
      aMap.set(arr[1], '')
    })
  count.forEach((v, i) => {
    v.sort((a, b) => a - b)
    v.forEach((y, j) => {
      let id = ('000000' + i).slice(-6)
      id += ('000000' + (j+1)).slice(-6)
      aMap.set(y, id)
    })
  })
  aMap.forEach(v => console.log(v))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
