n, m = map(int, input().split())
L = [-1]*n
for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if s == 0 and c == 0:
        if n != 1:
            print(-1)
            exit()
        else:
            L[s] = c
    if L[s] != -1 and L[s] != c:
        print(-1)
        exit()
    L[s] = c

#print(L)
ans = ''
for i in range(n):
    if L[i] == -1:
        if i == 0:
            ans += '1'
        else:
            ans += '0'
    else:
        ans += str(L[i])
print(ans)
