N, M = map(int, input().split())

ans = [-1 for i in range(N)]
flag = False
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] == c:
        continue
    else:
        flag = True
        break

if len(ans) > 1 and ans[0]:
    ans[0] = 1

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

if len(ans) > 1 and ans[0] == 0:
    flag = True

if flag:
    print(-1)
else:
    print("".join([str(c) for c in ans]))
