printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
d = [-1]*(n+1)
for i in range(m):
    s,c = inm()
    if d[s]>=0 and d[s]!=c:
        print(-1)
        exit()
    d[s] = c
if d[1]==0:
    print(-1)
    exit()
if d[1]<0:
    d[1] = 1
for i in range(2,n+1):
    if d[i]<0:
        d[i] = 0
for i in range(1,n+1):
    printn(d[i])
print('')
