N, M = list(map(int, input().split()))

p = {}
flag=True
for _ in range(M):
    s,c = list(map(int, input().split()))
    if s in p and p[s]!=c:
        flag=False
    p[s] = c

if 1 in p:
    if p[1]==0:
        flag=False
        
if flag:
    ans = ''
    for i in range(1, N+1):
        if i in p:
            ans+=str(p[i])
        elif i==1:
            ans+='1'
        else:
            ans+='0'
    print(int(ans))
else:
    print(-1)