n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
s = [0] * n
for i in sc:
    s[i[0]-1] = str(i[1])
ans = ""
first = True
for i in s:
    if i == 0 and first:
        ans += str(1)
        first = False
        continue
    ans += str(i)
if len(ans) != 1 and ans[0] == '0':
    print(-1)
else:
    print(ans)