A regional shipping depot marks every worker's badge with one of two colors: R for the receiving dock or G for the goods-out dock. After a scheduling mix-up, the badge colors must all be reversed -- every worker who currently wears an R badge switches to G, and every worker who currently wears a G badge switches to R. Worker identities and their order in the roster stay exactly the same; only the color changes. Produce the updated roster with every badge color flipped, keeping the workers in the same order they appeared in the input.
The first line contains an integer n, the number of workers on the roster.
Each of the next n lines contains a worker record id color, where id is a string of 1 to 20 characters from the set [A-Za-z0-9] (all ids are distinct) and color is a single character, either R or G.
Print n lines. The i-th line must contain the id from the i-th input record followed by a space and its flipped color (R becomes G, G becomes R).
id has length between 1 and 20 and uses only letters and digits.color is exactly R or G.Example 1
Input
3 W1 R W2 G W3 R
Expected
W1 G W2 R W3 G
Explanation
W1's R flips to G, W2's G flips to R, and W3's R flips to G, giving 'W1 G', 'W2 R', 'W3 G' in the original order.
Example 2
Input
1 Alpha G
Expected
Alpha R
Explanation
The only worker, Alpha, currently has a G badge, which flips to R, giving 'Alpha R'.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →