def check(x):

  if len(str(x))!=N:

    return False

  for i in range(M):

    if str(x)[S[i]]!=str(C[i]):

      return False

  return True



N,M=list(map(int,input().split()))

S=[]

C=[]

for i in range(M):

  s,c=list(map(int,input().split()))

  s-=1

  S.append(s)

  C.append(c)

#print(S,C)

for i in range(1000):

  if check(i):

    print(i)

    exit()   

print((-1))    
N,M=list(map(int,input().split()))

#SC=[s,c for input().split() in range(M)]

SC=[list(input().split()) for i in range(M)]

'''

SC=[]

for i in range(M):

  SC.append((input().split()))

'''

def check(x):

  x=str(x)

  if len(x)!=N:

    return False

  for s,c in SC:

    if x[int(s)-1]!=c:

      return False

  return True

for i in range(1000):

  if check(i):

    print(i)

    exit()

print((-1))
def check(x):
    if len(str(x)) != N:
        return False
    for i in range(M):
        if str(x)[S[i]] != str(C[i]):
            return False
    return True


N, M = list(map(int, input().split()))
S = []
C = []
for i in range(M):
    s, c = list(map(int, input().split()))
    s -= 1
    S.append(s)
    C.append(c)
# print(S,C)
for i in range(1000):
    if check(i):
        print(i)
        exit()
print((-1))

N, M = list(map(int, input().split()))
# SC=[s,c for input().split() in range(M)]
SC = [list(input().split()) for i in range(M)]
"""
SC=[]
for i in range(M):
  SC.append((input().split()))
"""


def check(x):
    x = str(x)
    if len(x) != N:
        return False
    for s, c in SC:
        if x[int(s) - 1] != c:
            return False
    return True


for i in range(1000):
    if check(i):
        print(i)
        exit()
print((-1))

+N, M = list(map(int, input().split())) +# SC=[s,c for input().split() in range(M)] +SC = [list(input().split()) for i in range(M)] +""" +SC=[] +for i in range(M): +  SC.append((input().split())) +""" + + -    if len(str(x)) != N: +    x = str(x) +    if len(x) != N: -    for i in range(M): -        if str(x)[S[i]] != str(C[i]): +    for s, c in SC: +        if x[int(s) - 1] != c: -N, M = list(map(int, input().split())) -S = [] -C = [] -for i in range(M): -    s, c = list(map(int, input().split())) -    s -= 1 -    S.append(s) -    C.append(c) -# print(S,C)