import sys

N, M = map(int, input().split())
S = [-1,-1,-1]
if N == 2:
    S[0] = 0
elif N == 1:
    S[0] = 0
    S[1] = 0

for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    #print(S)
    if S[s] == -1 or S[s] == c:
        S[s] = c
    else:
        print("-1")
        sys.exit()

for i in range(N):
    if S[i] == -1:
        if (N == 3 and i == 0) or (N == 2 and i == 1):
            S[i] = 1
        else:
            S[i] = 0
            
if (N == 3 and S[0] == 0) or (N == 2 and S[1] == 0):
    print("-1")
    sys.exit()

for i in range(N):
    print(S[i],end="")