n,m =map(int,input().split())
if n <m:
    print(-1)
else:
    l= [11]*n
    for _ in range(m):
        s,c=map(int,input().split())
        if l[s-1] != str(c) and l[s-1] != 11:
            print(-1)
            exit(0)
        else:
            l[s-1] = str(c)
    for index,i in enumerate(l):
        if i == 11:
            l[index] = '0'
    if n>=2:
        if l[0] == '0' or l[0]==l[1]=='0':
            print(-1)
            exit(0)
    print(''.join(l))
