n,m = map(int,input().split())
s = list(list(map(int,input().split())) for i in range(m))
x = [-1]*n
b = True
ans = -1
for i in range(m):
    if x[s[i][0]-1] == -1 or x[s[i][0]-1] == s[i][1]:
        x[s[i][0]-1] = s[i][1]
    else:
        b = False
for j in range(n):
    if x[j] == -1:
        if j == 0:
            x[j] = 1
        else:
            x[j] = 0
if len(x) != 1 and x[0] == 0:
    b = False
ans = ''.join([str(c) for c in x]) if b else -1
print(ans)