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

ans = ['a' for i in range(n)]

for i in range(m):
    s, c = input().split()
    s = int(s) - 1
    if ans[s] == 'a' or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        break
else:
    for i in range(n):
        if i == 0 and ans[i] == 'a':
            ans[i] = '1'
        elif ans[i] == 'a':
            ans[i] = '0'
    a = ''
    for _ in ans:
        a += _
    if len(str(int(a))) != n:
        print(-1)
    else:
        print(a)
