import math


n,m = map(int,input().split())
S = []
C = []
for i in range(m):
    s,c = map(int,input().split())
    S.append(s-1)
    C.append(c)

max_value = 10 ** n
min_value = 10 ** (n-1)


def check(s):
    for i in range(len(S)):
        if(len(s)<=S[i]):
            return False
        if(int(s[S[i]])!=int(C[i])):
            return False
    return True


def solve():
    for i in range(min_value,max_value):
        s = str(i)
        if check(s):
            return i
    return -1


print(str(solve()))
