n, m = list(map(int, input().split()))

d = [10] * n
r = 0

for i in range(m):
  s, c = list(map(int, input().split()))
  if d[s-1]>c:
    d[s-1]=c
  else:
    print(-1)
    exit()

if n==1:
  if d[0]==10:
    d[0] = 0
if n==2:
  if d[0]==10:
    d[0] = 1
  if d[1]==10:
    d[1] = 0
if n==3:
  if d[0]==10:
    d[0] = 1
  if d[1]==10:
    d[1] = 0
  if d[2]==10:
    d[2] = 0
        
if (r==-1):
  print(r)
else:
  dd = int(''.join(map(str, d)))
  if len(str(dd))==n:
    print(dd)
  else:
    print(-1)
