#K15936. Group Files by Owners
Group Files by Owners
Group Files by Owners
You are given a list of files with their corresponding owners. Your task is to group the files by their owners and then output the groups in alphabetical order of the owner names. For each owner, print the owner name followed by a colon, a space, and the list of file names (in the order they were provided) separated by a single space.
Formally, if you are given an integer \( n \) representing the number of file-owner pairs, and then \( n \) lines where each line contains a file name and owner, you need to produce output with one line per owner in sorted order (alphabetically). The format for each line should be:
[ \text{owner}: \text{file1 file2 ... filek} ]
Ensure that your program reads input from stdin and outputs the result to stdout.
inputFormat
The first line contains an integer \( n \) (\(1 \leq n \leq 10^5\)), representing the number of file-owner pairs.
The following \( n \) lines each contain two strings separated by space: the file name and the owner name. File names and owner names will be non-empty and will not contain spaces.
Example:
4 Input.txt Randy Output.txt Randy Code.py Stan Script.js Alan
outputFormat
For each unique owner, output one line in the following format:
owner: file1 file2 ... filek
Owners must be listed in alphabetical order. The file names for the same owner must be listed in the order they appear in the input.
## sample1
Input.txt Randy
Randy: Input.txt
</p>