Input
The first line of the input is a word which must contains either "S" or "R" to indicate that we have to "send" or "receive" a message, respectively.
If the first line is "S", it will be followed by 6 lines, each one of them being: the name of the sender, the range of the sender, the name of the receiver, the range of the receiver, the message text and the time in the format hhmm (being hh the hour and mm the minute).
If the first line is "R", it will be followed by a single line containing all the data of the message that has been received.
Output
If the input is a message that has to be sent (S), the output must be the transmitted message in a single line, with all the input fields separated by commas. Remember to put an extra field "URGENT" at the beginning of the message if the rank of the sender is higher than the rank of the receiver.
If the input is a received message (R), the output must be the interpretation of that message, as shown in the Example 2 below. If it is an "URGENT" message, remark that putting the word in between "<<< >>>", as shown in Example 2.
If the first line is neither "S" nor "R", you must indicate that there is an error in the input by showing the message "Invalid input.". Show that message also if any of the given military ranks is invalid. Be careful, because both sent and received messages may contain an invalid rank.
Input
S Bobby Shaftoe Lieutenant Lawrence Waterhouse Officer Bring coffee! 2357
Output
URGENT,Bobby Shaftoe,Lieutenant,Lawrence Waterhouse,Officer,Bring coffee!,2357
Input
R Bobby Shaftoe,Lieutenant,Lawrence Waterhouse,Officer,Bring coffee!,2357
Output
<<< URGENT >>> From: Bobby Shaftoe From rank: Lieutenant To: Lawrence Waterhouse To rank: Officer Content: Bring coffee! Timestamp: 2357
Input
M URGENT,Bobby Shaftoe,Lieutenant,Lawrence Waterhouse,Officer,Bring coffee!,2357
Output
Invalid input.