n,m = map(int, input().split())
M = [map(int,input().split()) for i in range(m)]
N = []
for i in range(n):
  N.append(-1)

for i,j in M:
  if N[i-1] == -1:
    N[i-1] = j
  elif N[i-1] == j:
    continue
  else:
    N[i-1] = -7
    break
flg=True
for i in range(n):
  if N[i-1] == -7:
    flg=False
  if N[i-1] == -1:
    if i-1 == 0:
      N[i-1] = 1
    else: N[i-1] = 0
if N[0] == 0: flg=False 
if flg:print(*N, sep="")
else: print(-1)