n, m = map(int, input().split())
s = []
c = []
number = 100000
for i in range(m):
    x, y = map(int, input().split())
    s = s + [x]
    c = c + [str(y)]
for i in range(1000):
    count = 0
    i_list = list(str(i))
    if len(i_list) == n:
        for j in range(m):
            if i_list[s[j] - 1] != c[j]:
                count += 1
        if count == 0:
            number = i
            break
print(number)                 
