# スペース区切りの整数入力
N,M = map(int, input().split())

s = []
c = []
snum = '0' * N

for i in range(M):
    ss,cc = map(int, input().split())
    s.append(ss)
    c.append(cc)

for i in range(M):
    snum = snum[:s[i]-1] + str(c[i]) + snum[s[i]:] 

if N == len(str(int(snum))):
    print(snum)
else:
    print(-1)

