a = list(map(int,input().split()))
x = []
y = []
for i in range(a[1]):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)


for i in range(10**(a[0]-1),10**a[0]):
  s = str(i)
  flag = True
  for j in range(len(x)):
    if str(y[j]) != s[x[j]-4]:
      flag = False
      break
  if flag:
    break
      
#s = str(702)
#print(s[-1])
if flag:
  print(i)
else:
  print(-1)