n,m = map(int, input().split())

if m==0:
    print("-1")

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

# print(ans)

if ans[0]=="0" or flag==1:
    print("-1")
    exit()

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

# print(ans)
ans = "".join(ans)
print(ans)
