N,M = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(M)]

ans = [0]*N

lst = list(map(list,set(map(tuple,lst))))
#print(lst)

if len(lst) == 0:
    ans[0] = 1

for i in range(len(lst)):
    ans[lst[i][0]-1] = lst[i][1]

#print(ans)

ans_r = []
for _ in ans:
    ans_r.append(str(_))
ans = ''.join(ans_r)

if ans[0] == '0':
    ans = -1

dct = {}
for i in range(len(lst)):
    if lst[i][0] in dct:
        #dct[lst[i][0]] += 1
        ans = -1
    else:
        dct[lst[i][0]] = 1

print(ans)

