def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


N, M = MI()
C = [tuple(MI())for _ in range(M)]

for i in range(10 ** (N - 1), 10 ** N):
    num = str(i)
    flg = True
    for s, c in C:
        if num[s - 1] != str(c):
            flg = False
    if flg:
        print(num)
        exit(0)
print(-1)
