import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
sc = [li() for _ in range(m)]

max_int = [9,99,999]
for i in range(10**(n-1),max_int[n-1]):
    str_num = str(i)
    flag = 0
    for j in range(m):
        if str_num[sc[j][0] - 1] != str(sc[j][1]):
            flag = 1
    if flag == 0:
        print(str_num)
        exit()
print(-1)