Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions:   take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color;  take any two (not necessarily adjacent) cards with the same color and exchange them for a new card with that color. 

She repeats this process until there is only one card left. What are the possible colors for the final card?


-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 200) — the total number of cards.

The next line contains a string s of length n — the colors of the cards. s contains only the characters 'B', 'G', and 'R', representing blue, green, and red, respectively.


-----Output-----

Print a single string of up to three characters — the possible colors of the final card (using the same symbols as the input) in alphabetical order.


-----Examples-----
Input
2
RB

Output
G

Input
3
GRG

Output
BR

Input
5
BBBBB

Output
B



-----Note-----

In the first sample, Catherine has one red card and one blue card, which she must exchange for a green card.

In the second sample, Catherine has two green cards and one red card. She has two options: she can exchange the two green cards for a green card, then exchange the new green card and the red card for a blue card. Alternatively, she can exchange a green and a red card for a blue card, then exchange the blue card and remaining green card for a red card.

In the third sample, Catherine only has blue cards, so she can only exchange them for more blue cards.

Difficulty: interview

Starter code:

Solutions:
def main():
    n = int(input())
    s = input()
    
    b, g, r = [s.count(i) for i in "BGR"]
    
    if min(b, g, r) > 0:
        print("BGR")
        return
    if max(b, g, r) == n:
        if b == n: print("B")
        if g == n: print("G")
        if r == n: print("R")
        return
    if max(b, g, r) == 1:
        if b == 0: print("B")
        if g == 0: print("G")
        if r == 0: print("R")
        return
    if max(b, g, r) == n - 1:
        if b == n - 1: print("GR")
        if g == n - 1: print("BR")
        if r == n - 1: print("BG")
        return 
    
    print("BGR")
    
    
main()


    
x = int(input())
y = input()
r = y.count('R')
g = y.count('G')
b = y.count('B')

if r>=1 and g>=1 and b>=1:
    print("BGR")
elif r>=1 and g>=1:
    if r==1 and g==1:
        print("B")
    elif r==1:
        print("BR")
    elif g==1:
        print("BG")
    else:
        print("BGR")
elif r>=1 and b>=1:
    if r==1 and b==1:
        print("G")
    elif r==1:
        print("GR")
    elif b==1:
        print("BG")
    else:
        print("BGR")
elif b>=1 and g>=1:
    if b==1 and g==1:
        print("R")
    elif b==1:
        print("BR")
    elif g==1:
        print("GR")
    else:
        print("BGR")
elif r>=1:
    print("R")
elif g>=1:
    print("G")
else:
    print("B")


n = int(input())
s = input()
g = s.count('G')
b = s.count('B')
r = s.count('R')

if g != 0 and r != 0 and b != 0: print('BGR')
elif g==0 and r == 0: print('B')
elif g==0 and b == 0: print('R')
elif b==0 and r == 0: print('G')
elif g==0:
    
    if r >= 2: print('B',end = '')
    print('G',end = '')
    if b >= 2: print('R', end = '')
elif r==0:
    
    if g >= 2: print('B',end = '')
    if b >= 2: print('G', end = '')
    print('R',end = '')
elif b==0:
    print('B',end = '')
    if r >= 2: print('G',end = '')
    if g >= 2: print('R', end = '')

from itertools import accumulate

n = int(input())
s = input()
D = {'R':0, 'G':0, 'B':0}
for c in s: D[c] += 1
L = ['R', 'G', 'B']
L.sort(key = lambda c: -D[c])
if all((D[c] > 0 for c in L)) or D[L[0]] > 1 and D[L[1]] > 1:
    print('BGR')
elif D[L[1]] == 1 and D[L[0]] > 1:
    L.pop(0)
    L.sort()
    print(''.join(L))
elif D[L[1]] == 1 and D[L[0]] == 1:
    print(L[2])
else:
    print(L[0])
    


le = int(input())
s = input()
l = [0,0,0]#B,G,R
for i in range(le):
    c = s[i]
    if c == 'B':
        l[0] += 1
    elif c == 'G':
        l[1] += 1
    else:
        l[2] += 1
