N, M = map(int,input().split())
s_c = [list(map(int, input().split())) for i in range(M)]
X = [-1]*N
for i in range(M):
    X[s_c[i][0] - 1] = s_c[i][1]
x = True
for i in range(N):
    u = True
    for j in range(M):
        if s_c[j][0] - 1 == i:
            u = False
            break
    if u:
        if i == 0:
            X[i] = 1
        else:
            X[i] = 0
for i in range(M):
    if s_c[i][0] == 1 and s_c[i][1] == 0 and N != 1:
        x = False
        break
if M >= 2:
  for i in range(M):
     for j in range(i+1,M):
        if s_c[i][0] == s_c[j][0]:
            if s_c[i][1] != s_c[j][1]:
                x = False
if x:
    for i in range(N):
        print(X[i], end= "")
    print()
else:
    print(-1)