import sys

n,m = map(int,input().split())
if m == 0:
    if n == 1:
        print(1)
        sys.exit()
    elif n == 2:
        print(10)
        sys.exit()
    elif n == 3:
        print(100)
        sys.exit()

a = []
wk =[]
kai = 0
for i in range(m):
    wk = (list(map(int,input().split())))
    if wk in a:
        m -= 1
    else:
        a.append(wk)
 
a.sort()
 
for i in range(m):
    if a[i][0] == 1 and a[i][1] == 0:
        print('-1')
        sys.exit()
 
for i in range(m-1):# onajiketaga 2tuaru
    if a[i][0] == a[i+1][0]:
        print('-1')
        sys.exit()
 
for i in range(m):
    kai += (10**(n-a[i][0]))*a[i][1]
 
print(kai)