# -*- coding: utf-8 -*-
import sys
n,m=map(int, input().split())

if m == 0:
    if n == 1:
        print("0")
        sys.exit(0)
    res = "1"
    for i in range(2,n+1):
        res += "0"
    print(res)
    sys.exit(0)
i=0
lst = {}
f = 0
while i < m: 
    s,c = map(int, input().split())
    #先頭が0のケース
    if c == 0 and s == 1 and n >= 2:
        f = 1
    if s not in lst:
        lst[s]=c
    #key重複のときはエラー
    elif c != lst[s]:
        f = 1
    i+=1

if f == 1:
    print(-1)
    sys.exit(0)
    
res = ""
for i in range(1,n+1):
    if i in lst:
        res += str(lst[i])
    else:
        res += "0"
print(res)
