N, M = map(int,input().split())
S = []
C = []
flag = True
for i in range(M):
    s,c = map(int,input().split())
    if s in S:
        if C[S.index(s)] != c:
            flag = False
            break
    if s == 1 and N > 1:
        if c == 0:
            flag = False
            break
    S.append(s)
    C.append(c)

if flag:
    n = [1] + [0 for i in range(N - 1)]
    for i in range(len(S)):
        n[S[i]-1] = C[i]
    print(*n, sep="")
else:
    print("-1")