n,m = map(int, input().split())
ans = [None] *n
f= 0
for i in range(m):
    s,c = map(int, input().split())
    if (ans[s-1] != None) and (ans[s-1] != c):  # 重複
        f = 1
    ans[s-1] = c

if f == 1:
    print('-1')
    exit()
elif ans[0] == None:
    ans[0] == 1
elif ans[0] == 0 and len(ans) != 1:
    print('-1')
    exit()

for i in range(n):
    if ans[i] == None:
        ans[i] = 0
print(''.join(map(str, ans)))

