n,m = map(int,input().split())

l = ['a']*(n+1)
for i in range(m):
    s,c = map(int,input().split())
    if l[s-1] == 'a':
        l[s-1] = c
    else:
        if l[s-1] != c:
            l[n] = 1

if l[0] == 0:
    l[n] = 1

if l[0] == 'a':
    l[0] = 1
    
if l[n] == 1:
    print('-1')
    
else:
    for i in range(n):
        if l[i] == 'a':
            l[i] = 0
    del l[-1]
    ans = map(str,l)
    ans = ''.join(ans)
    print(ans)