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

N,M=MI()

sc=[]

for i in range(M):

    x,y=MI()

    sc.append((x,y))

for i in range(0,10**3):

    h=str(i)

    if len(h)==N:

        if all([h[s-1]==str(c) for (s,c) in sc]):

            print(i)

            exit()

print((-1))

        
def mi():return list(map(int,input().split()))

n,m=mi()

sc=[]

for i in range(m):

  s,c=mi()

  sc+=(s,c),

  

for i in range(0,999+1):

  h=str(i)

  if len(h)==n:

    if all([h[s-1]==str(c) for s,c in sc]):

      print(i)

      exit()

print((-1))    
def MI():
    return list(map(int, input().split()))


N, M = MI()
sc = []
for i in range(M):
    x, y = MI()
    sc.append((x, y))
for i in range(0, 10**3):
    h = str(i)
    if len(h) == N:
        if all([h[s - 1] == str(c) for (s, c) in sc]):
            print(i)
            exit()
print((-1))

def mi():
    return list(map(int, input().split()))


n, m = mi()
sc = []
for i in range(m):
    s, c = mi()
    sc += ((s, c),)
for i in range(0, 999 + 1):
    h = str(i)
    if len(h) == n:
        if all([h[s - 1] == str(c) for s, c in sc]):
            print(i)
            exit()
print((-1))

-def MI(): +def mi(): -N, M = MI() +n, m = mi() -for i in range(M): -    x, y = MI() -    sc.append((x, y)) -for i in range(0, 10**3): +for i in range(m): +    s, c = mi() +    sc += ((s, c),) +for i in range(0, 999 + 1): -    if len(h) == N: -        if all([h[s - 1] == str(c) for (s, c) in sc]): +    if len(h) == n: +        if all([h[s - 1] == str(c) for s, c in sc]):