n,m = map(int,input().split())
s = [0]*m
c = [0]*m
flag = 1
q = [''] * n
ans = ''

for i in range(m):
    s[i] , c[i] = map(int,input().split())
    
for i in range(m):
    if q[s[i]-1] == '' or q[s[i]-1] == str(c[i]):
        q[s[i]-1] = str(c[i])
    else:
        flag = 0

if q[0] == '0' and n != 1:
    flag = 0
        
for i in range(n):
    if q[i] == '':
        if i == 0 and m != 0:
            q[i] = 1
        else:
            q[i] = 0
    ans += str(q[i])
    
if flag == 1:
    print(ans)
elif flag == 0:
    print("-1")