n, m = map(int, input().split())
num = [-1 for _ in range(n)]
for i in range(m):
    si, ci = map(int, input().split())
    if num[si-1] == -1 or num[si-1]==ci:
        num[si-1] = ci
    else:
        print(-1)
        exit()

ans = ''
for i in range(n):
    if num[i] != -1:
        if i == 0 and num[i] == 0:
            print(-1)
            exit()
        else:
            ans += str(num[i])
    else:
        if i == 0:
            ans += '1'
        else:
            ans += '0'

print(ans)