const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')

const [N, M] = lines[0].split(' ').map(Number)
const s = []
const c = []

for (let i = 0; i < M; i++) {
  const row = lines[i + 1].split(' ').map(Number)
  s[i] = row[0] - 1
  c[i] = row[1]
}

;(() => {
  const n = Array(N).fill(null)
  for (let i = 0; i < M; i++) {
	if (n[s[i]] && n[s[i]] !== c[i]) {
      console.log(-1)
      return
    }
    n[s[i]] = c[i]
  }
  
  if (n.length > 1 && n[0] === 0) {
    console.log(-1)
    return
  }
  
  for (let i = 0; i < N; i++) {
    if (n[i] === null)  {
      n[i] = i === 0 ? 1 : 0
    }
  }
  console.log(n.join(''))
  
})()