nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
slist = []
clist = []
for i in range(m):
  sc = [int(i) for i in input().split()]
  slist.append(sc[0])
  clist.append(sc[1])

fl = 0
if (n == 1):
  if (slist[0] == 1 and clist[0] == 0):
    print('-1')
    fl = 1

answerlist = ['-1' for i in range(n)]
for (i,s), c in zip(enumerate(slist),clist):
  if (c == 0 and s == 1):
    print('-1')
    break
    fl = 1
  if (answerlist[s-1] != '-1' and answerlist[s-1] != str(c)):
    print('-1')
    break
    fl = 1
  answerlist[s-1] = str(c)
for i in range(n):
  if (answerlist[i]) == '-1':
    if (i == 0):
      answerlist[i] = '1'
    else:
      answerlist[i] = '0'
if fl == 1:
	print("".join(answerlist))