using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int queryCount = int.Parse(Reader.ReadLine()); StringBuilder ans = new StringBuilder(); for(int i=0; i=0; i--) { if(inpt[i] == 'R') { rCount++; } else if(inpt[i] == 'G') { if(rCount == 0) { return false; } rCount--; gCount++; } else { if(gCount == 0) { if(wCount == 0) { return false; } } else { gCount--; wCount++; } } } if(rCount > 0 || gCount > 0) { return false; } return true; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }