n,m = map(int,input().split())
ans = ""
an = [0]*n
re = []
for i in range(m):
    s,c = map(int,input().split())
    an[s-1] = c

for i in an:
    ans += str(i)
ans = int(ans)
ans = str(ans)

if len(ans) == n:
    print(ans)
else:
    print(-1)
    