if min(l) > 0:
    print('BGR')
elif l[0] == 0 and l[1] == 0:
    print('R')
elif l[2] == 0 and l[1] == 0:
    print('B')
elif l[0] == 0 and l[2] == 0:
    print('G')
elif l[0] == 0:
    if l[1] == 1 and l[2] == 1:
        print('B')
    elif l[1] == 1:
        print('BG')
    elif l[2] == 1:
        print('BR')
    else:
        print('BGR')
elif l[1] == 0:
    if l[0] == 1 and l[2] == 1:
        print('G')
    elif l[0] == 1:
        print('BG')
    elif l[2] == 1:
        print('GR')
    else:
        print('BGR')
else:
    if l[1] == 1 and l[0] == 1:
        print('R')
    elif l[0] == 1:
        print('BR')
    elif l[1] == 1:
        print('GR')
    else:
        print('BGR')
    
        


n = int(input())
s = input().strip()
if 'R' in s and 'G' in s and 'B' in s:
	ans = "RGB"
elif 'R' in s and 'G' in s:
	a = 'R'
	b = 'G'
	c = 'B'
	if s.count(a) > 1 and s.count(b) > 1:
		ans = "RGB"
	else:
		if n == 2:
			ans = c
		else:
			if s.count(a) > s.count(b):
				ans = b+c
			else:
				ans = a+c
elif 'R' in s and 'B' in s:
	a = 'R'
	c = 'G'
	b = 'B'
	if s.count(a) > 1 and s.count(b) > 1:
		ans = "RGB"
	else:
		if n == 2:
			ans = c
		else:
			if s.count(a) > s.count(b):
				ans = b+c
			else:
				ans = a+c
elif 'G' in s and 'B' in s:
	c = 'R'
	a = 'G'
	b = 'B'
	if s.count(a) > 1 and s.count(b) > 1:
		ans = "RGB"
	else:
		if n == 2:
			ans = c
		else:
			if s.count(a) > s.count(b):
				ans = b+c
			else:
				ans = a+c
else:
	ans = s[0]
ret = []
for char in ans:
	ret.append(char)
ret.sort()
print (''.join(ret))

# You lost the game.
n = int(input())
ch = str(input())
r = ""
R = ch.count("R")
B = ch.count("B")
G = ch.count("G")
if R and B and G:
    print("BGR")
elif (R >= 2 and B >= 2) or (G >= 2 and R >= 2) or (G >= 2 and B >= 2):
    print("BGR")
elif R >= 2 and (B == 1 or G == 1): 
    print("BG")
elif B >= 2 and (R == 1 or G == 1):
    print("GR")
elif G >= 2 and (B == 1 or R == 1):
    print("BR")
elif B and G:
    print("R")
elif R and G:
    print("B")
elif B and R:
    print("G")
elif B:
    print("B")
elif G:
    print("G")
else:
    print("R")






#!/usr/bin/env python3
n = int(input())
s = input()
t = 'BGR'
a = [s.count(c) for c in t]
ans = ''
for i in range(3):
    x, y, z = a[i], a[(i+1)%3], a[(i+2)%3]
    if (x >= 1 and y == z == 0) or (y >= 1 and z >= 1) or (x >= 1 and (y >= 2 or z >= 2)):
        ans += t[i]
print(ans)


n = int(input())
s = input()
b = s.count('B')
r = s.count('R')
g = s.count('G')
if 'B' in s and 'G' in s and 'R' in s:
    print('BGR')
elif s == 'B' * n:
    print('B')
elif s == 'G' * n:
    print('G')
elif s == 'R' * n:
    print('R')
elif 'B' not in s:
    if g == r == 1:
        print('B')
    elif g > 1 and r > 1:
        print('BGR')
    elif g == 1 and r > 1: #grr br g; grr gr b
        print('BG')
    elif g > 1 and r == 1:
        print('BR')
elif 'G' not in s:
    if b == r == 1:
        print('G')
    elif b > 1 and r > 1:
        print('BGR')
    elif b == 1 and r > 1: # brr gr b; brr br g
        print('BG')
    elif b > 1 and r == 1: # bbr br g; bbr bg r;
        print('GR')
