def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  sc=[list(map(int,input().split())) for _ in range(m)]
  l=[0.0]*n
  for i in range(m):
    if type(l[sc[i][0]-1])==float:
      l[sc[i][0]-1]=sc[i][1]
  if len(''.join([str(int(i)) for i in l]))==n and int(''.join([str(int(i)) for i in l]))>=pow(10,n-1):
    print(int(''.join([str(int(i)) for i in l])))
  else:
    print(-1)
  
if __name__ == '__main__':
    main()