n, m = map(int, input().split())
s, c = [], []
for i in range(m):
    a, b = map(int, input().split())
    s.append(a), c.append(b)
loop = True

for i in range(0, 10 ** n):
    string = str(i)
    if len(string) != n:
        continue
    for j in range(m):
        if string[s[j] - 1] != str(c[j]):
            break
        if j == m - 1:
            print(string)
            loop = False
    if loop == False:
        break

if loop == True:
    print('-1')
