n, m = map(int, input().split())

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

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

ans = False
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if x[s[i]-1] == str(c[i]):
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break

if ans == False:
    print(-1)
