A = [[0 for i in range(10)]for l in range(N)]
ans = ''
end = False
for l in L:
    if l[0] == 1 & l[1] == 0:
        print(-1)
        end = True
        break
    else:
        A[l[0]-1][l[1]] = 1
if not end:
    if any(sum(a) > 1 for a in A):
        print(-1)
    else:
        for i in range(N):
            if i == 0:
                if sum(A[i]) == 0:
                    ans+='1'
                else:
                    ans+=str(A[i].index(1))
            else:
                if sum(A[i]) == 0:
                    ans+='0'
                else:
                    ans+=str(A[i].index(1))

        print(ans)
