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

# 初期値の作成
ans = ['0'] * n

# すり替え
for i in range(m):
  s, c = map(int, input().split())
  ans[s-1] = str(c)

ans = "".join(ans)
if (ans[0] == '0'):
  print('-1')
else:
  print(ans)