#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
SC = [list(map(int,input().split())) for i in range(m)]
N = [-1]*n
for i in range(m):
  s,c = SC[i]
  s -=1
  if (N[s] != -1 and N[s] != c):
    print(-1);exit()
  else:
    N[s] = c
if n != 1 and N[0] == 0:
  print(-1);exit()
if N[0] == -1:
  N[0] = 1
for i in range(1,len(N)):
  if N [i] == -1:
    N[i] = 0
print(*N,sep="")

  