N, M = map(int, input().split())

ans = ['a'] * N

for m in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] == 'a' or ans[s - 1] == str(c):
        ans[s - 1] = str(c)
    else:
        print(-1)
        exit()

if ans[0] == 'a':
    ans[0] = '1'

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

ans = int(''.join(ans))
if len(str(ans)) == N:
    print(ans)
else:
    print(-1)
