how to get the outuput in the correct format : def read_ndfa(file : open) -> {str:{str:{str}}}:
    pass

file =
start;0;start;1;start;0;near \n
near;1;end \n
end

correct output = {'end': {}, 'start': {'1': {'start'}, '0': {'start', 'near'}}, 'near': {'1': {'end'}}}

I need to write a function that takes a file as an input to get the correct output as above. however, I have no idea how to create the inner dictionary by using zip function. can someone show me the correct way to do it? Many thanks.