n, m = map(int, input().split())
ans = {}

for k in range(1,n+1):
    ans[k] = "x"


for i in range(m):
    s, c = map(int, input().split())
    ans[s] = c

#
# print(ans)
if ans[1] != "x" and ans[n] != "x":
    num = int(ans[1]) * (10**(n-1)) + int(ans[n])
    for j in range(2, n):
        if ans[j] != "x":
            num += int(ans[j]) * (10**(n-j))
    print(num)
else:
    print(-1)
