n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(m)]
sc_set = set(sc)
sc_list = list(sc_set)

# s = []
# c = []
# for i in range(m):
#     x, y = map(int, input().split())
#     s.append(x)
#     c.append(y)

num = [None for _ in range(n)]

for i in range(len(sc_list)):
    if num[sc_list[i][0] - 1] != None:
        print(-1)
        exit()
    num[sc_list[i][0] - 1] = sc_list[i][1]

if n != 1 and num[0] == 0:
    print(-1)
    exit()

if all([1 if i == None else 0 for i in num[:-1]]) and num[-1] == 0:
    print(0)
    exit()

if num[0] == None:
    num[0] = 1

for i in range(n):
    if num[i] == None:
        num[i] = 0

for i in range(n):
    num[i] = str(num[i])

print(''.join(num))