import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

ans = ['0']*n
for i in range(m):
    e = sc[i][0] - 1
    ans[e] = str(sc[i][1])

ans = int(''.join(ans))
if len(str(ans)) == n:
    print(ans)
else:
    print(-1)
