import collections
n, m = map(int, input().split())
sc = list()
ans=['1']+['0']*(n-1) 
for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1]!='0' and ans[s-1]!=str(c) and s!=1:
        print(-1)
        exit()
    elif s==1 and c==0:
        print(-1)
        exit()
    ans[s-1]=str(c)

print(int(''.join(ans)))