elif 'R' not in s:
    if b == g == 1:
        print('R')
    elif b > 1 and g > 1:
        print('BGR')
    elif b == 1 and g > 1:
        print('BR')
    elif b > 1 and g == 1:
        print('GR')


def main():
    n = int(input())
    s = input()
    r = s.count('R')
    g = s.count('G')
    b = s.count('B')
    if r > 0 and g > 0 and b > 0:
        print('BGR')
        return
    r = min(r, 2)
    g = min(g, 2)
    b = min(b, 2)
    a = r, 'R'
    c = b, 'B'
    b = g, 'G'
    if a[0] < b[0]:
        a, b = b, a
    if b[0] < c[0]:
        b, c = c, b
    if a[0] < b[0]:
        a, b = b, a
    if a[0] == 2 and b[0] == 2:
        print('BGR')
        return
    if a[0] == 2 and b[0] == 1:
        print(''.join(sorted((c[1], b[1]))))
    if a[0] > 0 and b[0] == 0:
        print(a[1])
    if a[0] == 1 and b[0] == 1:
        print(c[1])


main()


n = int(input())
c = (lambda s: {(s.count(color), color) for color in 'BGR' if s.count(color)})(input())
if len(c) == 3 or (len(c) == 2 and min(c)[0] > 1):
    print('BGR')
elif len(c) == 1:
    print(min(c)[1])
elif max(c)[0] > 1:
    print(*sorted(set('BGR') - {max(c)[1]}), sep = '')
else:
    print(*(set('BGR') - {x[1] for x in c}))


n = int(input())
s = input()
st = {'R', 'G', 'B'}
if s.count(s[0]) == n:
    print(s[0])
elif st == set(s):
    print(''.join(sorted(list(st))))
elif len(set(s)) == 2:
    if s.count(list(set(s))[0]) > 1 and s.count(list(set(s))[1]) > 1:
        print(''.join(sorted(list(st))))
    elif s.count(list(set(s))[0]) > 1:
        print(''.join(sorted(list(st - set(s))[0] + list(set(s))[1])))
    elif s.count(list(set(s))[1]) > 1:
        print(''.join(sorted(list(st - set(s))[0] + list(set(s))[0])))
    else:
        print(list(st - set(s))[0])

a = int(input())
per = input()
r = 0
g=0
b=0
for i in per:
    if i == 'R':
        r+=1
    if i == 'G':
        g+=1
    if i == 'B':
        b+=1

if r !=0 and b!=0 and g !=0:
    print('BGR')
elif r == 0 and b ==0:
    print('G')
elif r == 0 and g == 0:
    print('B')
elif g == 0 and b == 0:
    print('R')
elif r == 0:
    if g > 1:
        print('B', end='')    
    
    if b > 1:
        
        print('G', end ='')
    print('R', end = '')
    
elif g == 0:
    if r > 1:
        print('B',end ='')   
    print('G', end='')
    if b > 1:
        print('R', end ='')    
    
    
    
    
elif b == 0:
    print('B', end = '')
    if r > 1:
        print('G', end ='')    
    if g > 1:
        print('R', end='')    
    
    
    
    

def main():
    n = int(input())
    q = str(input())
    # 0 = B, 1 = G, 2 = R
    d = [0] * 3

    for e in q:
        if e == "B":
            d[0] += 1
        elif e == "G":
            d[1] += 1
        else:
            d[2] += 1

    answer = ""

    if d[0] != 0 and d[1] != 0:
        answer += "R"
        if d[0] > 1:
            answer += "G"

        if d[1] > 1:
            answer += "B"

    if d[0] != 0 and d[2] != 0:
        answer += "G"
        if d[0] > 1:
            answer += "R"

        if d[2] > 1:
            answer += "B"

    if d[1] != 0 and d[2] != 0:
        answer += "B"
        if d[1] > 1:
            answer += "R"

        if d[2] > 1:
            answer += "G"

    if d[0] > 0 and d[1] == 0 and d[2] == 0:
        answer += "B"

    if d[1] > 0 and d[0] == 0 and d[2] == 0:
        answer += "G"

    if d[2] > 0 and d[0] == 0 and d[1] == 0:
        answer += "R"

    q = ""
    for e in sorted(list(set(answer))):
        q += e

    print(q)

