N, M = [int(_) for _ in input().split()]
SC = [[int(_) for _ in input().split()] for _ in range(M)]
digit = [-1] * (N + 1)
ok = True
for s, c in SC:
    if digit[s] == -1:
        digit[s] = c
    elif digit[s] != c:
        ok = False
if digit[1] == 0:
    ok = False
for i in range(1, N + 1):
    if digit[i] == -1:
        digit[i] = 1 if i == 1 else 0
if ok:
    print(*digit[1:], sep='')
else:
    print(-1)
