n, m = map(int, input().split())
ans = [-1] * n

for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    c = str(c)
    
    if ans[s] == -1 :
        ans[s] = c
    
    elif ans[s] == c :
        continue
    
    else:
        print(-1)
        break
        
if ans[0] == "0":
    if n == 1:
        print("0")
    else:
        print(-1)

elif ans[0] == -1 :
    if n == 1:
        print("0")
    else:
        ans[0] = "1"

for j in range(1, n):
    if ans[j] == -1 :
        ans[j] = "0"

print("".join(ans))