import sys
input = sys.stdin.buffer.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, m = map(int, input().split())
S,C=[],[]
flg=False
for i in range(m):
    s,c = map(int,input().split())
    S.append(s)
    C.append(c)
for i in range(10**(n-1), 10**n):
    i=str(i)
    #print(i)
    cnt=0
    for j in range(m):
        #print(i[S[j]-1], C[j], i[S[j]-1] != str(C[j]))
        if i[S[j]-1]==str(C[j]):
            cnt+=1
        if cnt==m:
            print(i)
            flg=True
            sys.exit()
            
if not flg:
    print(-1)
