import itertools
import math
import fractions
import functools
n, m = map(int, input().split())
l = []
for i in range(m):
    l.append(list(map(int, input().split())))
    l[i][0] -= 1

minimum = [10]*n

for i in range(m):
    minimum[l[i][0]] = min(l[i][1], minimum[l[i][0]])

if m == 0:
    if n == 3:
        print("100")
    if n == 2:
        print("10")
    if n == 1:
        print("0")
    quit()

if minimum[0] == 10 or (n != 1 and minimum[0] == 0):
    print(-1)
    quit()



for i in range(n):
    if minimum[i] == 10:
        minimum[i] = '0'
    else:
        minimum[i] = str(minimum[i])

print(('').join(minimum))
