import sys
n,m = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(m)]
ls.sort()
di=[[] for _ in range(n)]
for i in range(m):
    di[ls[i][0]-1].append(ls[i][1])
for j in range(m):
    if len(di[j]) >=1:
        di[j] = list(set(di[j]))
        if 0 in di[j]:
            print(-1)
            sys.exit()
        if len(di[j]) > 1:
            print(-1)
            sys.exit()
    elif len(di[j]) == 0:
        if j == 0:
            di[j] = [1]
        else:
            di[j] = [0]
ans = []
for l in range(n):
    ans += di[l]
for k in range(len(ans)):
    ans[k] = str(ans[k])
if ans != []:
    print("".join(ans))
    sys.exit()
if n == 1:
    print(0)
else:
    print("1"+"0"*(n-1))
    