import sys
N,M = map(int,input().split())
if N > 1 and M == 0:
  print(10**(N-1))
  sys.exit()
  
num = [0]*N
flag = 0
for i in range(M):
  si,ci = map(int,input().split())
  if N > 1 and si == 1 and ci == 0:
    print(-1)
    sys.exit()
  if num[si-1] != 0 and ci != num[si-1]:
    print('-1')
    sys.exit()
  num[si-1] = ci
if num[0] == 0:  
  num[0] = 1
n = int(''.join(map(str,num)))
print(n)
          