N, M = [int(_) for _ in input().split()]
X = [[int(_) for _ in input().split()] for _ in range(M)]

for i in range(10 ** (N-1), 10 ** N):
    v = str(i)
    f = True
    for s, c in X:
        if int(v[s-1]) != c:
            f = False
            continue
    if f:
        print(v)
        exit(0)
print(-1)
