n, m = input().split()

n = int(n)
m = int(m)

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = input().split()

s = [int(i) for i in s]

for i in range(10 ** n - 10 ** (n - 1)):
    found_data = True
    word = str(i + 10 ** (n - 1))
    for j in range(m):
        if word[s[j]-1] == c[j]:
            pass
        else:
            found_data = False
            break
    if(found_data):
        print(word)
        break
if not (found_data):
    print("-1")
