n, m = map(int, input().split())
ans = []
tmp = True
for i in range(n): ans.append('a')

for i in range(m):
    s, c = map(int, input().split())

    if s == 1 and c == 0:
        tmp = False
        break

    if ans[s - 1] == 'a':
        ans[s - 1] = str(c)
    else:
        if ans[s - 1] != str(c):
            tmp = False
            break

if ans[0] == 'a': ans[0] = '1'
for i in range(n):
    if ans[i] == 'a': ans[i] = '0'

if tmp:
    for i in range(n):
        print(ans[i], end='')
    print()
else:
    print(-1)