def __starting_point():
    main()
__starting_point()

import collections
import math

n = int(input())
s = input()
a, b, c = s.count('B'), s.count('G'), s.count('R')
if a * b * c != 0 or (a >= 2 and b >= 2) or (a >= 2 and c >= 2) or (c >= 2 and b >= 2):
    print('BGR')
elif a != 0 and b == 0 and c == 0:
    print('B')
elif a == 0 and b != 0 and c == 0:
    print('G')
elif a == 0 and b == 0 and c != 0:
    print('R')
elif a == 0:
    if b == c:
        print('B')
    elif b > c:
        print('BR')
    else:
        print('BG')
elif b == 0:
    if a == c:
        print('G')
    elif a > c:
        print('GR')
    else:
        print('BG')
elif c == 0:
    if b == a:
        print('R')
    elif b > a:
        print('BR')
    else:
        print('GR')

t = input()
d = input()
r = d.count('R')
g = d.count('G')
b = d.count('B')	
if (r>0 and g>0 and b>0):
	print('BGR')
	return;
if (r==0 and g==0):
	print('B')
	return
if (r==0 and b==0):
	print('G')
	return
if (b==0 and g==0):
	print('R')
	return
if (b==1 and r ==1):
	print ('G')
	return
if (b==1 and g ==1):
	print ('R')
	return
if (r==1 and g ==1):
	print ('B')
	return
if (b>1 and r ==1):
	print ('GR')
	return
if (b>1 and g ==1):
	print ('GR')
	return
if (r>1 and g ==1):
	print ('BG')
	return
if (r>1 and b ==1):
	print ('BG')
	return
if (g>1 and b ==1):
	print ('BR')
	return
if (g>1 and r ==1):
	print ('BR')
	return
print('BGR')

n = int(input())
s = input()
b = 0
g = 0
r = 0
for i in range(n):
    if s[i] == 'B':
        b += 1
    elif s[i] == 'G':
        g += 1
    else:
        r += 1
if b == 0:
    if g == 0:
        print('R')
    elif r == 0:
        print('G')
    elif g == 1:
        if r == 1:
            print('B')
        else:
            print('BG')
    elif r == 1:
        print('BR')
    else:
        print('BGR')
elif g == 0:
    if b == 0:
        print('R')
    elif r == 0:
        print('B')
    elif b == 1:
        if r == 1:
            print('G')
        else:
            print('BG')
    elif r == 1:
        print('GR')
    else:
        print('BGR')
elif r == 0:
    if b == 0:
        print('G')
    elif g == 0:
        print('B')
    elif b == 1:
        if g == 1:
            print('R')
        else:
            print('BR')
    elif g == 1:
        print('GR')
    else:
        print('BGR')
else:
    print('BGR')

#!/usr/bin/env python3

n = int(input())
s = input()

b, g, r = 0, 0, 0
for i in range(0, len(s)):
    if s[i] == 'B':
        b += 1
    elif s[i] == 'G':
        g += 1
    elif s[i] == 'R':
        r += 1
    else:
        assert False

if b != 0 and g == 0 and r == 0 or \
        b == 0 and g == 1 and r == 1:
            print('B')
elif b == 0 and g != 0 and r == 0 or \
        b == 1 and g == 0 and r == 1:
            print('G')
elif b == 0 and g == 0 and r != 0 or \
        b == 1 and g == 1 and r == 0:
            print('R')
elif b > 1 and g == 1 and r == 0 or\
        b > 1 and g == 0 and r == 1:
            print('GR')
elif b == 0 and g > 1 and r == 1 or\
        b == 1 and g > 1 and r == 0:
            print('BR')
elif b == 0 and g == 1 and r > 1 or\
        b == 1 and g == 0 and r > 1:
            print('BG')
else:
    print('BGR')


from collections import namedtuple

