I've been working on this project for hours. Can anyone give me some hint about how to go about doing this?

Sample input below:
hello world program
hello hello
program

Sample output should look like this:
hello: 3 times, lines: 1, 2
world: 1 times, lines: 1
program: 2 times, lines: 1, 3



I already used a hash for counting instances of all the words. I just can't seem to figure out how to find the line numbers and print them. I used an array type code, even hash. I also used a temporary variable for counting '\n' characters and got some erroneous printout. There's got to be an easier way.

Best help gets the points! Thanks for reading!