n,m =map(int,input().split())
l = [0]*n
l1 = []
l2 = []
for i in range(m):
    s,c =map(int,input().split())
    if s in l1 and c != l2[l1.index(s)]:
        print('-1')
        exit()
    if s == 1 and c == 0 and n >1:
        print('-1')
        exit()
    
    l[s-1] = c
    l1.append(s)
    l2.append(c)
if l1 == [1] and l2 == [0]:
    print(0)
if 1 not in l1:
    l[0] = 1
l =[str(i) for i in l]
ans = '<'.join(l)
print(ans.replace('<',''))