import sys

n, m = map(int, sys.stdin.readline().rstrip().split())
sc = [sys.stdin.readline().rstrip().split() for i in range(m)]
ans = ['1'] + ['0'] * (n-1)
tmp = [0] * n
for sci in sc:
    s, c = sci
    if s == '1' and c == '0':
        print(-1)
        sys.exit()
    if tmp[int(s) - 1] > 0 and ans[int(s)-1] != c:
        print(-1)
        sys.exit()
    ans[int(s)-1] = c
    tmp[int(s) - 1] += 1
# print(ans)
print(''.join(ans))