#!/usr/bin/env python3

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


d = {}
for i in range(M):
    s, c = map(int, input().split())
    if s in d:
        if d[s] == c:
            continue
        else:
            print(-1)
            exit()
    else:
        d[s] = c



start = 10 ** (N-1)
end = 10 ** N

ans = -1
for i in range(start, end):
    si = str(i)
    f = True
    for s, c in d.items():
        if si[s-1] != str(c):
            f = False
            break
    if f:
        ans = i
        break

    
print(ans)
