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] = 'N'


if l[0] == 'a':
    l[0] = 1
    
if n == 1 and l[n] =='a':
    print('0')
else:
    if l[0] ==0:
        l[n] = 'N'
    if l[n] == 'N':
        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)