import sys
input = sys.stdin.readline

N, M  = (int(i) for i in input().split())
SM = [[int(i) for i in input().split()] for i in range(M)]

ans = [-1]*N


for i in range(M):
    if ans[SM[i][0]-1] == -1 or ans[SM[i][0]-1] == SM[i][1]:
        ans[SM[i][0]-1] = SM[i][1]
    else:
        print(-1)
        exit()

for i in range(N):
    if ans[i] == -1:
        if i == 0:
            ans[i] = 1
        else:
            ans[i] = 0

#if ans[0] == 0:
 #   print(-1)
 #   exit()

fans = str(int("".join(map(str, ans))))
#print(len(str(fans)))
#print(int(fans))

if len(fans) != N:
    print(-1)
    exit()
else:
    print(fans)
