n,m = map(int,input().split())
ans = list()
sc_list = [list(map(str,input().split())) for _ in range(m)]
if n == 0:
    j = 0
else:
    j = 10 ** n
for k in range(j,10 ** n):
    st = str(i)
    for s,c in sc_list:
        if st[s] != 'c':
            break
    else:
        print(st)
        exit()
else:
    print('-1')
