You've asked your question very poorly. I'm half thinking "Welcome to LQ" because it's your first post, however it also shows you registered in 2011. So you may have registered and never looked at any threads, or maybe you've just looked at threads over the years when needed and never needed to ask a question. Either case, in these forums, the responders are not paid, they're being collaborative to help others, but also the main idea is to help others to learn how to do these things on their own so that they can move further.
Therefore a program or script is the most typical solution. To that people will want to know what, if anything you have tried, and like to see you post that within [code][/code] tags, or at least indicate whether or not you have even started coding anything and that this would be where you need help, such as starting. So please do this.
Another thing to consider is the definition of the problem. You have example input/output, which seems pretty good; however you need to consider whether or not there can be varied interpretations of the output or even variations on the input which can't be shown in the illustrations.
For instance, "abf" does not show in the output, but one possible interpretation is that "abf" shows in the output by itself with no subjects. This interpretation shows that "abf" exists, but that the name has no subjects. As the problem/solution is shown, "abf" will not presently show up as being present, which may be your intent, but just opening this line of thinking.
Also "abe" is an example of a name with two subjects. This is fine and illustrates this possibility. But what would be the limits on that? In other words, can a name have 500 subjects? 10 subjects? How many maximum?
Next would be any possible variations for the names and subject numbers. Can subject numbers be 1, 2, 3, 4, 5, 6, or more digits? Or do they always have to be 3 digits?
Your example shows entirely unique subjects per name. Can different names use the same subject number?
And what about a repeated name?
If this is a school assignment, that's all fine, but understand that you need to state this and also put in your own effort to try and solve it and people will be responsive with suggestions to improve or get you past a stuck point. Right now, all you've done is ask for a solution.