N, K = gets.split.map(&:to_i) Q = K.times.map { a, c = gets.chomp.split; [a.to_i, c] } Q.sort_by! { |a, c| a } ans = [] counter = Hash.new(0) 1.upto(N) do |n| if Q.size > 0 if n == Q[0][0] a, c = Q.shift case c when 'R' if counter['R'] == counter['G'] && counter['G'] == counter['B'] ans << 'R' counter['R'] += 1 else if counter['G'] < counter['R'] ans << 'G' counter['G'] += 1 elsif counter['B'] < counter['R'] ans << 'B' counter['B'] += 1 else ans << 'R' counter['R'] += 1 end end when 'G' if counter['R'] == counter['G'] && counter['G'] == counter['B'] ans << 'G' counter['G'] += 1 else if counter['R'] < counter['G'] ans << 'R' counter['R'] += 1 elsif counter['B'] < counter['G'] ans << 'B' counter['B'] += 1 else ans << 'G' counter['G'] += 1 end end when 'B' if counter['R'] == counter['G'] && counter['G'] == counter['B'] ans << 'B' counter['B'] += 1 else if counter['R'] < counter['B'] ans << 'R' counter['R'] += 1 elsif counter['G'] < counter['B'] ans << 'G' counter['G'] += 1 else ans << 'B' counter['B'] += 1 end end end else if counter['R'] < counter['G'] && counter['R'] < counter['B'] ans << 'R' counter['R'] += 1 elsif counter['G'] < counter['R'] && counter['G'] < counter['B'] ans << 'G' counter['G'] += 1 elsif counter['B'] < counter['R'] && counter['B'] < counter['G'] ans << 'B' counter['B'] += 1 else if counter['R'] < counter['G'] || counter['R'] < counter['B'] ans << 'R' counter['R'] += 1 elsif counter['G'] < counter['R'] || counter['G'] < counter['B'] ans << 'G' counter['G'] += 1 else ans << 'B' counter['B'] += 1 end end end else ans << 'R' counter['R'] += 1 end end puts ans.join