import sys

n, m = map(int, input().split())
l = []
for i in range(m):
    l.append(list(map(int, input().split())))
'''
if n == 1:
    s = "0"
    flag = True
    for j in l:
        if s[j[0]-1] != str(j[1]):
            flag = False
    if flag:
        print(0)
        sys.exit()
'''
for i in range(10**(n-1), 10**n):
    s = str(i)
    flag = True
    for j in l:
        if s[j[0]-1] != str(j[1]):
            flag = False
    if flag:
        print(i)
        sys.exit()

print(-1)