hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

s_list = []
c_list = []

for i in range(M):
  hoge = input().split()
  s_list.append(int(hoge[0]))
  c_list.append(int(hoge[1]))
num = [10] * M

for i in range(len(s_list)):
  if s_list[i] == 1 and c_list[i] == 0:
    num[s_list[i]-1] = 100
  elif num[s_list[i]-1] == 10:
    num[s_list[i]-1] = c_list[i]
  elif num[s_list[i]-1] != c_list[i]:
    num[s_list[i]-1] = 100

if 100 in num:
  print(-1)
elif 10 in num:
  for i in range(len(num)):
    if num[i] == 10:
      num[i] = 0
  for i in range(len(num)):
    print(num[i], sep="", end="")
else:
  for i in range(len(num)):
    print(num[i], sep="", end="")