N,M = map(int,input().split())
C = [-1] * N
flag = True
x = 1
for i in range(M):
  s, c = map(int, input().split())
  if C[s - 1] == -1 or C[s - 1] == c:
    C[s - 1] = c
  else:
    flag = False

if C[0] == 0:
  flag = False
if N == 1 and C[0] == 0:
  flag = True 
  x = 0
if flag == False:
  print(-1)
else:
  for i in range(N):
    if C[i] == -1 or C[i] == 0:
      if i == 0:
        C[i] = 1
      else:
        C[i] = 0
  ans = "".join([str(n) for n in C])
  
  print(int(ans * x))
  