n, m = list (map (int, input ().split ()))
d = [-1 for i in range (n + 1)]
flg = True
for i in range (m) :
    s, c = list (map (int, input ().split ()))
    if (flg) :
        if (d[s] != -1 and d[s] != c) :
            flg = False
            continue
        d[s] = c

if (d[1] == 0) :
    flg = False

if (flg) :
    for i in range (1, n + 1) :
        if (d[i] == -1) :
            if (i == 1) :
                d[i] = 1
            else :
                d[i] = 0

print (''.join (list (map (str, d[1:]))) if flg else "-1")