function main(input) {
  const inputs =input.split('\n')
  const [N, M] = inputs[0].split(' ').map(Number)
  let max = N
  const sc = inputs.slice(1).map(e => {
    [s, c] = e.split(' ').map(Number)
    return [s, c]
  })
  for (let n = Math.pow(10, max - 1) - 1 ; n < 1000; n++) {
    let ok = true
    // console.log('n:', n)
    for(let i = 0; i < M; i++) {
      // console.log('sc[i]:', sc[i][0], 'str:', String(n)[sc[i][0]-1], 'c:', sc[i][1])
      if (String(n)[sc[i][0]-1] != sc[i][1]) {
        ok = false
        break
      }
    }
    if (ok) {
      console.log(n)
      return
    }
  }
  console.log('-1')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())
