I have a data structure such as following. The input file is pretty large and thus I am trying to find an efficient method.