# c = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# a = [list(map(int, list(input()))) for i in range(n)]
n, m = map(int, input().split())
l = []

ret = list("0" * n)

for i in range(0, m):
    v = list(map(int, input().split()))
    l.append(v)

for j in l:
    ret[j[0] - 1] = str(j[1])

if len(ret) != 1 and ret[0] == '0':
    print(-1)
else:
    print("".join(ret))