def __starting_point():

    n = int(input())
    cards = input()

    r = 0
    g = 0
    b = 0
    for card in cards:
        if card == "R":
            r += 1
        elif card == "G":
            g += 1
        elif card == "B":
            b += 1

    #print(r,g,b)

    colornum = 0
    if r:
        colornum += 1
    if g:
        colornum += 1
    if b:
        colornum += 1

    res = ""
    if colornum == 3:
        res = "BGR"
    elif colornum == 2:
        if r == 1:
            if b == 1:
                res = "G"
            elif b > 1:
                res = "GR"
            elif g == 1:
                res = "B"
            elif g > 1:
                res = "BR"
        elif g == 1:
            if r == 1:
                res = "B"
            elif b == 1:
                res = "R"
            elif r > 1:
                res = "BG"
            elif b > 1:
                res = "GR"
        elif b == 1:
            if r == 1:
                res = "G"
            elif g == 1:
                res = "R"
            elif r > 1:
                res = "BG"
            elif g > 1:
                res = "BR"
        else:
            res = "BGR"
    else:
        if r:
            res = "R"
        elif g:
            res = "G"
        elif b:
            res = "B"

    print(res)
__starting_point()

'''
Catherine has a deck of n cards, each of which is either red, green, or blue.
 As long as there are at least two cards left, she can do one of two actions:

    take any two (not necessarily adjacent) cards with different colors and 
    exchange them for a new card of the third color;
    take any two (not necessarily adjacent) cards with the same color and 
    exchange them for a new card with that color. 

She repeats this process until there is only one card left. What are the 
possible colors for the final card?

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200) — 
the total number of cards.

The next line contains a string s of length n — the colors of the cards. 
s contains only the characters 'B', 'G', and 'R', representing blue, green, 
and red, respectively.
Output

Print a single string of up to three characters — the possible colors of 
the final card (using the same symbols as the input) in alphabetical order.
'''

import io
import sys
import time
import random
#~ start = time.clock()
#~ test ='''5
#~ BBBBB'''
#~ test = '''2
#~ RB'''
#~ test = '''3
#~ GRG'''
#~ test = '''3
#~ RGB'''
#~ test = '''5
#~ RGBBB'''
#~ test = '''2
#~ RG'''
#~ test = '''3
#~ RRG'''
#~ test = '''3
#~ BBG'''

#~ sys.stdin = io.StringIO(test)

n = int(input())
cols = 'RGB'
counts = {'R':0,'G':0,'B':0}
for c in input():
   counts[c] += 1

# single color
# 2 colors -> c1, c2
# 3 colors

def gettwocolors(counts):
   if counts['R']==0:
      return "GB"
   if counts['G']==0:
      return "RB"
   if counts['B']==0:
      return "RG"
      
def printcols(cols):
   print(sortedcols(cols))

def sortedcols(cols):
   return "".join(sorted(list(cols)))
   
complement = { 
   sortedcols("RG"):"B",
   sortedcols("RB"):"G",
   sortedcols("GB"):"R" 
}   

if counts['R']>0 and counts['G']>0 and counts['B']>0:
   printcols("RGB")
else:
   c1,c2 = gettwocolors(counts)
   if counts[c1]==0:
      printcols(c2)
   elif counts[c2]==0:
      printcols(c1)
   else:
      # really two colors
      if counts[c1]>=2 and counts[c2]>=2:
         printcols("RGB")
      elif counts[c1]>=2:
         printcols( c2+complement[sortedcols(c1+c2)] )
      elif counts[c2]>=2:
         printcols( c1+complement[sortedcols(c1+c2)] )
      else:
         printcols( complement[sortedcols(c1+c2)] )
         
#~ dur = time.clock()-start
#~ print("Time:",dur)


n=int(input())
s=input()
d={}
B,G,R=s.count('B'),s.count('G'),s.count('R')
if B==0 and G==0: print('R')
elif B==0 and R==0: print('G')
elif G==0 and R==0: print('B')
elif B==0 and G==1 and R==1: print('B')
elif B==1 and G==0 and R==1: print('G')
elif B==1 and G==1 and R==0: print('R')
elif B==0 and G==1: print('BG')
elif B==0 and R==1: print('BR')
elif G==0 and B==1: print('BG')
elif G==0 and R==1: print('GR')
elif R==0 and B==1: print('BR')
elif R==0 and G==1: print('GR')
else: print('BGR')

