n, m = map(int, input().split())
lst = [-1] * n
flag = False
for i in range(m):
  s, c = map(int, input().split())
  if c != lst[s-1] or (n != 1 and s == 1 and c == 0):
    flag = True
  lst[s-1] = c
if flag:
  print(-1)
else:
  for i in range(n):
    if lst[i] == -1:
      lst[i] = '1' if n != 1 and i == 0 else '0'
    else:
      lst[i] = str(lst[i])
  print(''.join(lst))