import java.util.Scanner
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val m = scn.nextInt()
	val arr = IntArray(n){-1}
	repeat(m){
		val s = scn.nextInt()-1
		val c = scn.nextInt()
		if (arr[s]!=-1 && arr[s]!=c) impos()
		arr[s] = c
	}
	if (arr[0]==0 && n!=1) impos()
	if (arr[0]==-1) arr[0] = if (n==1) 0 else 1
	for (i in 1 until arr.size){
		if (arr[i]==-1) arr[i] = 0
	}
	print(arr.joinToString(separator = ""))
}

fun impos(){
	print(-1)
	exitProcess(0)
}