n, m = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(m)]
if m == 0:
    if n == 1:
        print(0)
    else:
        print(10**(n-1))
else:
    ans = -1
    i = 10**(n-1)
    while (ans == -1) & (i < 10**n):
        s = 0
        for j in lis:
            if str(i)[j[0]-1] == str(j[1]):
                s += 1
            else:
                s += 0
        if s == m:
            ans = i
        else:
            i += 1
    print(ans)