import math
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
sc = [SL() for i in range(M)]

ans = ["-1"]*N
for s,c in sc:
  s = int(s)
  if s == 1 and c == "0":
    print(-1)
    exit()
  if ans[s-1] == "-1":
    ans[s-1] = c
  else:
    if ans[s-1] != c:
      print(-1)
      exit()

if ans[0] == "-1":
  ans[0] = "1"
for i in range(1,N):
  if ans[i] == "-1":
    ans[i] = "0"

print("".join(ans))