n = int(input())
s = input()
if "R" in s and "G" in s and "B" in s:
    print('BGR')
    return
if 'R' not in s and 'G' not in s:
    print('B')
    return
if 'R' not in s and 'B' not in s:
    print('G')
    return
if 'B' not in s and 'G' not in s:
    print('R')
    return

if "R" in s and "G" in s:
    answer = 'B'
    if s.count('R') > 1:
        answer += 'G'
    if s.count('G') > 1:
        answer += 'R'
    print(answer)
    return
if "R" in s and "B" in s:
    answer = 'G'
    if s.count('R') > 1:
        answer = 'B' + answer
    if s.count('B') > 1:
        answer += 'R'
    print(answer)
    return
if "B" in s and "G" in s:
    answer = 'R'
    if s.count('B') > 1:
        answer = 'G' + answer
    if s.count('G') > 1:
        answer = 'B' + answer
    print(answer)
    return

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time

def pr(d, k):
    ans = []
    for i in d.keys():
        if d[i] == k:
            ans = i
    return ans

n   = int(input())
a   = list(input())

start = time.time()

d = {'R' :0, 'G' :0, 'B' : 0}

for i in a:
    d[i] += 1

b = list(set(a))

if len(b) == 1:
    ans = b[0]
elif len(b) == 2:
    if d[b[0]] == 1 and d[b[1]] == 1:
        ans = pr(d, 0)
    elif d[b[0]] == 1 :
        ans = b[0]+pr(d, 0)
    elif d[b[1]] == 1 :
        ans = b[1]+pr(d, 0)
    else:
        ans = 'BGR'
else:
    ans = 'BGR'

for i in sorted(ans):
    print(i, end='')
print()

finish = time.time()
#print(finish - start)


3

n = int(input())
s = str(input())

colors = set()
for i in s:
    colors.add(i)

if len(colors) == 1:
    print(s[0])
elif len(colors) == 3:
    print("BGR")
else:
    if s.count("R") == 0:
        if s.count("G") >= 2 and s.count("B") >= 2:
            print("BGR")
        elif s.count("G") >=2 and s.count("B") == 1:
            print("BR")
        elif s.count("G") == 1 and s.count("B") >= 2:
            print("GR")
        elif s.count("G") == 1 and s.count("B") == 1:
            print("R")
    elif s.count("G") == 0:
        if s.count("R") >= 2 and s.count("B") >= 2:
            print("BGR")
        elif s.count("R") >=2 and s.count("B") == 1:
            print("BG")
        elif s.count("R") == 1 and s.count("B") >= 2:
            print("GR")
        elif s.count("R") == 1 and s.count("B") == 1:
            print("G")
    elif s.count("B") == 0:
        if s.count("R") >= 2 and s.count("G") >= 2:
            print("BGR")
        elif s.count("R") >=2 and s.count("G") == 1:
            print("BG")
        elif s.count("R") == 1 and s.count("G") >= 2:
            print("BR")
        elif s.count("R") == 1 and s.count("G") == 1:
            print("B")


n = int(input())
s = input()
l = []
v = [0,0,0]

def val(c):
    if c == 'B':
        return 0
    elif c == 'G':
        return 1
    else:
        return 2

for c in s:
    l += [val(c)]
    v[val(c)] += 1
    
if (len(set(l))) == 3:
    print('BGR')
elif (len(set(l))) == 1:
    print(s[0])
else:
    if v[0] == 1 or v[1] == 1 or v[2] == 1:
        a = ''
        if v[0] == 0:
            a = 'B'
        elif v[1] == 0:
            a = 'G'
        else:
            a = 'R'
        if max(v) > 1:
            if v[0] == 1:
                a += 'B'
            elif v[1] == 1:
                a += 'G'
            else:
                a += 'R'
        for c in sorted(a):
            print(c,end='')
    else:
        print('BGR')