#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().strip().split())
  scs = [10]*n

  for _ in range(m):
    s, c = map(int, input().strip().split())
    s -= 1
    if scs[s] != 10 and scs[s] != c:
      print(-1)
      return
    scs[s] = c

  if n>1 and scs[0] == 0:
    print(-1)
    return

  if n==1 and scs[0] == 0:
    print(0)
    return

  num = ['0'] * n
  for i in range(len(scs)):
    if scs[i] != 10:
      num[i] = str(scs[i])
    elif i == 0:
      num[i] = '1'
    else:
      num[i] = '0'
  print(int(''.join(num)))

if __name__=='__main__':
  main()

