in1 = input('')
n = int(in1.split(' ')[0])
m = int(in1.split(' ')[1])
l = []
for i in range(1,n+1):
  l.append(0)

for i in range(0,m):
  in2 = input('')
  idx = int(in2.split(' ')[0])
  li = int(in2.split(' ')[1])
  l[idx-1] = li

result = 0
for i in range(0,n):
  ix = 1
  for j in range(0,(n-i-1)):
    ix *=10
  result += int(l[i])*ix
if result < 0:
  result = -1
if len(str(result)) != n and result != 0:
  result = -1
print(result)

