n, m = [int(i) for i in input().split()]
res = ['0'] * n 
dic = dict()
for i in range(m):
  j, k = input().split()
  if j not in dic.keys():
    dic[j] = k
  else:
    if dic[j] != k:
      print('-1')
      exit()

if '1' in dic.keys():
  if dic['1'] == '0':
    if n == 1:
      print('0')
      exit()
    else:
      print('-1')
      exit()
      
res[0] = '1'
for k, v in dic.items():
  res[int(k)-1] = v
print(''.join(res))