n, m = map(int, input().split())
digits = '1' if n == 1 else ['1'] + (['0'] * (n - 1))
f = False
for _ in range(m):
    s, c = input().split()
    s = int(s) - 1
    if digits[s] == '0' or digits[s] == c:
        digits[s] = c
    else:
        f = True

ans = ''.join(digits)
f = f or len(str(int(ans))) != n
print(-1 if f else ans)