import sys
input = sys.stdin.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 = []
for i in range(m):
    a, b = map(int, input().split())
    s.append(a)
    c.append(b)

if n==1:
    if c[0]==0:
        print(0)
        sys.exit()
def ok(num,m,s,c):
    for i in range(m):
        if str(num)[s[i]-1] != str(c[i]):
            return False
    return True
    
for num in range(10**(n-1),10**n):
    if ok(num,m,s,c):
        print(num)
        sys.exit()

print(-1)
            
