import sys

N, M = list(map(int, input().split()))

ans = [None] * N

for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    
    if not ans[s] is None and ans[s] != c: print(-1); sys.exit()
    ans[s] = c

if ans[0] == 0: print(-1); sys.exit()
if ans[0] is None: ans[0] = 1
for i in range(N):
    if ans[i] is None: ans[i] = 0
print(''.join(map(str, ans)))