n, m = map(int, input().split())

num = [str(x) for x in range(10**(n-1), 10**n)]
judge = [True]*len(num)

for i in range(m):
  s, c = map(int, input().split())
  for j in range(len(num)):
    if num[j][s] != c:
      judge[j] = False
      
ans = -1
for i in range(len(num)):
  if judge[i] == True:
    ans = num[i]
    break

print(ans)