n,m = map(int,input().split())
ls = []
for i in range(m):
    ls.append( list(map(int,input().split())) )
w = ["d"]*n
flag = False
for s,c in ls:
    if w[s-1] == "d":
        w[s-1] = str(c)
    elif w[s-1] != str(c) :
        flag = True
        break

for i in range(1,n):
    if w[i] == "d" :
        w[i] = "0"
if w[0] == "0":
    flag = True
elif w[0] == "d":
    w[0] = "1"

########
if flag:
    print(-1)
else :
    print("".join(w))
