n,m = map(int,input().split())

s = []
c = []

list = ['a' for _ in range(n)]

for i in range(m):
    s_,c_ = map(int,input().split())
    s.append(s_)
    c.append(c_)

if n != m:
    print('-1')
else:
    for i in range(n):
        list[int(s[i])-1] = str(c[i])
    for j in range(len(list)):
        if list[j] == 'a':
            list[j] = '0'
    print(''.join(list))