N, M = map(int, input().split())
sc = []
ans = [-1] * N

for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        continue
    sc.append([s, c])

sc.sort(key=lambda x: x[1], reverse=True)

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

if ans[0] == -1:
    print(-1)

else:
    for a in range(N):
        if ans[a] == -1:
            ans[a] = 0
    print("".join(map(str, ans)))