Last Letter
Time limit2sMemory limit1024 MB
Given a string S, print the result of removing its last character if that character is G, or appending G to the end otherwise.
- Level
Easy1 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
Aoi is a student at JOI High School. Aoi noticed that appending the character G to the end of the string JOI gives JOIG.
After that, Aoi plays with various strings by appending G to the end or removing a trailing G.
Specifically, when Aoi sees a string, Aoi plays as follows.
- If the last character of the string is
G, Aoi imagines the string with that last characterGremoved. Only the last single character is removed. - If the last character of the string is not
G, Aoi imagines the string withGappended to the end.
A string S of length N is given. Write a program that outputs the string Aoi imagines when seeing S.
Input
The input is given in the following format.
N
S
Output
Print the string that Aoi imagines when seeing S.
Constraints
2 ≤ N ≤ 100.Sis a string of lengthN.- Each character of
Sis an uppercase English letter. Nis an integer.