N, M  = map(int,input().split())
s = [-1]*M
c = [-1]*M
for i in range(M):
  s[i],c[i] = map(int,input().split())
if N==1 and s[0]==1 and c[0]==0:
  print(0)
  exit()
arr_ans = [-1]*(N+1)
for i in range(M):
  if arr_ans[s[i]] == -1 or arr_ans[s[i]] == c[i]:
    arr_ans[s[i]] = c[i]
  else:
    print(-1)
    exit()
    
if arr_ans[1] == 0:
  print(-1)
  exit()
for i in range(1,N+1):
  if arr_ans[i] == -1:
    if i == 1:
      arr_ans[i] = 1
    else:
      arr_ans[i] = 0

_ans = [str(arr_ans[i]) for i in range(N+1)]
ans = ''.join(_ans[1:])
print(ans)
  