M = int(M)
N = int(N)
ans = ['0' for i in range (N)]
fl = True

for i in range (M) :
    s , c = input().split()
    s = int(s) - 1
    if (s == 0 and c == '0') :
        fl = False
    if (ans[s] != '0') :
        if (ans[s] != c) :
            fl = False
    else :
        ans[s] = c

res = ''

if (ans[0] == '0') :
    ans[0] = '1'

for i in ans :
    res += i

print (res if fl else -1)
